babylon.module.d.ts 5.7 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860124861124862124863124864124865124866124867124868124869124870124871124872124873124874124875124876124877124878124879124880124881124882124883124884124885124886124887124888124889124890124891124892124893124894124895124896124897124898124899124900124901124902124903124904124905124906124907124908124909124910124911124912124913124914124915124916124917124918124919124920124921124922124923124924124925124926124927124928124929124930124931124932124933124934124935124936124937124938124939124940124941124942124943124944124945124946124947124948124949124950124951124952124953124954124955124956124957124958124959124960124961124962124963124964124965124966124967124968124969124970124971124972124973124974124975124976124977124978124979124980124981124982124983124984124985124986124987124988124989124990124991124992124993124994124995124996124997124998124999125000125001125002125003125004125005125006125007125008125009125010125011125012125013125014125015125016125017125018125019125020125021125022125023125024125025125026125027125028125029125030125031125032125033125034125035125036125037125038125039125040125041125042125043125044125045125046125047125048125049125050125051125052125053125054125055125056125057125058125059125060125061125062125063125064125065125066125067125068125069125070125071125072125073125074125075125076125077125078125079125080125081125082125083125084125085125086125087125088125089125090125091125092125093125094125095125096125097125098125099125100125101125102125103125104125105125106125107125108125109125110125111125112125113125114125115125116125117125118125119125120125121125122125123125124125125125126125127125128125129125130125131125132125133125134125135125136125137125138125139125140125141125142125143125144125145125146125147125148125149125150125151125152125153125154125155125156125157125158125159125160125161125162125163125164125165125166125167125168125169125170125171125172125173125174125175125176125177125178125179125180125181125182125183125184125185125186125187125188125189125190125191125192125193125194125195125196125197125198125199125200125201125202125203125204125205125206125207125208125209125210125211125212125213125214125215125216125217125218125219125220125221125222125223125224125225125226125227125228125229125230125231125232125233125234125235125236125237125238125239125240125241125242125243125244125245125246125247125248125249125250125251125252125253125254125255125256125257125258125259125260125261125262125263125264125265125266125267125268125269125270125271125272125273125274125275125276125277125278125279125280125281125282125283125284125285125286125287125288125289125290125291125292125293125294125295125296125297125298125299125300125301125302125303125304125305125306125307125308125309125310125311125312125313125314125315125316125317125318125319125320125321125322125323125324125325125326125327125328125329125330125331125332125333125334125335125336125337125338125339125340125341125342125343125344125345125346125347125348125349125350125351125352125353125354125355125356125357125358125359125360125361125362125363125364125365125366125367125368125369125370125371125372125373125374125375125376125377125378125379125380125381125382125383125384125385125386125387125388125389125390125391125392125393125394125395125396125397125398125399125400125401125402125403125404125405125406125407125408125409125410125411125412125413125414125415125416125417125418125419125420125421125422125423125424125425125426125427125428125429125430125431125432125433125434125435125436125437125438125439125440125441125442125443125444125445125446125447125448125449125450125451125452125453125454125455125456125457125458125459125460125461125462125463125464125465125466125467125468125469125470125471125472125473125474125475125476125477125478125479125480125481125482125483125484125485125486125487125488125489125490125491125492125493125494125495125496125497125498125499125500125501125502125503125504125505125506125507125508125509125510125511125512125513125514125515125516125517125518125519125520125521125522125523125524125525125526125527125528125529125530125531125532125533125534125535125536125537125538125539125540125541125542125543125544125545125546125547125548125549125550125551125552125553125554125555125556125557125558125559125560125561125562125563125564125565125566125567125568125569125570125571125572125573125574125575125576125577125578125579125580125581125582125583125584125585125586125587125588125589125590125591125592125593125594125595125596125597125598125599125600125601125602125603125604125605125606125607125608125609125610125611125612125613125614125615125616125617125618125619125620125621125622125623125624125625125626125627125628125629125630125631125632125633125634125635125636125637125638125639125640125641125642125643125644125645125646125647125648125649125650125651125652125653125654125655125656125657125658125659125660125661125662125663125664125665125666125667125668125669125670125671125672125673125674125675125676125677125678125679125680125681125682125683125684125685125686125687125688125689125690125691125692125693125694125695125696125697125698125699125700125701125702125703125704125705125706125707125708125709125710125711125712125713125714125715125716125717125718125719125720125721125722125723125724125725125726125727125728125729125730125731125732125733125734125735125736125737125738125739125740125741125742125743125744125745125746125747125748125749125750125751125752125753125754125755125756125757125758125759125760125761125762125763125764125765125766125767125768125769125770125771125772125773125774125775125776125777125778125779125780125781125782125783125784125785125786125787125788125789125790125791125792125793125794125795125796125797125798125799125800125801125802125803125804125805125806125807125808125809125810125811125812125813125814125815125816125817125818125819125820125821125822125823125824125825125826125827125828125829125830125831125832125833125834125835125836125837125838125839125840125841125842125843125844125845125846125847125848125849125850125851125852125853125854125855125856125857125858125859125860125861125862125863125864125865125866125867125868125869125870125871125872125873125874125875125876125877125878125879125880125881125882125883125884125885125886125887125888125889125890125891125892125893125894125895125896125897125898125899125900125901125902125903125904125905125906125907125908125909125910125911125912125913125914125915125916125917125918125919125920125921125922125923125924125925125926125927125928125929125930125931125932125933125934125935125936125937125938125939125940125941125942125943125944125945125946125947125948125949125950125951125952125953125954125955125956125957125958125959125960125961125962125963125964125965125966125967125968125969125970125971125972125973125974125975125976125977125978125979125980125981125982125983125984125985125986125987125988125989125990125991125992125993125994125995125996125997125998125999126000126001126002126003126004126005126006126007126008126009126010126011126012126013126014126015126016126017126018126019126020126021126022126023126024126025126026126027126028126029126030126031126032126033126034126035126036126037126038126039126040126041126042126043126044126045126046126047126048126049126050126051126052126053126054126055126056126057126058126059126060126061126062126063126064126065126066126067126068126069126070126071126072126073126074126075126076126077126078126079126080126081126082126083126084126085126086126087126088126089126090126091126092126093126094126095126096126097126098126099126100126101126102126103126104126105126106126107126108126109126110126111126112126113126114126115126116126117126118126119126120126121126122126123126124126125126126126127126128126129126130126131126132126133126134126135126136126137126138126139126140126141126142126143126144126145126146126147126148126149126150126151126152126153126154126155126156126157126158126159126160126161126162126163126164126165126166126167126168126169126170126171126172126173126174126175126176126177126178126179126180126181126182126183126184126185126186126187126188126189126190126191126192126193126194126195126196126197126198126199126200126201126202126203126204126205126206126207126208126209126210126211126212126213126214126215126216126217126218126219126220126221126222126223126224126225126226126227126228126229126230126231126232126233126234126235126236126237126238126239126240126241126242126243126244126245126246126247126248126249126250126251126252126253126254126255126256126257126258126259126260126261126262126263126264126265126266126267126268126269126270126271126272126273126274126275126276126277126278126279126280126281126282126283126284126285126286126287126288126289126290126291126292126293126294126295126296126297126298126299126300126301126302126303126304126305126306126307126308126309126310126311126312126313126314126315126316126317126318126319126320126321126322126323126324126325126326126327126328126329126330126331126332126333126334126335126336126337126338126339126340126341126342126343126344126345126346126347126348126349126350126351126352126353126354126355126356126357126358126359126360126361126362126363126364126365126366126367126368126369126370126371126372126373126374126375126376126377126378126379126380126381126382126383126384126385126386126387126388126389126390126391126392126393126394126395126396126397126398126399126400126401126402126403126404126405126406126407126408126409126410126411126412126413126414126415126416126417126418126419126420126421126422126423126424126425126426126427126428126429126430126431126432126433126434126435126436126437126438126439126440126441126442126443126444126445126446126447126448126449126450126451126452126453126454126455126456126457126458126459126460126461126462126463126464126465126466126467126468126469126470126471126472126473126474126475126476126477126478126479126480126481126482126483126484126485126486126487126488126489126490126491126492126493126494126495126496126497126498126499126500126501126502126503126504126505126506126507126508126509126510126511126512126513126514126515126516126517126518126519126520126521126522126523126524126525126526126527126528126529126530126531126532126533126534126535126536126537126538126539126540126541126542126543126544126545126546126547126548126549126550126551126552126553126554126555126556126557126558126559126560126561126562126563126564126565126566126567126568126569126570126571126572126573126574126575126576126577126578126579126580126581126582126583126584126585126586126587126588126589126590126591126592126593126594126595126596126597126598126599126600126601126602126603126604126605126606126607126608126609126610126611126612126613126614126615126616126617126618126619126620126621126622126623126624126625126626126627126628126629126630126631126632126633126634126635126636126637126638126639126640126641126642126643126644126645126646126647126648126649126650126651126652126653126654126655126656126657126658126659126660126661126662126663126664126665126666126667126668126669126670126671126672126673126674126675126676126677126678126679126680126681126682126683126684126685126686126687126688126689126690126691126692126693126694126695126696126697126698126699126700126701126702126703126704126705126706126707126708126709126710126711126712126713126714126715126716126717126718126719126720126721126722126723126724126725126726126727126728126729126730126731126732126733126734126735126736126737126738126739126740126741126742126743126744126745126746126747126748126749126750126751126752126753126754126755126756126757126758126759126760126761126762126763126764126765126766126767126768126769126770126771126772126773126774126775126776126777126778126779126780126781126782126783126784126785126786126787126788126789126790126791126792126793126794126795126796126797126798126799126800126801126802126803126804126805126806126807126808126809126810126811126812126813126814126815126816126817126818126819126820126821126822126823126824126825126826126827126828126829126830126831126832126833126834126835126836126837126838126839126840126841126842126843126844126845126846126847126848126849126850126851126852126853126854126855126856126857126858126859126860126861126862126863126864126865126866126867126868126869126870126871126872126873126874126875126876126877126878126879126880126881126882126883126884126885126886126887126888126889126890126891126892126893126894126895126896126897126898126899126900126901126902126903126904126905126906126907126908126909126910126911126912126913126914126915126916126917126918126919126920126921126922126923126924126925126926126927126928126929126930126931126932126933126934126935126936126937126938126939126940126941126942126943126944126945126946126947126948126949126950126951126952126953126954126955126956126957126958126959126960126961126962126963126964126965126966126967126968126969126970126971126972126973126974126975126976126977126978126979126980126981126982126983126984126985126986126987126988126989126990126991126992126993126994126995126996126997126998126999127000127001127002127003127004127005127006127007127008127009127010127011127012127013127014127015127016127017127018127019127020127021127022127023127024127025127026127027127028127029127030127031127032127033127034127035127036127037127038127039127040127041127042127043127044127045127046127047127048127049127050127051127052127053127054127055127056127057127058127059127060127061127062127063127064127065127066127067127068127069127070127071127072127073127074127075127076127077127078127079127080127081127082127083127084127085127086127087127088127089127090127091127092127093127094127095127096127097127098127099127100127101127102127103127104127105127106127107127108127109127110127111127112127113127114127115127116127117127118127119127120127121127122127123127124127125127126127127127128127129127130127131127132127133127134127135127136127137127138127139127140127141127142127143127144127145127146127147127148127149127150127151127152127153127154127155127156127157127158127159127160127161127162127163127164127165127166127167127168127169127170127171127172127173127174127175127176127177127178127179127180127181127182127183127184127185127186127187127188127189127190127191127192127193127194127195127196127197127198127199127200127201127202127203127204127205127206127207127208127209127210127211127212127213127214127215127216127217127218127219127220127221127222127223127224127225127226127227127228127229127230127231127232127233127234127235127236127237127238127239127240127241127242127243127244127245127246127247127248127249127250127251127252127253127254127255127256127257127258127259127260127261127262127263127264127265127266127267127268127269127270127271127272127273127274127275127276127277127278127279127280127281127282127283127284127285127286127287127288127289127290127291127292127293127294127295127296127297127298127299127300127301127302127303127304127305127306127307127308127309127310127311127312127313127314127315127316127317127318127319127320127321127322127323127324127325127326127327127328127329127330127331127332127333127334127335127336127337127338127339127340127341127342127343127344127345127346127347127348127349127350127351127352127353127354127355127356127357127358127359127360127361127362127363127364127365127366127367127368127369127370127371127372127373127374127375127376127377127378127379127380127381127382127383127384127385127386127387127388127389127390127391127392127393127394127395127396127397127398127399127400127401127402127403127404127405127406127407127408127409127410127411127412127413127414127415127416127417127418127419127420127421127422127423127424127425127426127427127428127429127430127431127432127433127434127435127436127437127438127439127440127441127442127443127444127445127446127447127448127449127450127451127452127453127454127455127456127457127458127459127460127461127462127463127464127465127466127467127468127469127470127471127472127473127474127475127476127477127478127479127480127481127482127483127484127485127486127487127488127489127490127491127492127493127494127495127496127497127498127499127500127501127502127503127504127505127506127507127508127509127510127511127512127513127514127515127516127517127518127519127520127521127522127523127524127525127526127527127528127529127530127531127532127533127534127535127536127537127538127539127540127541127542127543127544127545127546127547127548127549127550127551127552127553127554127555127556127557127558127559127560127561127562127563127564127565127566127567127568127569127570127571127572127573127574127575127576127577127578127579127580127581127582127583127584127585127586127587127588127589127590127591127592127593127594127595127596127597127598127599127600127601127602127603127604127605127606127607127608127609127610127611127612127613127614127615127616127617127618127619127620127621127622127623127624127625127626127627127628127629127630127631127632127633127634127635127636127637127638127639127640127641127642127643127644127645127646127647127648127649127650127651127652127653127654127655127656127657127658127659127660127661127662127663127664127665127666127667127668127669127670127671127672127673127674127675127676127677127678127679127680127681127682127683127684127685127686127687127688127689127690127691127692127693127694127695127696127697127698127699127700127701127702127703127704127705127706127707127708127709127710127711127712127713127714127715127716127717127718127719127720127721127722127723127724127725127726127727127728127729127730127731127732127733127734127735127736127737127738127739127740127741127742127743127744127745127746127747127748127749127750127751127752127753127754127755127756127757127758127759127760127761127762127763127764127765127766127767127768127769127770127771127772127773127774127775127776127777127778127779127780127781127782127783127784127785127786127787127788127789127790127791127792127793127794127795127796127797127798127799127800127801127802127803127804127805127806127807127808127809127810127811127812127813127814127815127816127817127818127819127820127821127822127823127824127825127826127827127828127829127830127831127832127833127834127835127836127837127838127839127840127841127842127843127844127845127846127847127848127849127850127851127852127853127854127855127856127857127858127859127860127861127862127863127864127865127866127867127868127869127870127871127872127873127874127875127876127877127878127879127880127881127882127883127884127885127886127887127888127889127890127891127892127893127894127895127896127897127898127899127900127901127902127903127904127905127906127907127908127909127910127911127912127913127914127915127916127917127918127919127920127921127922127923127924127925127926127927127928127929127930127931127932127933127934127935127936127937127938127939127940127941127942127943127944127945127946127947127948127949127950127951127952127953127954127955127956127957127958127959127960127961127962127963127964127965127966127967127968127969127970127971127972127973127974127975127976127977127978127979127980127981127982127983127984127985127986127987127988127989127990127991127992127993127994127995127996127997127998127999128000128001128002128003128004128005128006128007128008128009128010128011128012128013128014128015128016128017128018128019128020128021128022128023128024128025128026128027128028128029128030128031128032128033128034128035128036128037128038128039128040128041128042128043128044128045128046128047128048128049128050128051128052128053128054128055128056128057128058128059128060128061128062128063128064128065128066128067128068128069128070128071128072128073128074128075128076128077128078128079128080128081128082128083128084128085128086128087128088128089128090128091128092128093128094128095128096128097128098128099128100128101128102128103128104128105128106128107128108128109128110128111128112128113128114128115128116128117128118128119128120128121128122128123128124128125128126128127128128128129128130128131128132128133128134128135128136128137128138128139128140128141128142128143128144128145128146128147128148128149128150128151128152128153128154128155128156128157128158128159128160128161128162128163128164128165128166128167128168128169128170128171128172128173128174128175128176128177128178128179128180128181128182128183128184128185128186128187128188128189128190128191128192128193128194128195128196128197128198128199128200128201128202128203128204128205128206128207128208128209128210128211128212128213128214128215128216128217128218128219128220128221128222128223128224128225128226128227128228128229128230128231128232128233128234128235128236128237128238128239128240128241128242128243128244128245128246128247128248128249128250128251128252128253128254128255128256128257128258128259128260128261128262128263128264128265128266128267128268128269128270128271128272128273128274128275128276128277128278128279128280128281128282128283128284128285128286128287128288128289128290128291128292128293128294128295128296128297128298128299128300128301128302128303128304128305128306128307128308128309128310128311128312128313128314128315128316128317128318128319128320128321128322128323128324128325128326128327128328128329128330128331128332128333128334128335128336128337128338128339128340128341128342128343128344128345128346128347128348128349128350128351128352128353128354128355128356128357128358128359128360128361128362128363128364128365128366128367128368128369128370128371128372128373128374128375128376128377128378128379128380128381128382128383128384128385128386128387128388128389128390128391128392128393128394128395128396128397128398128399128400128401128402128403128404128405128406128407128408128409128410128411128412128413128414128415128416128417128418128419128420128421128422128423128424128425128426128427128428128429128430128431128432128433128434128435128436128437128438128439128440128441128442128443128444128445128446128447128448128449128450128451128452128453128454128455128456128457128458128459128460128461128462128463128464128465128466128467128468128469128470128471128472128473128474128475128476128477128478128479128480128481128482128483128484128485128486128487128488128489128490128491128492128493128494128495128496128497128498128499128500128501128502128503128504128505128506128507128508128509128510128511128512128513128514128515128516128517128518128519128520128521128522128523128524128525128526128527128528128529128530128531128532128533128534128535128536128537128538128539128540128541128542128543128544128545128546128547128548128549128550128551128552128553128554128555128556128557128558128559128560128561128562128563128564128565128566128567128568128569128570128571128572128573128574128575128576128577128578128579128580128581128582128583128584128585128586128587128588128589128590128591128592128593128594128595128596128597128598128599128600128601128602128603128604128605128606128607128608128609128610128611128612128613128614128615128616128617128618128619128620128621128622128623128624128625128626128627128628128629128630128631128632128633128634128635128636128637128638128639128640128641128642128643128644128645128646128647128648128649128650128651128652128653128654128655128656128657128658128659128660128661128662128663128664128665128666128667128668128669128670128671128672128673128674128675128676128677128678128679128680128681128682128683128684128685128686128687128688128689128690128691128692128693128694128695128696128697128698128699128700128701128702128703128704128705128706128707128708128709128710128711128712128713128714128715128716128717128718128719128720128721128722128723128724128725128726128727128728128729128730128731128732128733128734128735128736128737128738128739128740128741128742128743128744128745128746128747128748128749128750128751128752128753128754128755128756128757128758128759128760128761128762128763128764128765128766128767128768128769128770128771128772128773128774128775128776128777128778128779128780128781128782128783128784128785128786128787128788128789128790128791128792128793128794128795128796128797128798128799128800128801128802128803128804128805128806128807128808128809128810128811128812128813128814128815128816128817128818128819128820128821128822128823128824128825128826128827128828128829128830128831128832128833128834128835128836128837128838128839128840128841128842128843128844128845128846128847128848128849128850128851128852128853128854128855128856128857128858128859128860128861128862128863128864128865128866128867128868128869128870128871128872128873128874128875128876128877128878128879128880128881128882128883128884128885128886128887128888128889128890128891128892128893128894128895128896128897128898128899128900128901128902128903128904128905128906128907128908128909128910128911128912128913128914128915128916128917128918128919128920128921128922128923128924128925128926128927128928128929128930128931128932128933128934128935128936128937128938128939128940128941128942128943128944128945128946128947128948128949128950128951128952128953128954128955128956128957128958128959128960128961128962128963128964128965128966128967128968128969128970128971128972128973128974128975128976128977128978128979128980128981128982128983128984128985128986128987128988128989128990128991128992128993128994128995128996128997128998128999129000129001129002129003129004129005129006129007129008129009129010129011129012129013129014129015129016129017129018129019129020129021129022129023129024129025129026129027129028129029129030129031129032129033129034129035129036129037129038129039129040129041129042129043129044129045129046129047129048129049129050129051129052129053129054129055129056129057129058129059129060129061129062129063129064129065129066129067129068129069129070129071129072129073129074129075129076129077129078129079129080129081129082129083129084129085129086129087129088129089129090129091129092129093129094129095129096129097129098129099129100129101129102129103129104129105129106129107129108129109129110129111129112129113129114129115129116129117129118129119129120129121129122129123129124129125129126129127129128129129129130129131129132129133129134129135129136129137129138129139129140129141129142129143129144129145129146129147129148129149129150129151129152129153129154129155129156129157129158129159129160129161129162129163129164129165129166129167129168129169129170129171129172129173129174129175129176129177129178129179129180129181129182129183129184129185129186129187129188129189129190129191129192129193129194129195129196129197129198129199129200129201129202129203129204129205129206129207129208129209129210129211129212129213129214129215129216129217129218129219129220129221129222129223129224129225129226129227129228129229129230129231129232129233129234129235129236129237129238129239129240129241129242129243129244129245129246129247129248129249129250129251129252129253129254129255129256129257129258129259129260129261129262129263129264129265129266129267129268129269129270129271129272129273129274129275129276129277129278129279129280129281129282129283129284129285129286129287129288129289129290129291129292129293129294129295129296129297129298129299129300129301129302129303129304129305129306129307129308129309129310129311129312129313129314129315129316129317129318129319129320129321129322129323129324129325129326129327129328129329129330129331129332129333129334129335129336129337129338129339129340129341129342129343129344129345129346129347129348129349129350129351129352129353129354129355129356129357129358129359129360129361129362129363129364129365129366129367129368129369129370129371129372129373129374129375129376129377129378129379129380129381129382129383129384129385129386129387129388129389129390129391129392129393129394129395129396129397129398129399129400129401129402129403129404129405129406129407129408129409129410129411129412129413129414129415129416129417129418129419129420129421129422129423129424129425129426129427129428129429129430129431129432129433129434129435129436129437129438129439129440129441129442129443129444129445129446129447129448129449129450129451129452129453129454129455129456129457129458129459129460129461129462129463129464129465129466129467129468129469129470129471129472129473129474129475129476129477129478129479129480129481129482129483129484129485129486129487129488129489129490129491129492129493129494129495129496129497129498129499129500129501129502129503129504129505129506129507129508129509129510129511129512129513129514129515129516129517129518129519129520129521129522129523129524129525129526129527129528129529129530129531129532129533129534129535129536129537129538129539129540129541129542129543129544129545129546129547129548129549129550129551129552129553129554129555129556129557129558129559129560129561129562129563129564129565129566129567129568129569129570129571129572129573129574129575129576129577129578129579129580129581129582129583129584129585129586129587129588129589129590129591129592129593129594129595129596129597129598129599129600129601129602129603129604129605129606129607129608129609129610129611129612129613129614129615129616129617129618129619129620129621129622129623129624129625129626129627129628129629129630129631129632129633129634129635129636129637129638129639129640129641129642129643129644129645129646129647129648129649129650129651129652129653129654129655129656129657129658129659129660129661129662129663129664129665129666129667129668129669129670129671129672129673129674129675129676129677129678129679129680129681129682129683129684129685129686129687129688129689129690129691129692129693129694129695129696129697129698129699129700129701129702129703129704129705129706129707129708129709129710129711129712129713129714129715129716129717129718129719129720129721129722129723129724129725129726129727129728129729129730129731129732129733129734129735129736129737129738129739129740129741129742129743129744129745129746129747129748129749129750129751129752129753129754129755129756129757129758129759129760129761129762129763129764129765129766129767129768129769129770129771129772129773129774129775129776129777129778129779129780129781129782129783129784129785129786129787129788129789129790129791129792129793129794129795129796129797129798129799129800129801129802129803129804129805129806129807129808129809129810129811129812129813129814129815129816129817129818129819129820129821129822129823129824129825129826129827129828129829129830129831129832129833129834129835129836129837129838129839129840129841129842129843129844129845129846129847129848129849129850129851129852129853129854129855129856129857129858129859129860129861129862129863129864129865129866129867129868129869129870129871129872129873129874129875129876129877129878129879129880129881129882129883129884129885129886129887129888129889129890129891129892129893129894129895129896129897129898129899129900129901129902129903129904129905129906129907129908129909129910129911129912129913129914129915129916129917129918129919129920129921129922129923129924129925129926129927129928129929129930129931129932129933129934129935129936129937129938129939129940129941129942129943129944129945129946129947129948129949129950129951129952129953129954129955129956129957129958129959129960129961129962129963129964129965129966129967129968129969129970129971129972129973129974129975129976129977129978129979129980129981129982129983129984129985129986129987129988129989129990129991129992129993129994129995129996129997129998129999130000130001130002130003130004130005130006130007130008130009130010130011130012130013130014130015130016130017130018130019130020130021130022130023130024130025130026130027130028130029130030130031130032130033130034130035130036130037130038130039130040130041130042130043130044130045130046130047130048130049130050130051130052130053130054130055130056130057130058130059130060130061130062130063130064130065130066130067130068130069130070130071130072130073130074130075130076130077130078130079130080130081130082130083130084130085130086130087130088130089130090130091130092130093130094130095130096130097130098130099130100130101130102130103130104130105130106130107130108130109130110130111130112130113130114130115130116130117130118130119130120130121130122130123130124130125130126130127130128130129130130130131130132130133130134130135130136130137130138130139130140130141130142130143130144130145130146130147130148130149130150130151130152130153130154130155130156130157130158130159130160130161130162130163130164130165130166130167130168130169130170130171130172130173130174130175130176130177130178130179130180130181130182130183130184130185130186130187130188130189130190130191130192130193130194130195130196130197130198130199130200130201130202130203130204130205130206130207130208130209130210130211130212130213130214130215130216130217130218130219130220130221130222130223130224130225130226130227130228130229130230130231130232130233130234130235130236130237130238130239130240130241130242130243130244130245130246130247130248130249130250130251130252130253130254130255130256130257130258130259130260130261130262130263130264130265130266130267130268130269130270130271130272130273130274130275130276130277130278130279130280130281130282130283130284130285130286130287130288130289130290130291130292130293130294130295130296130297130298130299130300130301130302130303130304130305130306130307130308130309130310130311130312130313130314130315130316130317130318130319130320130321130322130323130324130325130326130327130328130329130330130331130332130333130334130335130336130337130338130339130340130341130342130343130344130345130346130347130348130349130350130351130352130353130354130355130356130357130358130359130360130361130362130363130364130365130366130367130368130369130370130371130372130373130374130375130376130377130378130379130380130381130382130383130384130385130386130387130388130389130390130391130392130393130394130395130396130397130398130399130400130401130402130403130404130405130406130407130408130409130410130411130412130413130414130415130416130417130418130419130420130421130422130423130424130425130426130427130428130429130430130431130432130433130434130435130436130437130438130439130440130441130442130443130444130445130446130447130448130449130450130451130452130453130454130455130456130457130458130459130460130461130462130463130464130465130466130467130468130469130470130471130472130473130474130475130476130477130478130479130480130481130482130483130484130485130486130487130488130489130490130491130492130493130494130495130496130497130498130499130500130501130502130503130504130505130506130507130508130509130510130511130512130513130514130515130516130517130518130519130520130521130522130523130524130525130526130527130528130529130530130531130532130533130534130535130536130537130538130539130540130541130542130543130544130545130546130547130548130549130550130551130552130553130554130555130556130557130558130559130560130561130562130563130564130565130566130567130568130569130570130571130572130573130574130575130576130577130578130579130580130581130582130583130584130585130586130587130588130589130590130591130592130593130594130595130596130597130598130599130600130601130602130603130604130605130606130607130608130609130610130611130612130613130614130615130616130617130618130619130620130621130622130623130624130625130626130627130628130629130630130631130632130633130634130635130636130637130638130639130640130641130642130643130644130645130646130647130648130649130650130651130652130653130654130655130656130657130658130659130660130661130662130663130664130665130666130667130668130669130670130671130672130673130674130675130676130677130678130679130680130681130682130683130684130685130686130687130688130689130690130691130692130693130694130695130696130697130698130699130700130701130702130703130704130705130706130707130708130709130710130711130712130713130714130715130716130717130718130719130720130721130722130723130724130725130726130727130728130729130730130731130732130733130734130735130736130737130738130739130740130741130742130743130744130745130746130747130748130749130750130751130752130753130754130755130756130757130758130759130760130761130762130763130764130765130766130767130768130769130770130771130772130773130774130775130776130777130778130779130780130781130782130783130784130785130786130787130788130789130790130791130792130793130794130795130796130797130798130799130800130801130802130803130804130805130806130807130808130809130810130811130812130813130814130815130816130817130818130819130820130821130822130823130824130825130826130827130828130829130830130831130832130833130834130835130836130837130838130839130840130841130842130843130844130845130846130847130848130849130850130851130852130853130854130855130856130857130858130859130860130861130862130863130864130865130866130867130868130869130870130871130872130873130874130875130876130877130878130879130880130881130882130883130884130885130886130887130888130889130890130891130892130893130894130895130896130897130898130899130900130901130902130903130904130905130906130907130908130909130910130911130912130913130914130915130916130917130918130919130920130921130922130923130924130925130926130927130928130929130930130931130932130933130934130935130936130937130938130939130940130941130942130943130944130945130946130947130948130949130950130951130952130953130954130955130956130957130958130959130960130961130962130963130964130965130966130967130968130969130970130971130972130973130974130975130976130977130978130979130980130981130982130983130984130985130986130987130988130989130990130991130992130993130994130995130996130997130998130999131000131001131002131003131004131005131006131007131008131009131010131011131012131013131014131015131016131017131018131019131020131021131022131023131024131025131026131027131028131029131030131031131032131033131034131035131036131037131038131039131040131041131042131043131044131045131046131047131048131049131050131051131052131053131054131055131056131057131058131059131060131061131062131063131064131065131066131067131068131069131070131071131072131073131074131075131076131077131078131079131080131081131082131083131084131085131086131087131088131089131090131091131092131093131094131095131096131097131098131099131100131101131102131103131104131105131106131107131108131109131110131111131112131113131114131115131116131117131118131119131120131121131122131123131124131125131126131127131128131129131130131131131132131133131134131135131136131137131138131139131140131141131142131143131144131145131146131147131148131149131150131151131152131153131154131155131156131157131158131159131160131161131162131163131164131165131166131167131168131169131170131171131172131173131174131175131176131177131178131179131180131181131182131183131184131185131186131187131188131189131190131191131192131193131194131195131196131197131198131199131200131201131202131203131204131205131206131207131208131209131210131211131212131213131214131215131216131217131218131219131220131221131222131223131224131225131226131227131228131229131230131231131232131233131234131235131236131237131238131239131240131241131242131243131244131245131246131247131248131249131250131251131252131253131254131255131256131257131258131259131260131261131262131263131264131265131266131267131268131269131270131271131272131273131274131275131276131277131278131279131280131281131282131283131284131285131286131287131288131289131290131291131292131293131294131295131296131297131298131299131300131301131302131303131304131305131306131307131308131309131310131311131312131313131314131315131316131317131318131319131320131321131322131323131324131325131326131327131328131329131330131331131332131333131334131335131336131337131338131339131340131341131342131343131344131345131346131347131348131349131350131351131352131353131354131355131356131357131358131359131360131361131362131363131364131365131366131367131368131369131370131371131372131373131374131375131376131377131378131379131380131381131382131383131384131385131386131387131388131389131390131391131392131393131394131395131396131397131398131399131400131401131402131403131404131405131406131407131408131409131410131411131412131413131414131415131416131417131418131419131420131421131422131423131424131425131426131427131428131429131430131431131432131433131434131435131436131437131438131439131440131441131442131443131444131445131446131447131448131449131450131451131452131453131454131455131456131457131458131459131460131461131462131463131464131465131466131467131468131469131470131471131472131473131474131475131476131477131478131479131480131481131482131483131484131485131486131487131488131489131490131491131492131493131494131495131496131497131498131499131500131501131502131503131504131505131506131507131508131509131510131511131512131513131514131515131516131517131518131519131520131521131522131523131524131525131526131527131528131529131530131531131532131533131534131535131536131537131538131539131540131541131542131543131544131545131546131547131548131549131550131551131552131553131554131555131556131557131558131559131560131561131562131563131564131565131566131567131568131569131570131571131572131573131574131575131576131577131578131579131580131581131582131583131584131585131586131587131588131589131590131591131592131593131594131595131596131597131598131599131600131601131602131603131604131605131606131607131608131609131610131611131612131613131614131615131616131617131618131619131620131621131622131623131624131625131626131627131628131629131630131631131632131633131634131635131636131637131638131639131640131641131642131643131644131645131646131647131648131649131650131651131652131653131654131655131656131657131658131659131660131661131662131663131664131665131666131667131668131669131670131671131672131673131674131675131676131677131678131679131680131681131682131683131684131685131686131687131688131689131690131691131692131693131694131695131696131697131698131699131700131701131702131703131704131705131706131707131708131709131710131711131712131713131714131715131716131717131718131719131720131721131722131723131724131725131726131727131728131729131730131731131732131733131734131735131736131737131738131739131740131741131742131743131744131745131746131747131748131749131750131751131752131753131754131755131756131757131758131759131760131761131762131763131764131765131766131767131768131769131770131771131772131773131774131775131776131777131778131779131780131781131782131783131784131785131786131787131788131789131790131791131792131793131794131795131796131797131798131799131800131801131802131803131804131805131806131807131808131809131810131811131812131813131814131815131816131817131818131819131820131821131822131823131824131825131826131827131828131829131830131831131832131833131834131835131836131837131838131839131840131841131842131843131844131845131846131847131848131849131850131851131852131853131854131855131856131857131858131859131860131861131862131863131864131865131866131867131868131869131870131871131872131873131874131875131876131877131878131879131880131881131882131883131884131885131886131887131888131889131890131891131892131893131894131895131896131897131898131899131900131901131902131903131904131905131906131907131908131909131910131911131912131913131914131915131916131917131918131919131920131921131922131923131924131925131926131927131928131929131930131931131932131933131934131935131936131937131938131939131940131941131942131943131944131945131946131947131948131949131950131951131952131953131954131955131956131957131958131959131960131961131962131963131964131965131966131967131968131969131970131971131972131973131974131975131976131977131978131979131980131981131982131983131984131985131986131987131988131989131990131991131992131993131994131995131996131997131998131999132000132001132002132003132004132005132006132007132008132009132010132011132012132013132014132015132016132017132018132019132020132021132022132023132024132025132026132027132028132029132030132031132032132033132034132035132036132037132038132039132040132041132042132043132044132045132046132047132048132049132050132051132052132053132054132055132056132057132058132059132060132061132062132063132064132065132066132067132068132069132070132071132072132073132074132075132076132077132078132079132080132081132082132083132084132085132086132087132088132089132090132091132092132093132094132095132096132097132098132099132100132101132102132103132104132105132106132107132108132109132110132111132112132113132114132115132116132117132118132119132120132121132122132123132124132125132126132127132128132129132130132131132132132133132134132135132136132137132138132139132140132141132142132143132144132145132146132147132148132149132150132151132152132153132154132155132156132157132158132159132160132161132162132163132164132165132166132167132168132169132170132171132172132173132174132175132176132177132178132179132180132181132182132183132184132185132186132187132188132189132190132191132192132193132194132195132196132197132198132199132200132201132202132203132204132205132206132207132208132209132210132211132212132213132214132215132216132217132218132219132220132221132222132223132224132225132226132227132228132229132230132231132232132233132234132235132236132237132238132239132240132241132242132243132244132245132246132247132248132249132250132251132252132253132254132255132256132257132258132259132260132261132262132263132264132265132266132267132268132269132270132271132272132273132274132275132276132277132278132279132280132281132282132283132284132285132286132287132288132289132290132291132292132293132294132295132296132297132298132299132300132301132302132303132304132305132306132307132308132309132310132311132312132313132314132315132316132317132318132319132320132321132322132323132324132325132326132327132328132329132330132331132332132333132334132335132336132337132338132339132340132341132342132343132344132345132346132347132348132349132350132351132352132353132354132355132356132357132358132359132360132361132362132363132364132365132366132367132368132369132370132371132372132373132374132375132376132377132378132379132380132381132382132383132384132385132386132387132388132389132390132391132392132393132394132395132396132397132398132399132400132401132402132403132404132405132406132407132408132409132410132411132412132413132414132415132416132417132418132419132420132421132422132423132424132425132426132427132428132429132430132431132432132433132434132435132436132437132438132439132440132441132442132443132444132445132446132447132448132449132450132451132452132453132454132455132456132457132458132459132460132461132462132463132464132465132466132467132468132469132470132471132472132473132474132475132476132477132478132479132480132481132482132483132484132485132486132487132488132489132490132491132492132493132494132495132496132497132498132499132500132501132502132503132504132505132506132507132508132509132510132511132512132513132514132515132516132517132518132519132520132521132522132523132524132525132526132527132528132529132530132531132532132533132534132535132536132537132538132539132540132541132542132543132544132545132546132547132548132549132550132551132552132553132554132555132556132557132558132559132560132561132562132563132564132565132566132567132568132569132570132571132572132573132574132575132576132577132578132579132580132581132582132583132584132585132586132587132588132589132590132591132592132593132594132595132596132597132598132599132600132601132602132603132604132605132606132607132608132609132610132611132612132613132614132615132616132617132618132619132620132621132622132623132624132625132626132627132628132629132630132631132632132633132634132635132636132637132638132639132640132641132642132643132644132645132646132647132648132649132650132651132652132653132654132655132656132657132658132659132660132661132662132663132664132665132666132667132668132669132670132671132672132673132674132675132676132677132678132679132680132681132682132683132684132685132686132687132688132689132690132691132692132693132694132695132696132697132698132699132700132701132702132703132704132705132706132707132708132709132710132711132712132713132714132715132716132717132718132719132720132721132722132723132724132725132726132727132728132729132730132731132732132733132734132735132736132737132738132739132740132741132742132743132744132745132746132747132748132749132750132751132752132753132754132755132756132757132758132759132760132761132762132763132764132765132766132767132768132769132770132771132772132773132774132775132776132777132778132779132780132781132782132783132784132785132786132787132788132789132790132791132792132793132794132795132796132797132798132799132800132801132802132803132804132805132806132807132808132809132810132811132812132813132814132815132816132817132818132819132820132821132822132823132824132825132826132827132828132829132830132831132832132833132834132835132836132837132838132839132840132841132842132843132844132845132846132847132848132849132850132851132852132853132854132855132856132857132858132859132860132861132862132863132864132865132866132867132868132869132870132871132872132873132874132875132876132877132878132879132880132881132882132883132884132885132886132887132888132889132890132891132892132893132894132895132896132897132898132899132900132901132902132903132904132905132906132907132908132909132910132911132912132913132914132915132916132917132918132919132920132921132922132923132924132925132926132927132928132929132930132931132932132933132934132935132936132937132938132939132940132941132942132943132944132945132946132947132948132949132950132951132952132953132954132955132956132957132958132959132960132961132962132963132964132965132966132967132968132969132970132971132972132973132974132975132976132977132978132979132980132981132982132983132984132985132986132987132988132989132990132991132992132993132994132995132996132997132998132999133000133001133002133003133004133005133006133007133008133009133010133011133012133013133014133015133016133017133018133019133020133021133022133023133024133025133026133027133028133029133030133031133032133033133034133035133036133037133038133039133040133041133042133043133044133045133046133047133048133049133050133051133052133053133054133055133056133057133058133059133060133061133062133063133064133065133066133067133068133069133070133071133072133073133074133075133076133077133078133079133080133081133082133083133084133085133086133087133088133089133090133091133092133093133094133095133096133097133098133099133100133101133102133103133104133105133106133107133108133109133110133111133112133113133114133115133116133117133118133119133120133121133122133123133124133125133126133127133128133129133130133131133132133133133134133135133136133137133138133139133140133141133142133143133144133145133146133147133148133149133150133151133152133153133154133155133156133157133158133159133160133161133162133163133164133165133166133167133168133169133170133171133172133173133174133175133176133177133178133179133180133181133182133183133184133185133186133187133188133189133190133191133192133193133194133195133196133197133198133199133200133201133202133203133204133205133206133207133208133209133210133211133212133213133214133215133216133217133218133219133220133221133222133223133224133225133226133227133228133229133230133231133232133233133234133235133236133237133238133239133240133241133242133243133244133245133246133247133248133249133250133251133252133253133254133255133256133257133258133259133260133261133262133263133264133265133266133267133268133269133270133271133272133273133274133275133276133277133278133279133280133281133282133283133284133285133286133287133288133289133290133291133292133293133294133295133296133297133298133299133300133301133302133303133304133305133306133307133308133309133310133311133312133313133314133315133316133317133318133319133320133321133322133323133324133325133326133327133328133329133330133331133332133333133334133335133336133337133338133339133340133341133342133343133344133345133346133347133348133349133350133351133352133353133354133355133356133357133358133359133360133361133362133363133364133365133366133367133368133369133370133371133372133373133374133375133376133377133378133379133380133381133382133383133384133385133386133387133388133389133390133391133392133393133394133395133396133397133398133399133400133401133402133403133404133405133406133407133408133409133410133411133412133413133414133415133416133417133418133419133420133421133422133423133424133425133426133427133428133429133430133431133432133433133434133435133436133437133438133439133440133441133442133443133444133445133446133447133448133449133450133451133452133453133454133455133456133457133458133459133460133461133462133463133464133465133466133467133468133469133470133471133472133473133474133475133476133477133478133479133480133481133482133483133484133485133486133487133488133489133490133491133492133493133494133495133496133497133498133499133500133501133502133503133504133505133506133507133508133509133510133511133512133513133514133515133516133517133518133519133520133521133522133523133524133525133526133527133528133529133530133531133532133533133534133535133536133537133538133539133540133541133542133543133544133545133546133547133548133549133550133551133552133553133554133555133556133557133558133559133560133561133562133563133564133565133566133567133568133569133570133571133572133573133574133575133576133577133578133579133580133581133582133583133584133585133586133587133588133589133590133591133592133593133594133595133596133597133598133599133600133601133602133603133604133605133606133607133608133609133610133611133612133613133614133615133616133617133618133619133620133621133622133623133624133625133626133627133628133629133630133631133632133633133634133635133636133637133638133639133640133641133642133643133644133645133646133647133648133649133650133651133652133653133654133655133656133657133658133659133660133661133662133663133664133665133666133667133668133669133670133671133672133673133674133675133676133677133678133679133680133681133682133683133684133685133686133687133688133689133690133691133692133693133694133695133696133697133698133699133700133701133702133703133704133705133706133707133708133709133710133711133712133713133714133715133716133717133718133719133720133721133722133723133724133725133726133727133728133729133730133731133732133733133734133735133736133737133738133739133740133741133742133743133744133745133746133747133748133749133750133751133752133753133754133755133756133757133758133759133760133761133762133763133764133765133766133767133768133769133770133771133772133773133774133775133776133777133778133779133780133781133782133783133784133785133786133787133788133789133790133791133792133793133794133795133796133797133798133799133800133801133802133803133804133805133806133807133808133809133810133811133812133813133814133815133816133817133818133819133820133821133822133823133824133825133826133827133828133829133830133831133832133833133834133835133836133837133838133839133840133841133842133843133844133845133846133847133848133849133850133851133852133853133854133855133856133857133858133859133860133861133862133863133864133865133866133867133868133869133870133871133872133873133874133875133876133877133878133879133880133881133882133883133884133885133886133887133888133889133890133891133892133893133894133895133896133897133898133899133900133901133902133903133904133905133906133907133908133909133910133911133912133913133914133915133916133917133918133919133920133921133922133923133924133925133926133927133928133929133930133931133932133933133934133935133936133937133938133939133940133941133942133943133944133945133946133947133948133949133950133951133952133953133954133955133956133957133958133959133960133961133962133963133964133965133966133967
  1. declare module "babylonjs/types" {
  2. /** Alias type for value that can be null */
  3. export type Nullable<T> = T | null;
  4. /**
  5. * Alias type for number that are floats
  6. * @ignorenaming
  7. */
  8. export type float = number;
  9. /**
  10. * Alias type for number that are doubles.
  11. * @ignorenaming
  12. */
  13. export type double = number;
  14. /**
  15. * Alias type for number that are integer
  16. * @ignorenaming
  17. */
  18. export type int = number;
  19. /** Alias type for number array or Float32Array */
  20. export type FloatArray = number[] | Float32Array;
  21. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  22. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  23. /**
  24. * Alias for types that can be used by a Buffer or VertexBuffer.
  25. */
  26. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  27. /**
  28. * Alias type for primitive types
  29. * @ignorenaming
  30. */
  31. type Primitive = undefined | null | boolean | string | number | Function;
  32. /**
  33. * Type modifier to make all the properties of an object Readonly
  34. */
  35. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  36. /**
  37. * Type modifier to make all the properties of an object Readonly recursively
  38. */
  39. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  40. /**
  41. * Type modifier to make object properties readonly.
  42. */
  43. export type DeepImmutableObject<T> = {
  44. readonly [K in keyof T]: DeepImmutable<T[K]>;
  45. };
  46. /** @hidden */
  47. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  48. }
  49. }
  50. declare module "babylonjs/Misc/observable" {
  51. import { Nullable } from "babylonjs/types";
  52. /**
  53. * A class serves as a medium between the observable and its observers
  54. */
  55. export class EventState {
  56. /**
  57. * Create a new EventState
  58. * @param mask defines the mask associated with this state
  59. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  60. * @param target defines the original target of the state
  61. * @param currentTarget defines the current target of the state
  62. */
  63. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  64. /**
  65. * Initialize the current event state
  66. * @param mask defines the mask associated with this state
  67. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  68. * @param target defines the original target of the state
  69. * @param currentTarget defines the current target of the state
  70. * @returns the current event state
  71. */
  72. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  73. /**
  74. * An Observer can set this property to true to prevent subsequent observers of being notified
  75. */
  76. skipNextObservers: boolean;
  77. /**
  78. * Get the mask value that were used to trigger the event corresponding to this EventState object
  79. */
  80. mask: number;
  81. /**
  82. * The object that originally notified the event
  83. */
  84. target?: any;
  85. /**
  86. * The current object in the bubbling phase
  87. */
  88. currentTarget?: any;
  89. /**
  90. * This will be populated with the return value of the last function that was executed.
  91. * If it is the first function in the callback chain it will be the event data.
  92. */
  93. lastReturnValue?: any;
  94. }
  95. /**
  96. * Represent an Observer registered to a given Observable object.
  97. */
  98. export class Observer<T> {
  99. /**
  100. * Defines the callback to call when the observer is notified
  101. */
  102. callback: (eventData: T, eventState: EventState) => void;
  103. /**
  104. * Defines the mask of the observer (used to filter notifications)
  105. */
  106. mask: number;
  107. /**
  108. * Defines the current scope used to restore the JS context
  109. */
  110. scope: any;
  111. /** @hidden */
  112. _willBeUnregistered: boolean;
  113. /**
  114. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  115. */
  116. unregisterOnNextCall: boolean;
  117. /**
  118. * Creates a new observer
  119. * @param callback defines the callback to call when the observer is notified
  120. * @param mask defines the mask of the observer (used to filter notifications)
  121. * @param scope defines the current scope used to restore the JS context
  122. */
  123. constructor(
  124. /**
  125. * Defines the callback to call when the observer is notified
  126. */
  127. callback: (eventData: T, eventState: EventState) => void,
  128. /**
  129. * Defines the mask of the observer (used to filter notifications)
  130. */
  131. mask: number,
  132. /**
  133. * Defines the current scope used to restore the JS context
  134. */
  135. scope?: any);
  136. }
  137. /**
  138. * Represent a list of observers registered to multiple Observables object.
  139. */
  140. export class MultiObserver<T> {
  141. private _observers;
  142. private _observables;
  143. /**
  144. * Release associated resources
  145. */
  146. dispose(): void;
  147. /**
  148. * Raise a callback when one of the observable will notify
  149. * @param observables defines a list of observables to watch
  150. * @param callback defines the callback to call on notification
  151. * @param mask defines the mask used to filter notifications
  152. * @param scope defines the current scope used to restore the JS context
  153. * @returns the new MultiObserver
  154. */
  155. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  156. }
  157. /**
  158. * The Observable class is a simple implementation of the Observable pattern.
  159. *
  160. * There's one slight particularity though: a given Observable can notify its observer using a particular mask value, only the Observers registered with this mask value will be notified.
  161. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  162. * For instance you may have a given Observable that have four different types of notifications: Move (mask = 0x01), Stop (mask = 0x02), Turn Right (mask = 0X04), Turn Left (mask = 0X08).
  163. * A given observer can register itself with only Move and Stop (mask = 0x03), then it will only be notified when one of these two occurs and will never be for Turn Left/Right.
  164. */
  165. export class Observable<T> {
  166. private _observers;
  167. private _eventState;
  168. private _onObserverAdded;
  169. /**
  170. * Gets the list of observers
  171. */
  172. readonly observers: Array<Observer<T>>;
  173. /**
  174. * Creates a new observable
  175. * @param onObserverAdded defines a callback to call when a new observer is added
  176. */
  177. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  178. /**
  179. * Create a new Observer with the specified callback
  180. * @param callback the callback that will be executed for that Observer
  181. * @param mask the mask used to filter observers
  182. * @param insertFirst if true the callback will be inserted at the first position, hence executed before the others ones. If false (default behavior) the callback will be inserted at the last position, executed after all the others already present.
  183. * @param scope optional scope for the callback to be called from
  184. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  185. * @returns the new observer created for the callback
  186. */
  187. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  188. /**
  189. * Create a new Observer with the specified callback and unregisters after the next notification
  190. * @param callback the callback that will be executed for that Observer
  191. * @returns the new observer created for the callback
  192. */
  193. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  194. /**
  195. * Remove an Observer from the Observable object
  196. * @param observer the instance of the Observer to remove
  197. * @returns false if it doesn't belong to this Observable
  198. */
  199. remove(observer: Nullable<Observer<T>>): boolean;
  200. /**
  201. * Remove a callback from the Observable object
  202. * @param callback the callback to remove
  203. * @param scope optional scope. If used only the callbacks with this scope will be removed
  204. * @returns false if it doesn't belong to this Observable
  205. */
  206. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  207. private _deferUnregister;
  208. private _remove;
  209. /**
  210. * Moves the observable to the top of the observer list making it get called first when notified
  211. * @param observer the observer to move
  212. */
  213. makeObserverTopPriority(observer: Observer<T>): void;
  214. /**
  215. * Moves the observable to the bottom of the observer list making it get called last when notified
  216. * @param observer the observer to move
  217. */
  218. makeObserverBottomPriority(observer: Observer<T>): void;
  219. /**
  220. * Notify all Observers by calling their respective callback with the given data
  221. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  222. * @param eventData defines the data to send to all observers
  223. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  224. * @param target defines the original target of the state
  225. * @param currentTarget defines the current target of the state
  226. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  227. */
  228. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  229. /**
  230. * Calling this will execute each callback, expecting it to be a promise or return a value.
  231. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  232. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  233. * and it is crucial that all callbacks will be executed.
  234. * The order of the callbacks is kept, callbacks are not executed parallel.
  235. *
  236. * @param eventData The data to be sent to each callback
  237. * @param mask is used to filter observers defaults to -1
  238. * @param target defines the callback target (see EventState)
  239. * @param currentTarget defines he current object in the bubbling phase
  240. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  241. */
  242. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  243. /**
  244. * Notify a specific observer
  245. * @param observer defines the observer to notify
  246. * @param eventData defines the data to be sent to each callback
  247. * @param mask is used to filter observers defaults to -1
  248. */
  249. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  250. /**
  251. * Gets a boolean indicating if the observable has at least one observer
  252. * @returns true is the Observable has at least one Observer registered
  253. */
  254. hasObservers(): boolean;
  255. /**
  256. * Clear the list of observers
  257. */
  258. clear(): void;
  259. /**
  260. * Clone the current observable
  261. * @returns a new observable
  262. */
  263. clone(): Observable<T>;
  264. /**
  265. * Does this observable handles observer registered with a given mask
  266. * @param mask defines the mask to be tested
  267. * @return whether or not one observer registered with the given mask is handeled
  268. **/
  269. hasSpecificMask(mask?: number): boolean;
  270. }
  271. }
  272. declare module "babylonjs/Misc/domManagement" {
  273. /**
  274. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  275. * Babylon.js
  276. */
  277. export class DomManagement {
  278. /**
  279. * Checks if the window object exists
  280. * @returns true if the window object exists
  281. */
  282. static IsWindowObjectExist(): boolean;
  283. /**
  284. * Checks if the navigator object exists
  285. * @returns true if the navigator object exists
  286. */
  287. static IsNavigatorAvailable(): boolean;
  288. /**
  289. * Extracts text content from a DOM element hierarchy
  290. * @param element defines the root element
  291. * @returns a string
  292. */
  293. static GetDOMTextContent(element: HTMLElement): string;
  294. }
  295. }
  296. declare module "babylonjs/Misc/logger" {
  297. /**
  298. * Logger used througouht the application to allow configuration of
  299. * the log level required for the messages.
  300. */
  301. export class Logger {
  302. /**
  303. * No log
  304. */
  305. static readonly NoneLogLevel: number;
  306. /**
  307. * Only message logs
  308. */
  309. static readonly MessageLogLevel: number;
  310. /**
  311. * Only warning logs
  312. */
  313. static readonly WarningLogLevel: number;
  314. /**
  315. * Only error logs
  316. */
  317. static readonly ErrorLogLevel: number;
  318. /**
  319. * All logs
  320. */
  321. static readonly AllLogLevel: number;
  322. private static _LogCache;
  323. /**
  324. * Gets a value indicating the number of loading errors
  325. * @ignorenaming
  326. */
  327. static errorsCount: number;
  328. /**
  329. * Callback called when a new log is added
  330. */
  331. static OnNewCacheEntry: (entry: string) => void;
  332. private static _AddLogEntry;
  333. private static _FormatMessage;
  334. private static _LogDisabled;
  335. private static _LogEnabled;
  336. private static _WarnDisabled;
  337. private static _WarnEnabled;
  338. private static _ErrorDisabled;
  339. private static _ErrorEnabled;
  340. /**
  341. * Log a message to the console
  342. */
  343. static Log: (message: string) => void;
  344. /**
  345. * Write a warning message to the console
  346. */
  347. static Warn: (message: string) => void;
  348. /**
  349. * Write an error message to the console
  350. */
  351. static Error: (message: string) => void;
  352. /**
  353. * Gets current log cache (list of logs)
  354. */
  355. static readonly LogCache: string;
  356. /**
  357. * Clears the log cache
  358. */
  359. static ClearLogCache(): void;
  360. /**
  361. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  362. */
  363. static LogLevels: number;
  364. }
  365. }
  366. declare module "babylonjs/Misc/typeStore" {
  367. /** @hidden */
  368. export class _TypeStore {
  369. /** @hidden */
  370. static RegisteredTypes: {
  371. [key: string]: Object;
  372. };
  373. /** @hidden */
  374. static GetClass(fqdn: string): any;
  375. }
  376. }
  377. declare module "babylonjs/Misc/stringTools" {
  378. /**
  379. * Helper to manipulate strings
  380. */
  381. export class StringTools {
  382. /**
  383. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  384. * @param str Source string
  385. * @param suffix Suffix to search for in the source string
  386. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  387. */
  388. static EndsWith(str: string, suffix: string): boolean;
  389. /**
  390. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  391. * @param str Source string
  392. * @param suffix Suffix to search for in the source string
  393. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  394. */
  395. static StartsWith(str: string, suffix: string): boolean;
  396. /**
  397. * Decodes a buffer into a string
  398. * @param buffer The buffer to decode
  399. * @returns The decoded string
  400. */
  401. static Decode(buffer: Uint8Array | Uint16Array): string;
  402. /**
  403. * Encode a buffer to a base64 string
  404. * @param buffer defines the buffer to encode
  405. * @returns the encoded string
  406. */
  407. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  408. }
  409. }
  410. declare module "babylonjs/Misc/deepCopier" {
  411. /**
  412. * Class containing a set of static utilities functions for deep copy.
  413. */
  414. export class DeepCopier {
  415. /**
  416. * Tries to copy an object by duplicating every property
  417. * @param source defines the source object
  418. * @param destination defines the target object
  419. * @param doNotCopyList defines a list of properties to avoid
  420. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  421. */
  422. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  423. }
  424. }
  425. declare module "babylonjs/Misc/precisionDate" {
  426. /**
  427. * Class containing a set of static utilities functions for precision date
  428. */
  429. export class PrecisionDate {
  430. /**
  431. * Gets either window.performance.now() if supported or Date.now() else
  432. */
  433. static readonly Now: number;
  434. }
  435. }
  436. declare module "babylonjs/Misc/devTools" {
  437. /** @hidden */
  438. export class _DevTools {
  439. static WarnImport(name: string): string;
  440. }
  441. }
  442. declare module "babylonjs/Misc/interfaces/iWebRequest" {
  443. /**
  444. * Interface used to define the mechanism to get data from the network
  445. */
  446. export interface IWebRequest {
  447. /**
  448. * Returns client's response url
  449. */
  450. responseURL: string;
  451. /**
  452. * Returns client's status
  453. */
  454. status: number;
  455. /**
  456. * Returns client's status as a text
  457. */
  458. statusText: string;
  459. }
  460. }
  461. declare module "babylonjs/Misc/webRequest" {
  462. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  463. import { Nullable } from "babylonjs/types";
  464. /**
  465. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  466. */
  467. export class WebRequest implements IWebRequest {
  468. private _xhr;
  469. /**
  470. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  471. * i.e. when loading files, where the server/service expects an Authorization header
  472. */
  473. static CustomRequestHeaders: {
  474. [key: string]: string;
  475. };
  476. /**
  477. * Add callback functions in this array to update all the requests before they get sent to the network
  478. */
  479. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  480. private _injectCustomRequestHeaders;
  481. /**
  482. * Gets or sets a function to be called when loading progress changes
  483. */
  484. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  485. /**
  486. * Returns client's state
  487. */
  488. readonly readyState: number;
  489. /**
  490. * Returns client's status
  491. */
  492. readonly status: number;
  493. /**
  494. * Returns client's status as a text
  495. */
  496. readonly statusText: string;
  497. /**
  498. * Returns client's response
  499. */
  500. readonly response: any;
  501. /**
  502. * Returns client's response url
  503. */
  504. readonly responseURL: string;
  505. /**
  506. * Returns client's response as text
  507. */
  508. readonly responseText: string;
  509. /**
  510. * Gets or sets the expected response type
  511. */
  512. responseType: XMLHttpRequestResponseType;
  513. /** @hidden */
  514. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  515. /** @hidden */
  516. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  517. /**
  518. * Cancels any network activity
  519. */
  520. abort(): void;
  521. /**
  522. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  523. * @param body defines an optional request body
  524. */
  525. send(body?: Document | BodyInit | null): void;
  526. /**
  527. * Sets the request method, request URL
  528. * @param method defines the method to use (GET, POST, etc..)
  529. * @param url defines the url to connect with
  530. */
  531. open(method: string, url: string): void;
  532. /**
  533. * Sets the value of a request header.
  534. * @param name The name of the header whose value is to be set
  535. * @param value The value to set as the body of the header
  536. */
  537. setRequestHeader(name: string, value: string): void;
  538. /**
  539. * Get the string containing the text of a particular header's value.
  540. * @param name The name of the header
  541. * @returns The string containing the text of the given header name
  542. */
  543. getResponseHeader(name: string): Nullable<string>;
  544. }
  545. }
  546. declare module "babylonjs/Misc/fileRequest" {
  547. import { Observable } from "babylonjs/Misc/observable";
  548. /**
  549. * File request interface
  550. */
  551. export interface IFileRequest {
  552. /**
  553. * Raised when the request is complete (success or error).
  554. */
  555. onCompleteObservable: Observable<IFileRequest>;
  556. /**
  557. * Aborts the request for a file.
  558. */
  559. abort: () => void;
  560. }
  561. }
  562. declare module "babylonjs/Materials/Textures/renderTargetCreationOptions" {
  563. /**
  564. * Define options used to create a render target texture
  565. */
  566. export class RenderTargetCreationOptions {
  567. /**
  568. * Specifies is mipmaps must be generated
  569. */
  570. generateMipMaps?: boolean;
  571. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  572. generateDepthBuffer?: boolean;
  573. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  574. generateStencilBuffer?: boolean;
  575. /** Defines texture type (int by default) */
  576. type?: number;
  577. /** Defines sampling mode (trilinear by default) */
  578. samplingMode?: number;
  579. /** Defines format (RGBA by default) */
  580. format?: number;
  581. }
  582. }
  583. declare module "babylonjs/Instrumentation/timeToken" {
  584. import { Nullable } from "babylonjs/types";
  585. /**
  586. * @hidden
  587. **/
  588. export class _TimeToken {
  589. _startTimeQuery: Nullable<WebGLQuery>;
  590. _endTimeQuery: Nullable<WebGLQuery>;
  591. _timeElapsedQuery: Nullable<WebGLQuery>;
  592. _timeElapsedQueryEnded: boolean;
  593. }
  594. }
  595. declare module "babylonjs/Engines/constants" {
  596. /** Defines the cross module used constants to avoid circular dependncies */
  597. export class Constants {
  598. /** Defines that alpha blending is disabled */
  599. static readonly ALPHA_DISABLE: number;
  600. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  601. static readonly ALPHA_ADD: number;
  602. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  603. static readonly ALPHA_COMBINE: number;
  604. /** Defines that alpha blending to DEST - SRC * DEST */
  605. static readonly ALPHA_SUBTRACT: number;
  606. /** Defines that alpha blending to SRC * DEST */
  607. static readonly ALPHA_MULTIPLY: number;
  608. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  609. static readonly ALPHA_MAXIMIZED: number;
  610. /** Defines that alpha blending to SRC + DEST */
  611. static readonly ALPHA_ONEONE: number;
  612. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  613. static readonly ALPHA_PREMULTIPLIED: number;
  614. /**
  615. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  616. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  617. */
  618. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  619. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  620. static readonly ALPHA_INTERPOLATE: number;
  621. /**
  622. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  623. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  624. */
  625. static readonly ALPHA_SCREENMODE: number;
  626. /**
  627. * Defines that alpha blending to SRC + DST
  628. * Alpha will be set to SRC ALPHA + DST ALPHA
  629. */
  630. static readonly ALPHA_ONEONE_ONEONE: number;
  631. /**
  632. * Defines that alpha blending to SRC * DST ALPHA + DST
  633. * Alpha will be set to 0
  634. */
  635. static readonly ALPHA_ALPHATOCOLOR: number;
  636. /**
  637. * Defines that alpha blending to SRC * (1 - DST) + DST * (1 - SRC)
  638. */
  639. static readonly ALPHA_REVERSEONEMINUS: number;
  640. /**
  641. * Defines that alpha blending to SRC + DST * (1 - SRC ALPHA)
  642. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  643. */
  644. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  645. /**
  646. * Defines that alpha blending to SRC + DST
  647. * Alpha will be set to SRC ALPHA
  648. */
  649. static readonly ALPHA_ONEONE_ONEZERO: number;
  650. /** Defines that alpha blending equation a SUM */
  651. static readonly ALPHA_EQUATION_ADD: number;
  652. /** Defines that alpha blending equation a SUBSTRACTION */
  653. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  654. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  655. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  656. /** Defines that alpha blending equation a MAX operation */
  657. static readonly ALPHA_EQUATION_MAX: number;
  658. /** Defines that alpha blending equation a MIN operation */
  659. static readonly ALPHA_EQUATION_MIN: number;
  660. /**
  661. * Defines that alpha blending equation a DARKEN operation:
  662. * It takes the min of the src and sums the alpha channels.
  663. */
  664. static readonly ALPHA_EQUATION_DARKEN: number;
  665. /** Defines that the ressource is not delayed*/
  666. static readonly DELAYLOADSTATE_NONE: number;
  667. /** Defines that the ressource was successfully delay loaded */
  668. static readonly DELAYLOADSTATE_LOADED: number;
  669. /** Defines that the ressource is currently delay loading */
  670. static readonly DELAYLOADSTATE_LOADING: number;
  671. /** Defines that the ressource is delayed and has not started loading */
  672. static readonly DELAYLOADSTATE_NOTLOADED: number;
  673. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  674. static readonly NEVER: number;
  675. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */
  676. static readonly ALWAYS: number;
  677. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  678. static readonly LESS: number;
  679. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  680. static readonly EQUAL: number;
  681. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than or equal to the stored value */
  682. static readonly LEQUAL: number;
  683. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  684. static readonly GREATER: number;
  685. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than or equal to the stored value */
  686. static readonly GEQUAL: number;
  687. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is not equal to the stored value */
  688. static readonly NOTEQUAL: number;
  689. /** Passed to stencilOperation to specify that stencil value must be kept */
  690. static readonly KEEP: number;
  691. /** Passed to stencilOperation to specify that stencil value must be replaced */
  692. static readonly REPLACE: number;
  693. /** Passed to stencilOperation to specify that stencil value must be incremented */
  694. static readonly INCR: number;
  695. /** Passed to stencilOperation to specify that stencil value must be decremented */
  696. static readonly DECR: number;
  697. /** Passed to stencilOperation to specify that stencil value must be inverted */
  698. static readonly INVERT: number;
  699. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  700. static readonly INCR_WRAP: number;
  701. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  702. static readonly DECR_WRAP: number;
  703. /** Texture is not repeating outside of 0..1 UVs */
  704. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  705. /** Texture is repeating outside of 0..1 UVs */
  706. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  707. /** Texture is repeating and mirrored */
  708. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  709. /** ALPHA */
  710. static readonly TEXTUREFORMAT_ALPHA: number;
  711. /** LUMINANCE */
  712. static readonly TEXTUREFORMAT_LUMINANCE: number;
  713. /** LUMINANCE_ALPHA */
  714. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  715. /** RGB */
  716. static readonly TEXTUREFORMAT_RGB: number;
  717. /** RGBA */
  718. static readonly TEXTUREFORMAT_RGBA: number;
  719. /** RED */
  720. static readonly TEXTUREFORMAT_RED: number;
  721. /** RED (2nd reference) */
  722. static readonly TEXTUREFORMAT_R: number;
  723. /** RG */
  724. static readonly TEXTUREFORMAT_RG: number;
  725. /** RED_INTEGER */
  726. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  727. /** RED_INTEGER (2nd reference) */
  728. static readonly TEXTUREFORMAT_R_INTEGER: number;
  729. /** RG_INTEGER */
  730. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  731. /** RGB_INTEGER */
  732. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  733. /** RGBA_INTEGER */
  734. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  735. /** UNSIGNED_BYTE */
  736. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  737. /** UNSIGNED_BYTE (2nd reference) */
  738. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  739. /** FLOAT */
  740. static readonly TEXTURETYPE_FLOAT: number;
  741. /** HALF_FLOAT */
  742. static readonly TEXTURETYPE_HALF_FLOAT: number;
  743. /** BYTE */
  744. static readonly TEXTURETYPE_BYTE: number;
  745. /** SHORT */
  746. static readonly TEXTURETYPE_SHORT: number;
  747. /** UNSIGNED_SHORT */
  748. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  749. /** INT */
  750. static readonly TEXTURETYPE_INT: number;
  751. /** UNSIGNED_INT */
  752. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  753. /** UNSIGNED_SHORT_4_4_4_4 */
  754. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  755. /** UNSIGNED_SHORT_5_5_5_1 */
  756. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  757. /** UNSIGNED_SHORT_5_6_5 */
  758. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  759. /** UNSIGNED_INT_2_10_10_10_REV */
  760. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  761. /** UNSIGNED_INT_24_8 */
  762. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  763. /** UNSIGNED_INT_10F_11F_11F_REV */
  764. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  765. /** UNSIGNED_INT_5_9_9_9_REV */
  766. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  767. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  768. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  769. /** nearest is mag = nearest and min = nearest and mip = nearest */
  770. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  771. /** Bilinear is mag = linear and min = linear and mip = nearest */
  772. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  773. /** Trilinear is mag = linear and min = linear and mip = linear */
  774. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  775. /** nearest is mag = nearest and min = nearest and mip = linear */
  776. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  777. /** Bilinear is mag = linear and min = linear and mip = nearest */
  778. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  779. /** Trilinear is mag = linear and min = linear and mip = linear */
  780. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  781. /** mag = nearest and min = nearest and mip = nearest */
  782. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  783. /** mag = nearest and min = linear and mip = nearest */
  784. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  785. /** mag = nearest and min = linear and mip = linear */
  786. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  787. /** mag = nearest and min = linear and mip = none */
  788. static readonly TEXTURE_NEAREST_LINEAR: number;
  789. /** mag = nearest and min = nearest and mip = none */
  790. static readonly TEXTURE_NEAREST_NEAREST: number;
  791. /** mag = linear and min = nearest and mip = nearest */
  792. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  793. /** mag = linear and min = nearest and mip = linear */
  794. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  795. /** mag = linear and min = linear and mip = none */
  796. static readonly TEXTURE_LINEAR_LINEAR: number;
  797. /** mag = linear and min = nearest and mip = none */
  798. static readonly TEXTURE_LINEAR_NEAREST: number;
  799. /** Explicit coordinates mode */
  800. static readonly TEXTURE_EXPLICIT_MODE: number;
  801. /** Spherical coordinates mode */
  802. static readonly TEXTURE_SPHERICAL_MODE: number;
  803. /** Planar coordinates mode */
  804. static readonly TEXTURE_PLANAR_MODE: number;
  805. /** Cubic coordinates mode */
  806. static readonly TEXTURE_CUBIC_MODE: number;
  807. /** Projection coordinates mode */
  808. static readonly TEXTURE_PROJECTION_MODE: number;
  809. /** Skybox coordinates mode */
  810. static readonly TEXTURE_SKYBOX_MODE: number;
  811. /** Inverse Cubic coordinates mode */
  812. static readonly TEXTURE_INVCUBIC_MODE: number;
  813. /** Equirectangular coordinates mode */
  814. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  815. /** Equirectangular Fixed coordinates mode */
  816. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  817. /** Equirectangular Fixed Mirrored coordinates mode */
  818. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  819. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  820. static readonly SCALEMODE_FLOOR: number;
  821. /** Defines that texture rescaling will look for the nearest power of 2 size */
  822. static readonly SCALEMODE_NEAREST: number;
  823. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  824. static readonly SCALEMODE_CEILING: number;
  825. /**
  826. * The dirty texture flag value
  827. */
  828. static readonly MATERIAL_TextureDirtyFlag: number;
  829. /**
  830. * The dirty light flag value
  831. */
  832. static readonly MATERIAL_LightDirtyFlag: number;
  833. /**
  834. * The dirty fresnel flag value
  835. */
  836. static readonly MATERIAL_FresnelDirtyFlag: number;
  837. /**
  838. * The dirty attribute flag value
  839. */
  840. static readonly MATERIAL_AttributesDirtyFlag: number;
  841. /**
  842. * The dirty misc flag value
  843. */
  844. static readonly MATERIAL_MiscDirtyFlag: number;
  845. /**
  846. * The all dirty flag value
  847. */
  848. static readonly MATERIAL_AllDirtyFlag: number;
  849. /**
  850. * Returns the triangle fill mode
  851. */
  852. static readonly MATERIAL_TriangleFillMode: number;
  853. /**
  854. * Returns the wireframe mode
  855. */
  856. static readonly MATERIAL_WireFrameFillMode: number;
  857. /**
  858. * Returns the point fill mode
  859. */
  860. static readonly MATERIAL_PointFillMode: number;
  861. /**
  862. * Returns the point list draw mode
  863. */
  864. static readonly MATERIAL_PointListDrawMode: number;
  865. /**
  866. * Returns the line list draw mode
  867. */
  868. static readonly MATERIAL_LineListDrawMode: number;
  869. /**
  870. * Returns the line loop draw mode
  871. */
  872. static readonly MATERIAL_LineLoopDrawMode: number;
  873. /**
  874. * Returns the line strip draw mode
  875. */
  876. static readonly MATERIAL_LineStripDrawMode: number;
  877. /**
  878. * Returns the triangle strip draw mode
  879. */
  880. static readonly MATERIAL_TriangleStripDrawMode: number;
  881. /**
  882. * Returns the triangle fan draw mode
  883. */
  884. static readonly MATERIAL_TriangleFanDrawMode: number;
  885. /**
  886. * Stores the clock-wise side orientation
  887. */
  888. static readonly MATERIAL_ClockWiseSideOrientation: number;
  889. /**
  890. * Stores the counter clock-wise side orientation
  891. */
  892. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  893. /**
  894. * Nothing
  895. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  896. */
  897. static readonly ACTION_NothingTrigger: number;
  898. /**
  899. * On pick
  900. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  901. */
  902. static readonly ACTION_OnPickTrigger: number;
  903. /**
  904. * On left pick
  905. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  906. */
  907. static readonly ACTION_OnLeftPickTrigger: number;
  908. /**
  909. * On right pick
  910. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  911. */
  912. static readonly ACTION_OnRightPickTrigger: number;
  913. /**
  914. * On center pick
  915. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  916. */
  917. static readonly ACTION_OnCenterPickTrigger: number;
  918. /**
  919. * On pick down
  920. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  921. */
  922. static readonly ACTION_OnPickDownTrigger: number;
  923. /**
  924. * On double pick
  925. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  926. */
  927. static readonly ACTION_OnDoublePickTrigger: number;
  928. /**
  929. * On pick up
  930. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  931. */
  932. static readonly ACTION_OnPickUpTrigger: number;
  933. /**
  934. * On pick out.
  935. * This trigger will only be raised if you also declared a OnPickDown
  936. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  937. */
  938. static readonly ACTION_OnPickOutTrigger: number;
  939. /**
  940. * On long press
  941. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  942. */
  943. static readonly ACTION_OnLongPressTrigger: number;
  944. /**
  945. * On pointer over
  946. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  947. */
  948. static readonly ACTION_OnPointerOverTrigger: number;
  949. /**
  950. * On pointer out
  951. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  952. */
  953. static readonly ACTION_OnPointerOutTrigger: number;
  954. /**
  955. * On every frame
  956. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  957. */
  958. static readonly ACTION_OnEveryFrameTrigger: number;
  959. /**
  960. * On intersection enter
  961. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  962. */
  963. static readonly ACTION_OnIntersectionEnterTrigger: number;
  964. /**
  965. * On intersection exit
  966. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  967. */
  968. static readonly ACTION_OnIntersectionExitTrigger: number;
  969. /**
  970. * On key down
  971. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  972. */
  973. static readonly ACTION_OnKeyDownTrigger: number;
  974. /**
  975. * On key up
  976. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  977. */
  978. static readonly ACTION_OnKeyUpTrigger: number;
  979. /**
  980. * Billboard mode will only apply to Y axis
  981. */
  982. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  983. /**
  984. * Billboard mode will apply to all axes
  985. */
  986. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  987. /**
  988. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  989. */
  990. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  991. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  992. * Test order :
  993. * Is the bounding sphere outside the frustum ?
  994. * If not, are the bounding box vertices outside the frustum ?
  995. * It not, then the cullable object is in the frustum.
  996. */
  997. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  998. /** Culling strategy : Bounding Sphere Only.
  999. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  1000. * It's also less accurate than the standard because some not visible objects can still be selected.
  1001. * Test : is the bounding sphere outside the frustum ?
  1002. * If not, then the cullable object is in the frustum.
  1003. */
  1004. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  1005. /** Culling strategy : Optimistic Inclusion.
  1006. * This in an inclusion test first, then the standard exclusion test.
  1007. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  1008. * This could also be a little slower than the standard test when the tested object center is not the frustum but one of its bounding box vertex is still inside.
  1009. * Anyway, it's as accurate as the standard strategy.
  1010. * Test :
  1011. * Is the cullable object bounding sphere center in the frustum ?
  1012. * If not, apply the default culling strategy.
  1013. */
  1014. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  1015. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  1016. * This in an inclusion test first, then the bounding sphere only exclusion test.
  1017. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  1018. * This could also be a little slower than the BoundingSphereOnly strategy when the tested object center is not in the frustum but its bounding sphere still intersects it.
  1019. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  1020. * Test :
  1021. * Is the cullable object bounding sphere center in the frustum ?
  1022. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  1023. */
  1024. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  1025. /**
  1026. * No logging while loading
  1027. */
  1028. static readonly SCENELOADER_NO_LOGGING: number;
  1029. /**
  1030. * Minimal logging while loading
  1031. */
  1032. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  1033. /**
  1034. * Summary logging while loading
  1035. */
  1036. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  1037. /**
  1038. * Detailled logging while loading
  1039. */
  1040. static readonly SCENELOADER_DETAILED_LOGGING: number;
  1041. }
  1042. }
  1043. declare module "babylonjs/Materials/Textures/internalTextureLoader" {
  1044. import { Nullable } from "babylonjs/types";
  1045. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  1046. /**
  1047. * This represents the required contract to create a new type of texture loader.
  1048. */
  1049. export interface IInternalTextureLoader {
  1050. /**
  1051. * Defines wether the loader supports cascade loading the different faces.
  1052. */
  1053. supportCascades: boolean;
  1054. /**
  1055. * This returns if the loader support the current file information.
  1056. * @param extension defines the file extension of the file being loaded
  1057. * @param textureFormatInUse defines the current compressed format in use iun the engine
  1058. * @param fallback defines the fallback internal texture if any
  1059. * @param isBase64 defines whether the texture is encoded as a base64
  1060. * @param isBuffer defines whether the texture data are stored as a buffer
  1061. * @returns true if the loader can load the specified file
  1062. */
  1063. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  1064. /**
  1065. * Transform the url before loading if required.
  1066. * @param rootUrl the url of the texture
  1067. * @param textureFormatInUse defines the current compressed format in use iun the engine
  1068. * @returns the transformed texture
  1069. */
  1070. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  1071. /**
  1072. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  1073. * @param rootUrl the url of the texture
  1074. * @param textureFormatInUse defines the current compressed format in use iun the engine
  1075. * @returns the fallback texture
  1076. */
  1077. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  1078. /**
  1079. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  1080. * @param data contains the texture data
  1081. * @param texture defines the BabylonJS internal texture
  1082. * @param createPolynomials will be true if polynomials have been requested
  1083. * @param onLoad defines the callback to trigger once the texture is ready
  1084. * @param onError defines the callback to trigger in case of error
  1085. */
  1086. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  1087. /**
  1088. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  1089. * @param data contains the texture data
  1090. * @param texture defines the BabylonJS internal texture
  1091. * @param callback defines the method to call once ready to upload
  1092. */
  1093. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  1094. }
  1095. }
  1096. declare module "babylonjs/Engines/IPipelineContext" {
  1097. /**
  1098. * Class used to store and describe the pipeline context associated with an effect
  1099. */
  1100. export interface IPipelineContext {
  1101. /**
  1102. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  1103. */
  1104. isAsync: boolean;
  1105. /**
  1106. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  1107. */
  1108. isReady: boolean;
  1109. /** @hidden */
  1110. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1111. }
  1112. }
  1113. declare module "babylonjs/Meshes/dataBuffer" {
  1114. /**
  1115. * Class used to store gfx data (like WebGLBuffer)
  1116. */
  1117. export class DataBuffer {
  1118. /**
  1119. * Gets or sets the number of objects referencing this buffer
  1120. */
  1121. references: number;
  1122. /** Gets or sets the size of the underlying buffer */
  1123. capacity: number;
  1124. /**
  1125. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1126. */
  1127. is32Bits: boolean;
  1128. /**
  1129. * Gets the underlying buffer
  1130. */
  1131. readonly underlyingResource: any;
  1132. }
  1133. }
  1134. declare module "babylonjs/Engines/Processors/iShaderProcessor" {
  1135. /** @hidden */
  1136. export interface IShaderProcessor {
  1137. attributeProcessor?: (attribute: string) => string;
  1138. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  1139. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  1140. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  1141. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  1142. lineProcessor?: (line: string, isFragment: boolean) => string;
  1143. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1144. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1145. }
  1146. }
  1147. declare module "babylonjs/Engines/Processors/shaderProcessingOptions" {
  1148. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  1149. /** @hidden */
  1150. export interface ProcessingOptions {
  1151. defines: string[];
  1152. indexParameters: any;
  1153. isFragment: boolean;
  1154. shouldUseHighPrecisionShader: boolean;
  1155. supportsUniformBuffers: boolean;
  1156. shadersRepository: string;
  1157. includesShadersStore: {
  1158. [key: string]: string;
  1159. };
  1160. processor?: IShaderProcessor;
  1161. version: string;
  1162. platformName: string;
  1163. lookForClosingBracketForUniformBuffer?: boolean;
  1164. }
  1165. }
  1166. declare module "babylonjs/Engines/Processors/shaderCodeNode" {
  1167. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1168. /** @hidden */
  1169. export class ShaderCodeNode {
  1170. line: string;
  1171. children: ShaderCodeNode[];
  1172. additionalDefineKey?: string;
  1173. additionalDefineValue?: string;
  1174. isValid(preprocessors: {
  1175. [key: string]: string;
  1176. }): boolean;
  1177. process(preprocessors: {
  1178. [key: string]: string;
  1179. }, options: ProcessingOptions): string;
  1180. }
  1181. }
  1182. declare module "babylonjs/Engines/Processors/shaderCodeCursor" {
  1183. /** @hidden */
  1184. export class ShaderCodeCursor {
  1185. private _lines;
  1186. lineIndex: number;
  1187. readonly currentLine: string;
  1188. readonly canRead: boolean;
  1189. lines: string[];
  1190. }
  1191. }
  1192. declare module "babylonjs/Engines/Processors/shaderCodeConditionNode" {
  1193. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  1194. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1195. /** @hidden */
  1196. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1197. process(preprocessors: {
  1198. [key: string]: string;
  1199. }, options: ProcessingOptions): string;
  1200. }
  1201. }
  1202. declare module "babylonjs/Engines/Processors/Expressions/shaderDefineExpression" {
  1203. /** @hidden */
  1204. export class ShaderDefineExpression {
  1205. isTrue(preprocessors: {
  1206. [key: string]: string;
  1207. }): boolean;
  1208. }
  1209. }
  1210. declare module "babylonjs/Engines/Processors/shaderCodeTestNode" {
  1211. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  1212. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1213. /** @hidden */
  1214. export class ShaderCodeTestNode extends ShaderCodeNode {
  1215. testExpression: ShaderDefineExpression;
  1216. isValid(preprocessors: {
  1217. [key: string]: string;
  1218. }): boolean;
  1219. }
  1220. }
  1221. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator" {
  1222. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1223. /** @hidden */
  1224. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1225. define: string;
  1226. not: boolean;
  1227. constructor(define: string, not?: boolean);
  1228. isTrue(preprocessors: {
  1229. [key: string]: string;
  1230. }): boolean;
  1231. }
  1232. }
  1233. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator" {
  1234. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1235. /** @hidden */
  1236. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  1237. leftOperand: ShaderDefineExpression;
  1238. rightOperand: ShaderDefineExpression;
  1239. isTrue(preprocessors: {
  1240. [key: string]: string;
  1241. }): boolean;
  1242. }
  1243. }
  1244. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator" {
  1245. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1246. /** @hidden */
  1247. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1248. leftOperand: ShaderDefineExpression;
  1249. rightOperand: ShaderDefineExpression;
  1250. isTrue(preprocessors: {
  1251. [key: string]: string;
  1252. }): boolean;
  1253. }
  1254. }
  1255. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator" {
  1256. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1257. /** @hidden */
  1258. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1259. define: string;
  1260. operand: string;
  1261. testValue: string;
  1262. constructor(define: string, operand: string, testValue: string);
  1263. isTrue(preprocessors: {
  1264. [key: string]: string;
  1265. }): boolean;
  1266. }
  1267. }
  1268. declare module "babylonjs/Offline/IOfflineProvider" {
  1269. /**
  1270. * Class used to enable access to offline support
  1271. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1272. */
  1273. export interface IOfflineProvider {
  1274. /**
  1275. * Gets a boolean indicating if scene must be saved in the database
  1276. */
  1277. enableSceneOffline: boolean;
  1278. /**
  1279. * Gets a boolean indicating if textures must be saved in the database
  1280. */
  1281. enableTexturesOffline: boolean;
  1282. /**
  1283. * Open the offline support and make it available
  1284. * @param successCallback defines the callback to call on success
  1285. * @param errorCallback defines the callback to call on error
  1286. */
  1287. open(successCallback: () => void, errorCallback: () => void): void;
  1288. /**
  1289. * Loads an image from the offline support
  1290. * @param url defines the url to load from
  1291. * @param image defines the target DOM image
  1292. */
  1293. loadImage(url: string, image: HTMLImageElement): void;
  1294. /**
  1295. * Loads a file from offline support
  1296. * @param url defines the URL to load from
  1297. * @param sceneLoaded defines a callback to call on success
  1298. * @param progressCallBack defines a callback to call when progress changed
  1299. * @param errorCallback defines a callback to call on error
  1300. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1301. */
  1302. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1303. }
  1304. }
  1305. declare module "babylonjs/Misc/filesInputStore" {
  1306. /**
  1307. * Class used to help managing file picking and drag'n'drop
  1308. * File Storage
  1309. */
  1310. export class FilesInputStore {
  1311. /**
  1312. * List of files ready to be loaded
  1313. */
  1314. static FilesToLoad: {
  1315. [key: string]: File;
  1316. };
  1317. }
  1318. }
  1319. declare module "babylonjs/Misc/retryStrategy" {
  1320. import { WebRequest } from "babylonjs/Misc/webRequest";
  1321. /**
  1322. * Class used to define a retry strategy when error happens while loading assets
  1323. */
  1324. export class RetryStrategy {
  1325. /**
  1326. * Function used to defines an exponential back off strategy
  1327. * @param maxRetries defines the maximum number of retries (3 by default)
  1328. * @param baseInterval defines the interval between retries
  1329. * @returns the strategy function to use
  1330. */
  1331. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1332. }
  1333. }
  1334. declare module "babylonjs/Misc/baseError" {
  1335. /**
  1336. * @ignore
  1337. * Application error to support additional information when loading a file
  1338. */
  1339. export abstract class BaseError extends Error {
  1340. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  1341. }
  1342. }
  1343. declare module "babylonjs/Misc/fileTools" {
  1344. import { WebRequest } from "babylonjs/Misc/webRequest";
  1345. import { Nullable } from "babylonjs/types";
  1346. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  1347. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  1348. import { BaseError } from "babylonjs/Misc/baseError";
  1349. /** @ignore */
  1350. export class LoadFileError extends BaseError {
  1351. request?: WebRequest;
  1352. file?: File;
  1353. /**
  1354. * Creates a new LoadFileError
  1355. * @param message defines the message of the error
  1356. * @param request defines the optional web request
  1357. * @param file defines the optional file
  1358. */
  1359. constructor(message: string, object?: WebRequest | File);
  1360. }
  1361. /** @ignore */
  1362. export class RequestFileError extends BaseError {
  1363. request: WebRequest;
  1364. /**
  1365. * Creates a new LoadFileError
  1366. * @param message defines the message of the error
  1367. * @param request defines the optional web request
  1368. */
  1369. constructor(message: string, request: WebRequest);
  1370. }
  1371. /** @ignore */
  1372. export class ReadFileError extends BaseError {
  1373. file: File;
  1374. /**
  1375. * Creates a new ReadFileError
  1376. * @param message defines the message of the error
  1377. * @param file defines the optional file
  1378. */
  1379. constructor(message: string, file: File);
  1380. }
  1381. /**
  1382. * @hidden
  1383. */
  1384. export class FileTools {
  1385. /**
  1386. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1387. */
  1388. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1389. /**
  1390. * Gets or sets the base URL to use to load assets
  1391. */
  1392. static BaseUrl: string;
  1393. /**
  1394. * Default behaviour for cors in the application.
  1395. * It can be a string if the expected behavior is identical in the entire app.
  1396. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1397. */
  1398. static CorsBehavior: string | ((url: string | string[]) => string);
  1399. /**
  1400. * Gets or sets a function used to pre-process url before using them to load assets
  1401. */
  1402. static PreprocessUrl: (url: string) => string;
  1403. /**
  1404. * Removes unwanted characters from an url
  1405. * @param url defines the url to clean
  1406. * @returns the cleaned url
  1407. */
  1408. private static _CleanUrl;
  1409. /**
  1410. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1411. * @param url define the url we are trying
  1412. * @param element define the dom element where to configure the cors policy
  1413. */
  1414. static SetCorsBehavior(url: string | string[], element: {
  1415. crossOrigin: string | null;
  1416. }): void;
  1417. /**
  1418. * Loads an image as an HTMLImageElement.
  1419. * @param input url string, ArrayBuffer, or Blob to load
  1420. * @param onLoad callback called when the image successfully loads
  1421. * @param onError callback called when the image fails to load
  1422. * @param offlineProvider offline provider for caching
  1423. * @param mimeType optional mime type
  1424. * @returns the HTMLImageElement of the loaded image
  1425. */
  1426. static LoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  1427. /**
  1428. * Reads a file from a File object
  1429. * @param file defines the file to load
  1430. * @param onSuccess defines the callback to call when data is loaded
  1431. * @param onProgress defines the callback to call during loading process
  1432. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1433. * @param onError defines the callback to call when an error occurs
  1434. * @returns a file request object
  1435. */
  1436. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  1437. /**
  1438. * Loads a file from a url
  1439. * @param url url to load
  1440. * @param onSuccess callback called when the file successfully loads
  1441. * @param onProgress callback called while file is loading (if the server supports this mode)
  1442. * @param offlineProvider defines the offline provider for caching
  1443. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1444. * @param onError callback called when the file fails to load
  1445. * @returns a file request object
  1446. */
  1447. static LoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  1448. /**
  1449. * Loads a file
  1450. * @param url url to load
  1451. * @param onSuccess callback called when the file successfully loads
  1452. * @param onProgress callback called while file is loading (if the server supports this mode)
  1453. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1454. * @param onError callback called when the file fails to load
  1455. * @param onOpened callback called when the web request is opened
  1456. * @returns a file request object
  1457. */
  1458. static RequestFile(url: string, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, onProgress?: (event: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  1459. /**
  1460. * Checks if the loaded document was accessed via `file:`-Protocol.
  1461. * @returns boolean
  1462. */
  1463. static IsFileURL(): boolean;
  1464. }
  1465. }
  1466. declare module "babylonjs/Engines/Processors/shaderProcessor" {
  1467. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1468. /** @hidden */
  1469. export class ShaderProcessor {
  1470. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  1471. private static _ProcessPrecision;
  1472. private static _ExtractOperation;
  1473. private static _BuildSubExpression;
  1474. private static _BuildExpression;
  1475. private static _MoveCursorWithinIf;
  1476. private static _MoveCursor;
  1477. private static _EvaluatePreProcessors;
  1478. private static _PreparePreProcessors;
  1479. private static _ProcessShaderConversion;
  1480. private static _ProcessIncludes;
  1481. }
  1482. }
  1483. declare module "babylonjs/Maths/math.like" {
  1484. import { float, int, DeepImmutable } from "babylonjs/types";
  1485. /**
  1486. * @hidden
  1487. */
  1488. export interface IColor4Like {
  1489. r: float;
  1490. g: float;
  1491. b: float;
  1492. a: float;
  1493. }
  1494. /**
  1495. * @hidden
  1496. */
  1497. export interface IColor3Like {
  1498. r: float;
  1499. g: float;
  1500. b: float;
  1501. }
  1502. /**
  1503. * @hidden
  1504. */
  1505. export interface IVector4Like {
  1506. x: float;
  1507. y: float;
  1508. z: float;
  1509. w: float;
  1510. }
  1511. /**
  1512. * @hidden
  1513. */
  1514. export interface IVector3Like {
  1515. x: float;
  1516. y: float;
  1517. z: float;
  1518. }
  1519. /**
  1520. * @hidden
  1521. */
  1522. export interface IVector2Like {
  1523. x: float;
  1524. y: float;
  1525. }
  1526. /**
  1527. * @hidden
  1528. */
  1529. export interface IMatrixLike {
  1530. toArray(): DeepImmutable<Float32Array>;
  1531. updateFlag: int;
  1532. }
  1533. /**
  1534. * @hidden
  1535. */
  1536. export interface IViewportLike {
  1537. x: float;
  1538. y: float;
  1539. width: float;
  1540. height: float;
  1541. }
  1542. /**
  1543. * @hidden
  1544. */
  1545. export interface IPlaneLike {
  1546. normal: IVector3Like;
  1547. d: float;
  1548. normalize(): void;
  1549. }
  1550. }
  1551. declare module "babylonjs/Materials/iEffectFallbacks" {
  1552. import { Effect } from "babylonjs/Materials/effect";
  1553. /**
  1554. * Interface used to define common properties for effect fallbacks
  1555. */
  1556. export interface IEffectFallbacks {
  1557. /**
  1558. * Removes the defines that should be removed when falling back.
  1559. * @param currentDefines defines the current define statements for the shader.
  1560. * @param effect defines the current effect we try to compile
  1561. * @returns The resulting defines with defines of the current rank removed.
  1562. */
  1563. reduce(currentDefines: string, effect: Effect): string;
  1564. /**
  1565. * Removes the fallback from the bound mesh.
  1566. */
  1567. unBindMesh(): void;
  1568. /**
  1569. * Checks to see if more fallbacks are still availible.
  1570. */
  1571. hasMoreFallbacks: boolean;
  1572. }
  1573. }
  1574. declare module "babylonjs/Misc/andOrNotEvaluator" {
  1575. /**
  1576. * Class used to evalaute queries containing `and` and `or` operators
  1577. */
  1578. export class AndOrNotEvaluator {
  1579. /**
  1580. * Evaluate a query
  1581. * @param query defines the query to evaluate
  1582. * @param evaluateCallback defines the callback used to filter result
  1583. * @returns true if the query matches
  1584. */
  1585. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  1586. private static _HandleParenthesisContent;
  1587. private static _SimplifyNegation;
  1588. }
  1589. }
  1590. declare module "babylonjs/Misc/tags" {
  1591. /**
  1592. * Class used to store custom tags
  1593. */
  1594. export class Tags {
  1595. /**
  1596. * Adds support for tags on the given object
  1597. * @param obj defines the object to use
  1598. */
  1599. static EnableFor(obj: any): void;
  1600. /**
  1601. * Removes tags support
  1602. * @param obj defines the object to use
  1603. */
  1604. static DisableFor(obj: any): void;
  1605. /**
  1606. * Gets a boolean indicating if the given object has tags
  1607. * @param obj defines the object to use
  1608. * @returns a boolean
  1609. */
  1610. static HasTags(obj: any): boolean;
  1611. /**
  1612. * Gets the tags available on a given object
  1613. * @param obj defines the object to use
  1614. * @param asString defines if the tags must be returned as a string instead of an array of strings
  1615. * @returns the tags
  1616. */
  1617. static GetTags(obj: any, asString?: boolean): any;
  1618. /**
  1619. * Adds tags to an object
  1620. * @param obj defines the object to use
  1621. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  1622. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  1623. */
  1624. static AddTagsTo(obj: any, tagsString: string): void;
  1625. /**
  1626. * @hidden
  1627. */
  1628. static _AddTagTo(obj: any, tag: string): void;
  1629. /**
  1630. * Removes specific tags from a specific object
  1631. * @param obj defines the object to use
  1632. * @param tagsString defines the tags to remove
  1633. */
  1634. static RemoveTagsFrom(obj: any, tagsString: string): void;
  1635. /**
  1636. * @hidden
  1637. */
  1638. static _RemoveTagFrom(obj: any, tag: string): void;
  1639. /**
  1640. * Defines if tags hosted on an object match a given query
  1641. * @param obj defines the object to use
  1642. * @param tagsQuery defines the tag query
  1643. * @returns a boolean
  1644. */
  1645. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  1646. }
  1647. }
  1648. declare module "babylonjs/Maths/math.scalar" {
  1649. /**
  1650. * Scalar computation library
  1651. */
  1652. export class Scalar {
  1653. /**
  1654. * Two pi constants convenient for computation.
  1655. */
  1656. static TwoPi: number;
  1657. /**
  1658. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1659. * @param a number
  1660. * @param b number
  1661. * @param epsilon (default = 1.401298E-45)
  1662. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1663. */
  1664. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1665. /**
  1666. * Returns a string : the upper case translation of the number i to hexadecimal.
  1667. * @param i number
  1668. * @returns the upper case translation of the number i to hexadecimal.
  1669. */
  1670. static ToHex(i: number): string;
  1671. /**
  1672. * Returns -1 if value is negative and +1 is value is positive.
  1673. * @param value the value
  1674. * @returns the value itself if it's equal to zero.
  1675. */
  1676. static Sign(value: number): number;
  1677. /**
  1678. * Returns the value itself if it's between min and max.
  1679. * Returns min if the value is lower than min.
  1680. * Returns max if the value is greater than max.
  1681. * @param value the value to clmap
  1682. * @param min the min value to clamp to (default: 0)
  1683. * @param max the max value to clamp to (default: 1)
  1684. * @returns the clamped value
  1685. */
  1686. static Clamp(value: number, min?: number, max?: number): number;
  1687. /**
  1688. * the log2 of value.
  1689. * @param value the value to compute log2 of
  1690. * @returns the log2 of value.
  1691. */
  1692. static Log2(value: number): number;
  1693. /**
  1694. * Loops the value, so that it is never larger than length and never smaller than 0.
  1695. *
  1696. * This is similar to the modulo operator but it works with floating point numbers.
  1697. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1698. * With t = 5 and length = 2.5, the result would be 0.0.
  1699. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1700. * @param value the value
  1701. * @param length the length
  1702. * @returns the looped value
  1703. */
  1704. static Repeat(value: number, length: number): number;
  1705. /**
  1706. * Normalize the value between 0.0 and 1.0 using min and max values
  1707. * @param value value to normalize
  1708. * @param min max to normalize between
  1709. * @param max min to normalize between
  1710. * @returns the normalized value
  1711. */
  1712. static Normalize(value: number, min: number, max: number): number;
  1713. /**
  1714. * Denormalize the value from 0.0 and 1.0 using min and max values
  1715. * @param normalized value to denormalize
  1716. * @param min max to denormalize between
  1717. * @param max min to denormalize between
  1718. * @returns the denormalized value
  1719. */
  1720. static Denormalize(normalized: number, min: number, max: number): number;
  1721. /**
  1722. * Calculates the shortest difference between two given angles given in degrees.
  1723. * @param current current angle in degrees
  1724. * @param target target angle in degrees
  1725. * @returns the delta
  1726. */
  1727. static DeltaAngle(current: number, target: number): number;
  1728. /**
  1729. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1730. * @param tx value
  1731. * @param length length
  1732. * @returns The returned value will move back and forth between 0 and length
  1733. */
  1734. static PingPong(tx: number, length: number): number;
  1735. /**
  1736. * Interpolates between min and max with smoothing at the limits.
  1737. *
  1738. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1739. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1740. * @param from from
  1741. * @param to to
  1742. * @param tx value
  1743. * @returns the smooth stepped value
  1744. */
  1745. static SmoothStep(from: number, to: number, tx: number): number;
  1746. /**
  1747. * Moves a value current towards target.
  1748. *
  1749. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1750. * Negative values of maxDelta pushes the value away from target.
  1751. * @param current current value
  1752. * @param target target value
  1753. * @param maxDelta max distance to move
  1754. * @returns resulting value
  1755. */
  1756. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1757. /**
  1758. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1759. *
  1760. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1761. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1762. * @param current current value
  1763. * @param target target value
  1764. * @param maxDelta max distance to move
  1765. * @returns resulting angle
  1766. */
  1767. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1768. /**
  1769. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1770. * @param start start value
  1771. * @param end target value
  1772. * @param amount amount to lerp between
  1773. * @returns the lerped value
  1774. */
  1775. static Lerp(start: number, end: number, amount: number): number;
  1776. /**
  1777. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1778. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1779. * @param start start value
  1780. * @param end target value
  1781. * @param amount amount to lerp between
  1782. * @returns the lerped value
  1783. */
  1784. static LerpAngle(start: number, end: number, amount: number): number;
  1785. /**
  1786. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1787. * @param a start value
  1788. * @param b target value
  1789. * @param value value between a and b
  1790. * @returns the inverseLerp value
  1791. */
  1792. static InverseLerp(a: number, b: number, value: number): number;
  1793. /**
  1794. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1795. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1796. * @param value1 spline value
  1797. * @param tangent1 spline value
  1798. * @param value2 spline value
  1799. * @param tangent2 spline value
  1800. * @param amount input value
  1801. * @returns hermite result
  1802. */
  1803. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1804. /**
  1805. * Returns a random float number between and min and max values
  1806. * @param min min value of random
  1807. * @param max max value of random
  1808. * @returns random value
  1809. */
  1810. static RandomRange(min: number, max: number): number;
  1811. /**
  1812. * This function returns percentage of a number in a given range.
  1813. *
  1814. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1815. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1816. * @param number to convert to percentage
  1817. * @param min min range
  1818. * @param max max range
  1819. * @returns the percentage
  1820. */
  1821. static RangeToPercent(number: number, min: number, max: number): number;
  1822. /**
  1823. * This function returns number that corresponds to the percentage in a given range.
  1824. *
  1825. * PercentToRange(0.34,0,100) will return 34.
  1826. * @param percent to convert to number
  1827. * @param min min range
  1828. * @param max max range
  1829. * @returns the number
  1830. */
  1831. static PercentToRange(percent: number, min: number, max: number): number;
  1832. /**
  1833. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1834. * @param angle The angle to normalize in radian.
  1835. * @return The converted angle.
  1836. */
  1837. static NormalizeRadians(angle: number): number;
  1838. }
  1839. }
  1840. declare module "babylonjs/Maths/math.constants" {
  1841. /**
  1842. * Constant used to convert a value to gamma space
  1843. * @ignorenaming
  1844. */
  1845. export const ToGammaSpace: number;
  1846. /**
  1847. * Constant used to convert a value to linear space
  1848. * @ignorenaming
  1849. */
  1850. export const ToLinearSpace = 2.2;
  1851. /**
  1852. * Constant used to define the minimal number value in Babylon.js
  1853. * @ignorenaming
  1854. */
  1855. let Epsilon: number;
  1856. export { Epsilon };
  1857. }
  1858. declare module "babylonjs/Maths/math.viewport" {
  1859. /**
  1860. * Class used to represent a viewport on screen
  1861. */
  1862. export class Viewport {
  1863. /** viewport left coordinate */
  1864. x: number;
  1865. /** viewport top coordinate */
  1866. y: number;
  1867. /**viewport width */
  1868. width: number;
  1869. /** viewport height */
  1870. height: number;
  1871. /**
  1872. * Creates a Viewport object located at (x, y) and sized (width, height)
  1873. * @param x defines viewport left coordinate
  1874. * @param y defines viewport top coordinate
  1875. * @param width defines the viewport width
  1876. * @param height defines the viewport height
  1877. */
  1878. constructor(
  1879. /** viewport left coordinate */
  1880. x: number,
  1881. /** viewport top coordinate */
  1882. y: number,
  1883. /**viewport width */
  1884. width: number,
  1885. /** viewport height */
  1886. height: number);
  1887. /**
  1888. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1889. * @param renderWidth defines the rendering width
  1890. * @param renderHeight defines the rendering height
  1891. * @returns a new Viewport
  1892. */
  1893. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1894. /**
  1895. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1896. * @param renderWidth defines the rendering width
  1897. * @param renderHeight defines the rendering height
  1898. * @param ref defines the target viewport
  1899. * @returns the current viewport
  1900. */
  1901. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1902. /**
  1903. * Returns a new Viewport copied from the current one
  1904. * @returns a new Viewport
  1905. */
  1906. clone(): Viewport;
  1907. }
  1908. }
  1909. declare module "babylonjs/Misc/arrayTools" {
  1910. /**
  1911. * Class containing a set of static utilities functions for arrays.
  1912. */
  1913. export class ArrayTools {
  1914. /**
  1915. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1916. * @param size the number of element to construct and put in the array
  1917. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1918. * @returns a new array filled with new objects
  1919. */
  1920. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1921. }
  1922. }
  1923. declare module "babylonjs/Maths/math.vector" {
  1924. import { Viewport } from "babylonjs/Maths/math.viewport";
  1925. import { DeepImmutable, Nullable, FloatArray, float } from "babylonjs/types";
  1926. import { IPlaneLike } from "babylonjs/Maths/math.like";
  1927. /**
  1928. * Class representing a vector containing 2 coordinates
  1929. */
  1930. export class Vector2 {
  1931. /** defines the first coordinate */
  1932. x: number;
  1933. /** defines the second coordinate */
  1934. y: number;
  1935. /**
  1936. * Creates a new Vector2 from the given x and y coordinates
  1937. * @param x defines the first coordinate
  1938. * @param y defines the second coordinate
  1939. */
  1940. constructor(
  1941. /** defines the first coordinate */
  1942. x?: number,
  1943. /** defines the second coordinate */
  1944. y?: number);
  1945. /**
  1946. * Gets a string with the Vector2 coordinates
  1947. * @returns a string with the Vector2 coordinates
  1948. */
  1949. toString(): string;
  1950. /**
  1951. * Gets class name
  1952. * @returns the string "Vector2"
  1953. */
  1954. getClassName(): string;
  1955. /**
  1956. * Gets current vector hash code
  1957. * @returns the Vector2 hash code as a number
  1958. */
  1959. getHashCode(): number;
  1960. /**
  1961. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  1962. * @param array defines the source array
  1963. * @param index defines the offset in source array
  1964. * @returns the current Vector2
  1965. */
  1966. toArray(array: FloatArray, index?: number): Vector2;
  1967. /**
  1968. * Copy the current vector to an array
  1969. * @returns a new array with 2 elements: the Vector2 coordinates.
  1970. */
  1971. asArray(): number[];
  1972. /**
  1973. * Sets the Vector2 coordinates with the given Vector2 coordinates
  1974. * @param source defines the source Vector2
  1975. * @returns the current updated Vector2
  1976. */
  1977. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  1978. /**
  1979. * Sets the Vector2 coordinates with the given floats
  1980. * @param x defines the first coordinate
  1981. * @param y defines the second coordinate
  1982. * @returns the current updated Vector2
  1983. */
  1984. copyFromFloats(x: number, y: number): Vector2;
  1985. /**
  1986. * Sets the Vector2 coordinates with the given floats
  1987. * @param x defines the first coordinate
  1988. * @param y defines the second coordinate
  1989. * @returns the current updated Vector2
  1990. */
  1991. set(x: number, y: number): Vector2;
  1992. /**
  1993. * Add another vector with the current one
  1994. * @param otherVector defines the other vector
  1995. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  1996. */
  1997. add(otherVector: DeepImmutable<Vector2>): Vector2;
  1998. /**
  1999. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  2000. * @param otherVector defines the other vector
  2001. * @param result defines the target vector
  2002. * @returns the unmodified current Vector2
  2003. */
  2004. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2005. /**
  2006. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  2007. * @param otherVector defines the other vector
  2008. * @returns the current updated Vector2
  2009. */
  2010. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2011. /**
  2012. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  2013. * @param otherVector defines the other vector
  2014. * @returns a new Vector2
  2015. */
  2016. addVector3(otherVector: Vector3): Vector2;
  2017. /**
  2018. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  2019. * @param otherVector defines the other vector
  2020. * @returns a new Vector2
  2021. */
  2022. subtract(otherVector: Vector2): Vector2;
  2023. /**
  2024. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  2025. * @param otherVector defines the other vector
  2026. * @param result defines the target vector
  2027. * @returns the unmodified current Vector2
  2028. */
  2029. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2030. /**
  2031. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  2032. * @param otherVector defines the other vector
  2033. * @returns the current updated Vector2
  2034. */
  2035. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2036. /**
  2037. * Multiplies in place the current Vector2 coordinates by the given ones
  2038. * @param otherVector defines the other vector
  2039. * @returns the current updated Vector2
  2040. */
  2041. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2042. /**
  2043. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2044. * @param otherVector defines the other vector
  2045. * @returns a new Vector2
  2046. */
  2047. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2048. /**
  2049. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2050. * @param otherVector defines the other vector
  2051. * @param result defines the target vector
  2052. * @returns the unmodified current Vector2
  2053. */
  2054. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2055. /**
  2056. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2057. * @param x defines the first coordinate
  2058. * @param y defines the second coordinate
  2059. * @returns a new Vector2
  2060. */
  2061. multiplyByFloats(x: number, y: number): Vector2;
  2062. /**
  2063. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2064. * @param otherVector defines the other vector
  2065. * @returns a new Vector2
  2066. */
  2067. divide(otherVector: Vector2): Vector2;
  2068. /**
  2069. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2070. * @param otherVector defines the other vector
  2071. * @param result defines the target vector
  2072. * @returns the unmodified current Vector2
  2073. */
  2074. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2075. /**
  2076. * Divides the current Vector2 coordinates by the given ones
  2077. * @param otherVector defines the other vector
  2078. * @returns the current updated Vector2
  2079. */
  2080. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2081. /**
  2082. * Gets a new Vector2 with current Vector2 negated coordinates
  2083. * @returns a new Vector2
  2084. */
  2085. negate(): Vector2;
  2086. /**
  2087. * Multiply the Vector2 coordinates by scale
  2088. * @param scale defines the scaling factor
  2089. * @returns the current updated Vector2
  2090. */
  2091. scaleInPlace(scale: number): Vector2;
  2092. /**
  2093. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2094. * @param scale defines the scaling factor
  2095. * @returns a new Vector2
  2096. */
  2097. scale(scale: number): Vector2;
  2098. /**
  2099. * Scale the current Vector2 values by a factor to a given Vector2
  2100. * @param scale defines the scale factor
  2101. * @param result defines the Vector2 object where to store the result
  2102. * @returns the unmodified current Vector2
  2103. */
  2104. scaleToRef(scale: number, result: Vector2): Vector2;
  2105. /**
  2106. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2107. * @param scale defines the scale factor
  2108. * @param result defines the Vector2 object where to store the result
  2109. * @returns the unmodified current Vector2
  2110. */
  2111. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2112. /**
  2113. * Gets a boolean if two vectors are equals
  2114. * @param otherVector defines the other vector
  2115. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2116. */
  2117. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2118. /**
  2119. * Gets a boolean if two vectors are equals (using an epsilon value)
  2120. * @param otherVector defines the other vector
  2121. * @param epsilon defines the minimal distance to consider equality
  2122. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2123. */
  2124. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2125. /**
  2126. * Gets a new Vector2 from current Vector2 floored values
  2127. * @returns a new Vector2
  2128. */
  2129. floor(): Vector2;
  2130. /**
  2131. * Gets a new Vector2 from current Vector2 floored values
  2132. * @returns a new Vector2
  2133. */
  2134. fract(): Vector2;
  2135. /**
  2136. * Gets the length of the vector
  2137. * @returns the vector length (float)
  2138. */
  2139. length(): number;
  2140. /**
  2141. * Gets the vector squared length
  2142. * @returns the vector squared length (float)
  2143. */
  2144. lengthSquared(): number;
  2145. /**
  2146. * Normalize the vector
  2147. * @returns the current updated Vector2
  2148. */
  2149. normalize(): Vector2;
  2150. /**
  2151. * Gets a new Vector2 copied from the Vector2
  2152. * @returns a new Vector2
  2153. */
  2154. clone(): Vector2;
  2155. /**
  2156. * Gets a new Vector2(0, 0)
  2157. * @returns a new Vector2
  2158. */
  2159. static Zero(): Vector2;
  2160. /**
  2161. * Gets a new Vector2(1, 1)
  2162. * @returns a new Vector2
  2163. */
  2164. static One(): Vector2;
  2165. /**
  2166. * Gets a new Vector2 set from the given index element of the given array
  2167. * @param array defines the data source
  2168. * @param offset defines the offset in the data source
  2169. * @returns a new Vector2
  2170. */
  2171. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2172. /**
  2173. * Sets "result" from the given index element of the given array
  2174. * @param array defines the data source
  2175. * @param offset defines the offset in the data source
  2176. * @param result defines the target vector
  2177. */
  2178. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2179. /**
  2180. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2181. * @param value1 defines 1st point of control
  2182. * @param value2 defines 2nd point of control
  2183. * @param value3 defines 3rd point of control
  2184. * @param value4 defines 4th point of control
  2185. * @param amount defines the interpolation factor
  2186. * @returns a new Vector2
  2187. */
  2188. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2189. /**
  2190. * Returns a new Vector2 set with same the coordinates than "value" ones if the vector "value" is in the square defined by "min" and "max".
  2191. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2192. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2193. * @param value defines the value to clamp
  2194. * @param min defines the lower limit
  2195. * @param max defines the upper limit
  2196. * @returns a new Vector2
  2197. */
  2198. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  2199. /**
  2200. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  2201. * @param value1 defines the 1st control point
  2202. * @param tangent1 defines the outgoing tangent
  2203. * @param value2 defines the 2nd control point
  2204. * @param tangent2 defines the incoming tangent
  2205. * @param amount defines the interpolation factor
  2206. * @returns a new Vector2
  2207. */
  2208. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  2209. /**
  2210. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  2211. * @param start defines the start vector
  2212. * @param end defines the end vector
  2213. * @param amount defines the interpolation factor
  2214. * @returns a new Vector2
  2215. */
  2216. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  2217. /**
  2218. * Gets the dot product of the vector "left" and the vector "right"
  2219. * @param left defines first vector
  2220. * @param right defines second vector
  2221. * @returns the dot product (float)
  2222. */
  2223. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  2224. /**
  2225. * Returns a new Vector2 equal to the normalized given vector
  2226. * @param vector defines the vector to normalize
  2227. * @returns a new Vector2
  2228. */
  2229. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  2230. /**
  2231. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  2232. * @param left defines 1st vector
  2233. * @param right defines 2nd vector
  2234. * @returns a new Vector2
  2235. */
  2236. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2237. /**
  2238. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  2239. * @param left defines 1st vector
  2240. * @param right defines 2nd vector
  2241. * @returns a new Vector2
  2242. */
  2243. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2244. /**
  2245. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  2246. * @param vector defines the vector to transform
  2247. * @param transformation defines the matrix to apply
  2248. * @returns a new Vector2
  2249. */
  2250. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  2251. /**
  2252. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  2253. * @param vector defines the vector to transform
  2254. * @param transformation defines the matrix to apply
  2255. * @param result defines the target vector
  2256. */
  2257. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  2258. /**
  2259. * Determines if a given vector is included in a triangle
  2260. * @param p defines the vector to test
  2261. * @param p0 defines 1st triangle point
  2262. * @param p1 defines 2nd triangle point
  2263. * @param p2 defines 3rd triangle point
  2264. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  2265. */
  2266. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  2267. /**
  2268. * Gets the distance between the vectors "value1" and "value2"
  2269. * @param value1 defines first vector
  2270. * @param value2 defines second vector
  2271. * @returns the distance between vectors
  2272. */
  2273. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2274. /**
  2275. * Returns the squared distance between the vectors "value1" and "value2"
  2276. * @param value1 defines first vector
  2277. * @param value2 defines second vector
  2278. * @returns the squared distance between vectors
  2279. */
  2280. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2281. /**
  2282. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  2283. * @param value1 defines first vector
  2284. * @param value2 defines second vector
  2285. * @returns a new Vector2
  2286. */
  2287. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  2288. /**
  2289. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  2290. * @param p defines the middle point
  2291. * @param segA defines one point of the segment
  2292. * @param segB defines the other point of the segment
  2293. * @returns the shortest distance
  2294. */
  2295. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  2296. }
  2297. /**
  2298. * Classed used to store (x,y,z) vector representation
  2299. * A Vector3 is the main object used in 3D geometry
  2300. * It can represent etiher the coordinates of a point the space, either a direction
  2301. * Reminder: js uses a left handed forward facing system
  2302. */
  2303. export class Vector3 {
  2304. /**
  2305. * Defines the first coordinates (on X axis)
  2306. */
  2307. x: number;
  2308. /**
  2309. * Defines the second coordinates (on Y axis)
  2310. */
  2311. y: number;
  2312. /**
  2313. * Defines the third coordinates (on Z axis)
  2314. */
  2315. z: number;
  2316. private static _UpReadOnly;
  2317. private static _ZeroReadOnly;
  2318. /**
  2319. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2320. * @param x defines the first coordinates (on X axis)
  2321. * @param y defines the second coordinates (on Y axis)
  2322. * @param z defines the third coordinates (on Z axis)
  2323. */
  2324. constructor(
  2325. /**
  2326. * Defines the first coordinates (on X axis)
  2327. */
  2328. x?: number,
  2329. /**
  2330. * Defines the second coordinates (on Y axis)
  2331. */
  2332. y?: number,
  2333. /**
  2334. * Defines the third coordinates (on Z axis)
  2335. */
  2336. z?: number);
  2337. /**
  2338. * Creates a string representation of the Vector3
  2339. * @returns a string with the Vector3 coordinates.
  2340. */
  2341. toString(): string;
  2342. /**
  2343. * Gets the class name
  2344. * @returns the string "Vector3"
  2345. */
  2346. getClassName(): string;
  2347. /**
  2348. * Creates the Vector3 hash code
  2349. * @returns a number which tends to be unique between Vector3 instances
  2350. */
  2351. getHashCode(): number;
  2352. /**
  2353. * Creates an array containing three elements : the coordinates of the Vector3
  2354. * @returns a new array of numbers
  2355. */
  2356. asArray(): number[];
  2357. /**
  2358. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2359. * @param array defines the destination array
  2360. * @param index defines the offset in the destination array
  2361. * @returns the current Vector3
  2362. */
  2363. toArray(array: FloatArray, index?: number): Vector3;
  2364. /**
  2365. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2366. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2367. */
  2368. toQuaternion(): Quaternion;
  2369. /**
  2370. * Adds the given vector to the current Vector3
  2371. * @param otherVector defines the second operand
  2372. * @returns the current updated Vector3
  2373. */
  2374. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2375. /**
  2376. * Adds the given coordinates to the current Vector3
  2377. * @param x defines the x coordinate of the operand
  2378. * @param y defines the y coordinate of the operand
  2379. * @param z defines the z coordinate of the operand
  2380. * @returns the current updated Vector3
  2381. */
  2382. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2383. /**
  2384. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2385. * @param otherVector defines the second operand
  2386. * @returns the resulting Vector3
  2387. */
  2388. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2389. /**
  2390. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  2391. * @param otherVector defines the second operand
  2392. * @param result defines the Vector3 object where to store the result
  2393. * @returns the current Vector3
  2394. */
  2395. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2396. /**
  2397. * Subtract the given vector from the current Vector3
  2398. * @param otherVector defines the second operand
  2399. * @returns the current updated Vector3
  2400. */
  2401. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2402. /**
  2403. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2404. * @param otherVector defines the second operand
  2405. * @returns the resulting Vector3
  2406. */
  2407. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  2408. /**
  2409. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  2410. * @param otherVector defines the second operand
  2411. * @param result defines the Vector3 object where to store the result
  2412. * @returns the current Vector3
  2413. */
  2414. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2415. /**
  2416. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  2417. * @param x defines the x coordinate of the operand
  2418. * @param y defines the y coordinate of the operand
  2419. * @param z defines the z coordinate of the operand
  2420. * @returns the resulting Vector3
  2421. */
  2422. subtractFromFloats(x: number, y: number, z: number): Vector3;
  2423. /**
  2424. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  2425. * @param x defines the x coordinate of the operand
  2426. * @param y defines the y coordinate of the operand
  2427. * @param z defines the z coordinate of the operand
  2428. * @param result defines the Vector3 object where to store the result
  2429. * @returns the current Vector3
  2430. */
  2431. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  2432. /**
  2433. * Gets a new Vector3 set with the current Vector3 negated coordinates
  2434. * @returns a new Vector3
  2435. */
  2436. negate(): Vector3;
  2437. /**
  2438. * Multiplies the Vector3 coordinates by the float "scale"
  2439. * @param scale defines the multiplier factor
  2440. * @returns the current updated Vector3
  2441. */
  2442. scaleInPlace(scale: number): Vector3;
  2443. /**
  2444. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  2445. * @param scale defines the multiplier factor
  2446. * @returns a new Vector3
  2447. */
  2448. scale(scale: number): Vector3;
  2449. /**
  2450. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  2451. * @param scale defines the multiplier factor
  2452. * @param result defines the Vector3 object where to store the result
  2453. * @returns the current Vector3
  2454. */
  2455. scaleToRef(scale: number, result: Vector3): Vector3;
  2456. /**
  2457. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  2458. * @param scale defines the scale factor
  2459. * @param result defines the Vector3 object where to store the result
  2460. * @returns the unmodified current Vector3
  2461. */
  2462. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  2463. /**
  2464. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  2465. * @param otherVector defines the second operand
  2466. * @returns true if both vectors are equals
  2467. */
  2468. equals(otherVector: DeepImmutable<Vector3>): boolean;
  2469. /**
  2470. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  2471. * @param otherVector defines the second operand
  2472. * @param epsilon defines the minimal distance to define values as equals
  2473. * @returns true if both vectors are distant less than epsilon
  2474. */
  2475. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  2476. /**
  2477. * Returns true if the current Vector3 coordinates equals the given floats
  2478. * @param x defines the x coordinate of the operand
  2479. * @param y defines the y coordinate of the operand
  2480. * @param z defines the z coordinate of the operand
  2481. * @returns true if both vectors are equals
  2482. */
  2483. equalsToFloats(x: number, y: number, z: number): boolean;
  2484. /**
  2485. * Multiplies the current Vector3 coordinates by the given ones
  2486. * @param otherVector defines the second operand
  2487. * @returns the current updated Vector3
  2488. */
  2489. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2490. /**
  2491. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  2492. * @param otherVector defines the second operand
  2493. * @returns the new Vector3
  2494. */
  2495. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  2496. /**
  2497. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  2498. * @param otherVector defines the second operand
  2499. * @param result defines the Vector3 object where to store the result
  2500. * @returns the current Vector3
  2501. */
  2502. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2503. /**
  2504. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  2505. * @param x defines the x coordinate of the operand
  2506. * @param y defines the y coordinate of the operand
  2507. * @param z defines the z coordinate of the operand
  2508. * @returns the new Vector3
  2509. */
  2510. multiplyByFloats(x: number, y: number, z: number): Vector3;
  2511. /**
  2512. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  2513. * @param otherVector defines the second operand
  2514. * @returns the new Vector3
  2515. */
  2516. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  2517. /**
  2518. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  2519. * @param otherVector defines the second operand
  2520. * @param result defines the Vector3 object where to store the result
  2521. * @returns the current Vector3
  2522. */
  2523. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2524. /**
  2525. * Divides the current Vector3 coordinates by the given ones.
  2526. * @param otherVector defines the second operand
  2527. * @returns the current updated Vector3
  2528. */
  2529. divideInPlace(otherVector: Vector3): Vector3;
  2530. /**
  2531. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  2532. * @param other defines the second operand
  2533. * @returns the current updated Vector3
  2534. */
  2535. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2536. /**
  2537. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2538. * @param other defines the second operand
  2539. * @returns the current updated Vector3
  2540. */
  2541. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2542. /**
  2543. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2544. * @param x defines the x coordinate of the operand
  2545. * @param y defines the y coordinate of the operand
  2546. * @param z defines the z coordinate of the operand
  2547. * @returns the current updated Vector3
  2548. */
  2549. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2550. /**
  2551. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2552. * @param x defines the x coordinate of the operand
  2553. * @param y defines the y coordinate of the operand
  2554. * @param z defines the z coordinate of the operand
  2555. * @returns the current updated Vector3
  2556. */
  2557. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2558. /**
  2559. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2560. * Check if is non uniform within a certain amount of decimal places to account for this
  2561. * @param epsilon the amount the values can differ
  2562. * @returns if the the vector is non uniform to a certain number of decimal places
  2563. */
  2564. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2565. /**
  2566. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2567. */
  2568. readonly isNonUniform: boolean;
  2569. /**
  2570. * Gets a new Vector3 from current Vector3 floored values
  2571. * @returns a new Vector3
  2572. */
  2573. floor(): Vector3;
  2574. /**
  2575. * Gets a new Vector3 from current Vector3 floored values
  2576. * @returns a new Vector3
  2577. */
  2578. fract(): Vector3;
  2579. /**
  2580. * Gets the length of the Vector3
  2581. * @returns the length of the Vector3
  2582. */
  2583. length(): number;
  2584. /**
  2585. * Gets the squared length of the Vector3
  2586. * @returns squared length of the Vector3
  2587. */
  2588. lengthSquared(): number;
  2589. /**
  2590. * Normalize the current Vector3.
  2591. * Please note that this is an in place operation.
  2592. * @returns the current updated Vector3
  2593. */
  2594. normalize(): Vector3;
  2595. /**
  2596. * Reorders the x y z properties of the vector in place
  2597. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2598. * @returns the current updated vector
  2599. */
  2600. reorderInPlace(order: string): this;
  2601. /**
  2602. * Rotates the vector around 0,0,0 by a quaternion
  2603. * @param quaternion the rotation quaternion
  2604. * @param result vector to store the result
  2605. * @returns the resulting vector
  2606. */
  2607. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2608. /**
  2609. * Rotates a vector around a given point
  2610. * @param quaternion the rotation quaternion
  2611. * @param point the point to rotate around
  2612. * @param result vector to store the result
  2613. * @returns the resulting vector
  2614. */
  2615. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2616. /**
  2617. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2618. * The cross product is then orthogonal to both current and "other"
  2619. * @param other defines the right operand
  2620. * @returns the cross product
  2621. */
  2622. cross(other: Vector3): Vector3;
  2623. /**
  2624. * Normalize the current Vector3 with the given input length.
  2625. * Please note that this is an in place operation.
  2626. * @param len the length of the vector
  2627. * @returns the current updated Vector3
  2628. */
  2629. normalizeFromLength(len: number): Vector3;
  2630. /**
  2631. * Normalize the current Vector3 to a new vector
  2632. * @returns the new Vector3
  2633. */
  2634. normalizeToNew(): Vector3;
  2635. /**
  2636. * Normalize the current Vector3 to the reference
  2637. * @param reference define the Vector3 to update
  2638. * @returns the updated Vector3
  2639. */
  2640. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  2641. /**
  2642. * Creates a new Vector3 copied from the current Vector3
  2643. * @returns the new Vector3
  2644. */
  2645. clone(): Vector3;
  2646. /**
  2647. * Copies the given vector coordinates to the current Vector3 ones
  2648. * @param source defines the source Vector3
  2649. * @returns the current updated Vector3
  2650. */
  2651. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2652. /**
  2653. * Copies the given floats to the current Vector3 coordinates
  2654. * @param x defines the x coordinate of the operand
  2655. * @param y defines the y coordinate of the operand
  2656. * @param z defines the z coordinate of the operand
  2657. * @returns the current updated Vector3
  2658. */
  2659. copyFromFloats(x: number, y: number, z: number): Vector3;
  2660. /**
  2661. * Copies the given floats to the current Vector3 coordinates
  2662. * @param x defines the x coordinate of the operand
  2663. * @param y defines the y coordinate of the operand
  2664. * @param z defines the z coordinate of the operand
  2665. * @returns the current updated Vector3
  2666. */
  2667. set(x: number, y: number, z: number): Vector3;
  2668. /**
  2669. * Copies the given float to the current Vector3 coordinates
  2670. * @param v defines the x, y and z coordinates of the operand
  2671. * @returns the current updated Vector3
  2672. */
  2673. setAll(v: number): Vector3;
  2674. /**
  2675. * Get the clip factor between two vectors
  2676. * @param vector0 defines the first operand
  2677. * @param vector1 defines the second operand
  2678. * @param axis defines the axis to use
  2679. * @param size defines the size along the axis
  2680. * @returns the clip factor
  2681. */
  2682. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2683. /**
  2684. * Get angle between two vectors
  2685. * @param vector0 angle between vector0 and vector1
  2686. * @param vector1 angle between vector0 and vector1
  2687. * @param normal direction of the normal
  2688. * @return the angle between vector0 and vector1
  2689. */
  2690. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2691. /**
  2692. * Returns a new Vector3 set from the index "offset" of the given array
  2693. * @param array defines the source array
  2694. * @param offset defines the offset in the source array
  2695. * @returns the new Vector3
  2696. */
  2697. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2698. /**
  2699. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2700. * This function is deprecated. Use FromArray instead
  2701. * @param array defines the source array
  2702. * @param offset defines the offset in the source array
  2703. * @returns the new Vector3
  2704. */
  2705. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2706. /**
  2707. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2708. * @param array defines the source array
  2709. * @param offset defines the offset in the source array
  2710. * @param result defines the Vector3 where to store the result
  2711. */
  2712. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2713. /**
  2714. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2715. * This function is deprecated. Use FromArrayToRef instead.
  2716. * @param array defines the source array
  2717. * @param offset defines the offset in the source array
  2718. * @param result defines the Vector3 where to store the result
  2719. */
  2720. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2721. /**
  2722. * Sets the given vector "result" with the given floats.
  2723. * @param x defines the x coordinate of the source
  2724. * @param y defines the y coordinate of the source
  2725. * @param z defines the z coordinate of the source
  2726. * @param result defines the Vector3 where to store the result
  2727. */
  2728. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2729. /**
  2730. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2731. * @returns a new empty Vector3
  2732. */
  2733. static Zero(): Vector3;
  2734. /**
  2735. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2736. * @returns a new unit Vector3
  2737. */
  2738. static One(): Vector3;
  2739. /**
  2740. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2741. * @returns a new up Vector3
  2742. */
  2743. static Up(): Vector3;
  2744. /**
  2745. * Gets a up Vector3 that must not be updated
  2746. */
  2747. static readonly UpReadOnly: DeepImmutable<Vector3>;
  2748. /**
  2749. * Gets a zero Vector3 that must not be updated
  2750. */
  2751. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  2752. /**
  2753. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2754. * @returns a new down Vector3
  2755. */
  2756. static Down(): Vector3;
  2757. /**
  2758. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2759. * @returns a new forward Vector3
  2760. */
  2761. static Forward(): Vector3;
  2762. /**
  2763. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2764. * @returns a new forward Vector3
  2765. */
  2766. static Backward(): Vector3;
  2767. /**
  2768. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2769. * @returns a new right Vector3
  2770. */
  2771. static Right(): Vector3;
  2772. /**
  2773. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2774. * @returns a new left Vector3
  2775. */
  2776. static Left(): Vector3;
  2777. /**
  2778. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2779. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2780. * @param vector defines the Vector3 to transform
  2781. * @param transformation defines the transformation matrix
  2782. * @returns the transformed Vector3
  2783. */
  2784. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2785. /**
  2786. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2787. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2788. * @param vector defines the Vector3 to transform
  2789. * @param transformation defines the transformation matrix
  2790. * @param result defines the Vector3 where to store the result
  2791. */
  2792. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2793. /**
  2794. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2795. * This method computes tranformed coordinates only, not transformed direction vectors
  2796. * @param x define the x coordinate of the source vector
  2797. * @param y define the y coordinate of the source vector
  2798. * @param z define the z coordinate of the source vector
  2799. * @param transformation defines the transformation matrix
  2800. * @param result defines the Vector3 where to store the result
  2801. */
  2802. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2803. /**
  2804. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  2805. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2806. * @param vector defines the Vector3 to transform
  2807. * @param transformation defines the transformation matrix
  2808. * @returns the new Vector3
  2809. */
  2810. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2811. /**
  2812. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  2813. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2814. * @param vector defines the Vector3 to transform
  2815. * @param transformation defines the transformation matrix
  2816. * @param result defines the Vector3 where to store the result
  2817. */
  2818. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2819. /**
  2820. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  2821. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2822. * @param x define the x coordinate of the source vector
  2823. * @param y define the y coordinate of the source vector
  2824. * @param z define the z coordinate of the source vector
  2825. * @param transformation defines the transformation matrix
  2826. * @param result defines the Vector3 where to store the result
  2827. */
  2828. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2829. /**
  2830. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  2831. * @param value1 defines the first control point
  2832. * @param value2 defines the second control point
  2833. * @param value3 defines the third control point
  2834. * @param value4 defines the fourth control point
  2835. * @param amount defines the amount on the spline to use
  2836. * @returns the new Vector3
  2837. */
  2838. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  2839. /**
  2840. * Returns a new Vector3 set with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  2841. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2842. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2843. * @param value defines the current value
  2844. * @param min defines the lower range value
  2845. * @param max defines the upper range value
  2846. * @returns the new Vector3
  2847. */
  2848. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  2849. /**
  2850. * Sets the given vector "result" with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  2851. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2852. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2853. * @param value defines the current value
  2854. * @param min defines the lower range value
  2855. * @param max defines the upper range value
  2856. * @param result defines the Vector3 where to store the result
  2857. */
  2858. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  2859. /**
  2860. * Checks if a given vector is inside a specific range
  2861. * @param v defines the vector to test
  2862. * @param min defines the minimum range
  2863. * @param max defines the maximum range
  2864. */
  2865. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  2866. /**
  2867. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  2868. * @param value1 defines the first control point
  2869. * @param tangent1 defines the first tangent vector
  2870. * @param value2 defines the second control point
  2871. * @param tangent2 defines the second tangent vector
  2872. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  2873. * @returns the new Vector3
  2874. */
  2875. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  2876. /**
  2877. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  2878. * @param start defines the start value
  2879. * @param end defines the end value
  2880. * @param amount max defines amount between both (between 0 and 1)
  2881. * @returns the new Vector3
  2882. */
  2883. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  2884. /**
  2885. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  2886. * @param start defines the start value
  2887. * @param end defines the end value
  2888. * @param amount max defines amount between both (between 0 and 1)
  2889. * @param result defines the Vector3 where to store the result
  2890. */
  2891. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  2892. /**
  2893. * Returns the dot product (float) between the vectors "left" and "right"
  2894. * @param left defines the left operand
  2895. * @param right defines the right operand
  2896. * @returns the dot product
  2897. */
  2898. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  2899. /**
  2900. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  2901. * The cross product is then orthogonal to both "left" and "right"
  2902. * @param left defines the left operand
  2903. * @param right defines the right operand
  2904. * @returns the cross product
  2905. */
  2906. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2907. /**
  2908. * Sets the given vector "result" with the cross product of "left" and "right"
  2909. * The cross product is then orthogonal to both "left" and "right"
  2910. * @param left defines the left operand
  2911. * @param right defines the right operand
  2912. * @param result defines the Vector3 where to store the result
  2913. */
  2914. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  2915. /**
  2916. * Returns a new Vector3 as the normalization of the given vector
  2917. * @param vector defines the Vector3 to normalize
  2918. * @returns the new Vector3
  2919. */
  2920. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  2921. /**
  2922. * Sets the given vector "result" with the normalization of the given first vector
  2923. * @param vector defines the Vector3 to normalize
  2924. * @param result defines the Vector3 where to store the result
  2925. */
  2926. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  2927. /**
  2928. * Project a Vector3 onto screen space
  2929. * @param vector defines the Vector3 to project
  2930. * @param world defines the world matrix to use
  2931. * @param transform defines the transform (view x projection) matrix to use
  2932. * @param viewport defines the screen viewport to use
  2933. * @returns the new Vector3
  2934. */
  2935. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  2936. /** @hidden */
  2937. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  2938. /**
  2939. * Unproject from screen space to object space
  2940. * @param source defines the screen space Vector3 to use
  2941. * @param viewportWidth defines the current width of the viewport
  2942. * @param viewportHeight defines the current height of the viewport
  2943. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2944. * @param transform defines the transform (view x projection) matrix to use
  2945. * @returns the new Vector3
  2946. */
  2947. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  2948. /**
  2949. * Unproject from screen space to object space
  2950. * @param source defines the screen space Vector3 to use
  2951. * @param viewportWidth defines the current width of the viewport
  2952. * @param viewportHeight defines the current height of the viewport
  2953. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2954. * @param view defines the view matrix to use
  2955. * @param projection defines the projection matrix to use
  2956. * @returns the new Vector3
  2957. */
  2958. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  2959. /**
  2960. * Unproject from screen space to object space
  2961. * @param source defines the screen space Vector3 to use
  2962. * @param viewportWidth defines the current width of the viewport
  2963. * @param viewportHeight defines the current height of the viewport
  2964. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2965. * @param view defines the view matrix to use
  2966. * @param projection defines the projection matrix to use
  2967. * @param result defines the Vector3 where to store the result
  2968. */
  2969. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2970. /**
  2971. * Unproject from screen space to object space
  2972. * @param sourceX defines the screen space x coordinate to use
  2973. * @param sourceY defines the screen space y coordinate to use
  2974. * @param sourceZ defines the screen space z coordinate to use
  2975. * @param viewportWidth defines the current width of the viewport
  2976. * @param viewportHeight defines the current height of the viewport
  2977. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2978. * @param view defines the view matrix to use
  2979. * @param projection defines the projection matrix to use
  2980. * @param result defines the Vector3 where to store the result
  2981. */
  2982. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2983. /**
  2984. * Gets the minimal coordinate values between two Vector3
  2985. * @param left defines the first operand
  2986. * @param right defines the second operand
  2987. * @returns the new Vector3
  2988. */
  2989. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2990. /**
  2991. * Gets the maximal coordinate values between two Vector3
  2992. * @param left defines the first operand
  2993. * @param right defines the second operand
  2994. * @returns the new Vector3
  2995. */
  2996. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2997. /**
  2998. * Returns the distance between the vectors "value1" and "value2"
  2999. * @param value1 defines the first operand
  3000. * @param value2 defines the second operand
  3001. * @returns the distance
  3002. */
  3003. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3004. /**
  3005. * Returns the squared distance between the vectors "value1" and "value2"
  3006. * @param value1 defines the first operand
  3007. * @param value2 defines the second operand
  3008. * @returns the squared distance
  3009. */
  3010. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3011. /**
  3012. * Returns a new Vector3 located at the center between "value1" and "value2"
  3013. * @param value1 defines the first operand
  3014. * @param value2 defines the second operand
  3015. * @returns the new Vector3
  3016. */
  3017. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  3018. /**
  3019. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  3020. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  3021. * to something in order to rotate it from its local system to the given target system
  3022. * Note: axis1, axis2 and axis3 are normalized during this operation
  3023. * @param axis1 defines the first axis
  3024. * @param axis2 defines the second axis
  3025. * @param axis3 defines the third axis
  3026. * @returns a new Vector3
  3027. */
  3028. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  3029. /**
  3030. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3031. * @param axis1 defines the first axis
  3032. * @param axis2 defines the second axis
  3033. * @param axis3 defines the third axis
  3034. * @param ref defines the Vector3 where to store the result
  3035. */
  3036. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3037. }
  3038. /**
  3039. * Vector4 class created for EulerAngle class conversion to Quaternion
  3040. */
  3041. export class Vector4 {
  3042. /** x value of the vector */
  3043. x: number;
  3044. /** y value of the vector */
  3045. y: number;
  3046. /** z value of the vector */
  3047. z: number;
  3048. /** w value of the vector */
  3049. w: number;
  3050. /**
  3051. * Creates a Vector4 object from the given floats.
  3052. * @param x x value of the vector
  3053. * @param y y value of the vector
  3054. * @param z z value of the vector
  3055. * @param w w value of the vector
  3056. */
  3057. constructor(
  3058. /** x value of the vector */
  3059. x: number,
  3060. /** y value of the vector */
  3061. y: number,
  3062. /** z value of the vector */
  3063. z: number,
  3064. /** w value of the vector */
  3065. w: number);
  3066. /**
  3067. * Returns the string with the Vector4 coordinates.
  3068. * @returns a string containing all the vector values
  3069. */
  3070. toString(): string;
  3071. /**
  3072. * Returns the string "Vector4".
  3073. * @returns "Vector4"
  3074. */
  3075. getClassName(): string;
  3076. /**
  3077. * Returns the Vector4 hash code.
  3078. * @returns a unique hash code
  3079. */
  3080. getHashCode(): number;
  3081. /**
  3082. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3083. * @returns the resulting array
  3084. */
  3085. asArray(): number[];
  3086. /**
  3087. * Populates the given array from the given index with the Vector4 coordinates.
  3088. * @param array array to populate
  3089. * @param index index of the array to start at (default: 0)
  3090. * @returns the Vector4.
  3091. */
  3092. toArray(array: FloatArray, index?: number): Vector4;
  3093. /**
  3094. * Adds the given vector to the current Vector4.
  3095. * @param otherVector the vector to add
  3096. * @returns the updated Vector4.
  3097. */
  3098. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3099. /**
  3100. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3101. * @param otherVector the vector to add
  3102. * @returns the resulting vector
  3103. */
  3104. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3105. /**
  3106. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3107. * @param otherVector the vector to add
  3108. * @param result the vector to store the result
  3109. * @returns the current Vector4.
  3110. */
  3111. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3112. /**
  3113. * Subtract in place the given vector from the current Vector4.
  3114. * @param otherVector the vector to subtract
  3115. * @returns the updated Vector4.
  3116. */
  3117. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3118. /**
  3119. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3120. * @param otherVector the vector to add
  3121. * @returns the new vector with the result
  3122. */
  3123. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3124. /**
  3125. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3126. * @param otherVector the vector to subtract
  3127. * @param result the vector to store the result
  3128. * @returns the current Vector4.
  3129. */
  3130. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3131. /**
  3132. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3133. */
  3134. /**
  3135. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3136. * @param x value to subtract
  3137. * @param y value to subtract
  3138. * @param z value to subtract
  3139. * @param w value to subtract
  3140. * @returns new vector containing the result
  3141. */
  3142. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3143. /**
  3144. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3145. * @param x value to subtract
  3146. * @param y value to subtract
  3147. * @param z value to subtract
  3148. * @param w value to subtract
  3149. * @param result the vector to store the result in
  3150. * @returns the current Vector4.
  3151. */
  3152. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3153. /**
  3154. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3155. * @returns a new vector with the negated values
  3156. */
  3157. negate(): Vector4;
  3158. /**
  3159. * Multiplies the current Vector4 coordinates by scale (float).
  3160. * @param scale the number to scale with
  3161. * @returns the updated Vector4.
  3162. */
  3163. scaleInPlace(scale: number): Vector4;
  3164. /**
  3165. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3166. * @param scale the number to scale with
  3167. * @returns a new vector with the result
  3168. */
  3169. scale(scale: number): Vector4;
  3170. /**
  3171. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3172. * @param scale the number to scale with
  3173. * @param result a vector to store the result in
  3174. * @returns the current Vector4.
  3175. */
  3176. scaleToRef(scale: number, result: Vector4): Vector4;
  3177. /**
  3178. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3179. * @param scale defines the scale factor
  3180. * @param result defines the Vector4 object where to store the result
  3181. * @returns the unmodified current Vector4
  3182. */
  3183. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3184. /**
  3185. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3186. * @param otherVector the vector to compare against
  3187. * @returns true if they are equal
  3188. */
  3189. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3190. /**
  3191. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3192. * @param otherVector vector to compare against
  3193. * @param epsilon (Default: very small number)
  3194. * @returns true if they are equal
  3195. */
  3196. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3197. /**
  3198. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3199. * @param x x value to compare against
  3200. * @param y y value to compare against
  3201. * @param z z value to compare against
  3202. * @param w w value to compare against
  3203. * @returns true if equal
  3204. */
  3205. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3206. /**
  3207. * Multiplies in place the current Vector4 by the given one.
  3208. * @param otherVector vector to multiple with
  3209. * @returns the updated Vector4.
  3210. */
  3211. multiplyInPlace(otherVector: Vector4): Vector4;
  3212. /**
  3213. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3214. * @param otherVector vector to multiple with
  3215. * @returns resulting new vector
  3216. */
  3217. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3218. /**
  3219. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3220. * @param otherVector vector to multiple with
  3221. * @param result vector to store the result
  3222. * @returns the current Vector4.
  3223. */
  3224. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3225. /**
  3226. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3227. * @param x x value multiply with
  3228. * @param y y value multiply with
  3229. * @param z z value multiply with
  3230. * @param w w value multiply with
  3231. * @returns resulting new vector
  3232. */
  3233. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3234. /**
  3235. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3236. * @param otherVector vector to devide with
  3237. * @returns resulting new vector
  3238. */
  3239. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3240. /**
  3241. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3242. * @param otherVector vector to devide with
  3243. * @param result vector to store the result
  3244. * @returns the current Vector4.
  3245. */
  3246. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3247. /**
  3248. * Divides the current Vector3 coordinates by the given ones.
  3249. * @param otherVector vector to devide with
  3250. * @returns the updated Vector3.
  3251. */
  3252. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3253. /**
  3254. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3255. * @param other defines the second operand
  3256. * @returns the current updated Vector4
  3257. */
  3258. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3259. /**
  3260. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3261. * @param other defines the second operand
  3262. * @returns the current updated Vector4
  3263. */
  3264. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3265. /**
  3266. * Gets a new Vector4 from current Vector4 floored values
  3267. * @returns a new Vector4
  3268. */
  3269. floor(): Vector4;
  3270. /**
  3271. * Gets a new Vector4 from current Vector3 floored values
  3272. * @returns a new Vector4
  3273. */
  3274. fract(): Vector4;
  3275. /**
  3276. * Returns the Vector4 length (float).
  3277. * @returns the length
  3278. */
  3279. length(): number;
  3280. /**
  3281. * Returns the Vector4 squared length (float).
  3282. * @returns the length squared
  3283. */
  3284. lengthSquared(): number;
  3285. /**
  3286. * Normalizes in place the Vector4.
  3287. * @returns the updated Vector4.
  3288. */
  3289. normalize(): Vector4;
  3290. /**
  3291. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3292. * @returns this converted to a new vector3
  3293. */
  3294. toVector3(): Vector3;
  3295. /**
  3296. * Returns a new Vector4 copied from the current one.
  3297. * @returns the new cloned vector
  3298. */
  3299. clone(): Vector4;
  3300. /**
  3301. * Updates the current Vector4 with the given one coordinates.
  3302. * @param source the source vector to copy from
  3303. * @returns the updated Vector4.
  3304. */
  3305. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3306. /**
  3307. * Updates the current Vector4 coordinates with the given floats.
  3308. * @param x float to copy from
  3309. * @param y float to copy from
  3310. * @param z float to copy from
  3311. * @param w float to copy from
  3312. * @returns the updated Vector4.
  3313. */
  3314. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3315. /**
  3316. * Updates the current Vector4 coordinates with the given floats.
  3317. * @param x float to set from
  3318. * @param y float to set from
  3319. * @param z float to set from
  3320. * @param w float to set from
  3321. * @returns the updated Vector4.
  3322. */
  3323. set(x: number, y: number, z: number, w: number): Vector4;
  3324. /**
  3325. * Copies the given float to the current Vector3 coordinates
  3326. * @param v defines the x, y, z and w coordinates of the operand
  3327. * @returns the current updated Vector3
  3328. */
  3329. setAll(v: number): Vector4;
  3330. /**
  3331. * Returns a new Vector4 set from the starting index of the given array.
  3332. * @param array the array to pull values from
  3333. * @param offset the offset into the array to start at
  3334. * @returns the new vector
  3335. */
  3336. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3337. /**
  3338. * Updates the given vector "result" from the starting index of the given array.
  3339. * @param array the array to pull values from
  3340. * @param offset the offset into the array to start at
  3341. * @param result the vector to store the result in
  3342. */
  3343. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3344. /**
  3345. * Updates the given vector "result" from the starting index of the given Float32Array.
  3346. * @param array the array to pull values from
  3347. * @param offset the offset into the array to start at
  3348. * @param result the vector to store the result in
  3349. */
  3350. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3351. /**
  3352. * Updates the given vector "result" coordinates from the given floats.
  3353. * @param x float to set from
  3354. * @param y float to set from
  3355. * @param z float to set from
  3356. * @param w float to set from
  3357. * @param result the vector to the floats in
  3358. */
  3359. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3360. /**
  3361. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3362. * @returns the new vector
  3363. */
  3364. static Zero(): Vector4;
  3365. /**
  3366. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  3367. * @returns the new vector
  3368. */
  3369. static One(): Vector4;
  3370. /**
  3371. * Returns a new normalized Vector4 from the given one.
  3372. * @param vector the vector to normalize
  3373. * @returns the vector
  3374. */
  3375. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  3376. /**
  3377. * Updates the given vector "result" from the normalization of the given one.
  3378. * @param vector the vector to normalize
  3379. * @param result the vector to store the result in
  3380. */
  3381. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  3382. /**
  3383. * Returns a vector with the minimum values from the left and right vectors
  3384. * @param left left vector to minimize
  3385. * @param right right vector to minimize
  3386. * @returns a new vector with the minimum of the left and right vector values
  3387. */
  3388. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3389. /**
  3390. * Returns a vector with the maximum values from the left and right vectors
  3391. * @param left left vector to maximize
  3392. * @param right right vector to maximize
  3393. * @returns a new vector with the maximum of the left and right vector values
  3394. */
  3395. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3396. /**
  3397. * Returns the distance (float) between the vectors "value1" and "value2".
  3398. * @param value1 value to calulate the distance between
  3399. * @param value2 value to calulate the distance between
  3400. * @return the distance between the two vectors
  3401. */
  3402. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3403. /**
  3404. * Returns the squared distance (float) between the vectors "value1" and "value2".
  3405. * @param value1 value to calulate the distance between
  3406. * @param value2 value to calulate the distance between
  3407. * @return the distance between the two vectors squared
  3408. */
  3409. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3410. /**
  3411. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  3412. * @param value1 value to calulate the center between
  3413. * @param value2 value to calulate the center between
  3414. * @return the center between the two vectors
  3415. */
  3416. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  3417. /**
  3418. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  3419. * This methods computes transformed normalized direction vectors only.
  3420. * @param vector the vector to transform
  3421. * @param transformation the transformation matrix to apply
  3422. * @returns the new vector
  3423. */
  3424. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  3425. /**
  3426. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  3427. * This methods computes transformed normalized direction vectors only.
  3428. * @param vector the vector to transform
  3429. * @param transformation the transformation matrix to apply
  3430. * @param result the vector to store the result in
  3431. */
  3432. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3433. /**
  3434. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  3435. * This methods computes transformed normalized direction vectors only.
  3436. * @param x value to transform
  3437. * @param y value to transform
  3438. * @param z value to transform
  3439. * @param w value to transform
  3440. * @param transformation the transformation matrix to apply
  3441. * @param result the vector to store the results in
  3442. */
  3443. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3444. /**
  3445. * Creates a new Vector4 from a Vector3
  3446. * @param source defines the source data
  3447. * @param w defines the 4th component (default is 0)
  3448. * @returns a new Vector4
  3449. */
  3450. static FromVector3(source: Vector3, w?: number): Vector4;
  3451. }
  3452. /**
  3453. * Class used to store quaternion data
  3454. * @see https://en.wikipedia.org/wiki/Quaternion
  3455. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  3456. */
  3457. export class Quaternion {
  3458. /** defines the first component (0 by default) */
  3459. x: number;
  3460. /** defines the second component (0 by default) */
  3461. y: number;
  3462. /** defines the third component (0 by default) */
  3463. z: number;
  3464. /** defines the fourth component (1.0 by default) */
  3465. w: number;
  3466. /**
  3467. * Creates a new Quaternion from the given floats
  3468. * @param x defines the first component (0 by default)
  3469. * @param y defines the second component (0 by default)
  3470. * @param z defines the third component (0 by default)
  3471. * @param w defines the fourth component (1.0 by default)
  3472. */
  3473. constructor(
  3474. /** defines the first component (0 by default) */
  3475. x?: number,
  3476. /** defines the second component (0 by default) */
  3477. y?: number,
  3478. /** defines the third component (0 by default) */
  3479. z?: number,
  3480. /** defines the fourth component (1.0 by default) */
  3481. w?: number);
  3482. /**
  3483. * Gets a string representation for the current quaternion
  3484. * @returns a string with the Quaternion coordinates
  3485. */
  3486. toString(): string;
  3487. /**
  3488. * Gets the class name of the quaternion
  3489. * @returns the string "Quaternion"
  3490. */
  3491. getClassName(): string;
  3492. /**
  3493. * Gets a hash code for this quaternion
  3494. * @returns the quaternion hash code
  3495. */
  3496. getHashCode(): number;
  3497. /**
  3498. * Copy the quaternion to an array
  3499. * @returns a new array populated with 4 elements from the quaternion coordinates
  3500. */
  3501. asArray(): number[];
  3502. /**
  3503. * Check if two quaternions are equals
  3504. * @param otherQuaternion defines the second operand
  3505. * @return true if the current quaternion and the given one coordinates are strictly equals
  3506. */
  3507. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  3508. /**
  3509. * Clone the current quaternion
  3510. * @returns a new quaternion copied from the current one
  3511. */
  3512. clone(): Quaternion;
  3513. /**
  3514. * Copy a quaternion to the current one
  3515. * @param other defines the other quaternion
  3516. * @returns the updated current quaternion
  3517. */
  3518. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  3519. /**
  3520. * Updates the current quaternion with the given float coordinates
  3521. * @param x defines the x coordinate
  3522. * @param y defines the y coordinate
  3523. * @param z defines the z coordinate
  3524. * @param w defines the w coordinate
  3525. * @returns the updated current quaternion
  3526. */
  3527. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  3528. /**
  3529. * Updates the current quaternion from the given float coordinates
  3530. * @param x defines the x coordinate
  3531. * @param y defines the y coordinate
  3532. * @param z defines the z coordinate
  3533. * @param w defines the w coordinate
  3534. * @returns the updated current quaternion
  3535. */
  3536. set(x: number, y: number, z: number, w: number): Quaternion;
  3537. /**
  3538. * Adds two quaternions
  3539. * @param other defines the second operand
  3540. * @returns a new quaternion as the addition result of the given one and the current quaternion
  3541. */
  3542. add(other: DeepImmutable<Quaternion>): Quaternion;
  3543. /**
  3544. * Add a quaternion to the current one
  3545. * @param other defines the quaternion to add
  3546. * @returns the current quaternion
  3547. */
  3548. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3549. /**
  3550. * Subtract two quaternions
  3551. * @param other defines the second operand
  3552. * @returns a new quaternion as the subtraction result of the given one from the current one
  3553. */
  3554. subtract(other: Quaternion): Quaternion;
  3555. /**
  3556. * Multiplies the current quaternion by a scale factor
  3557. * @param value defines the scale factor
  3558. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3559. */
  3560. scale(value: number): Quaternion;
  3561. /**
  3562. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3563. * @param scale defines the scale factor
  3564. * @param result defines the Quaternion object where to store the result
  3565. * @returns the unmodified current quaternion
  3566. */
  3567. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3568. /**
  3569. * Multiplies in place the current quaternion by a scale factor
  3570. * @param value defines the scale factor
  3571. * @returns the current modified quaternion
  3572. */
  3573. scaleInPlace(value: number): Quaternion;
  3574. /**
  3575. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3576. * @param scale defines the scale factor
  3577. * @param result defines the Quaternion object where to store the result
  3578. * @returns the unmodified current quaternion
  3579. */
  3580. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3581. /**
  3582. * Multiplies two quaternions
  3583. * @param q1 defines the second operand
  3584. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3585. */
  3586. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3587. /**
  3588. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3589. * @param q1 defines the second operand
  3590. * @param result defines the target quaternion
  3591. * @returns the current quaternion
  3592. */
  3593. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3594. /**
  3595. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3596. * @param q1 defines the second operand
  3597. * @returns the currentupdated quaternion
  3598. */
  3599. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3600. /**
  3601. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3602. * @param ref defines the target quaternion
  3603. * @returns the current quaternion
  3604. */
  3605. conjugateToRef(ref: Quaternion): Quaternion;
  3606. /**
  3607. * Conjugates in place (1-q) the current quaternion
  3608. * @returns the current updated quaternion
  3609. */
  3610. conjugateInPlace(): Quaternion;
  3611. /**
  3612. * Conjugates in place (1-q) the current quaternion
  3613. * @returns a new quaternion
  3614. */
  3615. conjugate(): Quaternion;
  3616. /**
  3617. * Gets length of current quaternion
  3618. * @returns the quaternion length (float)
  3619. */
  3620. length(): number;
  3621. /**
  3622. * Normalize in place the current quaternion
  3623. * @returns the current updated quaternion
  3624. */
  3625. normalize(): Quaternion;
  3626. /**
  3627. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3628. * @param order is a reserved parameter and is ignore for now
  3629. * @returns a new Vector3 containing the Euler angles
  3630. */
  3631. toEulerAngles(order?: string): Vector3;
  3632. /**
  3633. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3634. * @param result defines the vector which will be filled with the Euler angles
  3635. * @param order is a reserved parameter and is ignore for now
  3636. * @returns the current unchanged quaternion
  3637. */
  3638. toEulerAnglesToRef(result: Vector3): Quaternion;
  3639. /**
  3640. * Updates the given rotation matrix with the current quaternion values
  3641. * @param result defines the target matrix
  3642. * @returns the current unchanged quaternion
  3643. */
  3644. toRotationMatrix(result: Matrix): Quaternion;
  3645. /**
  3646. * Updates the current quaternion from the given rotation matrix values
  3647. * @param matrix defines the source matrix
  3648. * @returns the current updated quaternion
  3649. */
  3650. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3651. /**
  3652. * Creates a new quaternion from a rotation matrix
  3653. * @param matrix defines the source matrix
  3654. * @returns a new quaternion created from the given rotation matrix values
  3655. */
  3656. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3657. /**
  3658. * Updates the given quaternion with the given rotation matrix values
  3659. * @param matrix defines the source matrix
  3660. * @param result defines the target quaternion
  3661. */
  3662. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3663. /**
  3664. * Returns the dot product (float) between the quaternions "left" and "right"
  3665. * @param left defines the left operand
  3666. * @param right defines the right operand
  3667. * @returns the dot product
  3668. */
  3669. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3670. /**
  3671. * Checks if the two quaternions are close to each other
  3672. * @param quat0 defines the first quaternion to check
  3673. * @param quat1 defines the second quaternion to check
  3674. * @returns true if the two quaternions are close to each other
  3675. */
  3676. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3677. /**
  3678. * Creates an empty quaternion
  3679. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3680. */
  3681. static Zero(): Quaternion;
  3682. /**
  3683. * Inverse a given quaternion
  3684. * @param q defines the source quaternion
  3685. * @returns a new quaternion as the inverted current quaternion
  3686. */
  3687. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3688. /**
  3689. * Inverse a given quaternion
  3690. * @param q defines the source quaternion
  3691. * @param result the quaternion the result will be stored in
  3692. * @returns the result quaternion
  3693. */
  3694. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3695. /**
  3696. * Creates an identity quaternion
  3697. * @returns the identity quaternion
  3698. */
  3699. static Identity(): Quaternion;
  3700. /**
  3701. * Gets a boolean indicating if the given quaternion is identity
  3702. * @param quaternion defines the quaternion to check
  3703. * @returns true if the quaternion is identity
  3704. */
  3705. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3706. /**
  3707. * Creates a quaternion from a rotation around an axis
  3708. * @param axis defines the axis to use
  3709. * @param angle defines the angle to use
  3710. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3711. */
  3712. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3713. /**
  3714. * Creates a rotation around an axis and stores it into the given quaternion
  3715. * @param axis defines the axis to use
  3716. * @param angle defines the angle to use
  3717. * @param result defines the target quaternion
  3718. * @returns the target quaternion
  3719. */
  3720. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3721. /**
  3722. * Creates a new quaternion from data stored into an array
  3723. * @param array defines the data source
  3724. * @param offset defines the offset in the source array where the data starts
  3725. * @returns a new quaternion
  3726. */
  3727. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3728. /**
  3729. * Create a quaternion from Euler rotation angles
  3730. * @param x Pitch
  3731. * @param y Yaw
  3732. * @param z Roll
  3733. * @returns the new Quaternion
  3734. */
  3735. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3736. /**
  3737. * Updates a quaternion from Euler rotation angles
  3738. * @param x Pitch
  3739. * @param y Yaw
  3740. * @param z Roll
  3741. * @param result the quaternion to store the result
  3742. * @returns the updated quaternion
  3743. */
  3744. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3745. /**
  3746. * Create a quaternion from Euler rotation vector
  3747. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3748. * @returns the new Quaternion
  3749. */
  3750. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3751. /**
  3752. * Updates a quaternion from Euler rotation vector
  3753. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3754. * @param result the quaternion to store the result
  3755. * @returns the updated quaternion
  3756. */
  3757. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  3758. /**
  3759. * Creates a new quaternion from the given Euler float angles (y, x, z)
  3760. * @param yaw defines the rotation around Y axis
  3761. * @param pitch defines the rotation around X axis
  3762. * @param roll defines the rotation around Z axis
  3763. * @returns the new quaternion
  3764. */
  3765. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  3766. /**
  3767. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  3768. * @param yaw defines the rotation around Y axis
  3769. * @param pitch defines the rotation around X axis
  3770. * @param roll defines the rotation around Z axis
  3771. * @param result defines the target quaternion
  3772. */
  3773. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  3774. /**
  3775. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  3776. * @param alpha defines the rotation around first axis
  3777. * @param beta defines the rotation around second axis
  3778. * @param gamma defines the rotation around third axis
  3779. * @returns the new quaternion
  3780. */
  3781. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  3782. /**
  3783. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  3784. * @param alpha defines the rotation around first axis
  3785. * @param beta defines the rotation around second axis
  3786. * @param gamma defines the rotation around third axis
  3787. * @param result defines the target quaternion
  3788. */
  3789. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  3790. /**
  3791. * Creates a new quaternion containing the rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation)
  3792. * @param axis1 defines the first axis
  3793. * @param axis2 defines the second axis
  3794. * @param axis3 defines the third axis
  3795. * @returns the new quaternion
  3796. */
  3797. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  3798. /**
  3799. * Creates a rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation) and stores it in the target quaternion
  3800. * @param axis1 defines the first axis
  3801. * @param axis2 defines the second axis
  3802. * @param axis3 defines the third axis
  3803. * @param ref defines the target quaternion
  3804. */
  3805. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  3806. /**
  3807. * Interpolates between two quaternions
  3808. * @param left defines first quaternion
  3809. * @param right defines second quaternion
  3810. * @param amount defines the gradient to use
  3811. * @returns the new interpolated quaternion
  3812. */
  3813. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3814. /**
  3815. * Interpolates between two quaternions and stores it into a target quaternion
  3816. * @param left defines first quaternion
  3817. * @param right defines second quaternion
  3818. * @param amount defines the gradient to use
  3819. * @param result defines the target quaternion
  3820. */
  3821. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  3822. /**
  3823. * Interpolate between two quaternions using Hermite interpolation
  3824. * @param value1 defines first quaternion
  3825. * @param tangent1 defines the incoming tangent
  3826. * @param value2 defines second quaternion
  3827. * @param tangent2 defines the outgoing tangent
  3828. * @param amount defines the target quaternion
  3829. * @returns the new interpolated quaternion
  3830. */
  3831. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3832. }
  3833. /**
  3834. * Class used to store matrix data (4x4)
  3835. */
  3836. export class Matrix {
  3837. private static _updateFlagSeed;
  3838. private static _identityReadOnly;
  3839. private _isIdentity;
  3840. private _isIdentityDirty;
  3841. private _isIdentity3x2;
  3842. private _isIdentity3x2Dirty;
  3843. /**
  3844. * Gets the update flag of the matrix which is an unique number for the matrix.
  3845. * It will be incremented every time the matrix data change.
  3846. * You can use it to speed the comparison between two versions of the same matrix.
  3847. */
  3848. updateFlag: number;
  3849. private readonly _m;
  3850. /**
  3851. * Gets the internal data of the matrix
  3852. */
  3853. readonly m: DeepImmutable<Float32Array>;
  3854. /** @hidden */
  3855. _markAsUpdated(): void;
  3856. /** @hidden */
  3857. private _updateIdentityStatus;
  3858. /**
  3859. * Creates an empty matrix (filled with zeros)
  3860. */
  3861. constructor();
  3862. /**
  3863. * Check if the current matrix is identity
  3864. * @returns true is the matrix is the identity matrix
  3865. */
  3866. isIdentity(): boolean;
  3867. /**
  3868. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  3869. * @returns true is the matrix is the identity matrix
  3870. */
  3871. isIdentityAs3x2(): boolean;
  3872. /**
  3873. * Gets the determinant of the matrix
  3874. * @returns the matrix determinant
  3875. */
  3876. determinant(): number;
  3877. /**
  3878. * Returns the matrix as a Float32Array
  3879. * @returns the matrix underlying array
  3880. */
  3881. toArray(): DeepImmutable<Float32Array>;
  3882. /**
  3883. * Returns the matrix as a Float32Array
  3884. * @returns the matrix underlying array.
  3885. */
  3886. asArray(): DeepImmutable<Float32Array>;
  3887. /**
  3888. * Inverts the current matrix in place
  3889. * @returns the current inverted matrix
  3890. */
  3891. invert(): Matrix;
  3892. /**
  3893. * Sets all the matrix elements to zero
  3894. * @returns the current matrix
  3895. */
  3896. reset(): Matrix;
  3897. /**
  3898. * Adds the current matrix with a second one
  3899. * @param other defines the matrix to add
  3900. * @returns a new matrix as the addition of the current matrix and the given one
  3901. */
  3902. add(other: DeepImmutable<Matrix>): Matrix;
  3903. /**
  3904. * Sets the given matrix "result" to the addition of the current matrix and the given one
  3905. * @param other defines the matrix to add
  3906. * @param result defines the target matrix
  3907. * @returns the current matrix
  3908. */
  3909. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3910. /**
  3911. * Adds in place the given matrix to the current matrix
  3912. * @param other defines the second operand
  3913. * @returns the current updated matrix
  3914. */
  3915. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  3916. /**
  3917. * Sets the given matrix to the current inverted Matrix
  3918. * @param other defines the target matrix
  3919. * @returns the unmodified current matrix
  3920. */
  3921. invertToRef(other: Matrix): Matrix;
  3922. /**
  3923. * add a value at the specified position in the current Matrix
  3924. * @param index the index of the value within the matrix. between 0 and 15.
  3925. * @param value the value to be added
  3926. * @returns the current updated matrix
  3927. */
  3928. addAtIndex(index: number, value: number): Matrix;
  3929. /**
  3930. * mutiply the specified position in the current Matrix by a value
  3931. * @param index the index of the value within the matrix. between 0 and 15.
  3932. * @param value the value to be added
  3933. * @returns the current updated matrix
  3934. */
  3935. multiplyAtIndex(index: number, value: number): Matrix;
  3936. /**
  3937. * Inserts the translation vector (using 3 floats) in the current matrix
  3938. * @param x defines the 1st component of the translation
  3939. * @param y defines the 2nd component of the translation
  3940. * @param z defines the 3rd component of the translation
  3941. * @returns the current updated matrix
  3942. */
  3943. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3944. /**
  3945. * Adds the translation vector (using 3 floats) in the current matrix
  3946. * @param x defines the 1st component of the translation
  3947. * @param y defines the 2nd component of the translation
  3948. * @param z defines the 3rd component of the translation
  3949. * @returns the current updated matrix
  3950. */
  3951. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3952. /**
  3953. * Inserts the translation vector in the current matrix
  3954. * @param vector3 defines the translation to insert
  3955. * @returns the current updated matrix
  3956. */
  3957. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  3958. /**
  3959. * Gets the translation value of the current matrix
  3960. * @returns a new Vector3 as the extracted translation from the matrix
  3961. */
  3962. getTranslation(): Vector3;
  3963. /**
  3964. * Fill a Vector3 with the extracted translation from the matrix
  3965. * @param result defines the Vector3 where to store the translation
  3966. * @returns the current matrix
  3967. */
  3968. getTranslationToRef(result: Vector3): Matrix;
  3969. /**
  3970. * Remove rotation and scaling part from the matrix
  3971. * @returns the updated matrix
  3972. */
  3973. removeRotationAndScaling(): Matrix;
  3974. /**
  3975. * Multiply two matrices
  3976. * @param other defines the second operand
  3977. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  3978. */
  3979. multiply(other: DeepImmutable<Matrix>): Matrix;
  3980. /**
  3981. * Copy the current matrix from the given one
  3982. * @param other defines the source matrix
  3983. * @returns the current updated matrix
  3984. */
  3985. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  3986. /**
  3987. * Populates the given array from the starting index with the current matrix values
  3988. * @param array defines the target array
  3989. * @param offset defines the offset in the target array where to start storing values
  3990. * @returns the current matrix
  3991. */
  3992. copyToArray(array: Float32Array, offset?: number): Matrix;
  3993. /**
  3994. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  3995. * @param other defines the second operand
  3996. * @param result defines the matrix where to store the multiplication
  3997. * @returns the current matrix
  3998. */
  3999. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4000. /**
  4001. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  4002. * @param other defines the second operand
  4003. * @param result defines the array where to store the multiplication
  4004. * @param offset defines the offset in the target array where to start storing values
  4005. * @returns the current matrix
  4006. */
  4007. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  4008. /**
  4009. * Check equality between this matrix and a second one
  4010. * @param value defines the second matrix to compare
  4011. * @returns true is the current matrix and the given one values are strictly equal
  4012. */
  4013. equals(value: DeepImmutable<Matrix>): boolean;
  4014. /**
  4015. * Clone the current matrix
  4016. * @returns a new matrix from the current matrix
  4017. */
  4018. clone(): Matrix;
  4019. /**
  4020. * Returns the name of the current matrix class
  4021. * @returns the string "Matrix"
  4022. */
  4023. getClassName(): string;
  4024. /**
  4025. * Gets the hash code of the current matrix
  4026. * @returns the hash code
  4027. */
  4028. getHashCode(): number;
  4029. /**
  4030. * Decomposes the current Matrix into a translation, rotation and scaling components
  4031. * @param scale defines the scale vector3 given as a reference to update
  4032. * @param rotation defines the rotation quaternion given as a reference to update
  4033. * @param translation defines the translation vector3 given as a reference to update
  4034. * @returns true if operation was successful
  4035. */
  4036. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4037. /**
  4038. * Gets specific row of the matrix
  4039. * @param index defines the number of the row to get
  4040. * @returns the index-th row of the current matrix as a new Vector4
  4041. */
  4042. getRow(index: number): Nullable<Vector4>;
  4043. /**
  4044. * Sets the index-th row of the current matrix to the vector4 values
  4045. * @param index defines the number of the row to set
  4046. * @param row defines the target vector4
  4047. * @returns the updated current matrix
  4048. */
  4049. setRow(index: number, row: Vector4): Matrix;
  4050. /**
  4051. * Compute the transpose of the matrix
  4052. * @returns the new transposed matrix
  4053. */
  4054. transpose(): Matrix;
  4055. /**
  4056. * Compute the transpose of the matrix and store it in a given matrix
  4057. * @param result defines the target matrix
  4058. * @returns the current matrix
  4059. */
  4060. transposeToRef(result: Matrix): Matrix;
  4061. /**
  4062. * Sets the index-th row of the current matrix with the given 4 x float values
  4063. * @param index defines the row index
  4064. * @param x defines the x component to set
  4065. * @param y defines the y component to set
  4066. * @param z defines the z component to set
  4067. * @param w defines the w component to set
  4068. * @returns the updated current matrix
  4069. */
  4070. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4071. /**
  4072. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4073. * @param scale defines the scale factor
  4074. * @returns a new matrix
  4075. */
  4076. scale(scale: number): Matrix;
  4077. /**
  4078. * Scale the current matrix values by a factor to a given result matrix
  4079. * @param scale defines the scale factor
  4080. * @param result defines the matrix to store the result
  4081. * @returns the current matrix
  4082. */
  4083. scaleToRef(scale: number, result: Matrix): Matrix;
  4084. /**
  4085. * Scale the current matrix values by a factor and add the result to a given matrix
  4086. * @param scale defines the scale factor
  4087. * @param result defines the Matrix to store the result
  4088. * @returns the current matrix
  4089. */
  4090. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4091. /**
  4092. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4093. * @param ref matrix to store the result
  4094. */
  4095. toNormalMatrix(ref: Matrix): void;
  4096. /**
  4097. * Gets only rotation part of the current matrix
  4098. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4099. */
  4100. getRotationMatrix(): Matrix;
  4101. /**
  4102. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4103. * @param result defines the target matrix to store data to
  4104. * @returns the current matrix
  4105. */
  4106. getRotationMatrixToRef(result: Matrix): Matrix;
  4107. /**
  4108. * Toggles model matrix from being right handed to left handed in place and vice versa
  4109. */
  4110. toggleModelMatrixHandInPlace(): void;
  4111. /**
  4112. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4113. */
  4114. toggleProjectionMatrixHandInPlace(): void;
  4115. /**
  4116. * Creates a matrix from an array
  4117. * @param array defines the source array
  4118. * @param offset defines an offset in the source array
  4119. * @returns a new Matrix set from the starting index of the given array
  4120. */
  4121. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4122. /**
  4123. * Copy the content of an array into a given matrix
  4124. * @param array defines the source array
  4125. * @param offset defines an offset in the source array
  4126. * @param result defines the target matrix
  4127. */
  4128. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4129. /**
  4130. * Stores an array into a matrix after having multiplied each component by a given factor
  4131. * @param array defines the source array
  4132. * @param offset defines the offset in the source array
  4133. * @param scale defines the scaling factor
  4134. * @param result defines the target matrix
  4135. */
  4136. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  4137. /**
  4138. * Gets an identity matrix that must not be updated
  4139. */
  4140. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  4141. /**
  4142. * Stores a list of values (16) inside a given matrix
  4143. * @param initialM11 defines 1st value of 1st row
  4144. * @param initialM12 defines 2nd value of 1st row
  4145. * @param initialM13 defines 3rd value of 1st row
  4146. * @param initialM14 defines 4th value of 1st row
  4147. * @param initialM21 defines 1st value of 2nd row
  4148. * @param initialM22 defines 2nd value of 2nd row
  4149. * @param initialM23 defines 3rd value of 2nd row
  4150. * @param initialM24 defines 4th value of 2nd row
  4151. * @param initialM31 defines 1st value of 3rd row
  4152. * @param initialM32 defines 2nd value of 3rd row
  4153. * @param initialM33 defines 3rd value of 3rd row
  4154. * @param initialM34 defines 4th value of 3rd row
  4155. * @param initialM41 defines 1st value of 4th row
  4156. * @param initialM42 defines 2nd value of 4th row
  4157. * @param initialM43 defines 3rd value of 4th row
  4158. * @param initialM44 defines 4th value of 4th row
  4159. * @param result defines the target matrix
  4160. */
  4161. static FromValuesToRef(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number, result: Matrix): void;
  4162. /**
  4163. * Creates new matrix from a list of values (16)
  4164. * @param initialM11 defines 1st value of 1st row
  4165. * @param initialM12 defines 2nd value of 1st row
  4166. * @param initialM13 defines 3rd value of 1st row
  4167. * @param initialM14 defines 4th value of 1st row
  4168. * @param initialM21 defines 1st value of 2nd row
  4169. * @param initialM22 defines 2nd value of 2nd row
  4170. * @param initialM23 defines 3rd value of 2nd row
  4171. * @param initialM24 defines 4th value of 2nd row
  4172. * @param initialM31 defines 1st value of 3rd row
  4173. * @param initialM32 defines 2nd value of 3rd row
  4174. * @param initialM33 defines 3rd value of 3rd row
  4175. * @param initialM34 defines 4th value of 3rd row
  4176. * @param initialM41 defines 1st value of 4th row
  4177. * @param initialM42 defines 2nd value of 4th row
  4178. * @param initialM43 defines 3rd value of 4th row
  4179. * @param initialM44 defines 4th value of 4th row
  4180. * @returns the new matrix
  4181. */
  4182. static FromValues(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number): Matrix;
  4183. /**
  4184. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4185. * @param scale defines the scale vector3
  4186. * @param rotation defines the rotation quaternion
  4187. * @param translation defines the translation vector3
  4188. * @returns a new matrix
  4189. */
  4190. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4191. /**
  4192. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4193. * @param scale defines the scale vector3
  4194. * @param rotation defines the rotation quaternion
  4195. * @param translation defines the translation vector3
  4196. * @param result defines the target matrix
  4197. */
  4198. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4199. /**
  4200. * Creates a new identity matrix
  4201. * @returns a new identity matrix
  4202. */
  4203. static Identity(): Matrix;
  4204. /**
  4205. * Creates a new identity matrix and stores the result in a given matrix
  4206. * @param result defines the target matrix
  4207. */
  4208. static IdentityToRef(result: Matrix): void;
  4209. /**
  4210. * Creates a new zero matrix
  4211. * @returns a new zero matrix
  4212. */
  4213. static Zero(): Matrix;
  4214. /**
  4215. * Creates a new rotation matrix for "angle" radians around the X axis
  4216. * @param angle defines the angle (in radians) to use
  4217. * @return the new matrix
  4218. */
  4219. static RotationX(angle: number): Matrix;
  4220. /**
  4221. * Creates a new matrix as the invert of a given matrix
  4222. * @param source defines the source matrix
  4223. * @returns the new matrix
  4224. */
  4225. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4226. /**
  4227. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  4228. * @param angle defines the angle (in radians) to use
  4229. * @param result defines the target matrix
  4230. */
  4231. static RotationXToRef(angle: number, result: Matrix): void;
  4232. /**
  4233. * Creates a new rotation matrix for "angle" radians around the Y axis
  4234. * @param angle defines the angle (in radians) to use
  4235. * @return the new matrix
  4236. */
  4237. static RotationY(angle: number): Matrix;
  4238. /**
  4239. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  4240. * @param angle defines the angle (in radians) to use
  4241. * @param result defines the target matrix
  4242. */
  4243. static RotationYToRef(angle: number, result: Matrix): void;
  4244. /**
  4245. * Creates a new rotation matrix for "angle" radians around the Z axis
  4246. * @param angle defines the angle (in radians) to use
  4247. * @return the new matrix
  4248. */
  4249. static RotationZ(angle: number): Matrix;
  4250. /**
  4251. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4252. * @param angle defines the angle (in radians) to use
  4253. * @param result defines the target matrix
  4254. */
  4255. static RotationZToRef(angle: number, result: Matrix): void;
  4256. /**
  4257. * Creates a new rotation matrix for "angle" radians around the given axis
  4258. * @param axis defines the axis to use
  4259. * @param angle defines the angle (in radians) to use
  4260. * @return the new matrix
  4261. */
  4262. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4263. /**
  4264. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4265. * @param axis defines the axis to use
  4266. * @param angle defines the angle (in radians) to use
  4267. * @param result defines the target matrix
  4268. */
  4269. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4270. /**
  4271. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4272. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4273. * @param from defines the vector to align
  4274. * @param to defines the vector to align to
  4275. * @param result defines the target matrix
  4276. */
  4277. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4278. /**
  4279. * Creates a rotation matrix
  4280. * @param yaw defines the yaw angle in radians (Y axis)
  4281. * @param pitch defines the pitch angle in radians (X axis)
  4282. * @param roll defines the roll angle in radians (X axis)
  4283. * @returns the new rotation matrix
  4284. */
  4285. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4286. /**
  4287. * Creates a rotation matrix and stores it in a given matrix
  4288. * @param yaw defines the yaw angle in radians (Y axis)
  4289. * @param pitch defines the pitch angle in radians (X axis)
  4290. * @param roll defines the roll angle in radians (X axis)
  4291. * @param result defines the target matrix
  4292. */
  4293. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4294. /**
  4295. * Creates a scaling matrix
  4296. * @param x defines the scale factor on X axis
  4297. * @param y defines the scale factor on Y axis
  4298. * @param z defines the scale factor on Z axis
  4299. * @returns the new matrix
  4300. */
  4301. static Scaling(x: number, y: number, z: number): Matrix;
  4302. /**
  4303. * Creates a scaling matrix and stores it in a given matrix
  4304. * @param x defines the scale factor on X axis
  4305. * @param y defines the scale factor on Y axis
  4306. * @param z defines the scale factor on Z axis
  4307. * @param result defines the target matrix
  4308. */
  4309. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4310. /**
  4311. * Creates a translation matrix
  4312. * @param x defines the translation on X axis
  4313. * @param y defines the translation on Y axis
  4314. * @param z defines the translationon Z axis
  4315. * @returns the new matrix
  4316. */
  4317. static Translation(x: number, y: number, z: number): Matrix;
  4318. /**
  4319. * Creates a translation matrix and stores it in a given matrix
  4320. * @param x defines the translation on X axis
  4321. * @param y defines the translation on Y axis
  4322. * @param z defines the translationon Z axis
  4323. * @param result defines the target matrix
  4324. */
  4325. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4326. /**
  4327. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4328. * @param startValue defines the start value
  4329. * @param endValue defines the end value
  4330. * @param gradient defines the gradient factor
  4331. * @returns the new matrix
  4332. */
  4333. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4334. /**
  4335. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4336. * @param startValue defines the start value
  4337. * @param endValue defines the end value
  4338. * @param gradient defines the gradient factor
  4339. * @param result defines the Matrix object where to store data
  4340. */
  4341. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4342. /**
  4343. * Builds a new matrix whose values are computed by:
  4344. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4345. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4346. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4347. * @param startValue defines the first matrix
  4348. * @param endValue defines the second matrix
  4349. * @param gradient defines the gradient between the two matrices
  4350. * @returns the new matrix
  4351. */
  4352. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4353. /**
  4354. * Update a matrix to values which are computed by:
  4355. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4356. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4357. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4358. * @param startValue defines the first matrix
  4359. * @param endValue defines the second matrix
  4360. * @param gradient defines the gradient between the two matrices
  4361. * @param result defines the target matrix
  4362. */
  4363. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4364. /**
  4365. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  4366. * This function works in left handed mode
  4367. * @param eye defines the final position of the entity
  4368. * @param target defines where the entity should look at
  4369. * @param up defines the up vector for the entity
  4370. * @returns the new matrix
  4371. */
  4372. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4373. /**
  4374. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  4375. * This function works in left handed mode
  4376. * @param eye defines the final position of the entity
  4377. * @param target defines where the entity should look at
  4378. * @param up defines the up vector for the entity
  4379. * @param result defines the target matrix
  4380. */
  4381. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4382. /**
  4383. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  4384. * This function works in right handed mode
  4385. * @param eye defines the final position of the entity
  4386. * @param target defines where the entity should look at
  4387. * @param up defines the up vector for the entity
  4388. * @returns the new matrix
  4389. */
  4390. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4391. /**
  4392. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  4393. * This function works in right handed mode
  4394. * @param eye defines the final position of the entity
  4395. * @param target defines where the entity should look at
  4396. * @param up defines the up vector for the entity
  4397. * @param result defines the target matrix
  4398. */
  4399. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4400. /**
  4401. * Create a left-handed orthographic projection matrix
  4402. * @param width defines the viewport width
  4403. * @param height defines the viewport height
  4404. * @param znear defines the near clip plane
  4405. * @param zfar defines the far clip plane
  4406. * @returns a new matrix as a left-handed orthographic projection matrix
  4407. */
  4408. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4409. /**
  4410. * Store a left-handed orthographic projection to a given matrix
  4411. * @param width defines the viewport width
  4412. * @param height defines the viewport height
  4413. * @param znear defines the near clip plane
  4414. * @param zfar defines the far clip plane
  4415. * @param result defines the target matrix
  4416. */
  4417. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  4418. /**
  4419. * Create a left-handed orthographic projection matrix
  4420. * @param left defines the viewport left coordinate
  4421. * @param right defines the viewport right coordinate
  4422. * @param bottom defines the viewport bottom coordinate
  4423. * @param top defines the viewport top coordinate
  4424. * @param znear defines the near clip plane
  4425. * @param zfar defines the far clip plane
  4426. * @returns a new matrix as a left-handed orthographic projection matrix
  4427. */
  4428. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4429. /**
  4430. * Stores a left-handed orthographic projection into a given matrix
  4431. * @param left defines the viewport left coordinate
  4432. * @param right defines the viewport right coordinate
  4433. * @param bottom defines the viewport bottom coordinate
  4434. * @param top defines the viewport top coordinate
  4435. * @param znear defines the near clip plane
  4436. * @param zfar defines the far clip plane
  4437. * @param result defines the target matrix
  4438. */
  4439. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4440. /**
  4441. * Creates a right-handed orthographic projection matrix
  4442. * @param left defines the viewport left coordinate
  4443. * @param right defines the viewport right coordinate
  4444. * @param bottom defines the viewport bottom coordinate
  4445. * @param top defines the viewport top coordinate
  4446. * @param znear defines the near clip plane
  4447. * @param zfar defines the far clip plane
  4448. * @returns a new matrix as a right-handed orthographic projection matrix
  4449. */
  4450. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4451. /**
  4452. * Stores a right-handed orthographic projection into a given matrix
  4453. * @param left defines the viewport left coordinate
  4454. * @param right defines the viewport right coordinate
  4455. * @param bottom defines the viewport bottom coordinate
  4456. * @param top defines the viewport top coordinate
  4457. * @param znear defines the near clip plane
  4458. * @param zfar defines the far clip plane
  4459. * @param result defines the target matrix
  4460. */
  4461. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4462. /**
  4463. * Creates a left-handed perspective projection matrix
  4464. * @param width defines the viewport width
  4465. * @param height defines the viewport height
  4466. * @param znear defines the near clip plane
  4467. * @param zfar defines the far clip plane
  4468. * @returns a new matrix as a left-handed perspective projection matrix
  4469. */
  4470. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4471. /**
  4472. * Creates a left-handed perspective projection matrix
  4473. * @param fov defines the horizontal field of view
  4474. * @param aspect defines the aspect ratio
  4475. * @param znear defines the near clip plane
  4476. * @param zfar defines the far clip plane
  4477. * @returns a new matrix as a left-handed perspective projection matrix
  4478. */
  4479. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4480. /**
  4481. * Stores a left-handed perspective projection into a given matrix
  4482. * @param fov defines the horizontal field of view
  4483. * @param aspect defines the aspect ratio
  4484. * @param znear defines the near clip plane
  4485. * @param zfar defines the far clip plane
  4486. * @param result defines the target matrix
  4487. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4488. */
  4489. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4490. /**
  4491. * Stores a left-handed perspective projection into a given matrix with depth reversed
  4492. * @param fov defines the horizontal field of view
  4493. * @param aspect defines the aspect ratio
  4494. * @param znear defines the near clip plane
  4495. * @param zfar not used as infinity is used as far clip
  4496. * @param result defines the target matrix
  4497. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4498. */
  4499. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4500. /**
  4501. * Creates a right-handed perspective projection matrix
  4502. * @param fov defines the horizontal field of view
  4503. * @param aspect defines the aspect ratio
  4504. * @param znear defines the near clip plane
  4505. * @param zfar defines the far clip plane
  4506. * @returns a new matrix as a right-handed perspective projection matrix
  4507. */
  4508. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4509. /**
  4510. * Stores a right-handed perspective projection into a given matrix
  4511. * @param fov defines the horizontal field of view
  4512. * @param aspect defines the aspect ratio
  4513. * @param znear defines the near clip plane
  4514. * @param zfar defines the far clip plane
  4515. * @param result defines the target matrix
  4516. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4517. */
  4518. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4519. /**
  4520. * Stores a right-handed perspective projection into a given matrix
  4521. * @param fov defines the horizontal field of view
  4522. * @param aspect defines the aspect ratio
  4523. * @param znear defines the near clip plane
  4524. * @param zfar not used as infinity is used as far clip
  4525. * @param result defines the target matrix
  4526. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4527. */
  4528. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4529. /**
  4530. * Stores a perspective projection for WebVR info a given matrix
  4531. * @param fov defines the field of view
  4532. * @param znear defines the near clip plane
  4533. * @param zfar defines the far clip plane
  4534. * @param result defines the target matrix
  4535. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  4536. */
  4537. static PerspectiveFovWebVRToRef(fov: {
  4538. upDegrees: number;
  4539. downDegrees: number;
  4540. leftDegrees: number;
  4541. rightDegrees: number;
  4542. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  4543. /**
  4544. * Computes a complete transformation matrix
  4545. * @param viewport defines the viewport to use
  4546. * @param world defines the world matrix
  4547. * @param view defines the view matrix
  4548. * @param projection defines the projection matrix
  4549. * @param zmin defines the near clip plane
  4550. * @param zmax defines the far clip plane
  4551. * @returns the transformation matrix
  4552. */
  4553. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  4554. /**
  4555. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4556. * @param matrix defines the matrix to use
  4557. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4558. */
  4559. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  4560. /**
  4561. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4562. * @param matrix defines the matrix to use
  4563. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4564. */
  4565. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  4566. /**
  4567. * Compute the transpose of a given matrix
  4568. * @param matrix defines the matrix to transpose
  4569. * @returns the new matrix
  4570. */
  4571. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4572. /**
  4573. * Compute the transpose of a matrix and store it in a target matrix
  4574. * @param matrix defines the matrix to transpose
  4575. * @param result defines the target matrix
  4576. */
  4577. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4578. /**
  4579. * Computes a reflection matrix from a plane
  4580. * @param plane defines the reflection plane
  4581. * @returns a new matrix
  4582. */
  4583. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4584. /**
  4585. * Computes a reflection matrix from a plane
  4586. * @param plane defines the reflection plane
  4587. * @param result defines the target matrix
  4588. */
  4589. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4590. /**
  4591. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4592. * @param xaxis defines the value of the 1st axis
  4593. * @param yaxis defines the value of the 2nd axis
  4594. * @param zaxis defines the value of the 3rd axis
  4595. * @param result defines the target matrix
  4596. */
  4597. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4598. /**
  4599. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4600. * @param quat defines the quaternion to use
  4601. * @param result defines the target matrix
  4602. */
  4603. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4604. }
  4605. /**
  4606. * @hidden
  4607. */
  4608. export class TmpVectors {
  4609. static Vector2: Vector2[];
  4610. static Vector3: Vector3[];
  4611. static Vector4: Vector4[];
  4612. static Quaternion: Quaternion[];
  4613. static Matrix: Matrix[];
  4614. }
  4615. }
  4616. declare module "babylonjs/Maths/math.path" {
  4617. import { DeepImmutable, Nullable } from "babylonjs/types";
  4618. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  4619. /**
  4620. * Defines potential orientation for back face culling
  4621. */
  4622. export enum Orientation {
  4623. /**
  4624. * Clockwise
  4625. */
  4626. CW = 0,
  4627. /** Counter clockwise */
  4628. CCW = 1
  4629. }
  4630. /** Class used to represent a Bezier curve */
  4631. export class BezierCurve {
  4632. /**
  4633. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  4634. * @param t defines the time
  4635. * @param x1 defines the left coordinate on X axis
  4636. * @param y1 defines the left coordinate on Y axis
  4637. * @param x2 defines the right coordinate on X axis
  4638. * @param y2 defines the right coordinate on Y axis
  4639. * @returns the interpolated value
  4640. */
  4641. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  4642. }
  4643. /**
  4644. * Defines angle representation
  4645. */
  4646. export class Angle {
  4647. private _radians;
  4648. /**
  4649. * Creates an Angle object of "radians" radians (float).
  4650. * @param radians the angle in radians
  4651. */
  4652. constructor(radians: number);
  4653. /**
  4654. * Get value in degrees
  4655. * @returns the Angle value in degrees (float)
  4656. */
  4657. degrees(): number;
  4658. /**
  4659. * Get value in radians
  4660. * @returns the Angle value in radians (float)
  4661. */
  4662. radians(): number;
  4663. /**
  4664. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  4665. * @param a defines first vector
  4666. * @param b defines second vector
  4667. * @returns a new Angle
  4668. */
  4669. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  4670. /**
  4671. * Gets a new Angle object from the given float in radians
  4672. * @param radians defines the angle value in radians
  4673. * @returns a new Angle
  4674. */
  4675. static FromRadians(radians: number): Angle;
  4676. /**
  4677. * Gets a new Angle object from the given float in degrees
  4678. * @param degrees defines the angle value in degrees
  4679. * @returns a new Angle
  4680. */
  4681. static FromDegrees(degrees: number): Angle;
  4682. }
  4683. /**
  4684. * This represents an arc in a 2d space.
  4685. */
  4686. export class Arc2 {
  4687. /** Defines the start point of the arc */
  4688. startPoint: Vector2;
  4689. /** Defines the mid point of the arc */
  4690. midPoint: Vector2;
  4691. /** Defines the end point of the arc */
  4692. endPoint: Vector2;
  4693. /**
  4694. * Defines the center point of the arc.
  4695. */
  4696. centerPoint: Vector2;
  4697. /**
  4698. * Defines the radius of the arc.
  4699. */
  4700. radius: number;
  4701. /**
  4702. * Defines the angle of the arc (from mid point to end point).
  4703. */
  4704. angle: Angle;
  4705. /**
  4706. * Defines the start angle of the arc (from start point to middle point).
  4707. */
  4708. startAngle: Angle;
  4709. /**
  4710. * Defines the orientation of the arc (clock wise/counter clock wise).
  4711. */
  4712. orientation: Orientation;
  4713. /**
  4714. * Creates an Arc object from the three given points : start, middle and end.
  4715. * @param startPoint Defines the start point of the arc
  4716. * @param midPoint Defines the midlle point of the arc
  4717. * @param endPoint Defines the end point of the arc
  4718. */
  4719. constructor(
  4720. /** Defines the start point of the arc */
  4721. startPoint: Vector2,
  4722. /** Defines the mid point of the arc */
  4723. midPoint: Vector2,
  4724. /** Defines the end point of the arc */
  4725. endPoint: Vector2);
  4726. }
  4727. /**
  4728. * Represents a 2D path made up of multiple 2D points
  4729. */
  4730. export class Path2 {
  4731. private _points;
  4732. private _length;
  4733. /**
  4734. * If the path start and end point are the same
  4735. */
  4736. closed: boolean;
  4737. /**
  4738. * Creates a Path2 object from the starting 2D coordinates x and y.
  4739. * @param x the starting points x value
  4740. * @param y the starting points y value
  4741. */
  4742. constructor(x: number, y: number);
  4743. /**
  4744. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  4745. * @param x the added points x value
  4746. * @param y the added points y value
  4747. * @returns the updated Path2.
  4748. */
  4749. addLineTo(x: number, y: number): Path2;
  4750. /**
  4751. * Adds _numberOfSegments_ segments according to the arc definition (middle point coordinates, end point coordinates, the arc start point being the current Path2 last point) to the current Path2.
  4752. * @param midX middle point x value
  4753. * @param midY middle point y value
  4754. * @param endX end point x value
  4755. * @param endY end point y value
  4756. * @param numberOfSegments (default: 36)
  4757. * @returns the updated Path2.
  4758. */
  4759. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  4760. /**
  4761. * Closes the Path2.
  4762. * @returns the Path2.
  4763. */
  4764. close(): Path2;
  4765. /**
  4766. * Gets the sum of the distance between each sequential point in the path
  4767. * @returns the Path2 total length (float).
  4768. */
  4769. length(): number;
  4770. /**
  4771. * Gets the points which construct the path
  4772. * @returns the Path2 internal array of points.
  4773. */
  4774. getPoints(): Vector2[];
  4775. /**
  4776. * Retreives the point at the distance aways from the starting point
  4777. * @param normalizedLengthPosition the length along the path to retreive the point from
  4778. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  4779. */
  4780. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  4781. /**
  4782. * Creates a new path starting from an x and y position
  4783. * @param x starting x value
  4784. * @param y starting y value
  4785. * @returns a new Path2 starting at the coordinates (x, y).
  4786. */
  4787. static StartingAt(x: number, y: number): Path2;
  4788. }
  4789. /**
  4790. * Represents a 3D path made up of multiple 3D points
  4791. */
  4792. export class Path3D {
  4793. /**
  4794. * an array of Vector3, the curve axis of the Path3D
  4795. */
  4796. path: Vector3[];
  4797. private _curve;
  4798. private _distances;
  4799. private _tangents;
  4800. private _normals;
  4801. private _binormals;
  4802. private _raw;
  4803. private _alignTangentsWithPath;
  4804. private readonly _pointAtData;
  4805. /**
  4806. * new Path3D(path, normal, raw)
  4807. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  4808. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  4809. * @param path an array of Vector3, the curve axis of the Path3D
  4810. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  4811. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  4812. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  4813. */
  4814. constructor(
  4815. /**
  4816. * an array of Vector3, the curve axis of the Path3D
  4817. */
  4818. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  4819. /**
  4820. * Returns the Path3D array of successive Vector3 designing its curve.
  4821. * @returns the Path3D array of successive Vector3 designing its curve.
  4822. */
  4823. getCurve(): Vector3[];
  4824. /**
  4825. * Returns the Path3D array of successive Vector3 designing its curve.
  4826. * @returns the Path3D array of successive Vector3 designing its curve.
  4827. */
  4828. getPoints(): Vector3[];
  4829. /**
  4830. * @returns the computed length (float) of the path.
  4831. */
  4832. length(): number;
  4833. /**
  4834. * Returns an array populated with tangent vectors on each Path3D curve point.
  4835. * @returns an array populated with tangent vectors on each Path3D curve point.
  4836. */
  4837. getTangents(): Vector3[];
  4838. /**
  4839. * Returns an array populated with normal vectors on each Path3D curve point.
  4840. * @returns an array populated with normal vectors on each Path3D curve point.
  4841. */
  4842. getNormals(): Vector3[];
  4843. /**
  4844. * Returns an array populated with binormal vectors on each Path3D curve point.
  4845. * @returns an array populated with binormal vectors on each Path3D curve point.
  4846. */
  4847. getBinormals(): Vector3[];
  4848. /**
  4849. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  4850. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  4851. */
  4852. getDistances(): number[];
  4853. /**
  4854. * Returns an interpolated point along this path
  4855. * @param position the position of the point along this path, from 0.0 to 1.0
  4856. * @returns a new Vector3 as the point
  4857. */
  4858. getPointAt(position: number): Vector3;
  4859. /**
  4860. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  4861. * @param position the position of the point along this path, from 0.0 to 1.0
  4862. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  4863. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  4864. */
  4865. getTangentAt(position: number, interpolated?: boolean): Vector3;
  4866. /**
  4867. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  4868. * @param position the position of the point along this path, from 0.0 to 1.0
  4869. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  4870. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  4871. */
  4872. getNormalAt(position: number, interpolated?: boolean): Vector3;
  4873. /**
  4874. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  4875. * @param position the position of the point along this path, from 0.0 to 1.0
  4876. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  4877. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  4878. */
  4879. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  4880. /**
  4881. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  4882. * @param position the position of the point along this path, from 0.0 to 1.0
  4883. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  4884. */
  4885. getDistanceAt(position: number): number;
  4886. /**
  4887. * Returns the array index of the previous point of an interpolated point along this path
  4888. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  4889. * @returns the array index
  4890. */
  4891. getPreviousPointIndexAt(position: number): number;
  4892. /**
  4893. * Returns the position of an interpolated point relative to the two path points it lies between, from 0.0 (point A) to 1.0 (point B)
  4894. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  4895. * @returns the sub position
  4896. */
  4897. getSubPositionAt(position: number): number;
  4898. /**
  4899. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  4900. * @param target the vector of which to get the closest position to
  4901. * @returns the position of the closest virtual point on this path to the target vector
  4902. */
  4903. getClosestPositionTo(target: Vector3): number;
  4904. /**
  4905. * Returns a sub path (slice) of this path
  4906. * @param start the position of the fist path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values
  4907. * @param end the position of the last path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values
  4908. * @returns a sub path (slice) of this path
  4909. */
  4910. slice(start?: number, end?: number): Path3D;
  4911. /**
  4912. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  4913. * @param path path which all values are copied into the curves points
  4914. * @param firstNormal which should be projected onto the curve
  4915. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  4916. * @returns the same object updated.
  4917. */
  4918. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  4919. private _compute;
  4920. private _getFirstNonNullVector;
  4921. private _getLastNonNullVector;
  4922. private _normalVector;
  4923. /**
  4924. * Updates the point at data for an interpolated point along this curve
  4925. * @param position the position of the point along this curve, from 0.0 to 1.0
  4926. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  4927. * @returns the (updated) point at data
  4928. */
  4929. private _updatePointAtData;
  4930. /**
  4931. * Updates the point at data from the specified parameters
  4932. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  4933. * @param point the interpolated point
  4934. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  4935. */
  4936. private _setPointAtData;
  4937. /**
  4938. * Updates the point at interpolation matrix for the tangents, normals and binormals
  4939. */
  4940. private _updateInterpolationMatrix;
  4941. }
  4942. /**
  4943. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4944. * A Curve3 is designed from a series of successive Vector3.
  4945. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  4946. */
  4947. export class Curve3 {
  4948. private _points;
  4949. private _length;
  4950. /**
  4951. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  4952. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  4953. * @param v1 (Vector3) the control point
  4954. * @param v2 (Vector3) the end point of the Quadratic Bezier
  4955. * @param nbPoints (integer) the wanted number of points in the curve
  4956. * @returns the created Curve3
  4957. */
  4958. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4959. /**
  4960. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  4961. * @param v0 (Vector3) the origin point of the Cubic Bezier
  4962. * @param v1 (Vector3) the first control point
  4963. * @param v2 (Vector3) the second control point
  4964. * @param v3 (Vector3) the end point of the Cubic Bezier
  4965. * @param nbPoints (integer) the wanted number of points in the curve
  4966. * @returns the created Curve3
  4967. */
  4968. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4969. /**
  4970. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  4971. * @param p1 (Vector3) the origin point of the Hermite Spline
  4972. * @param t1 (Vector3) the tangent vector at the origin point
  4973. * @param p2 (Vector3) the end point of the Hermite Spline
  4974. * @param t2 (Vector3) the tangent vector at the end point
  4975. * @param nbPoints (integer) the wanted number of points in the curve
  4976. * @returns the created Curve3
  4977. */
  4978. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4979. /**
  4980. * Returns a Curve3 object along a CatmullRom Spline curve :
  4981. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  4982. * @param nbPoints (integer) the wanted number of points between each curve control points
  4983. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  4984. * @returns the created Curve3
  4985. */
  4986. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  4987. /**
  4988. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4989. * A Curve3 is designed from a series of successive Vector3.
  4990. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  4991. * @param points points which make up the curve
  4992. */
  4993. constructor(points: Vector3[]);
  4994. /**
  4995. * @returns the Curve3 stored array of successive Vector3
  4996. */
  4997. getPoints(): Vector3[];
  4998. /**
  4999. * @returns the computed length (float) of the curve.
  5000. */
  5001. length(): number;
  5002. /**
  5003. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5004. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5005. * curveA and curveB keep unchanged.
  5006. * @param curve the curve to continue from this curve
  5007. * @returns the newly constructed curve
  5008. */
  5009. continue(curve: DeepImmutable<Curve3>): Curve3;
  5010. private _computeLength;
  5011. }
  5012. }
  5013. declare module "babylonjs/Animations/easing" {
  5014. /**
  5015. * This represents the main contract an easing function should follow.
  5016. * Easing functions are used throughout the animation system.
  5017. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5018. */
  5019. export interface IEasingFunction {
  5020. /**
  5021. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5022. * of the easing function.
  5023. * The link below provides some of the most common examples of easing functions.
  5024. * @see https://easings.net/
  5025. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5026. * @returns the corresponding value on the curve defined by the easing function
  5027. */
  5028. ease(gradient: number): number;
  5029. }
  5030. /**
  5031. * Base class used for every default easing function.
  5032. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5033. */
  5034. export class EasingFunction implements IEasingFunction {
  5035. /**
  5036. * Interpolation follows the mathematical formula associated with the easing function.
  5037. */
  5038. static readonly EASINGMODE_EASEIN: number;
  5039. /**
  5040. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5041. */
  5042. static readonly EASINGMODE_EASEOUT: number;
  5043. /**
  5044. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5045. */
  5046. static readonly EASINGMODE_EASEINOUT: number;
  5047. private _easingMode;
  5048. /**
  5049. * Sets the easing mode of the current function.
  5050. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5051. */
  5052. setEasingMode(easingMode: number): void;
  5053. /**
  5054. * Gets the current easing mode.
  5055. * @returns the easing mode
  5056. */
  5057. getEasingMode(): number;
  5058. /**
  5059. * @hidden
  5060. */
  5061. easeInCore(gradient: number): number;
  5062. /**
  5063. * Given an input gradient between 0 and 1, this returns the corresponding value
  5064. * of the easing function.
  5065. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5066. * @returns the corresponding value on the curve defined by the easing function
  5067. */
  5068. ease(gradient: number): number;
  5069. }
  5070. /**
  5071. * Easing function with a circle shape (see link below).
  5072. * @see https://easings.net/#easeInCirc
  5073. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5074. */
  5075. export class CircleEase extends EasingFunction implements IEasingFunction {
  5076. /** @hidden */
  5077. easeInCore(gradient: number): number;
  5078. }
  5079. /**
  5080. * Easing function with a ease back shape (see link below).
  5081. * @see https://easings.net/#easeInBack
  5082. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5083. */
  5084. export class BackEase extends EasingFunction implements IEasingFunction {
  5085. /** Defines the amplitude of the function */
  5086. amplitude: number;
  5087. /**
  5088. * Instantiates a back ease easing
  5089. * @see https://easings.net/#easeInBack
  5090. * @param amplitude Defines the amplitude of the function
  5091. */
  5092. constructor(
  5093. /** Defines the amplitude of the function */
  5094. amplitude?: number);
  5095. /** @hidden */
  5096. easeInCore(gradient: number): number;
  5097. }
  5098. /**
  5099. * Easing function with a bouncing shape (see link below).
  5100. * @see https://easings.net/#easeInBounce
  5101. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5102. */
  5103. export class BounceEase extends EasingFunction implements IEasingFunction {
  5104. /** Defines the number of bounces */
  5105. bounces: number;
  5106. /** Defines the amplitude of the bounce */
  5107. bounciness: number;
  5108. /**
  5109. * Instantiates a bounce easing
  5110. * @see https://easings.net/#easeInBounce
  5111. * @param bounces Defines the number of bounces
  5112. * @param bounciness Defines the amplitude of the bounce
  5113. */
  5114. constructor(
  5115. /** Defines the number of bounces */
  5116. bounces?: number,
  5117. /** Defines the amplitude of the bounce */
  5118. bounciness?: number);
  5119. /** @hidden */
  5120. easeInCore(gradient: number): number;
  5121. }
  5122. /**
  5123. * Easing function with a power of 3 shape (see link below).
  5124. * @see https://easings.net/#easeInCubic
  5125. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5126. */
  5127. export class CubicEase extends EasingFunction implements IEasingFunction {
  5128. /** @hidden */
  5129. easeInCore(gradient: number): number;
  5130. }
  5131. /**
  5132. * Easing function with an elastic shape (see link below).
  5133. * @see https://easings.net/#easeInElastic
  5134. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5135. */
  5136. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5137. /** Defines the number of oscillations*/
  5138. oscillations: number;
  5139. /** Defines the amplitude of the oscillations*/
  5140. springiness: number;
  5141. /**
  5142. * Instantiates an elastic easing function
  5143. * @see https://easings.net/#easeInElastic
  5144. * @param oscillations Defines the number of oscillations
  5145. * @param springiness Defines the amplitude of the oscillations
  5146. */
  5147. constructor(
  5148. /** Defines the number of oscillations*/
  5149. oscillations?: number,
  5150. /** Defines the amplitude of the oscillations*/
  5151. springiness?: number);
  5152. /** @hidden */
  5153. easeInCore(gradient: number): number;
  5154. }
  5155. /**
  5156. * Easing function with an exponential shape (see link below).
  5157. * @see https://easings.net/#easeInExpo
  5158. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5159. */
  5160. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5161. /** Defines the exponent of the function */
  5162. exponent: number;
  5163. /**
  5164. * Instantiates an exponential easing function
  5165. * @see https://easings.net/#easeInExpo
  5166. * @param exponent Defines the exponent of the function
  5167. */
  5168. constructor(
  5169. /** Defines the exponent of the function */
  5170. exponent?: number);
  5171. /** @hidden */
  5172. easeInCore(gradient: number): number;
  5173. }
  5174. /**
  5175. * Easing function with a power shape (see link below).
  5176. * @see https://easings.net/#easeInQuad
  5177. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5178. */
  5179. export class PowerEase extends EasingFunction implements IEasingFunction {
  5180. /** Defines the power of the function */
  5181. power: number;
  5182. /**
  5183. * Instantiates an power base easing function
  5184. * @see https://easings.net/#easeInQuad
  5185. * @param power Defines the power of the function
  5186. */
  5187. constructor(
  5188. /** Defines the power of the function */
  5189. power?: number);
  5190. /** @hidden */
  5191. easeInCore(gradient: number): number;
  5192. }
  5193. /**
  5194. * Easing function with a power of 2 shape (see link below).
  5195. * @see https://easings.net/#easeInQuad
  5196. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5197. */
  5198. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5199. /** @hidden */
  5200. easeInCore(gradient: number): number;
  5201. }
  5202. /**
  5203. * Easing function with a power of 4 shape (see link below).
  5204. * @see https://easings.net/#easeInQuart
  5205. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5206. */
  5207. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5208. /** @hidden */
  5209. easeInCore(gradient: number): number;
  5210. }
  5211. /**
  5212. * Easing function with a power of 5 shape (see link below).
  5213. * @see https://easings.net/#easeInQuint
  5214. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5215. */
  5216. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5217. /** @hidden */
  5218. easeInCore(gradient: number): number;
  5219. }
  5220. /**
  5221. * Easing function with a sin shape (see link below).
  5222. * @see https://easings.net/#easeInSine
  5223. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5224. */
  5225. export class SineEase extends EasingFunction implements IEasingFunction {
  5226. /** @hidden */
  5227. easeInCore(gradient: number): number;
  5228. }
  5229. /**
  5230. * Easing function with a bezier shape (see link below).
  5231. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5232. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5233. */
  5234. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5235. /** Defines the x component of the start tangent in the bezier curve */
  5236. x1: number;
  5237. /** Defines the y component of the start tangent in the bezier curve */
  5238. y1: number;
  5239. /** Defines the x component of the end tangent in the bezier curve */
  5240. x2: number;
  5241. /** Defines the y component of the end tangent in the bezier curve */
  5242. y2: number;
  5243. /**
  5244. * Instantiates a bezier function
  5245. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5246. * @param x1 Defines the x component of the start tangent in the bezier curve
  5247. * @param y1 Defines the y component of the start tangent in the bezier curve
  5248. * @param x2 Defines the x component of the end tangent in the bezier curve
  5249. * @param y2 Defines the y component of the end tangent in the bezier curve
  5250. */
  5251. constructor(
  5252. /** Defines the x component of the start tangent in the bezier curve */
  5253. x1?: number,
  5254. /** Defines the y component of the start tangent in the bezier curve */
  5255. y1?: number,
  5256. /** Defines the x component of the end tangent in the bezier curve */
  5257. x2?: number,
  5258. /** Defines the y component of the end tangent in the bezier curve */
  5259. y2?: number);
  5260. /** @hidden */
  5261. easeInCore(gradient: number): number;
  5262. }
  5263. }
  5264. declare module "babylonjs/Maths/math.color" {
  5265. import { DeepImmutable, FloatArray } from "babylonjs/types";
  5266. /**
  5267. * Class used to hold a RBG color
  5268. */
  5269. export class Color3 {
  5270. /**
  5271. * Defines the red component (between 0 and 1, default is 0)
  5272. */
  5273. r: number;
  5274. /**
  5275. * Defines the green component (between 0 and 1, default is 0)
  5276. */
  5277. g: number;
  5278. /**
  5279. * Defines the blue component (between 0 and 1, default is 0)
  5280. */
  5281. b: number;
  5282. /**
  5283. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5284. * @param r defines the red component (between 0 and 1, default is 0)
  5285. * @param g defines the green component (between 0 and 1, default is 0)
  5286. * @param b defines the blue component (between 0 and 1, default is 0)
  5287. */
  5288. constructor(
  5289. /**
  5290. * Defines the red component (between 0 and 1, default is 0)
  5291. */
  5292. r?: number,
  5293. /**
  5294. * Defines the green component (between 0 and 1, default is 0)
  5295. */
  5296. g?: number,
  5297. /**
  5298. * Defines the blue component (between 0 and 1, default is 0)
  5299. */
  5300. b?: number);
  5301. /**
  5302. * Creates a string with the Color3 current values
  5303. * @returns the string representation of the Color3 object
  5304. */
  5305. toString(): string;
  5306. /**
  5307. * Returns the string "Color3"
  5308. * @returns "Color3"
  5309. */
  5310. getClassName(): string;
  5311. /**
  5312. * Compute the Color3 hash code
  5313. * @returns an unique number that can be used to hash Color3 objects
  5314. */
  5315. getHashCode(): number;
  5316. /**
  5317. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5318. * @param array defines the array where to store the r,g,b components
  5319. * @param index defines an optional index in the target array to define where to start storing values
  5320. * @returns the current Color3 object
  5321. */
  5322. toArray(array: FloatArray, index?: number): Color3;
  5323. /**
  5324. * Returns a new Color4 object from the current Color3 and the given alpha
  5325. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5326. * @returns a new Color4 object
  5327. */
  5328. toColor4(alpha?: number): Color4;
  5329. /**
  5330. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5331. * @returns the new array
  5332. */
  5333. asArray(): number[];
  5334. /**
  5335. * Returns the luminance value
  5336. * @returns a float value
  5337. */
  5338. toLuminance(): number;
  5339. /**
  5340. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5341. * @param otherColor defines the second operand
  5342. * @returns the new Color3 object
  5343. */
  5344. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5345. /**
  5346. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5347. * @param otherColor defines the second operand
  5348. * @param result defines the Color3 object where to store the result
  5349. * @returns the current Color3
  5350. */
  5351. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5352. /**
  5353. * Determines equality between Color3 objects
  5354. * @param otherColor defines the second operand
  5355. * @returns true if the rgb values are equal to the given ones
  5356. */
  5357. equals(otherColor: DeepImmutable<Color3>): boolean;
  5358. /**
  5359. * Determines equality between the current Color3 object and a set of r,b,g values
  5360. * @param r defines the red component to check
  5361. * @param g defines the green component to check
  5362. * @param b defines the blue component to check
  5363. * @returns true if the rgb values are equal to the given ones
  5364. */
  5365. equalsFloats(r: number, g: number, b: number): boolean;
  5366. /**
  5367. * Multiplies in place each rgb value by scale
  5368. * @param scale defines the scaling factor
  5369. * @returns the updated Color3
  5370. */
  5371. scale(scale: number): Color3;
  5372. /**
  5373. * Multiplies the rgb values by scale and stores the result into "result"
  5374. * @param scale defines the scaling factor
  5375. * @param result defines the Color3 object where to store the result
  5376. * @returns the unmodified current Color3
  5377. */
  5378. scaleToRef(scale: number, result: Color3): Color3;
  5379. /**
  5380. * Scale the current Color3 values by a factor and add the result to a given Color3
  5381. * @param scale defines the scale factor
  5382. * @param result defines color to store the result into
  5383. * @returns the unmodified current Color3
  5384. */
  5385. scaleAndAddToRef(scale: number, result: Color3): Color3;
  5386. /**
  5387. * Clamps the rgb values by the min and max values and stores the result into "result"
  5388. * @param min defines minimum clamping value (default is 0)
  5389. * @param max defines maximum clamping value (default is 1)
  5390. * @param result defines color to store the result into
  5391. * @returns the original Color3
  5392. */
  5393. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  5394. /**
  5395. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  5396. * @param otherColor defines the second operand
  5397. * @returns the new Color3
  5398. */
  5399. add(otherColor: DeepImmutable<Color3>): Color3;
  5400. /**
  5401. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  5402. * @param otherColor defines the second operand
  5403. * @param result defines Color3 object to store the result into
  5404. * @returns the unmodified current Color3
  5405. */
  5406. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5407. /**
  5408. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  5409. * @param otherColor defines the second operand
  5410. * @returns the new Color3
  5411. */
  5412. subtract(otherColor: DeepImmutable<Color3>): Color3;
  5413. /**
  5414. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  5415. * @param otherColor defines the second operand
  5416. * @param result defines Color3 object to store the result into
  5417. * @returns the unmodified current Color3
  5418. */
  5419. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5420. /**
  5421. * Copy the current object
  5422. * @returns a new Color3 copied the current one
  5423. */
  5424. clone(): Color3;
  5425. /**
  5426. * Copies the rgb values from the source in the current Color3
  5427. * @param source defines the source Color3 object
  5428. * @returns the updated Color3 object
  5429. */
  5430. copyFrom(source: DeepImmutable<Color3>): Color3;
  5431. /**
  5432. * Updates the Color3 rgb values from the given floats
  5433. * @param r defines the red component to read from
  5434. * @param g defines the green component to read from
  5435. * @param b defines the blue component to read from
  5436. * @returns the current Color3 object
  5437. */
  5438. copyFromFloats(r: number, g: number, b: number): Color3;
  5439. /**
  5440. * Updates the Color3 rgb values from the given floats
  5441. * @param r defines the red component to read from
  5442. * @param g defines the green component to read from
  5443. * @param b defines the blue component to read from
  5444. * @returns the current Color3 object
  5445. */
  5446. set(r: number, g: number, b: number): Color3;
  5447. /**
  5448. * Compute the Color3 hexadecimal code as a string
  5449. * @returns a string containing the hexadecimal representation of the Color3 object
  5450. */
  5451. toHexString(): string;
  5452. /**
  5453. * Computes a new Color3 converted from the current one to linear space
  5454. * @returns a new Color3 object
  5455. */
  5456. toLinearSpace(): Color3;
  5457. /**
  5458. * Converts current color in rgb space to HSV values
  5459. * @returns a new color3 representing the HSV values
  5460. */
  5461. toHSV(): Color3;
  5462. /**
  5463. * Converts current color in rgb space to HSV values
  5464. * @param result defines the Color3 where to store the HSV values
  5465. */
  5466. toHSVToRef(result: Color3): void;
  5467. /**
  5468. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5469. * @param convertedColor defines the Color3 object where to store the linear space version
  5470. * @returns the unmodified Color3
  5471. */
  5472. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5473. /**
  5474. * Computes a new Color3 converted from the current one to gamma space
  5475. * @returns a new Color3 object
  5476. */
  5477. toGammaSpace(): Color3;
  5478. /**
  5479. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5480. * @param convertedColor defines the Color3 object where to store the gamma space version
  5481. * @returns the unmodified Color3
  5482. */
  5483. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5484. private static _BlackReadOnly;
  5485. /**
  5486. * Convert Hue, saturation and value to a Color3 (RGB)
  5487. * @param hue defines the hue
  5488. * @param saturation defines the saturation
  5489. * @param value defines the value
  5490. * @param result defines the Color3 where to store the RGB values
  5491. */
  5492. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5493. /**
  5494. * Creates a new Color3 from the string containing valid hexadecimal values
  5495. * @param hex defines a string containing valid hexadecimal values
  5496. * @returns a new Color3 object
  5497. */
  5498. static FromHexString(hex: string): Color3;
  5499. /**
  5500. * Creates a new Color3 from the starting index of the given array
  5501. * @param array defines the source array
  5502. * @param offset defines an offset in the source array
  5503. * @returns a new Color3 object
  5504. */
  5505. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5506. /**
  5507. * Creates a new Color3 from integer values (< 256)
  5508. * @param r defines the red component to read from (value between 0 and 255)
  5509. * @param g defines the green component to read from (value between 0 and 255)
  5510. * @param b defines the blue component to read from (value between 0 and 255)
  5511. * @returns a new Color3 object
  5512. */
  5513. static FromInts(r: number, g: number, b: number): Color3;
  5514. /**
  5515. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5516. * @param start defines the start Color3 value
  5517. * @param end defines the end Color3 value
  5518. * @param amount defines the gradient value between start and end
  5519. * @returns a new Color3 object
  5520. */
  5521. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5522. /**
  5523. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5524. * @param left defines the start value
  5525. * @param right defines the end value
  5526. * @param amount defines the gradient factor
  5527. * @param result defines the Color3 object where to store the result
  5528. */
  5529. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5530. /**
  5531. * Returns a Color3 value containing a red color
  5532. * @returns a new Color3 object
  5533. */
  5534. static Red(): Color3;
  5535. /**
  5536. * Returns a Color3 value containing a green color
  5537. * @returns a new Color3 object
  5538. */
  5539. static Green(): Color3;
  5540. /**
  5541. * Returns a Color3 value containing a blue color
  5542. * @returns a new Color3 object
  5543. */
  5544. static Blue(): Color3;
  5545. /**
  5546. * Returns a Color3 value containing a black color
  5547. * @returns a new Color3 object
  5548. */
  5549. static Black(): Color3;
  5550. /**
  5551. * Gets a Color3 value containing a black color that must not be updated
  5552. */
  5553. static readonly BlackReadOnly: DeepImmutable<Color3>;
  5554. /**
  5555. * Returns a Color3 value containing a white color
  5556. * @returns a new Color3 object
  5557. */
  5558. static White(): Color3;
  5559. /**
  5560. * Returns a Color3 value containing a purple color
  5561. * @returns a new Color3 object
  5562. */
  5563. static Purple(): Color3;
  5564. /**
  5565. * Returns a Color3 value containing a magenta color
  5566. * @returns a new Color3 object
  5567. */
  5568. static Magenta(): Color3;
  5569. /**
  5570. * Returns a Color3 value containing a yellow color
  5571. * @returns a new Color3 object
  5572. */
  5573. static Yellow(): Color3;
  5574. /**
  5575. * Returns a Color3 value containing a gray color
  5576. * @returns a new Color3 object
  5577. */
  5578. static Gray(): Color3;
  5579. /**
  5580. * Returns a Color3 value containing a teal color
  5581. * @returns a new Color3 object
  5582. */
  5583. static Teal(): Color3;
  5584. /**
  5585. * Returns a Color3 value containing a random color
  5586. * @returns a new Color3 object
  5587. */
  5588. static Random(): Color3;
  5589. }
  5590. /**
  5591. * Class used to hold a RBGA color
  5592. */
  5593. export class Color4 {
  5594. /**
  5595. * Defines the red component (between 0 and 1, default is 0)
  5596. */
  5597. r: number;
  5598. /**
  5599. * Defines the green component (between 0 and 1, default is 0)
  5600. */
  5601. g: number;
  5602. /**
  5603. * Defines the blue component (between 0 and 1, default is 0)
  5604. */
  5605. b: number;
  5606. /**
  5607. * Defines the alpha component (between 0 and 1, default is 1)
  5608. */
  5609. a: number;
  5610. /**
  5611. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5612. * @param r defines the red component (between 0 and 1, default is 0)
  5613. * @param g defines the green component (between 0 and 1, default is 0)
  5614. * @param b defines the blue component (between 0 and 1, default is 0)
  5615. * @param a defines the alpha component (between 0 and 1, default is 1)
  5616. */
  5617. constructor(
  5618. /**
  5619. * Defines the red component (between 0 and 1, default is 0)
  5620. */
  5621. r?: number,
  5622. /**
  5623. * Defines the green component (between 0 and 1, default is 0)
  5624. */
  5625. g?: number,
  5626. /**
  5627. * Defines the blue component (between 0 and 1, default is 0)
  5628. */
  5629. b?: number,
  5630. /**
  5631. * Defines the alpha component (between 0 and 1, default is 1)
  5632. */
  5633. a?: number);
  5634. /**
  5635. * Adds in place the given Color4 values to the current Color4 object
  5636. * @param right defines the second operand
  5637. * @returns the current updated Color4 object
  5638. */
  5639. addInPlace(right: DeepImmutable<Color4>): Color4;
  5640. /**
  5641. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5642. * @returns the new array
  5643. */
  5644. asArray(): number[];
  5645. /**
  5646. * Stores from the starting index in the given array the Color4 successive values
  5647. * @param array defines the array where to store the r,g,b components
  5648. * @param index defines an optional index in the target array to define where to start storing values
  5649. * @returns the current Color4 object
  5650. */
  5651. toArray(array: number[], index?: number): Color4;
  5652. /**
  5653. * Determines equality between Color4 objects
  5654. * @param otherColor defines the second operand
  5655. * @returns true if the rgba values are equal to the given ones
  5656. */
  5657. equals(otherColor: DeepImmutable<Color4>): boolean;
  5658. /**
  5659. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5660. * @param right defines the second operand
  5661. * @returns a new Color4 object
  5662. */
  5663. add(right: DeepImmutable<Color4>): Color4;
  5664. /**
  5665. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5666. * @param right defines the second operand
  5667. * @returns a new Color4 object
  5668. */
  5669. subtract(right: DeepImmutable<Color4>): Color4;
  5670. /**
  5671. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5672. * @param right defines the second operand
  5673. * @param result defines the Color4 object where to store the result
  5674. * @returns the current Color4 object
  5675. */
  5676. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5677. /**
  5678. * Creates a new Color4 with the current Color4 values multiplied by scale
  5679. * @param scale defines the scaling factor to apply
  5680. * @returns a new Color4 object
  5681. */
  5682. scale(scale: number): Color4;
  5683. /**
  5684. * Multiplies the current Color4 values by scale and stores the result in "result"
  5685. * @param scale defines the scaling factor to apply
  5686. * @param result defines the Color4 object where to store the result
  5687. * @returns the current unmodified Color4
  5688. */
  5689. scaleToRef(scale: number, result: Color4): Color4;
  5690. /**
  5691. * Scale the current Color4 values by a factor and add the result to a given Color4
  5692. * @param scale defines the scale factor
  5693. * @param result defines the Color4 object where to store the result
  5694. * @returns the unmodified current Color4
  5695. */
  5696. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5697. /**
  5698. * Clamps the rgb values by the min and max values and stores the result into "result"
  5699. * @param min defines minimum clamping value (default is 0)
  5700. * @param max defines maximum clamping value (default is 1)
  5701. * @param result defines color to store the result into.
  5702. * @returns the cuurent Color4
  5703. */
  5704. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5705. /**
  5706. * Multipy an Color4 value by another and return a new Color4 object
  5707. * @param color defines the Color4 value to multiply by
  5708. * @returns a new Color4 object
  5709. */
  5710. multiply(color: Color4): Color4;
  5711. /**
  5712. * Multipy a Color4 value by another and push the result in a reference value
  5713. * @param color defines the Color4 value to multiply by
  5714. * @param result defines the Color4 to fill the result in
  5715. * @returns the result Color4
  5716. */
  5717. multiplyToRef(color: Color4, result: Color4): Color4;
  5718. /**
  5719. * Creates a string with the Color4 current values
  5720. * @returns the string representation of the Color4 object
  5721. */
  5722. toString(): string;
  5723. /**
  5724. * Returns the string "Color4"
  5725. * @returns "Color4"
  5726. */
  5727. getClassName(): string;
  5728. /**
  5729. * Compute the Color4 hash code
  5730. * @returns an unique number that can be used to hash Color4 objects
  5731. */
  5732. getHashCode(): number;
  5733. /**
  5734. * Creates a new Color4 copied from the current one
  5735. * @returns a new Color4 object
  5736. */
  5737. clone(): Color4;
  5738. /**
  5739. * Copies the given Color4 values into the current one
  5740. * @param source defines the source Color4 object
  5741. * @returns the current updated Color4 object
  5742. */
  5743. copyFrom(source: Color4): Color4;
  5744. /**
  5745. * Copies the given float values into the current one
  5746. * @param r defines the red component to read from
  5747. * @param g defines the green component to read from
  5748. * @param b defines the blue component to read from
  5749. * @param a defines the alpha component to read from
  5750. * @returns the current updated Color4 object
  5751. */
  5752. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  5753. /**
  5754. * Copies the given float values into the current one
  5755. * @param r defines the red component to read from
  5756. * @param g defines the green component to read from
  5757. * @param b defines the blue component to read from
  5758. * @param a defines the alpha component to read from
  5759. * @returns the current updated Color4 object
  5760. */
  5761. set(r: number, g: number, b: number, a: number): Color4;
  5762. /**
  5763. * Compute the Color4 hexadecimal code as a string
  5764. * @returns a string containing the hexadecimal representation of the Color4 object
  5765. */
  5766. toHexString(): string;
  5767. /**
  5768. * Computes a new Color4 converted from the current one to linear space
  5769. * @returns a new Color4 object
  5770. */
  5771. toLinearSpace(): Color4;
  5772. /**
  5773. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  5774. * @param convertedColor defines the Color4 object where to store the linear space version
  5775. * @returns the unmodified Color4
  5776. */
  5777. toLinearSpaceToRef(convertedColor: Color4): Color4;
  5778. /**
  5779. * Computes a new Color4 converted from the current one to gamma space
  5780. * @returns a new Color4 object
  5781. */
  5782. toGammaSpace(): Color4;
  5783. /**
  5784. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  5785. * @param convertedColor defines the Color4 object where to store the gamma space version
  5786. * @returns the unmodified Color4
  5787. */
  5788. toGammaSpaceToRef(convertedColor: Color4): Color4;
  5789. /**
  5790. * Creates a new Color4 from the string containing valid hexadecimal values
  5791. * @param hex defines a string containing valid hexadecimal values
  5792. * @returns a new Color4 object
  5793. */
  5794. static FromHexString(hex: string): Color4;
  5795. /**
  5796. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5797. * @param left defines the start value
  5798. * @param right defines the end value
  5799. * @param amount defines the gradient factor
  5800. * @returns a new Color4 object
  5801. */
  5802. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  5803. /**
  5804. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5805. * @param left defines the start value
  5806. * @param right defines the end value
  5807. * @param amount defines the gradient factor
  5808. * @param result defines the Color4 object where to store data
  5809. */
  5810. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  5811. /**
  5812. * Creates a new Color4 from a Color3 and an alpha value
  5813. * @param color3 defines the source Color3 to read from
  5814. * @param alpha defines the alpha component (1.0 by default)
  5815. * @returns a new Color4 object
  5816. */
  5817. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  5818. /**
  5819. * Creates a new Color4 from the starting index element of the given array
  5820. * @param array defines the source array to read from
  5821. * @param offset defines the offset in the source array
  5822. * @returns a new Color4 object
  5823. */
  5824. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5825. /**
  5826. * Creates a new Color3 from integer values (< 256)
  5827. * @param r defines the red component to read from (value between 0 and 255)
  5828. * @param g defines the green component to read from (value between 0 and 255)
  5829. * @param b defines the blue component to read from (value between 0 and 255)
  5830. * @param a defines the alpha component to read from (value between 0 and 255)
  5831. * @returns a new Color3 object
  5832. */
  5833. static FromInts(r: number, g: number, b: number, a: number): Color4;
  5834. /**
  5835. * Check the content of a given array and convert it to an array containing RGBA data
  5836. * If the original array was already containing count * 4 values then it is returned directly
  5837. * @param colors defines the array to check
  5838. * @param count defines the number of RGBA data to expect
  5839. * @returns an array containing count * 4 values (RGBA)
  5840. */
  5841. static CheckColors4(colors: number[], count: number): number[];
  5842. }
  5843. /**
  5844. * @hidden
  5845. */
  5846. export class TmpColors {
  5847. static Color3: Color3[];
  5848. static Color4: Color4[];
  5849. }
  5850. }
  5851. declare module "babylonjs/Animations/animationKey" {
  5852. /**
  5853. * Defines an interface which represents an animation key frame
  5854. */
  5855. export interface IAnimationKey {
  5856. /**
  5857. * Frame of the key frame
  5858. */
  5859. frame: number;
  5860. /**
  5861. * Value at the specifies key frame
  5862. */
  5863. value: any;
  5864. /**
  5865. * The input tangent for the cubic hermite spline
  5866. */
  5867. inTangent?: any;
  5868. /**
  5869. * The output tangent for the cubic hermite spline
  5870. */
  5871. outTangent?: any;
  5872. /**
  5873. * The animation interpolation type
  5874. */
  5875. interpolation?: AnimationKeyInterpolation;
  5876. }
  5877. /**
  5878. * Enum for the animation key frame interpolation type
  5879. */
  5880. export enum AnimationKeyInterpolation {
  5881. /**
  5882. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  5883. */
  5884. STEP = 1
  5885. }
  5886. }
  5887. declare module "babylonjs/Animations/animationRange" {
  5888. /**
  5889. * Represents the range of an animation
  5890. */
  5891. export class AnimationRange {
  5892. /**The name of the animation range**/
  5893. name: string;
  5894. /**The starting frame of the animation */
  5895. from: number;
  5896. /**The ending frame of the animation*/
  5897. to: number;
  5898. /**
  5899. * Initializes the range of an animation
  5900. * @param name The name of the animation range
  5901. * @param from The starting frame of the animation
  5902. * @param to The ending frame of the animation
  5903. */
  5904. constructor(
  5905. /**The name of the animation range**/
  5906. name: string,
  5907. /**The starting frame of the animation */
  5908. from: number,
  5909. /**The ending frame of the animation*/
  5910. to: number);
  5911. /**
  5912. * Makes a copy of the animation range
  5913. * @returns A copy of the animation range
  5914. */
  5915. clone(): AnimationRange;
  5916. }
  5917. }
  5918. declare module "babylonjs/Animations/animationEvent" {
  5919. /**
  5920. * Composed of a frame, and an action function
  5921. */
  5922. export class AnimationEvent {
  5923. /** The frame for which the event is triggered **/
  5924. frame: number;
  5925. /** The event to perform when triggered **/
  5926. action: (currentFrame: number) => void;
  5927. /** Specifies if the event should be triggered only once**/
  5928. onlyOnce?: boolean | undefined;
  5929. /**
  5930. * Specifies if the animation event is done
  5931. */
  5932. isDone: boolean;
  5933. /**
  5934. * Initializes the animation event
  5935. * @param frame The frame for which the event is triggered
  5936. * @param action The event to perform when triggered
  5937. * @param onlyOnce Specifies if the event should be triggered only once
  5938. */
  5939. constructor(
  5940. /** The frame for which the event is triggered **/
  5941. frame: number,
  5942. /** The event to perform when triggered **/
  5943. action: (currentFrame: number) => void,
  5944. /** Specifies if the event should be triggered only once**/
  5945. onlyOnce?: boolean | undefined);
  5946. /** @hidden */
  5947. _clone(): AnimationEvent;
  5948. }
  5949. }
  5950. declare module "babylonjs/Behaviors/behavior" {
  5951. import { Nullable } from "babylonjs/types";
  5952. /**
  5953. * Interface used to define a behavior
  5954. */
  5955. export interface Behavior<T> {
  5956. /** gets or sets behavior's name */
  5957. name: string;
  5958. /**
  5959. * Function called when the behavior needs to be initialized (after attaching it to a target)
  5960. */
  5961. init(): void;
  5962. /**
  5963. * Called when the behavior is attached to a target
  5964. * @param target defines the target where the behavior is attached to
  5965. */
  5966. attach(target: T): void;
  5967. /**
  5968. * Called when the behavior is detached from its target
  5969. */
  5970. detach(): void;
  5971. }
  5972. /**
  5973. * Interface implemented by classes supporting behaviors
  5974. */
  5975. export interface IBehaviorAware<T> {
  5976. /**
  5977. * Attach a behavior
  5978. * @param behavior defines the behavior to attach
  5979. * @returns the current host
  5980. */
  5981. addBehavior(behavior: Behavior<T>): T;
  5982. /**
  5983. * Remove a behavior from the current object
  5984. * @param behavior defines the behavior to detach
  5985. * @returns the current host
  5986. */
  5987. removeBehavior(behavior: Behavior<T>): T;
  5988. /**
  5989. * Gets a behavior using its name to search
  5990. * @param name defines the name to search
  5991. * @returns the behavior or null if not found
  5992. */
  5993. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  5994. }
  5995. }
  5996. declare module "babylonjs/Misc/smartArray" {
  5997. /**
  5998. * Defines an array and its length.
  5999. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  6000. */
  6001. export interface ISmartArrayLike<T> {
  6002. /**
  6003. * The data of the array.
  6004. */
  6005. data: Array<T>;
  6006. /**
  6007. * The active length of the array.
  6008. */
  6009. length: number;
  6010. }
  6011. /**
  6012. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6013. */
  6014. export class SmartArray<T> implements ISmartArrayLike<T> {
  6015. /**
  6016. * The full set of data from the array.
  6017. */
  6018. data: Array<T>;
  6019. /**
  6020. * The active length of the array.
  6021. */
  6022. length: number;
  6023. protected _id: number;
  6024. /**
  6025. * Instantiates a Smart Array.
  6026. * @param capacity defines the default capacity of the array.
  6027. */
  6028. constructor(capacity: number);
  6029. /**
  6030. * Pushes a value at the end of the active data.
  6031. * @param value defines the object to push in the array.
  6032. */
  6033. push(value: T): void;
  6034. /**
  6035. * Iterates over the active data and apply the lambda to them.
  6036. * @param func defines the action to apply on each value.
  6037. */
  6038. forEach(func: (content: T) => void): void;
  6039. /**
  6040. * Sorts the full sets of data.
  6041. * @param compareFn defines the comparison function to apply.
  6042. */
  6043. sort(compareFn: (a: T, b: T) => number): void;
  6044. /**
  6045. * Resets the active data to an empty array.
  6046. */
  6047. reset(): void;
  6048. /**
  6049. * Releases all the data from the array as well as the array.
  6050. */
  6051. dispose(): void;
  6052. /**
  6053. * Concats the active data with a given array.
  6054. * @param array defines the data to concatenate with.
  6055. */
  6056. concat(array: any): void;
  6057. /**
  6058. * Returns the position of a value in the active data.
  6059. * @param value defines the value to find the index for
  6060. * @returns the index if found in the active data otherwise -1
  6061. */
  6062. indexOf(value: T): number;
  6063. /**
  6064. * Returns whether an element is part of the active data.
  6065. * @param value defines the value to look for
  6066. * @returns true if found in the active data otherwise false
  6067. */
  6068. contains(value: T): boolean;
  6069. private static _GlobalId;
  6070. }
  6071. /**
  6072. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6073. * The data in this array can only be present once
  6074. */
  6075. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6076. private _duplicateId;
  6077. /**
  6078. * Pushes a value at the end of the active data.
  6079. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6080. * @param value defines the object to push in the array.
  6081. */
  6082. push(value: T): void;
  6083. /**
  6084. * Pushes a value at the end of the active data.
  6085. * If the data is already present, it won t be added again
  6086. * @param value defines the object to push in the array.
  6087. * @returns true if added false if it was already present
  6088. */
  6089. pushNoDuplicate(value: T): boolean;
  6090. /**
  6091. * Resets the active data to an empty array.
  6092. */
  6093. reset(): void;
  6094. /**
  6095. * Concats the active data with a given array.
  6096. * This ensures no dupplicate will be present in the result.
  6097. * @param array defines the data to concatenate with.
  6098. */
  6099. concatWithNoDuplicate(array: any): void;
  6100. }
  6101. }
  6102. declare module "babylonjs/Cameras/cameraInputsManager" {
  6103. import { Nullable } from "babylonjs/types";
  6104. import { Camera } from "babylonjs/Cameras/camera";
  6105. /**
  6106. * @ignore
  6107. * This is a list of all the different input types that are available in the application.
  6108. * Fo instance: ArcRotateCameraGamepadInput...
  6109. */
  6110. export var CameraInputTypes: {};
  6111. /**
  6112. * This is the contract to implement in order to create a new input class.
  6113. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6114. */
  6115. export interface ICameraInput<TCamera extends Camera> {
  6116. /**
  6117. * Defines the camera the input is attached to.
  6118. */
  6119. camera: Nullable<TCamera>;
  6120. /**
  6121. * Gets the class name of the current intput.
  6122. * @returns the class name
  6123. */
  6124. getClassName(): string;
  6125. /**
  6126. * Get the friendly name associated with the input class.
  6127. * @returns the input friendly name
  6128. */
  6129. getSimpleName(): string;
  6130. /**
  6131. * Attach the input controls to a specific dom element to get the input from.
  6132. * @param element Defines the element the controls should be listened from
  6133. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6134. */
  6135. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6136. /**
  6137. * Detach the current controls from the specified dom element.
  6138. * @param element Defines the element to stop listening the inputs from
  6139. */
  6140. detachControl(element: Nullable<HTMLElement>): void;
  6141. /**
  6142. * Update the current camera state depending on the inputs that have been used this frame.
  6143. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6144. */
  6145. checkInputs?: () => void;
  6146. }
  6147. /**
  6148. * Represents a map of input types to input instance or input index to input instance.
  6149. */
  6150. export interface CameraInputsMap<TCamera extends Camera> {
  6151. /**
  6152. * Accessor to the input by input type.
  6153. */
  6154. [name: string]: ICameraInput<TCamera>;
  6155. /**
  6156. * Accessor to the input by input index.
  6157. */
  6158. [idx: number]: ICameraInput<TCamera>;
  6159. }
  6160. /**
  6161. * This represents the input manager used within a camera.
  6162. * It helps dealing with all the different kind of input attached to a camera.
  6163. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6164. */
  6165. export class CameraInputsManager<TCamera extends Camera> {
  6166. /**
  6167. * Defines the list of inputs attahed to the camera.
  6168. */
  6169. attached: CameraInputsMap<TCamera>;
  6170. /**
  6171. * Defines the dom element the camera is collecting inputs from.
  6172. * This is null if the controls have not been attached.
  6173. */
  6174. attachedElement: Nullable<HTMLElement>;
  6175. /**
  6176. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6177. */
  6178. noPreventDefault: boolean;
  6179. /**
  6180. * Defined the camera the input manager belongs to.
  6181. */
  6182. camera: TCamera;
  6183. /**
  6184. * Update the current camera state depending on the inputs that have been used this frame.
  6185. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6186. */
  6187. checkInputs: () => void;
  6188. /**
  6189. * Instantiate a new Camera Input Manager.
  6190. * @param camera Defines the camera the input manager blongs to
  6191. */
  6192. constructor(camera: TCamera);
  6193. /**
  6194. * Add an input method to a camera
  6195. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6196. * @param input camera input method
  6197. */
  6198. add(input: ICameraInput<TCamera>): void;
  6199. /**
  6200. * Remove a specific input method from a camera
  6201. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6202. * @param inputToRemove camera input method
  6203. */
  6204. remove(inputToRemove: ICameraInput<TCamera>): void;
  6205. /**
  6206. * Remove a specific input type from a camera
  6207. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6208. * @param inputType the type of the input to remove
  6209. */
  6210. removeByType(inputType: string): void;
  6211. private _addCheckInputs;
  6212. /**
  6213. * Attach the input controls to the currently attached dom element to listen the events from.
  6214. * @param input Defines the input to attach
  6215. */
  6216. attachInput(input: ICameraInput<TCamera>): void;
  6217. /**
  6218. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6219. * @param element Defines the dom element to collect the events from
  6220. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6221. */
  6222. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6223. /**
  6224. * Detach the current manager inputs controls from a specific dom element.
  6225. * @param element Defines the dom element to collect the events from
  6226. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6227. */
  6228. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6229. /**
  6230. * Rebuild the dynamic inputCheck function from the current list of
  6231. * defined inputs in the manager.
  6232. */
  6233. rebuildInputCheck(): void;
  6234. /**
  6235. * Remove all attached input methods from a camera
  6236. */
  6237. clear(): void;
  6238. /**
  6239. * Serialize the current input manager attached to a camera.
  6240. * This ensures than once parsed,
  6241. * the input associated to the camera will be identical to the current ones
  6242. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6243. */
  6244. serialize(serializedCamera: any): void;
  6245. /**
  6246. * Parses an input manager serialized JSON to restore the previous list of inputs
  6247. * and states associated to a camera.
  6248. * @param parsedCamera Defines the JSON to parse
  6249. */
  6250. parse(parsedCamera: any): void;
  6251. }
  6252. }
  6253. declare module "babylonjs/Meshes/buffer" {
  6254. import { Nullable, DataArray } from "babylonjs/types";
  6255. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  6256. /**
  6257. * Class used to store data that will be store in GPU memory
  6258. */
  6259. export class Buffer {
  6260. private _engine;
  6261. private _buffer;
  6262. /** @hidden */
  6263. _data: Nullable<DataArray>;
  6264. private _updatable;
  6265. private _instanced;
  6266. private _divisor;
  6267. /**
  6268. * Gets the byte stride.
  6269. */
  6270. readonly byteStride: number;
  6271. /**
  6272. * Constructor
  6273. * @param engine the engine
  6274. * @param data the data to use for this buffer
  6275. * @param updatable whether the data is updatable
  6276. * @param stride the stride (optional)
  6277. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6278. * @param instanced whether the buffer is instanced (optional)
  6279. * @param useBytes set to true if the stride in in bytes (optional)
  6280. * @param divisor sets an optional divisor for instances (1 by default)
  6281. */
  6282. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6283. /**
  6284. * Create a new VertexBuffer based on the current buffer
  6285. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6286. * @param offset defines offset in the buffer (0 by default)
  6287. * @param size defines the size in floats of attributes (position is 3 for instance)
  6288. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6289. * @param instanced defines if the vertex buffer contains indexed data
  6290. * @param useBytes defines if the offset and stride are in bytes *
  6291. * @param divisor sets an optional divisor for instances (1 by default)
  6292. * @returns the new vertex buffer
  6293. */
  6294. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6295. /**
  6296. * Gets a boolean indicating if the Buffer is updatable?
  6297. * @returns true if the buffer is updatable
  6298. */
  6299. isUpdatable(): boolean;
  6300. /**
  6301. * Gets current buffer's data
  6302. * @returns a DataArray or null
  6303. */
  6304. getData(): Nullable<DataArray>;
  6305. /**
  6306. * Gets underlying native buffer
  6307. * @returns underlying native buffer
  6308. */
  6309. getBuffer(): Nullable<DataBuffer>;
  6310. /**
  6311. * Gets the stride in float32 units (i.e. byte stride / 4).
  6312. * May not be an integer if the byte stride is not divisible by 4.
  6313. * DEPRECATED. Use byteStride instead.
  6314. * @returns the stride in float32 units
  6315. */
  6316. getStrideSize(): number;
  6317. /**
  6318. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6319. * @param data defines the data to store
  6320. */
  6321. create(data?: Nullable<DataArray>): void;
  6322. /** @hidden */
  6323. _rebuild(): void;
  6324. /**
  6325. * Update current buffer data
  6326. * @param data defines the data to store
  6327. */
  6328. update(data: DataArray): void;
  6329. /**
  6330. * Updates the data directly.
  6331. * @param data the new data
  6332. * @param offset the new offset
  6333. * @param vertexCount the vertex count (optional)
  6334. * @param useBytes set to true if the offset is in bytes
  6335. */
  6336. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6337. /**
  6338. * Release all resources
  6339. */
  6340. dispose(): void;
  6341. }
  6342. /**
  6343. * Specialized buffer used to store vertex data
  6344. */
  6345. export class VertexBuffer {
  6346. /** @hidden */
  6347. _buffer: Buffer;
  6348. private _kind;
  6349. private _size;
  6350. private _ownsBuffer;
  6351. private _instanced;
  6352. private _instanceDivisor;
  6353. /**
  6354. * The byte type.
  6355. */
  6356. static readonly BYTE: number;
  6357. /**
  6358. * The unsigned byte type.
  6359. */
  6360. static readonly UNSIGNED_BYTE: number;
  6361. /**
  6362. * The short type.
  6363. */
  6364. static readonly SHORT: number;
  6365. /**
  6366. * The unsigned short type.
  6367. */
  6368. static readonly UNSIGNED_SHORT: number;
  6369. /**
  6370. * The integer type.
  6371. */
  6372. static readonly INT: number;
  6373. /**
  6374. * The unsigned integer type.
  6375. */
  6376. static readonly UNSIGNED_INT: number;
  6377. /**
  6378. * The float type.
  6379. */
  6380. static readonly FLOAT: number;
  6381. /**
  6382. * Gets or sets the instance divisor when in instanced mode
  6383. */
  6384. instanceDivisor: number;
  6385. /**
  6386. * Gets the byte stride.
  6387. */
  6388. readonly byteStride: number;
  6389. /**
  6390. * Gets the byte offset.
  6391. */
  6392. readonly byteOffset: number;
  6393. /**
  6394. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6395. */
  6396. readonly normalized: boolean;
  6397. /**
  6398. * Gets the data type of each component in the array.
  6399. */
  6400. readonly type: number;
  6401. /**
  6402. * Constructor
  6403. * @param engine the engine
  6404. * @param data the data to use for this vertex buffer
  6405. * @param kind the vertex buffer kind
  6406. * @param updatable whether the data is updatable
  6407. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6408. * @param stride the stride (optional)
  6409. * @param instanced whether the buffer is instanced (optional)
  6410. * @param offset the offset of the data (optional)
  6411. * @param size the number of components (optional)
  6412. * @param type the type of the component (optional)
  6413. * @param normalized whether the data contains normalized data (optional)
  6414. * @param useBytes set to true if stride and offset are in bytes (optional)
  6415. * @param divisor defines the instance divisor to use (1 by default)
  6416. */
  6417. constructor(engine: any, data: DataArray | Buffer, kind: string, updatable: boolean, postponeInternalCreation?: boolean, stride?: number, instanced?: boolean, offset?: number, size?: number, type?: number, normalized?: boolean, useBytes?: boolean, divisor?: number);
  6418. /** @hidden */
  6419. _rebuild(): void;
  6420. /**
  6421. * Returns the kind of the VertexBuffer (string)
  6422. * @returns a string
  6423. */
  6424. getKind(): string;
  6425. /**
  6426. * Gets a boolean indicating if the VertexBuffer is updatable?
  6427. * @returns true if the buffer is updatable
  6428. */
  6429. isUpdatable(): boolean;
  6430. /**
  6431. * Gets current buffer's data
  6432. * @returns a DataArray or null
  6433. */
  6434. getData(): Nullable<DataArray>;
  6435. /**
  6436. * Gets underlying native buffer
  6437. * @returns underlying native buffer
  6438. */
  6439. getBuffer(): Nullable<DataBuffer>;
  6440. /**
  6441. * Gets the stride in float32 units (i.e. byte stride / 4).
  6442. * May not be an integer if the byte stride is not divisible by 4.
  6443. * DEPRECATED. Use byteStride instead.
  6444. * @returns the stride in float32 units
  6445. */
  6446. getStrideSize(): number;
  6447. /**
  6448. * Returns the offset as a multiple of the type byte length.
  6449. * DEPRECATED. Use byteOffset instead.
  6450. * @returns the offset in bytes
  6451. */
  6452. getOffset(): number;
  6453. /**
  6454. * Returns the number of components per vertex attribute (integer)
  6455. * @returns the size in float
  6456. */
  6457. getSize(): number;
  6458. /**
  6459. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6460. * @returns true if this buffer is instanced
  6461. */
  6462. getIsInstanced(): boolean;
  6463. /**
  6464. * Returns the instancing divisor, zero for non-instanced (integer).
  6465. * @returns a number
  6466. */
  6467. getInstanceDivisor(): number;
  6468. /**
  6469. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6470. * @param data defines the data to store
  6471. */
  6472. create(data?: DataArray): void;
  6473. /**
  6474. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6475. * This function will create a new buffer if the current one is not updatable
  6476. * @param data defines the data to store
  6477. */
  6478. update(data: DataArray): void;
  6479. /**
  6480. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6481. * Returns the directly updated WebGLBuffer.
  6482. * @param data the new data
  6483. * @param offset the new offset
  6484. * @param useBytes set to true if the offset is in bytes
  6485. */
  6486. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6487. /**
  6488. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6489. */
  6490. dispose(): void;
  6491. /**
  6492. * Enumerates each value of this vertex buffer as numbers.
  6493. * @param count the number of values to enumerate
  6494. * @param callback the callback function called for each value
  6495. */
  6496. forEach(count: number, callback: (value: number, index: number) => void): void;
  6497. /**
  6498. * Positions
  6499. */
  6500. static readonly PositionKind: string;
  6501. /**
  6502. * Normals
  6503. */
  6504. static readonly NormalKind: string;
  6505. /**
  6506. * Tangents
  6507. */
  6508. static readonly TangentKind: string;
  6509. /**
  6510. * Texture coordinates
  6511. */
  6512. static readonly UVKind: string;
  6513. /**
  6514. * Texture coordinates 2
  6515. */
  6516. static readonly UV2Kind: string;
  6517. /**
  6518. * Texture coordinates 3
  6519. */
  6520. static readonly UV3Kind: string;
  6521. /**
  6522. * Texture coordinates 4
  6523. */
  6524. static readonly UV4Kind: string;
  6525. /**
  6526. * Texture coordinates 5
  6527. */
  6528. static readonly UV5Kind: string;
  6529. /**
  6530. * Texture coordinates 6
  6531. */
  6532. static readonly UV6Kind: string;
  6533. /**
  6534. * Colors
  6535. */
  6536. static readonly ColorKind: string;
  6537. /**
  6538. * Matrix indices (for bones)
  6539. */
  6540. static readonly MatricesIndicesKind: string;
  6541. /**
  6542. * Matrix weights (for bones)
  6543. */
  6544. static readonly MatricesWeightsKind: string;
  6545. /**
  6546. * Additional matrix indices (for bones)
  6547. */
  6548. static readonly MatricesIndicesExtraKind: string;
  6549. /**
  6550. * Additional matrix weights (for bones)
  6551. */
  6552. static readonly MatricesWeightsExtraKind: string;
  6553. /**
  6554. * Deduces the stride given a kind.
  6555. * @param kind The kind string to deduce
  6556. * @returns The deduced stride
  6557. */
  6558. static DeduceStride(kind: string): number;
  6559. /**
  6560. * Gets the byte length of the given type.
  6561. * @param type the type
  6562. * @returns the number of bytes
  6563. */
  6564. static GetTypeByteLength(type: number): number;
  6565. /**
  6566. * Enumerates each value of the given parameters as numbers.
  6567. * @param data the data to enumerate
  6568. * @param byteOffset the byte offset of the data
  6569. * @param byteStride the byte stride of the data
  6570. * @param componentCount the number of components per element
  6571. * @param componentType the type of the component
  6572. * @param count the number of values to enumerate
  6573. * @param normalized whether the data is normalized
  6574. * @param callback the callback function called for each value
  6575. */
  6576. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6577. private static _GetFloatValue;
  6578. }
  6579. }
  6580. declare module "babylonjs/Collisions/intersectionInfo" {
  6581. import { Nullable } from "babylonjs/types";
  6582. /**
  6583. * @hidden
  6584. */
  6585. export class IntersectionInfo {
  6586. bu: Nullable<number>;
  6587. bv: Nullable<number>;
  6588. distance: number;
  6589. faceId: number;
  6590. subMeshId: number;
  6591. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6592. }
  6593. }
  6594. declare module "babylonjs/Maths/math.plane" {
  6595. import { DeepImmutable } from "babylonjs/types";
  6596. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  6597. /**
  6598. * Represens a plane by the equation ax + by + cz + d = 0
  6599. */
  6600. export class Plane {
  6601. private static _TmpMatrix;
  6602. /**
  6603. * Normal of the plane (a,b,c)
  6604. */
  6605. normal: Vector3;
  6606. /**
  6607. * d component of the plane
  6608. */
  6609. d: number;
  6610. /**
  6611. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  6612. * @param a a component of the plane
  6613. * @param b b component of the plane
  6614. * @param c c component of the plane
  6615. * @param d d component of the plane
  6616. */
  6617. constructor(a: number, b: number, c: number, d: number);
  6618. /**
  6619. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  6620. */
  6621. asArray(): number[];
  6622. /**
  6623. * @returns a new plane copied from the current Plane.
  6624. */
  6625. clone(): Plane;
  6626. /**
  6627. * @returns the string "Plane".
  6628. */
  6629. getClassName(): string;
  6630. /**
  6631. * @returns the Plane hash code.
  6632. */
  6633. getHashCode(): number;
  6634. /**
  6635. * Normalize the current Plane in place.
  6636. * @returns the updated Plane.
  6637. */
  6638. normalize(): Plane;
  6639. /**
  6640. * Applies a transformation the plane and returns the result
  6641. * @param transformation the transformation matrix to be applied to the plane
  6642. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  6643. */
  6644. transform(transformation: DeepImmutable<Matrix>): Plane;
  6645. /**
  6646. * Calcualtte the dot product between the point and the plane normal
  6647. * @param point point to calculate the dot product with
  6648. * @returns the dot product (float) of the point coordinates and the plane normal.
  6649. */
  6650. dotCoordinate(point: DeepImmutable<Vector3>): number;
  6651. /**
  6652. * Updates the current Plane from the plane defined by the three given points.
  6653. * @param point1 one of the points used to contruct the plane
  6654. * @param point2 one of the points used to contruct the plane
  6655. * @param point3 one of the points used to contruct the plane
  6656. * @returns the updated Plane.
  6657. */
  6658. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6659. /**
  6660. * Checks if the plane is facing a given direction
  6661. * @param direction the direction to check if the plane is facing
  6662. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  6663. * @returns True is the vector "direction" is the same side than the plane normal.
  6664. */
  6665. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  6666. /**
  6667. * Calculates the distance to a point
  6668. * @param point point to calculate distance to
  6669. * @returns the signed distance (float) from the given point to the Plane.
  6670. */
  6671. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  6672. /**
  6673. * Creates a plane from an array
  6674. * @param array the array to create a plane from
  6675. * @returns a new Plane from the given array.
  6676. */
  6677. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  6678. /**
  6679. * Creates a plane from three points
  6680. * @param point1 point used to create the plane
  6681. * @param point2 point used to create the plane
  6682. * @param point3 point used to create the plane
  6683. * @returns a new Plane defined by the three given points.
  6684. */
  6685. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6686. /**
  6687. * Creates a plane from an origin point and a normal
  6688. * @param origin origin of the plane to be constructed
  6689. * @param normal normal of the plane to be constructed
  6690. * @returns a new Plane the normal vector to this plane at the given origin point.
  6691. * Note : the vector "normal" is updated because normalized.
  6692. */
  6693. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  6694. /**
  6695. * Calculates the distance from a plane and a point
  6696. * @param origin origin of the plane to be constructed
  6697. * @param normal normal of the plane to be constructed
  6698. * @param point point to calculate distance to
  6699. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  6700. */
  6701. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  6702. }
  6703. }
  6704. declare module "babylonjs/Culling/boundingSphere" {
  6705. import { DeepImmutable } from "babylonjs/types";
  6706. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6707. import { Plane } from "babylonjs/Maths/math.plane";
  6708. /**
  6709. * Class used to store bounding sphere information
  6710. */
  6711. export class BoundingSphere {
  6712. /**
  6713. * Gets the center of the bounding sphere in local space
  6714. */
  6715. readonly center: Vector3;
  6716. /**
  6717. * Radius of the bounding sphere in local space
  6718. */
  6719. radius: number;
  6720. /**
  6721. * Gets the center of the bounding sphere in world space
  6722. */
  6723. readonly centerWorld: Vector3;
  6724. /**
  6725. * Radius of the bounding sphere in world space
  6726. */
  6727. radiusWorld: number;
  6728. /**
  6729. * Gets the minimum vector in local space
  6730. */
  6731. readonly minimum: Vector3;
  6732. /**
  6733. * Gets the maximum vector in local space
  6734. */
  6735. readonly maximum: Vector3;
  6736. private _worldMatrix;
  6737. private static readonly TmpVector3;
  6738. /**
  6739. * Creates a new bounding sphere
  6740. * @param min defines the minimum vector (in local space)
  6741. * @param max defines the maximum vector (in local space)
  6742. * @param worldMatrix defines the new world matrix
  6743. */
  6744. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6745. /**
  6746. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6747. * @param min defines the new minimum vector (in local space)
  6748. * @param max defines the new maximum vector (in local space)
  6749. * @param worldMatrix defines the new world matrix
  6750. */
  6751. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6752. /**
  6753. * Scale the current bounding sphere by applying a scale factor
  6754. * @param factor defines the scale factor to apply
  6755. * @returns the current bounding box
  6756. */
  6757. scale(factor: number): BoundingSphere;
  6758. /**
  6759. * Gets the world matrix of the bounding box
  6760. * @returns a matrix
  6761. */
  6762. getWorldMatrix(): DeepImmutable<Matrix>;
  6763. /** @hidden */
  6764. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6765. /**
  6766. * Tests if the bounding sphere is intersecting the frustum planes
  6767. * @param frustumPlanes defines the frustum planes to test
  6768. * @returns true if there is an intersection
  6769. */
  6770. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6771. /**
  6772. * Tests if the bounding sphere center is in between the frustum planes.
  6773. * Used for optimistic fast inclusion.
  6774. * @param frustumPlanes defines the frustum planes to test
  6775. * @returns true if the sphere center is in between the frustum planes
  6776. */
  6777. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6778. /**
  6779. * Tests if a point is inside the bounding sphere
  6780. * @param point defines the point to test
  6781. * @returns true if the point is inside the bounding sphere
  6782. */
  6783. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6784. /**
  6785. * Checks if two sphere intersct
  6786. * @param sphere0 sphere 0
  6787. * @param sphere1 sphere 1
  6788. * @returns true if the speres intersect
  6789. */
  6790. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6791. }
  6792. }
  6793. declare module "babylonjs/Culling/boundingBox" {
  6794. import { DeepImmutable } from "babylonjs/types";
  6795. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6796. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  6797. import { ICullable } from "babylonjs/Culling/boundingInfo";
  6798. import { Plane } from "babylonjs/Maths/math.plane";
  6799. /**
  6800. * Class used to store bounding box information
  6801. */
  6802. export class BoundingBox implements ICullable {
  6803. /**
  6804. * Gets the 8 vectors representing the bounding box in local space
  6805. */
  6806. readonly vectors: Vector3[];
  6807. /**
  6808. * Gets the center of the bounding box in local space
  6809. */
  6810. readonly center: Vector3;
  6811. /**
  6812. * Gets the center of the bounding box in world space
  6813. */
  6814. readonly centerWorld: Vector3;
  6815. /**
  6816. * Gets the extend size in local space
  6817. */
  6818. readonly extendSize: Vector3;
  6819. /**
  6820. * Gets the extend size in world space
  6821. */
  6822. readonly extendSizeWorld: Vector3;
  6823. /**
  6824. * Gets the OBB (object bounding box) directions
  6825. */
  6826. readonly directions: Vector3[];
  6827. /**
  6828. * Gets the 8 vectors representing the bounding box in world space
  6829. */
  6830. readonly vectorsWorld: Vector3[];
  6831. /**
  6832. * Gets the minimum vector in world space
  6833. */
  6834. readonly minimumWorld: Vector3;
  6835. /**
  6836. * Gets the maximum vector in world space
  6837. */
  6838. readonly maximumWorld: Vector3;
  6839. /**
  6840. * Gets the minimum vector in local space
  6841. */
  6842. readonly minimum: Vector3;
  6843. /**
  6844. * Gets the maximum vector in local space
  6845. */
  6846. readonly maximum: Vector3;
  6847. private _worldMatrix;
  6848. private static readonly TmpVector3;
  6849. /**
  6850. * @hidden
  6851. */
  6852. _tag: number;
  6853. /**
  6854. * Creates a new bounding box
  6855. * @param min defines the minimum vector (in local space)
  6856. * @param max defines the maximum vector (in local space)
  6857. * @param worldMatrix defines the new world matrix
  6858. */
  6859. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6860. /**
  6861. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6862. * @param min defines the new minimum vector (in local space)
  6863. * @param max defines the new maximum vector (in local space)
  6864. * @param worldMatrix defines the new world matrix
  6865. */
  6866. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6867. /**
  6868. * Scale the current bounding box by applying a scale factor
  6869. * @param factor defines the scale factor to apply
  6870. * @returns the current bounding box
  6871. */
  6872. scale(factor: number): BoundingBox;
  6873. /**
  6874. * Gets the world matrix of the bounding box
  6875. * @returns a matrix
  6876. */
  6877. getWorldMatrix(): DeepImmutable<Matrix>;
  6878. /** @hidden */
  6879. _update(world: DeepImmutable<Matrix>): void;
  6880. /**
  6881. * Tests if the bounding box is intersecting the frustum planes
  6882. * @param frustumPlanes defines the frustum planes to test
  6883. * @returns true if there is an intersection
  6884. */
  6885. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6886. /**
  6887. * Tests if the bounding box is entirely inside the frustum planes
  6888. * @param frustumPlanes defines the frustum planes to test
  6889. * @returns true if there is an inclusion
  6890. */
  6891. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6892. /**
  6893. * Tests if a point is inside the bounding box
  6894. * @param point defines the point to test
  6895. * @returns true if the point is inside the bounding box
  6896. */
  6897. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6898. /**
  6899. * Tests if the bounding box intersects with a bounding sphere
  6900. * @param sphere defines the sphere to test
  6901. * @returns true if there is an intersection
  6902. */
  6903. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  6904. /**
  6905. * Tests if the bounding box intersects with a box defined by a min and max vectors
  6906. * @param min defines the min vector to use
  6907. * @param max defines the max vector to use
  6908. * @returns true if there is an intersection
  6909. */
  6910. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  6911. /**
  6912. * Tests if two bounding boxes are intersections
  6913. * @param box0 defines the first box to test
  6914. * @param box1 defines the second box to test
  6915. * @returns true if there is an intersection
  6916. */
  6917. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  6918. /**
  6919. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  6920. * @param minPoint defines the minimum vector of the bounding box
  6921. * @param maxPoint defines the maximum vector of the bounding box
  6922. * @param sphereCenter defines the sphere center
  6923. * @param sphereRadius defines the sphere radius
  6924. * @returns true if there is an intersection
  6925. */
  6926. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  6927. /**
  6928. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  6929. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6930. * @param frustumPlanes defines the frustum planes to test
  6931. * @return true if there is an inclusion
  6932. */
  6933. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6934. /**
  6935. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  6936. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6937. * @param frustumPlanes defines the frustum planes to test
  6938. * @return true if there is an intersection
  6939. */
  6940. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6941. }
  6942. }
  6943. declare module "babylonjs/Collisions/collider" {
  6944. import { Nullable, IndicesArray } from "babylonjs/types";
  6945. import { Vector3 } from "babylonjs/Maths/math.vector";
  6946. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  6947. import { Plane } from "babylonjs/Maths/math.plane";
  6948. /** @hidden */
  6949. export class Collider {
  6950. /** Define if a collision was found */
  6951. collisionFound: boolean;
  6952. /**
  6953. * Define last intersection point in local space
  6954. */
  6955. intersectionPoint: Vector3;
  6956. /**
  6957. * Define last collided mesh
  6958. */
  6959. collidedMesh: Nullable<AbstractMesh>;
  6960. private _collisionPoint;
  6961. private _planeIntersectionPoint;
  6962. private _tempVector;
  6963. private _tempVector2;
  6964. private _tempVector3;
  6965. private _tempVector4;
  6966. private _edge;
  6967. private _baseToVertex;
  6968. private _destinationPoint;
  6969. private _slidePlaneNormal;
  6970. private _displacementVector;
  6971. /** @hidden */
  6972. _radius: Vector3;
  6973. /** @hidden */
  6974. _retry: number;
  6975. private _velocity;
  6976. private _basePoint;
  6977. private _epsilon;
  6978. /** @hidden */
  6979. _velocityWorldLength: number;
  6980. /** @hidden */
  6981. _basePointWorld: Vector3;
  6982. private _velocityWorld;
  6983. private _normalizedVelocity;
  6984. /** @hidden */
  6985. _initialVelocity: Vector3;
  6986. /** @hidden */
  6987. _initialPosition: Vector3;
  6988. private _nearestDistance;
  6989. private _collisionMask;
  6990. collisionMask: number;
  6991. /**
  6992. * Gets the plane normal used to compute the sliding response (in local space)
  6993. */
  6994. readonly slidePlaneNormal: Vector3;
  6995. /** @hidden */
  6996. _initialize(source: Vector3, dir: Vector3, e: number): void;
  6997. /** @hidden */
  6998. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  6999. /** @hidden */
  7000. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7001. /** @hidden */
  7002. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7003. /** @hidden */
  7004. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7005. /** @hidden */
  7006. _getResponse(pos: Vector3, vel: Vector3): void;
  7007. }
  7008. }
  7009. declare module "babylonjs/Culling/boundingInfo" {
  7010. import { DeepImmutable } from "babylonjs/types";
  7011. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7012. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  7013. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7014. import { Plane } from "babylonjs/Maths/math.plane";
  7015. import { Collider } from "babylonjs/Collisions/collider";
  7016. /**
  7017. * Interface for cullable objects
  7018. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7019. */
  7020. export interface ICullable {
  7021. /**
  7022. * Checks if the object or part of the object is in the frustum
  7023. * @param frustumPlanes Camera near/planes
  7024. * @returns true if the object is in frustum otherwise false
  7025. */
  7026. isInFrustum(frustumPlanes: Plane[]): boolean;
  7027. /**
  7028. * Checks if a cullable object (mesh...) is in the camera frustum
  7029. * Unlike isInFrustum this cheks the full bounding box
  7030. * @param frustumPlanes Camera near/planes
  7031. * @returns true if the object is in frustum otherwise false
  7032. */
  7033. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7034. }
  7035. /**
  7036. * Info for a bounding data of a mesh
  7037. */
  7038. export class BoundingInfo implements ICullable {
  7039. /**
  7040. * Bounding box for the mesh
  7041. */
  7042. readonly boundingBox: BoundingBox;
  7043. /**
  7044. * Bounding sphere for the mesh
  7045. */
  7046. readonly boundingSphere: BoundingSphere;
  7047. private _isLocked;
  7048. private static readonly TmpVector3;
  7049. /**
  7050. * Constructs bounding info
  7051. * @param minimum min vector of the bounding box/sphere
  7052. * @param maximum max vector of the bounding box/sphere
  7053. * @param worldMatrix defines the new world matrix
  7054. */
  7055. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7056. /**
  7057. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7058. * @param min defines the new minimum vector (in local space)
  7059. * @param max defines the new maximum vector (in local space)
  7060. * @param worldMatrix defines the new world matrix
  7061. */
  7062. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7063. /**
  7064. * min vector of the bounding box/sphere
  7065. */
  7066. readonly minimum: Vector3;
  7067. /**
  7068. * max vector of the bounding box/sphere
  7069. */
  7070. readonly maximum: Vector3;
  7071. /**
  7072. * If the info is locked and won't be updated to avoid perf overhead
  7073. */
  7074. isLocked: boolean;
  7075. /**
  7076. * Updates the bounding sphere and box
  7077. * @param world world matrix to be used to update
  7078. */
  7079. update(world: DeepImmutable<Matrix>): void;
  7080. /**
  7081. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7082. * @param center New center of the bounding info
  7083. * @param extend New extend of the bounding info
  7084. * @returns the current bounding info
  7085. */
  7086. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7087. /**
  7088. * Scale the current bounding info by applying a scale factor
  7089. * @param factor defines the scale factor to apply
  7090. * @returns the current bounding info
  7091. */
  7092. scale(factor: number): BoundingInfo;
  7093. /**
  7094. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7095. * @param frustumPlanes defines the frustum to test
  7096. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7097. * @returns true if the bounding info is in the frustum planes
  7098. */
  7099. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7100. /**
  7101. * Gets the world distance between the min and max points of the bounding box
  7102. */
  7103. readonly diagonalLength: number;
  7104. /**
  7105. * Checks if a cullable object (mesh...) is in the camera frustum
  7106. * Unlike isInFrustum this cheks the full bounding box
  7107. * @param frustumPlanes Camera near/planes
  7108. * @returns true if the object is in frustum otherwise false
  7109. */
  7110. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7111. /** @hidden */
  7112. _checkCollision(collider: Collider): boolean;
  7113. /**
  7114. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7115. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7116. * @param point the point to check intersection with
  7117. * @returns if the point intersects
  7118. */
  7119. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7120. /**
  7121. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7122. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7123. * @param boundingInfo the bounding info to check intersection with
  7124. * @param precise if the intersection should be done using OBB
  7125. * @returns if the bounding info intersects
  7126. */
  7127. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7128. }
  7129. }
  7130. declare module "babylonjs/Maths/math.functions" {
  7131. import { FloatArray, Nullable, IndicesArray } from "babylonjs/types";
  7132. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  7133. /**
  7134. * Extracts minimum and maximum values from a list of indexed positions
  7135. * @param positions defines the positions to use
  7136. * @param indices defines the indices to the positions
  7137. * @param indexStart defines the start index
  7138. * @param indexCount defines the end index
  7139. * @param bias defines bias value to add to the result
  7140. * @return minimum and maximum values
  7141. */
  7142. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7143. minimum: Vector3;
  7144. maximum: Vector3;
  7145. };
  7146. /**
  7147. * Extracts minimum and maximum values from a list of positions
  7148. * @param positions defines the positions to use
  7149. * @param start defines the start index in the positions array
  7150. * @param count defines the number of positions to handle
  7151. * @param bias defines bias value to add to the result
  7152. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7153. * @return minimum and maximum values
  7154. */
  7155. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7156. minimum: Vector3;
  7157. maximum: Vector3;
  7158. };
  7159. }
  7160. declare module "babylonjs/Meshes/WebGL/webGLDataBuffer" {
  7161. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7162. /** @hidden */
  7163. export class WebGLDataBuffer extends DataBuffer {
  7164. private _buffer;
  7165. constructor(resource: WebGLBuffer);
  7166. readonly underlyingResource: any;
  7167. }
  7168. }
  7169. declare module "babylonjs/Engines/WebGL/webGLPipelineContext" {
  7170. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7171. import { Nullable } from "babylonjs/types";
  7172. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  7173. /** @hidden */
  7174. export class WebGLPipelineContext implements IPipelineContext {
  7175. engine: ThinEngine;
  7176. program: Nullable<WebGLProgram>;
  7177. context?: WebGLRenderingContext;
  7178. vertexShader?: WebGLShader;
  7179. fragmentShader?: WebGLShader;
  7180. isParallelCompiled: boolean;
  7181. onCompiled?: () => void;
  7182. transformFeedback?: WebGLTransformFeedback | null;
  7183. readonly isAsync: boolean;
  7184. readonly isReady: boolean;
  7185. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7186. }
  7187. }
  7188. declare module "babylonjs/Engines/Extensions/engine.uniformBuffer" {
  7189. import { FloatArray, Nullable } from "babylonjs/types";
  7190. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7191. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7192. module "babylonjs/Engines/thinEngine" {
  7193. interface ThinEngine {
  7194. /**
  7195. * Create an uniform buffer
  7196. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7197. * @param elements defines the content of the uniform buffer
  7198. * @returns the webGL uniform buffer
  7199. */
  7200. createUniformBuffer(elements: FloatArray): DataBuffer;
  7201. /**
  7202. * Create a dynamic uniform buffer
  7203. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7204. * @param elements defines the content of the uniform buffer
  7205. * @returns the webGL uniform buffer
  7206. */
  7207. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7208. /**
  7209. * Update an existing uniform buffer
  7210. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7211. * @param uniformBuffer defines the target uniform buffer
  7212. * @param elements defines the content to update
  7213. * @param offset defines the offset in the uniform buffer where update should start
  7214. * @param count defines the size of the data to update
  7215. */
  7216. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7217. /**
  7218. * Bind an uniform buffer to the current webGL context
  7219. * @param buffer defines the buffer to bind
  7220. */
  7221. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7222. /**
  7223. * Bind a buffer to the current webGL context at a given location
  7224. * @param buffer defines the buffer to bind
  7225. * @param location defines the index where to bind the buffer
  7226. */
  7227. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7228. /**
  7229. * Bind a specific block at a given index in a specific shader program
  7230. * @param pipelineContext defines the pipeline context to use
  7231. * @param blockName defines the block name
  7232. * @param index defines the index where to bind the block
  7233. */
  7234. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7235. }
  7236. }
  7237. }
  7238. declare module "babylonjs/Materials/uniformBuffer" {
  7239. import { Nullable, FloatArray } from "babylonjs/types";
  7240. import { Matrix, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  7241. import { Engine } from "babylonjs/Engines/engine";
  7242. import { Effect } from "babylonjs/Materials/effect";
  7243. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7244. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7245. import { Color3 } from "babylonjs/Maths/math.color";
  7246. import "babylonjs/Engines/Extensions/engine.uniformBuffer";
  7247. /**
  7248. * Uniform buffer objects.
  7249. *
  7250. * Handles blocks of uniform on the GPU.
  7251. *
  7252. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7253. *
  7254. * For more information, please refer to :
  7255. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7256. */
  7257. export class UniformBuffer {
  7258. private _engine;
  7259. private _buffer;
  7260. private _data;
  7261. private _bufferData;
  7262. private _dynamic?;
  7263. private _uniformLocations;
  7264. private _uniformSizes;
  7265. private _uniformLocationPointer;
  7266. private _needSync;
  7267. private _noUBO;
  7268. private _currentEffect;
  7269. /** @hidden */
  7270. _alreadyBound: boolean;
  7271. private static _MAX_UNIFORM_SIZE;
  7272. private static _tempBuffer;
  7273. /**
  7274. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7275. * This is dynamic to allow compat with webgl 1 and 2.
  7276. * You will need to pass the name of the uniform as well as the value.
  7277. */
  7278. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7279. /**
  7280. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7281. * This is dynamic to allow compat with webgl 1 and 2.
  7282. * You will need to pass the name of the uniform as well as the value.
  7283. */
  7284. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7285. /**
  7286. * Lambda to Update a single float in a uniform buffer.
  7287. * This is dynamic to allow compat with webgl 1 and 2.
  7288. * You will need to pass the name of the uniform as well as the value.
  7289. */
  7290. updateFloat: (name: string, x: number) => void;
  7291. /**
  7292. * Lambda to Update a vec2 of float in a uniform buffer.
  7293. * This is dynamic to allow compat with webgl 1 and 2.
  7294. * You will need to pass the name of the uniform as well as the value.
  7295. */
  7296. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7297. /**
  7298. * Lambda to Update a vec3 of float in a uniform buffer.
  7299. * This is dynamic to allow compat with webgl 1 and 2.
  7300. * You will need to pass the name of the uniform as well as the value.
  7301. */
  7302. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7303. /**
  7304. * Lambda to Update a vec4 of float in a uniform buffer.
  7305. * This is dynamic to allow compat with webgl 1 and 2.
  7306. * You will need to pass the name of the uniform as well as the value.
  7307. */
  7308. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7309. /**
  7310. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7311. * This is dynamic to allow compat with webgl 1 and 2.
  7312. * You will need to pass the name of the uniform as well as the value.
  7313. */
  7314. updateMatrix: (name: string, mat: Matrix) => void;
  7315. /**
  7316. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7317. * This is dynamic to allow compat with webgl 1 and 2.
  7318. * You will need to pass the name of the uniform as well as the value.
  7319. */
  7320. updateVector3: (name: string, vector: Vector3) => void;
  7321. /**
  7322. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7323. * This is dynamic to allow compat with webgl 1 and 2.
  7324. * You will need to pass the name of the uniform as well as the value.
  7325. */
  7326. updateVector4: (name: string, vector: Vector4) => void;
  7327. /**
  7328. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7329. * This is dynamic to allow compat with webgl 1 and 2.
  7330. * You will need to pass the name of the uniform as well as the value.
  7331. */
  7332. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7333. /**
  7334. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7335. * This is dynamic to allow compat with webgl 1 and 2.
  7336. * You will need to pass the name of the uniform as well as the value.
  7337. */
  7338. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7339. /**
  7340. * Instantiates a new Uniform buffer objects.
  7341. *
  7342. * Handles blocks of uniform on the GPU.
  7343. *
  7344. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7345. *
  7346. * For more information, please refer to :
  7347. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7348. * @param engine Define the engine the buffer is associated with
  7349. * @param data Define the data contained in the buffer
  7350. * @param dynamic Define if the buffer is updatable
  7351. */
  7352. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7353. /**
  7354. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7355. * or just falling back on setUniformXXX calls.
  7356. */
  7357. readonly useUbo: boolean;
  7358. /**
  7359. * Indicates if the WebGL underlying uniform buffer is in sync
  7360. * with the javascript cache data.
  7361. */
  7362. readonly isSync: boolean;
  7363. /**
  7364. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7365. * Also, a dynamic UniformBuffer will disable cache verification and always
  7366. * update the underlying WebGL uniform buffer to the GPU.
  7367. * @returns if Dynamic, otherwise false
  7368. */
  7369. isDynamic(): boolean;
  7370. /**
  7371. * The data cache on JS side.
  7372. * @returns the underlying data as a float array
  7373. */
  7374. getData(): Float32Array;
  7375. /**
  7376. * The underlying WebGL Uniform buffer.
  7377. * @returns the webgl buffer
  7378. */
  7379. getBuffer(): Nullable<DataBuffer>;
  7380. /**
  7381. * std140 layout specifies how to align data within an UBO structure.
  7382. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7383. * for specs.
  7384. */
  7385. private _fillAlignment;
  7386. /**
  7387. * Adds an uniform in the buffer.
  7388. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7389. * for the layout to be correct !
  7390. * @param name Name of the uniform, as used in the uniform block in the shader.
  7391. * @param size Data size, or data directly.
  7392. */
  7393. addUniform(name: string, size: number | number[]): void;
  7394. /**
  7395. * Adds a Matrix 4x4 to the uniform buffer.
  7396. * @param name Name of the uniform, as used in the uniform block in the shader.
  7397. * @param mat A 4x4 matrix.
  7398. */
  7399. addMatrix(name: string, mat: Matrix): void;
  7400. /**
  7401. * Adds a vec2 to the uniform buffer.
  7402. * @param name Name of the uniform, as used in the uniform block in the shader.
  7403. * @param x Define the x component value of the vec2
  7404. * @param y Define the y component value of the vec2
  7405. */
  7406. addFloat2(name: string, x: number, y: number): void;
  7407. /**
  7408. * Adds a vec3 to the uniform buffer.
  7409. * @param name Name of the uniform, as used in the uniform block in the shader.
  7410. * @param x Define the x component value of the vec3
  7411. * @param y Define the y component value of the vec3
  7412. * @param z Define the z component value of the vec3
  7413. */
  7414. addFloat3(name: string, x: number, y: number, z: number): void;
  7415. /**
  7416. * Adds a vec3 to the uniform buffer.
  7417. * @param name Name of the uniform, as used in the uniform block in the shader.
  7418. * @param color Define the vec3 from a Color
  7419. */
  7420. addColor3(name: string, color: Color3): void;
  7421. /**
  7422. * Adds a vec4 to the uniform buffer.
  7423. * @param name Name of the uniform, as used in the uniform block in the shader.
  7424. * @param color Define the rgb components from a Color
  7425. * @param alpha Define the a component of the vec4
  7426. */
  7427. addColor4(name: string, color: Color3, alpha: number): void;
  7428. /**
  7429. * Adds a vec3 to the uniform buffer.
  7430. * @param name Name of the uniform, as used in the uniform block in the shader.
  7431. * @param vector Define the vec3 components from a Vector
  7432. */
  7433. addVector3(name: string, vector: Vector3): void;
  7434. /**
  7435. * Adds a Matrix 3x3 to the uniform buffer.
  7436. * @param name Name of the uniform, as used in the uniform block in the shader.
  7437. */
  7438. addMatrix3x3(name: string): void;
  7439. /**
  7440. * Adds a Matrix 2x2 to the uniform buffer.
  7441. * @param name Name of the uniform, as used in the uniform block in the shader.
  7442. */
  7443. addMatrix2x2(name: string): void;
  7444. /**
  7445. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7446. */
  7447. create(): void;
  7448. /** @hidden */
  7449. _rebuild(): void;
  7450. /**
  7451. * Updates the WebGL Uniform Buffer on the GPU.
  7452. * If the `dynamic` flag is set to true, no cache comparison is done.
  7453. * Otherwise, the buffer will be updated only if the cache differs.
  7454. */
  7455. update(): void;
  7456. /**
  7457. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7458. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7459. * @param data Define the flattened data
  7460. * @param size Define the size of the data.
  7461. */
  7462. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7463. private _valueCache;
  7464. private _cacheMatrix;
  7465. private _updateMatrix3x3ForUniform;
  7466. private _updateMatrix3x3ForEffect;
  7467. private _updateMatrix2x2ForEffect;
  7468. private _updateMatrix2x2ForUniform;
  7469. private _updateFloatForEffect;
  7470. private _updateFloatForUniform;
  7471. private _updateFloat2ForEffect;
  7472. private _updateFloat2ForUniform;
  7473. private _updateFloat3ForEffect;
  7474. private _updateFloat3ForUniform;
  7475. private _updateFloat4ForEffect;
  7476. private _updateFloat4ForUniform;
  7477. private _updateMatrixForEffect;
  7478. private _updateMatrixForUniform;
  7479. private _updateVector3ForEffect;
  7480. private _updateVector3ForUniform;
  7481. private _updateVector4ForEffect;
  7482. private _updateVector4ForUniform;
  7483. private _updateColor3ForEffect;
  7484. private _updateColor3ForUniform;
  7485. private _updateColor4ForEffect;
  7486. private _updateColor4ForUniform;
  7487. /**
  7488. * Sets a sampler uniform on the effect.
  7489. * @param name Define the name of the sampler.
  7490. * @param texture Define the texture to set in the sampler
  7491. */
  7492. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7493. /**
  7494. * Directly updates the value of the uniform in the cache AND on the GPU.
  7495. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7496. * @param data Define the flattened data
  7497. */
  7498. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7499. /**
  7500. * Binds this uniform buffer to an effect.
  7501. * @param effect Define the effect to bind the buffer to
  7502. * @param name Name of the uniform block in the shader.
  7503. */
  7504. bindToEffect(effect: Effect, name: string): void;
  7505. /**
  7506. * Disposes the uniform buffer.
  7507. */
  7508. dispose(): void;
  7509. }
  7510. }
  7511. declare module "babylonjs/Misc/iInspectable" {
  7512. /**
  7513. * Enum that determines the text-wrapping mode to use.
  7514. */
  7515. export enum InspectableType {
  7516. /**
  7517. * Checkbox for booleans
  7518. */
  7519. Checkbox = 0,
  7520. /**
  7521. * Sliders for numbers
  7522. */
  7523. Slider = 1,
  7524. /**
  7525. * Vector3
  7526. */
  7527. Vector3 = 2,
  7528. /**
  7529. * Quaternions
  7530. */
  7531. Quaternion = 3,
  7532. /**
  7533. * Color3
  7534. */
  7535. Color3 = 4,
  7536. /**
  7537. * String
  7538. */
  7539. String = 5
  7540. }
  7541. /**
  7542. * Interface used to define custom inspectable properties.
  7543. * This interface is used by the inspector to display custom property grids
  7544. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7545. */
  7546. export interface IInspectable {
  7547. /**
  7548. * Gets the label to display
  7549. */
  7550. label: string;
  7551. /**
  7552. * Gets the name of the property to edit
  7553. */
  7554. propertyName: string;
  7555. /**
  7556. * Gets the type of the editor to use
  7557. */
  7558. type: InspectableType;
  7559. /**
  7560. * Gets the minimum value of the property when using in "slider" mode
  7561. */
  7562. min?: number;
  7563. /**
  7564. * Gets the maximum value of the property when using in "slider" mode
  7565. */
  7566. max?: number;
  7567. /**
  7568. * Gets the setp to use when using in "slider" mode
  7569. */
  7570. step?: number;
  7571. }
  7572. }
  7573. declare module "babylonjs/Misc/timingTools" {
  7574. /**
  7575. * Class used to provide helper for timing
  7576. */
  7577. export class TimingTools {
  7578. /**
  7579. * Polyfill for setImmediate
  7580. * @param action defines the action to execute after the current execution block
  7581. */
  7582. static SetImmediate(action: () => void): void;
  7583. }
  7584. }
  7585. declare module "babylonjs/Misc/instantiationTools" {
  7586. /**
  7587. * Class used to enable instatition of objects by class name
  7588. */
  7589. export class InstantiationTools {
  7590. /**
  7591. * Use this object to register external classes like custom textures or material
  7592. * to allow the laoders to instantiate them
  7593. */
  7594. static RegisteredExternalClasses: {
  7595. [key: string]: Object;
  7596. };
  7597. /**
  7598. * Tries to instantiate a new object from a given class name
  7599. * @param className defines the class name to instantiate
  7600. * @returns the new object or null if the system was not able to do the instantiation
  7601. */
  7602. static Instantiate(className: string): any;
  7603. }
  7604. }
  7605. declare module "babylonjs/Engines/depthTextureCreationOptions" {
  7606. /**
  7607. * Define options used to create a depth texture
  7608. */
  7609. export class DepthTextureCreationOptions {
  7610. /** Specifies whether or not a stencil should be allocated in the texture */
  7611. generateStencil?: boolean;
  7612. /** Specifies whether or not bilinear filtering is enable on the texture */
  7613. bilinearFiltering?: boolean;
  7614. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7615. comparisonFunction?: number;
  7616. /** Specifies if the created texture is a cube texture */
  7617. isCube?: boolean;
  7618. }
  7619. }
  7620. declare module "babylonjs/Engines/Extensions/engine.cubeTexture" {
  7621. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  7622. import { Nullable } from "babylonjs/types";
  7623. import { Scene } from "babylonjs/scene";
  7624. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  7625. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  7626. module "babylonjs/Engines/thinEngine" {
  7627. interface ThinEngine {
  7628. /**
  7629. * Creates a depth stencil cube texture.
  7630. * This is only available in WebGL 2.
  7631. * @param size The size of face edge in the cube texture.
  7632. * @param options The options defining the cube texture.
  7633. * @returns The cube texture
  7634. */
  7635. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7636. /**
  7637. * Creates a cube texture
  7638. * @param rootUrl defines the url where the files to load is located
  7639. * @param scene defines the current scene
  7640. * @param files defines the list of files to load (1 per face)
  7641. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7642. * @param onLoad defines an optional callback raised when the texture is loaded
  7643. * @param onError defines an optional callback raised if there is an issue to load the texture
  7644. * @param format defines the format of the data
  7645. * @param forcedExtension defines the extension to use to pick the right loader
  7646. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7647. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7648. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7649. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7650. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  7651. * @returns the cube texture as an InternalTexture
  7652. */
  7653. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean | undefined, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number, fallback: Nullable<InternalTexture>, excludeLoaders: Array<IInternalTextureLoader>): InternalTexture;
  7654. /**
  7655. * Creates a cube texture
  7656. * @param rootUrl defines the url where the files to load is located
  7657. * @param scene defines the current scene
  7658. * @param files defines the list of files to load (1 per face)
  7659. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7660. * @param onLoad defines an optional callback raised when the texture is loaded
  7661. * @param onError defines an optional callback raised if there is an issue to load the texture
  7662. * @param format defines the format of the data
  7663. * @param forcedExtension defines the extension to use to pick the right loader
  7664. * @returns the cube texture as an InternalTexture
  7665. */
  7666. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any): InternalTexture;
  7667. /**
  7668. * Creates a cube texture
  7669. * @param rootUrl defines the url where the files to load is located
  7670. * @param scene defines the current scene
  7671. * @param files defines the list of files to load (1 per face)
  7672. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7673. * @param onLoad defines an optional callback raised when the texture is loaded
  7674. * @param onError defines an optional callback raised if there is an issue to load the texture
  7675. * @param format defines the format of the data
  7676. * @param forcedExtension defines the extension to use to pick the right loader
  7677. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7678. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7679. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7680. * @returns the cube texture as an InternalTexture
  7681. */
  7682. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number): InternalTexture;
  7683. /** @hidden */
  7684. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7685. /** @hidden */
  7686. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7687. /** @hidden */
  7688. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7689. /** @hidden */
  7690. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7691. /**
  7692. * @hidden
  7693. */
  7694. _setCubeMapTextureParams(loadMipmap: boolean): void;
  7695. }
  7696. }
  7697. }
  7698. declare module "babylonjs/Materials/Textures/cubeTexture" {
  7699. import { Nullable } from "babylonjs/types";
  7700. import { Scene } from "babylonjs/scene";
  7701. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7702. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7703. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  7704. /**
  7705. * Class for creating a cube texture
  7706. */
  7707. export class CubeTexture extends BaseTexture {
  7708. private _delayedOnLoad;
  7709. /**
  7710. * The url of the texture
  7711. */
  7712. url: string;
  7713. /**
  7714. * Gets or sets the center of the bounding box associated with the cube texture.
  7715. * It must define where the camera used to render the texture was set
  7716. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7717. */
  7718. boundingBoxPosition: Vector3;
  7719. private _boundingBoxSize;
  7720. /**
  7721. * Gets or sets the size of the bounding box associated with the cube texture
  7722. * When defined, the cubemap will switch to local mode
  7723. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7724. * @example https://www.babylonjs-playground.com/#RNASML
  7725. */
  7726. /**
  7727. * Returns the bounding box size
  7728. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7729. */
  7730. boundingBoxSize: Vector3;
  7731. protected _rotationY: number;
  7732. /**
  7733. * Sets texture matrix rotation angle around Y axis in radians.
  7734. */
  7735. /**
  7736. * Gets texture matrix rotation angle around Y axis radians.
  7737. */
  7738. rotationY: number;
  7739. /**
  7740. * Are mip maps generated for this texture or not.
  7741. */
  7742. readonly noMipmap: boolean;
  7743. private _noMipmap;
  7744. private _files;
  7745. protected _forcedExtension: Nullable<string>;
  7746. private _extensions;
  7747. private _textureMatrix;
  7748. private _format;
  7749. private _createPolynomials;
  7750. /** @hidden */
  7751. _prefiltered: boolean;
  7752. /**
  7753. * Creates a cube texture from an array of image urls
  7754. * @param files defines an array of image urls
  7755. * @param scene defines the hosting scene
  7756. * @param noMipmap specifies if mip maps are not used
  7757. * @returns a cube texture
  7758. */
  7759. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7760. /**
  7761. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7762. * @param url defines the url of the prefiltered texture
  7763. * @param scene defines the scene the texture is attached to
  7764. * @param forcedExtension defines the extension of the file if different from the url
  7765. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7766. * @return the prefiltered texture
  7767. */
  7768. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7769. /**
  7770. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7771. * as prefiltered data.
  7772. * @param rootUrl defines the url of the texture or the root name of the six images
  7773. * @param scene defines the scene the texture is attached to
  7774. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7775. * @param noMipmap defines if mipmaps should be created or not
  7776. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7777. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7778. * @param onError defines a callback triggered in case of error during load
  7779. * @param format defines the internal format to use for the texture once loaded
  7780. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7781. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7782. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7783. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7784. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7785. * @return the cube texture
  7786. */
  7787. constructor(rootUrl: string, scene: Scene, extensions?: Nullable<string[]>, noMipmap?: boolean, files?: Nullable<string[]>, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, prefiltered?: boolean, forcedExtension?: any, createPolynomials?: boolean, lodScale?: number, lodOffset?: number);
  7788. /**
  7789. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7790. */
  7791. readonly isPrefiltered: boolean;
  7792. /**
  7793. * Get the current class name of the texture useful for serialization or dynamic coding.
  7794. * @returns "CubeTexture"
  7795. */
  7796. getClassName(): string;
  7797. /**
  7798. * Update the url (and optional buffer) of this texture if url was null during construction.
  7799. * @param url the url of the texture
  7800. * @param forcedExtension defines the extension to use
  7801. * @param onLoad callback called when the texture is loaded (defaults to null)
  7802. */
  7803. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  7804. /**
  7805. * Delays loading of the cube texture
  7806. * @param forcedExtension defines the extension to use
  7807. */
  7808. delayLoad(forcedExtension?: string): void;
  7809. /**
  7810. * Returns the reflection texture matrix
  7811. * @returns the reflection texture matrix
  7812. */
  7813. getReflectionTextureMatrix(): Matrix;
  7814. /**
  7815. * Sets the reflection texture matrix
  7816. * @param value Reflection texture matrix
  7817. */
  7818. setReflectionTextureMatrix(value: Matrix): void;
  7819. /**
  7820. * Parses text to create a cube texture
  7821. * @param parsedTexture define the serialized text to read from
  7822. * @param scene defines the hosting scene
  7823. * @param rootUrl defines the root url of the cube texture
  7824. * @returns a cube texture
  7825. */
  7826. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7827. /**
  7828. * Makes a clone, or deep copy, of the cube texture
  7829. * @returns a new cube texture
  7830. */
  7831. clone(): CubeTexture;
  7832. }
  7833. }
  7834. declare module "babylonjs/Materials/materialDefines" {
  7835. /**
  7836. * Manages the defines for the Material
  7837. */
  7838. export class MaterialDefines {
  7839. /** @hidden */
  7840. protected _keys: string[];
  7841. private _isDirty;
  7842. /** @hidden */
  7843. _renderId: number;
  7844. /** @hidden */
  7845. _areLightsDirty: boolean;
  7846. /** @hidden */
  7847. _areLightsDisposed: boolean;
  7848. /** @hidden */
  7849. _areAttributesDirty: boolean;
  7850. /** @hidden */
  7851. _areTexturesDirty: boolean;
  7852. /** @hidden */
  7853. _areFresnelDirty: boolean;
  7854. /** @hidden */
  7855. _areMiscDirty: boolean;
  7856. /** @hidden */
  7857. _areImageProcessingDirty: boolean;
  7858. /** @hidden */
  7859. _normals: boolean;
  7860. /** @hidden */
  7861. _uvs: boolean;
  7862. /** @hidden */
  7863. _needNormals: boolean;
  7864. /** @hidden */
  7865. _needUVs: boolean;
  7866. [id: string]: any;
  7867. /**
  7868. * Specifies if the material needs to be re-calculated
  7869. */
  7870. readonly isDirty: boolean;
  7871. /**
  7872. * Marks the material to indicate that it has been re-calculated
  7873. */
  7874. markAsProcessed(): void;
  7875. /**
  7876. * Marks the material to indicate that it needs to be re-calculated
  7877. */
  7878. markAsUnprocessed(): void;
  7879. /**
  7880. * Marks the material to indicate all of its defines need to be re-calculated
  7881. */
  7882. markAllAsDirty(): void;
  7883. /**
  7884. * Marks the material to indicate that image processing needs to be re-calculated
  7885. */
  7886. markAsImageProcessingDirty(): void;
  7887. /**
  7888. * Marks the material to indicate the lights need to be re-calculated
  7889. * @param disposed Defines whether the light is dirty due to dispose or not
  7890. */
  7891. markAsLightDirty(disposed?: boolean): void;
  7892. /**
  7893. * Marks the attribute state as changed
  7894. */
  7895. markAsAttributesDirty(): void;
  7896. /**
  7897. * Marks the texture state as changed
  7898. */
  7899. markAsTexturesDirty(): void;
  7900. /**
  7901. * Marks the fresnel state as changed
  7902. */
  7903. markAsFresnelDirty(): void;
  7904. /**
  7905. * Marks the misc state as changed
  7906. */
  7907. markAsMiscDirty(): void;
  7908. /**
  7909. * Rebuilds the material defines
  7910. */
  7911. rebuild(): void;
  7912. /**
  7913. * Specifies if two material defines are equal
  7914. * @param other - A material define instance to compare to
  7915. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  7916. */
  7917. isEqual(other: MaterialDefines): boolean;
  7918. /**
  7919. * Clones this instance's defines to another instance
  7920. * @param other - material defines to clone values to
  7921. */
  7922. cloneTo(other: MaterialDefines): void;
  7923. /**
  7924. * Resets the material define values
  7925. */
  7926. reset(): void;
  7927. /**
  7928. * Converts the material define values to a string
  7929. * @returns - String of material define information
  7930. */
  7931. toString(): string;
  7932. }
  7933. }
  7934. declare module "babylonjs/Materials/colorCurves" {
  7935. import { Effect } from "babylonjs/Materials/effect";
  7936. /**
  7937. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  7938. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  7939. * These are similar to controls found in many professional imaging or colorist software. The global controls are applied to the entire image. For advanced tuning, extra controls are provided to adjust the shadow, midtone and highlight areas of the image;
  7940. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  7941. */
  7942. export class ColorCurves {
  7943. private _dirty;
  7944. private _tempColor;
  7945. private _globalCurve;
  7946. private _highlightsCurve;
  7947. private _midtonesCurve;
  7948. private _shadowsCurve;
  7949. private _positiveCurve;
  7950. private _negativeCurve;
  7951. private _globalHue;
  7952. private _globalDensity;
  7953. private _globalSaturation;
  7954. private _globalExposure;
  7955. /**
  7956. * Gets the global Hue value.
  7957. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  7958. */
  7959. /**
  7960. * Sets the global Hue value.
  7961. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  7962. */
  7963. globalHue: number;
  7964. /**
  7965. * Gets the global Density value.
  7966. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  7967. * Values less than zero provide a filter of opposite hue.
  7968. */
  7969. /**
  7970. * Sets the global Density value.
  7971. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  7972. * Values less than zero provide a filter of opposite hue.
  7973. */
  7974. globalDensity: number;
  7975. /**
  7976. * Gets the global Saturation value.
  7977. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7978. */
  7979. /**
  7980. * Sets the global Saturation value.
  7981. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7982. */
  7983. globalSaturation: number;
  7984. /**
  7985. * Gets the global Exposure value.
  7986. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  7987. */
  7988. /**
  7989. * Sets the global Exposure value.
  7990. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  7991. */
  7992. globalExposure: number;
  7993. private _highlightsHue;
  7994. private _highlightsDensity;
  7995. private _highlightsSaturation;
  7996. private _highlightsExposure;
  7997. /**
  7998. * Gets the highlights Hue value.
  7999. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8000. */
  8001. /**
  8002. * Sets the highlights Hue value.
  8003. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8004. */
  8005. highlightsHue: number;
  8006. /**
  8007. * Gets the highlights Density value.
  8008. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8009. * Values less than zero provide a filter of opposite hue.
  8010. */
  8011. /**
  8012. * Sets the highlights Density value.
  8013. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8014. * Values less than zero provide a filter of opposite hue.
  8015. */
  8016. highlightsDensity: number;
  8017. /**
  8018. * Gets the highlights Saturation value.
  8019. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8020. */
  8021. /**
  8022. * Sets the highlights Saturation value.
  8023. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8024. */
  8025. highlightsSaturation: number;
  8026. /**
  8027. * Gets the highlights Exposure value.
  8028. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8029. */
  8030. /**
  8031. * Sets the highlights Exposure value.
  8032. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8033. */
  8034. highlightsExposure: number;
  8035. private _midtonesHue;
  8036. private _midtonesDensity;
  8037. private _midtonesSaturation;
  8038. private _midtonesExposure;
  8039. /**
  8040. * Gets the midtones Hue value.
  8041. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8042. */
  8043. /**
  8044. * Sets the midtones Hue value.
  8045. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8046. */
  8047. midtonesHue: number;
  8048. /**
  8049. * Gets the midtones Density value.
  8050. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8051. * Values less than zero provide a filter of opposite hue.
  8052. */
  8053. /**
  8054. * Sets the midtones Density value.
  8055. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8056. * Values less than zero provide a filter of opposite hue.
  8057. */
  8058. midtonesDensity: number;
  8059. /**
  8060. * Gets the midtones Saturation value.
  8061. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8062. */
  8063. /**
  8064. * Sets the midtones Saturation value.
  8065. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8066. */
  8067. midtonesSaturation: number;
  8068. /**
  8069. * Gets the midtones Exposure value.
  8070. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8071. */
  8072. /**
  8073. * Sets the midtones Exposure value.
  8074. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8075. */
  8076. midtonesExposure: number;
  8077. private _shadowsHue;
  8078. private _shadowsDensity;
  8079. private _shadowsSaturation;
  8080. private _shadowsExposure;
  8081. /**
  8082. * Gets the shadows Hue value.
  8083. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8084. */
  8085. /**
  8086. * Sets the shadows Hue value.
  8087. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8088. */
  8089. shadowsHue: number;
  8090. /**
  8091. * Gets the shadows Density value.
  8092. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8093. * Values less than zero provide a filter of opposite hue.
  8094. */
  8095. /**
  8096. * Sets the shadows Density value.
  8097. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8098. * Values less than zero provide a filter of opposite hue.
  8099. */
  8100. shadowsDensity: number;
  8101. /**
  8102. * Gets the shadows Saturation value.
  8103. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8104. */
  8105. /**
  8106. * Sets the shadows Saturation value.
  8107. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8108. */
  8109. shadowsSaturation: number;
  8110. /**
  8111. * Gets the shadows Exposure value.
  8112. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8113. */
  8114. /**
  8115. * Sets the shadows Exposure value.
  8116. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8117. */
  8118. shadowsExposure: number;
  8119. /**
  8120. * Returns the class name
  8121. * @returns The class name
  8122. */
  8123. getClassName(): string;
  8124. /**
  8125. * Binds the color curves to the shader.
  8126. * @param colorCurves The color curve to bind
  8127. * @param effect The effect to bind to
  8128. * @param positiveUniform The positive uniform shader parameter
  8129. * @param neutralUniform The neutral uniform shader parameter
  8130. * @param negativeUniform The negative uniform shader parameter
  8131. */
  8132. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8133. /**
  8134. * Prepare the list of uniforms associated with the ColorCurves effects.
  8135. * @param uniformsList The list of uniforms used in the effect
  8136. */
  8137. static PrepareUniforms(uniformsList: string[]): void;
  8138. /**
  8139. * Returns color grading data based on a hue, density, saturation and exposure value.
  8140. * @param filterHue The hue of the color filter.
  8141. * @param filterDensity The density of the color filter.
  8142. * @param saturation The saturation.
  8143. * @param exposure The exposure.
  8144. * @param result The result data container.
  8145. */
  8146. private getColorGradingDataToRef;
  8147. /**
  8148. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8149. * @param value The input slider value in range [-100,100].
  8150. * @returns Adjusted value.
  8151. */
  8152. private static applyColorGradingSliderNonlinear;
  8153. /**
  8154. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8155. * @param hue The hue (H) input.
  8156. * @param saturation The saturation (S) input.
  8157. * @param brightness The brightness (B) input.
  8158. * @result An RGBA color represented as Vector4.
  8159. */
  8160. private static fromHSBToRef;
  8161. /**
  8162. * Returns a value clamped between min and max
  8163. * @param value The value to clamp
  8164. * @param min The minimum of value
  8165. * @param max The maximum of value
  8166. * @returns The clamped value.
  8167. */
  8168. private static clamp;
  8169. /**
  8170. * Clones the current color curve instance.
  8171. * @return The cloned curves
  8172. */
  8173. clone(): ColorCurves;
  8174. /**
  8175. * Serializes the current color curve instance to a json representation.
  8176. * @return a JSON representation
  8177. */
  8178. serialize(): any;
  8179. /**
  8180. * Parses the color curve from a json representation.
  8181. * @param source the JSON source to parse
  8182. * @return The parsed curves
  8183. */
  8184. static Parse(source: any): ColorCurves;
  8185. }
  8186. }
  8187. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  8188. import { Observable } from "babylonjs/Misc/observable";
  8189. import { Nullable } from "babylonjs/types";
  8190. import { Color4 } from "babylonjs/Maths/math.color";
  8191. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  8192. import { Effect } from "babylonjs/Materials/effect";
  8193. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8194. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  8195. /**
  8196. * Interface to follow in your material defines to integrate easily the
  8197. * Image proccessing functions.
  8198. * @hidden
  8199. */
  8200. export interface IImageProcessingConfigurationDefines {
  8201. IMAGEPROCESSING: boolean;
  8202. VIGNETTE: boolean;
  8203. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8204. VIGNETTEBLENDMODEOPAQUE: boolean;
  8205. TONEMAPPING: boolean;
  8206. TONEMAPPING_ACES: boolean;
  8207. CONTRAST: boolean;
  8208. EXPOSURE: boolean;
  8209. COLORCURVES: boolean;
  8210. COLORGRADING: boolean;
  8211. COLORGRADING3D: boolean;
  8212. SAMPLER3DGREENDEPTH: boolean;
  8213. SAMPLER3DBGRMAP: boolean;
  8214. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8215. }
  8216. /**
  8217. * @hidden
  8218. */
  8219. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8220. IMAGEPROCESSING: boolean;
  8221. VIGNETTE: boolean;
  8222. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8223. VIGNETTEBLENDMODEOPAQUE: boolean;
  8224. TONEMAPPING: boolean;
  8225. TONEMAPPING_ACES: boolean;
  8226. CONTRAST: boolean;
  8227. COLORCURVES: boolean;
  8228. COLORGRADING: boolean;
  8229. COLORGRADING3D: boolean;
  8230. SAMPLER3DGREENDEPTH: boolean;
  8231. SAMPLER3DBGRMAP: boolean;
  8232. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8233. EXPOSURE: boolean;
  8234. constructor();
  8235. }
  8236. /**
  8237. * This groups together the common properties used for image processing either in direct forward pass
  8238. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8239. * or not.
  8240. */
  8241. export class ImageProcessingConfiguration {
  8242. /**
  8243. * Default tone mapping applied in BabylonJS.
  8244. */
  8245. static readonly TONEMAPPING_STANDARD: number;
  8246. /**
  8247. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8248. * to other engines rendering to increase portability.
  8249. */
  8250. static readonly TONEMAPPING_ACES: number;
  8251. /**
  8252. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8253. */
  8254. colorCurves: Nullable<ColorCurves>;
  8255. private _colorCurvesEnabled;
  8256. /**
  8257. * Gets wether the color curves effect is enabled.
  8258. */
  8259. /**
  8260. * Sets wether the color curves effect is enabled.
  8261. */
  8262. colorCurvesEnabled: boolean;
  8263. private _colorGradingTexture;
  8264. /**
  8265. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8266. */
  8267. /**
  8268. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8269. */
  8270. colorGradingTexture: Nullable<BaseTexture>;
  8271. private _colorGradingEnabled;
  8272. /**
  8273. * Gets wether the color grading effect is enabled.
  8274. */
  8275. /**
  8276. * Sets wether the color grading effect is enabled.
  8277. */
  8278. colorGradingEnabled: boolean;
  8279. private _colorGradingWithGreenDepth;
  8280. /**
  8281. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8282. */
  8283. /**
  8284. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8285. */
  8286. colorGradingWithGreenDepth: boolean;
  8287. private _colorGradingBGR;
  8288. /**
  8289. * Gets wether the color grading texture contains BGR values.
  8290. */
  8291. /**
  8292. * Sets wether the color grading texture contains BGR values.
  8293. */
  8294. colorGradingBGR: boolean;
  8295. /** @hidden */
  8296. _exposure: number;
  8297. /**
  8298. * Gets the Exposure used in the effect.
  8299. */
  8300. /**
  8301. * Sets the Exposure used in the effect.
  8302. */
  8303. exposure: number;
  8304. private _toneMappingEnabled;
  8305. /**
  8306. * Gets wether the tone mapping effect is enabled.
  8307. */
  8308. /**
  8309. * Sets wether the tone mapping effect is enabled.
  8310. */
  8311. toneMappingEnabled: boolean;
  8312. private _toneMappingType;
  8313. /**
  8314. * Gets the type of tone mapping effect.
  8315. */
  8316. /**
  8317. * Sets the type of tone mapping effect used in BabylonJS.
  8318. */
  8319. toneMappingType: number;
  8320. protected _contrast: number;
  8321. /**
  8322. * Gets the contrast used in the effect.
  8323. */
  8324. /**
  8325. * Sets the contrast used in the effect.
  8326. */
  8327. contrast: number;
  8328. /**
  8329. * Vignette stretch size.
  8330. */
  8331. vignetteStretch: number;
  8332. /**
  8333. * Vignette centre X Offset.
  8334. */
  8335. vignetteCentreX: number;
  8336. /**
  8337. * Vignette centre Y Offset.
  8338. */
  8339. vignetteCentreY: number;
  8340. /**
  8341. * Vignette weight or intensity of the vignette effect.
  8342. */
  8343. vignetteWeight: number;
  8344. /**
  8345. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8346. * if vignetteEnabled is set to true.
  8347. */
  8348. vignetteColor: Color4;
  8349. /**
  8350. * Camera field of view used by the Vignette effect.
  8351. */
  8352. vignetteCameraFov: number;
  8353. private _vignetteBlendMode;
  8354. /**
  8355. * Gets the vignette blend mode allowing different kind of effect.
  8356. */
  8357. /**
  8358. * Sets the vignette blend mode allowing different kind of effect.
  8359. */
  8360. vignetteBlendMode: number;
  8361. private _vignetteEnabled;
  8362. /**
  8363. * Gets wether the vignette effect is enabled.
  8364. */
  8365. /**
  8366. * Sets wether the vignette effect is enabled.
  8367. */
  8368. vignetteEnabled: boolean;
  8369. private _applyByPostProcess;
  8370. /**
  8371. * Gets wether the image processing is applied through a post process or not.
  8372. */
  8373. /**
  8374. * Sets wether the image processing is applied through a post process or not.
  8375. */
  8376. applyByPostProcess: boolean;
  8377. private _isEnabled;
  8378. /**
  8379. * Gets wether the image processing is enabled or not.
  8380. */
  8381. /**
  8382. * Sets wether the image processing is enabled or not.
  8383. */
  8384. isEnabled: boolean;
  8385. /**
  8386. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8387. */
  8388. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8389. /**
  8390. * Method called each time the image processing information changes requires to recompile the effect.
  8391. */
  8392. protected _updateParameters(): void;
  8393. /**
  8394. * Gets the current class name.
  8395. * @return "ImageProcessingConfiguration"
  8396. */
  8397. getClassName(): string;
  8398. /**
  8399. * Prepare the list of uniforms associated with the Image Processing effects.
  8400. * @param uniforms The list of uniforms used in the effect
  8401. * @param defines the list of defines currently in use
  8402. */
  8403. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8404. /**
  8405. * Prepare the list of samplers associated with the Image Processing effects.
  8406. * @param samplersList The list of uniforms used in the effect
  8407. * @param defines the list of defines currently in use
  8408. */
  8409. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8410. /**
  8411. * Prepare the list of defines associated to the shader.
  8412. * @param defines the list of defines to complete
  8413. * @param forPostProcess Define if we are currently in post process mode or not
  8414. */
  8415. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8416. /**
  8417. * Returns true if all the image processing information are ready.
  8418. * @returns True if ready, otherwise, false
  8419. */
  8420. isReady(): boolean;
  8421. /**
  8422. * Binds the image processing to the shader.
  8423. * @param effect The effect to bind to
  8424. * @param overrideAspectRatio Override the aspect ratio of the effect
  8425. */
  8426. bind(effect: Effect, overrideAspectRatio?: number): void;
  8427. /**
  8428. * Clones the current image processing instance.
  8429. * @return The cloned image processing
  8430. */
  8431. clone(): ImageProcessingConfiguration;
  8432. /**
  8433. * Serializes the current image processing instance to a json representation.
  8434. * @return a JSON representation
  8435. */
  8436. serialize(): any;
  8437. /**
  8438. * Parses the image processing from a json representation.
  8439. * @param source the JSON source to parse
  8440. * @return The parsed image processing
  8441. */
  8442. static Parse(source: any): ImageProcessingConfiguration;
  8443. private static _VIGNETTEMODE_MULTIPLY;
  8444. private static _VIGNETTEMODE_OPAQUE;
  8445. /**
  8446. * Used to apply the vignette as a mix with the pixel color.
  8447. */
  8448. static readonly VIGNETTEMODE_MULTIPLY: number;
  8449. /**
  8450. * Used to apply the vignette as a replacement of the pixel color.
  8451. */
  8452. static readonly VIGNETTEMODE_OPAQUE: number;
  8453. }
  8454. }
  8455. declare module "babylonjs/Shaders/postprocess.vertex" {
  8456. /** @hidden */
  8457. export var postprocessVertexShader: {
  8458. name: string;
  8459. shader: string;
  8460. };
  8461. }
  8462. declare module "babylonjs/Engines/Extensions/engine.renderTarget" {
  8463. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  8464. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  8465. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  8466. module "babylonjs/Engines/thinEngine" {
  8467. interface ThinEngine {
  8468. /**
  8469. * Creates a new render target texture
  8470. * @param size defines the size of the texture
  8471. * @param options defines the options used to create the texture
  8472. * @returns a new render target texture stored in an InternalTexture
  8473. */
  8474. createRenderTargetTexture(size: number | {
  8475. width: number;
  8476. height: number;
  8477. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8478. /**
  8479. * Creates a depth stencil texture.
  8480. * This is only available in WebGL 2 or with the depth texture extension available.
  8481. * @param size The size of face edge in the texture.
  8482. * @param options The options defining the texture.
  8483. * @returns The texture
  8484. */
  8485. createDepthStencilTexture(size: number | {
  8486. width: number;
  8487. height: number;
  8488. }, options: DepthTextureCreationOptions): InternalTexture;
  8489. /** @hidden */
  8490. _createDepthStencilTexture(size: number | {
  8491. width: number;
  8492. height: number;
  8493. }, options: DepthTextureCreationOptions): InternalTexture;
  8494. }
  8495. }
  8496. }
  8497. declare module "babylonjs/Maths/math.axis" {
  8498. import { Vector3 } from "babylonjs/Maths/math.vector";
  8499. /** Defines supported spaces */
  8500. export enum Space {
  8501. /** Local (object) space */
  8502. LOCAL = 0,
  8503. /** World space */
  8504. WORLD = 1,
  8505. /** Bone space */
  8506. BONE = 2
  8507. }
  8508. /** Defines the 3 main axes */
  8509. export class Axis {
  8510. /** X axis */
  8511. static X: Vector3;
  8512. /** Y axis */
  8513. static Y: Vector3;
  8514. /** Z axis */
  8515. static Z: Vector3;
  8516. }
  8517. }
  8518. declare module "babylonjs/Cameras/targetCamera" {
  8519. import { Nullable } from "babylonjs/types";
  8520. import { Camera } from "babylonjs/Cameras/camera";
  8521. import { Scene } from "babylonjs/scene";
  8522. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  8523. /**
  8524. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8525. * This is the base of the follow, arc rotate cameras and Free camera
  8526. * @see http://doc.babylonjs.com/features/cameras
  8527. */
  8528. export class TargetCamera extends Camera {
  8529. private static _RigCamTransformMatrix;
  8530. private static _TargetTransformMatrix;
  8531. private static _TargetFocalPoint;
  8532. /**
  8533. * Define the current direction the camera is moving to
  8534. */
  8535. cameraDirection: Vector3;
  8536. /**
  8537. * Define the current rotation the camera is rotating to
  8538. */
  8539. cameraRotation: Vector2;
  8540. /**
  8541. * When set, the up vector of the camera will be updated by the rotation of the camera
  8542. */
  8543. updateUpVectorFromRotation: boolean;
  8544. private _tmpQuaternion;
  8545. /**
  8546. * Define the current rotation of the camera
  8547. */
  8548. rotation: Vector3;
  8549. /**
  8550. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8551. */
  8552. rotationQuaternion: Quaternion;
  8553. /**
  8554. * Define the current speed of the camera
  8555. */
  8556. speed: number;
  8557. /**
  8558. * Add constraint to the camera to prevent it to move freely in all directions and
  8559. * around all axis.
  8560. */
  8561. noRotationConstraint: boolean;
  8562. /**
  8563. * Define the current target of the camera as an object or a position.
  8564. */
  8565. lockedTarget: any;
  8566. /** @hidden */
  8567. _currentTarget: Vector3;
  8568. /** @hidden */
  8569. _initialFocalDistance: number;
  8570. /** @hidden */
  8571. _viewMatrix: Matrix;
  8572. /** @hidden */
  8573. _camMatrix: Matrix;
  8574. /** @hidden */
  8575. _cameraTransformMatrix: Matrix;
  8576. /** @hidden */
  8577. _cameraRotationMatrix: Matrix;
  8578. /** @hidden */
  8579. _referencePoint: Vector3;
  8580. /** @hidden */
  8581. _transformedReferencePoint: Vector3;
  8582. protected _globalCurrentTarget: Vector3;
  8583. protected _globalCurrentUpVector: Vector3;
  8584. /** @hidden */
  8585. _reset: () => void;
  8586. private _defaultUp;
  8587. /**
  8588. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  8589. * This is the base of the follow, arc rotate cameras and Free camera
  8590. * @see http://doc.babylonjs.com/features/cameras
  8591. * @param name Defines the name of the camera in the scene
  8592. * @param position Defines the start position of the camera in the scene
  8593. * @param scene Defines the scene the camera belongs to
  8594. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8595. */
  8596. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8597. /**
  8598. * Gets the position in front of the camera at a given distance.
  8599. * @param distance The distance from the camera we want the position to be
  8600. * @returns the position
  8601. */
  8602. getFrontPosition(distance: number): Vector3;
  8603. /** @hidden */
  8604. _getLockedTargetPosition(): Nullable<Vector3>;
  8605. private _storedPosition;
  8606. private _storedRotation;
  8607. private _storedRotationQuaternion;
  8608. /**
  8609. * Store current camera state of the camera (fov, position, rotation, etc..)
  8610. * @returns the camera
  8611. */
  8612. storeState(): Camera;
  8613. /**
  8614. * Restored camera state. You must call storeState() first
  8615. * @returns whether it was successful or not
  8616. * @hidden
  8617. */
  8618. _restoreStateValues(): boolean;
  8619. /** @hidden */
  8620. _initCache(): void;
  8621. /** @hidden */
  8622. _updateCache(ignoreParentClass?: boolean): void;
  8623. /** @hidden */
  8624. _isSynchronizedViewMatrix(): boolean;
  8625. /** @hidden */
  8626. _computeLocalCameraSpeed(): number;
  8627. /**
  8628. * Defines the target the camera should look at.
  8629. * @param target Defines the new target as a Vector or a mesh
  8630. */
  8631. setTarget(target: Vector3): void;
  8632. /**
  8633. * Return the current target position of the camera. This value is expressed in local space.
  8634. * @returns the target position
  8635. */
  8636. getTarget(): Vector3;
  8637. /** @hidden */
  8638. _decideIfNeedsToMove(): boolean;
  8639. /** @hidden */
  8640. _updatePosition(): void;
  8641. /** @hidden */
  8642. _checkInputs(): void;
  8643. protected _updateCameraRotationMatrix(): void;
  8644. /**
  8645. * Update the up vector to apply the rotation of the camera (So if you changed the camera rotation.z this will let you update the up vector as well)
  8646. * @returns the current camera
  8647. */
  8648. private _rotateUpVectorWithCameraRotationMatrix;
  8649. private _cachedRotationZ;
  8650. private _cachedQuaternionRotationZ;
  8651. /** @hidden */
  8652. _getViewMatrix(): Matrix;
  8653. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8654. /**
  8655. * @hidden
  8656. */
  8657. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8658. /**
  8659. * @hidden
  8660. */
  8661. _updateRigCameras(): void;
  8662. private _getRigCamPositionAndTarget;
  8663. /**
  8664. * Gets the current object class name.
  8665. * @return the class name
  8666. */
  8667. getClassName(): string;
  8668. }
  8669. }
  8670. declare module "babylonjs/Events/keyboardEvents" {
  8671. /**
  8672. * Gather the list of keyboard event types as constants.
  8673. */
  8674. export class KeyboardEventTypes {
  8675. /**
  8676. * The keydown event is fired when a key becomes active (pressed).
  8677. */
  8678. static readonly KEYDOWN: number;
  8679. /**
  8680. * The keyup event is fired when a key has been released.
  8681. */
  8682. static readonly KEYUP: number;
  8683. }
  8684. /**
  8685. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8686. */
  8687. export class KeyboardInfo {
  8688. /**
  8689. * Defines the type of event (KeyboardEventTypes)
  8690. */
  8691. type: number;
  8692. /**
  8693. * Defines the related dom event
  8694. */
  8695. event: KeyboardEvent;
  8696. /**
  8697. * Instantiates a new keyboard info.
  8698. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8699. * @param type Defines the type of event (KeyboardEventTypes)
  8700. * @param event Defines the related dom event
  8701. */
  8702. constructor(
  8703. /**
  8704. * Defines the type of event (KeyboardEventTypes)
  8705. */
  8706. type: number,
  8707. /**
  8708. * Defines the related dom event
  8709. */
  8710. event: KeyboardEvent);
  8711. }
  8712. /**
  8713. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8714. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8715. */
  8716. export class KeyboardInfoPre extends KeyboardInfo {
  8717. /**
  8718. * Defines the type of event (KeyboardEventTypes)
  8719. */
  8720. type: number;
  8721. /**
  8722. * Defines the related dom event
  8723. */
  8724. event: KeyboardEvent;
  8725. /**
  8726. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8727. */
  8728. skipOnPointerObservable: boolean;
  8729. /**
  8730. * Instantiates a new keyboard pre info.
  8731. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8732. * @param type Defines the type of event (KeyboardEventTypes)
  8733. * @param event Defines the related dom event
  8734. */
  8735. constructor(
  8736. /**
  8737. * Defines the type of event (KeyboardEventTypes)
  8738. */
  8739. type: number,
  8740. /**
  8741. * Defines the related dom event
  8742. */
  8743. event: KeyboardEvent);
  8744. }
  8745. }
  8746. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  8747. import { Nullable } from "babylonjs/types";
  8748. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  8749. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  8750. /**
  8751. * Manage the keyboard inputs to control the movement of a free camera.
  8752. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8753. */
  8754. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8755. /**
  8756. * Defines the camera the input is attached to.
  8757. */
  8758. camera: FreeCamera;
  8759. /**
  8760. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8761. */
  8762. keysUp: number[];
  8763. /**
  8764. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8765. */
  8766. keysDown: number[];
  8767. /**
  8768. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8769. */
  8770. keysLeft: number[];
  8771. /**
  8772. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8773. */
  8774. keysRight: number[];
  8775. private _keys;
  8776. private _onCanvasBlurObserver;
  8777. private _onKeyboardObserver;
  8778. private _engine;
  8779. private _scene;
  8780. /**
  8781. * Attach the input controls to a specific dom element to get the input from.
  8782. * @param element Defines the element the controls should be listened from
  8783. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8784. */
  8785. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8786. /**
  8787. * Detach the current controls from the specified dom element.
  8788. * @param element Defines the element to stop listening the inputs from
  8789. */
  8790. detachControl(element: Nullable<HTMLElement>): void;
  8791. /**
  8792. * Update the current camera state depending on the inputs that have been used this frame.
  8793. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8794. */
  8795. checkInputs(): void;
  8796. /**
  8797. * Gets the class name of the current intput.
  8798. * @returns the class name
  8799. */
  8800. getClassName(): string;
  8801. /** @hidden */
  8802. _onLostFocus(): void;
  8803. /**
  8804. * Get the friendly name associated with the input class.
  8805. * @returns the input friendly name
  8806. */
  8807. getSimpleName(): string;
  8808. }
  8809. }
  8810. declare module "babylonjs/Lights/shadowLight" {
  8811. import { Camera } from "babylonjs/Cameras/camera";
  8812. import { Scene } from "babylonjs/scene";
  8813. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  8814. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8815. import { Light } from "babylonjs/Lights/light";
  8816. /**
  8817. * Interface describing all the common properties and methods a shadow light needs to implement.
  8818. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8819. * as well as binding the different shadow properties to the effects.
  8820. */
  8821. export interface IShadowLight extends Light {
  8822. /**
  8823. * The light id in the scene (used in scene.findLighById for instance)
  8824. */
  8825. id: string;
  8826. /**
  8827. * The position the shdow will be casted from.
  8828. */
  8829. position: Vector3;
  8830. /**
  8831. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8832. */
  8833. direction: Vector3;
  8834. /**
  8835. * The transformed position. Position of the light in world space taking parenting in account.
  8836. */
  8837. transformedPosition: Vector3;
  8838. /**
  8839. * The transformed direction. Direction of the light in world space taking parenting in account.
  8840. */
  8841. transformedDirection: Vector3;
  8842. /**
  8843. * The friendly name of the light in the scene.
  8844. */
  8845. name: string;
  8846. /**
  8847. * Defines the shadow projection clipping minimum z value.
  8848. */
  8849. shadowMinZ: number;
  8850. /**
  8851. * Defines the shadow projection clipping maximum z value.
  8852. */
  8853. shadowMaxZ: number;
  8854. /**
  8855. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8856. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8857. */
  8858. computeTransformedInformation(): boolean;
  8859. /**
  8860. * Gets the scene the light belongs to.
  8861. * @returns The scene
  8862. */
  8863. getScene(): Scene;
  8864. /**
  8865. * Callback defining a custom Projection Matrix Builder.
  8866. * This can be used to override the default projection matrix computation.
  8867. */
  8868. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8869. /**
  8870. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8871. * @param matrix The materix to updated with the projection information
  8872. * @param viewMatrix The transform matrix of the light
  8873. * @param renderList The list of mesh to render in the map
  8874. * @returns The current light
  8875. */
  8876. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8877. /**
  8878. * Gets the current depth scale used in ESM.
  8879. * @returns The scale
  8880. */
  8881. getDepthScale(): number;
  8882. /**
  8883. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8884. * @returns true if a cube texture needs to be use
  8885. */
  8886. needCube(): boolean;
  8887. /**
  8888. * Detects if the projection matrix requires to be recomputed this frame.
  8889. * @returns true if it requires to be recomputed otherwise, false.
  8890. */
  8891. needProjectionMatrixCompute(): boolean;
  8892. /**
  8893. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8894. */
  8895. forceProjectionMatrixCompute(): void;
  8896. /**
  8897. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8898. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8899. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8900. */
  8901. getShadowDirection(faceIndex?: number): Vector3;
  8902. /**
  8903. * Gets the minZ used for shadow according to both the scene and the light.
  8904. * @param activeCamera The camera we are returning the min for
  8905. * @returns the depth min z
  8906. */
  8907. getDepthMinZ(activeCamera: Camera): number;
  8908. /**
  8909. * Gets the maxZ used for shadow according to both the scene and the light.
  8910. * @param activeCamera The camera we are returning the max for
  8911. * @returns the depth max z
  8912. */
  8913. getDepthMaxZ(activeCamera: Camera): number;
  8914. }
  8915. /**
  8916. * Base implementation IShadowLight
  8917. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8918. */
  8919. export abstract class ShadowLight extends Light implements IShadowLight {
  8920. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8921. protected _position: Vector3;
  8922. protected _setPosition(value: Vector3): void;
  8923. /**
  8924. * Sets the position the shadow will be casted from. Also use as the light position for both
  8925. * point and spot lights.
  8926. */
  8927. /**
  8928. * Sets the position the shadow will be casted from. Also use as the light position for both
  8929. * point and spot lights.
  8930. */
  8931. position: Vector3;
  8932. protected _direction: Vector3;
  8933. protected _setDirection(value: Vector3): void;
  8934. /**
  8935. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8936. * Also use as the light direction on spot and directional lights.
  8937. */
  8938. /**
  8939. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  8940. * Also use as the light direction on spot and directional lights.
  8941. */
  8942. direction: Vector3;
  8943. private _shadowMinZ;
  8944. /**
  8945. * Gets the shadow projection clipping minimum z value.
  8946. */
  8947. /**
  8948. * Sets the shadow projection clipping minimum z value.
  8949. */
  8950. shadowMinZ: number;
  8951. private _shadowMaxZ;
  8952. /**
  8953. * Sets the shadow projection clipping maximum z value.
  8954. */
  8955. /**
  8956. * Gets the shadow projection clipping maximum z value.
  8957. */
  8958. shadowMaxZ: number;
  8959. /**
  8960. * Callback defining a custom Projection Matrix Builder.
  8961. * This can be used to override the default projection matrix computation.
  8962. */
  8963. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8964. /**
  8965. * The transformed position. Position of the light in world space taking parenting in account.
  8966. */
  8967. transformedPosition: Vector3;
  8968. /**
  8969. * The transformed direction. Direction of the light in world space taking parenting in account.
  8970. */
  8971. transformedDirection: Vector3;
  8972. private _needProjectionMatrixCompute;
  8973. /**
  8974. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8975. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8976. */
  8977. computeTransformedInformation(): boolean;
  8978. /**
  8979. * Return the depth scale used for the shadow map.
  8980. * @returns the depth scale.
  8981. */
  8982. getDepthScale(): number;
  8983. /**
  8984. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8985. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8986. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8987. */
  8988. getShadowDirection(faceIndex?: number): Vector3;
  8989. /**
  8990. * Returns the ShadowLight absolute position in the World.
  8991. * @returns the position vector in world space
  8992. */
  8993. getAbsolutePosition(): Vector3;
  8994. /**
  8995. * Sets the ShadowLight direction toward the passed target.
  8996. * @param target The point to target in local space
  8997. * @returns the updated ShadowLight direction
  8998. */
  8999. setDirectionToTarget(target: Vector3): Vector3;
  9000. /**
  9001. * Returns the light rotation in euler definition.
  9002. * @returns the x y z rotation in local space.
  9003. */
  9004. getRotation(): Vector3;
  9005. /**
  9006. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9007. * @returns true if a cube texture needs to be use
  9008. */
  9009. needCube(): boolean;
  9010. /**
  9011. * Detects if the projection matrix requires to be recomputed this frame.
  9012. * @returns true if it requires to be recomputed otherwise, false.
  9013. */
  9014. needProjectionMatrixCompute(): boolean;
  9015. /**
  9016. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9017. */
  9018. forceProjectionMatrixCompute(): void;
  9019. /** @hidden */
  9020. _initCache(): void;
  9021. /** @hidden */
  9022. _isSynchronized(): boolean;
  9023. /**
  9024. * Computes the world matrix of the node
  9025. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9026. * @returns the world matrix
  9027. */
  9028. computeWorldMatrix(force?: boolean): Matrix;
  9029. /**
  9030. * Gets the minZ used for shadow according to both the scene and the light.
  9031. * @param activeCamera The camera we are returning the min for
  9032. * @returns the depth min z
  9033. */
  9034. getDepthMinZ(activeCamera: Camera): number;
  9035. /**
  9036. * Gets the maxZ used for shadow according to both the scene and the light.
  9037. * @param activeCamera The camera we are returning the max for
  9038. * @returns the depth max z
  9039. */
  9040. getDepthMaxZ(activeCamera: Camera): number;
  9041. /**
  9042. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9043. * @param matrix The materix to updated with the projection information
  9044. * @param viewMatrix The transform matrix of the light
  9045. * @param renderList The list of mesh to render in the map
  9046. * @returns The current light
  9047. */
  9048. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9049. }
  9050. }
  9051. declare module "babylonjs/Materials/effectFallbacks" {
  9052. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  9053. import { Effect } from "babylonjs/Materials/effect";
  9054. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9055. /**
  9056. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  9057. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  9058. */
  9059. export class EffectFallbacks implements IEffectFallbacks {
  9060. private _defines;
  9061. private _currentRank;
  9062. private _maxRank;
  9063. private _mesh;
  9064. /**
  9065. * Removes the fallback from the bound mesh.
  9066. */
  9067. unBindMesh(): void;
  9068. /**
  9069. * Adds a fallback on the specified property.
  9070. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9071. * @param define The name of the define in the shader
  9072. */
  9073. addFallback(rank: number, define: string): void;
  9074. /**
  9075. * Sets the mesh to use CPU skinning when needing to fallback.
  9076. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9077. * @param mesh The mesh to use the fallbacks.
  9078. */
  9079. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  9080. /**
  9081. * Checks to see if more fallbacks are still availible.
  9082. */
  9083. readonly hasMoreFallbacks: boolean;
  9084. /**
  9085. * Removes the defines that should be removed when falling back.
  9086. * @param currentDefines defines the current define statements for the shader.
  9087. * @param effect defines the current effect we try to compile
  9088. * @returns The resulting defines with defines of the current rank removed.
  9089. */
  9090. reduce(currentDefines: string, effect: Effect): string;
  9091. }
  9092. }
  9093. declare module "babylonjs/Materials/materialHelper" {
  9094. import { Nullable } from "babylonjs/types";
  9095. import { Scene } from "babylonjs/scene";
  9096. import { Engine } from "babylonjs/Engines/engine";
  9097. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9098. import { Light } from "babylonjs/Lights/light";
  9099. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  9100. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  9101. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  9102. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  9103. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  9104. /**
  9105. * "Static Class" containing the most commonly used helper while dealing with material for
  9106. * rendering purpose.
  9107. *
  9108. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  9109. *
  9110. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  9111. */
  9112. export class MaterialHelper {
  9113. /**
  9114. * Bind the current view position to an effect.
  9115. * @param effect The effect to be bound
  9116. * @param scene The scene the eyes position is used from
  9117. */
  9118. static BindEyePosition(effect: Effect, scene: Scene): void;
  9119. /**
  9120. * Helps preparing the defines values about the UVs in used in the effect.
  9121. * UVs are shared as much as we can accross channels in the shaders.
  9122. * @param texture The texture we are preparing the UVs for
  9123. * @param defines The defines to update
  9124. * @param key The channel key "diffuse", "specular"... used in the shader
  9125. */
  9126. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  9127. /**
  9128. * Binds a texture matrix value to its corrsponding uniform
  9129. * @param texture The texture to bind the matrix for
  9130. * @param uniformBuffer The uniform buffer receivin the data
  9131. * @param key The channel key "diffuse", "specular"... used in the shader
  9132. */
  9133. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  9134. /**
  9135. * Gets the current status of the fog (should it be enabled?)
  9136. * @param mesh defines the mesh to evaluate for fog support
  9137. * @param scene defines the hosting scene
  9138. * @returns true if fog must be enabled
  9139. */
  9140. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  9141. /**
  9142. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  9143. * @param mesh defines the current mesh
  9144. * @param scene defines the current scene
  9145. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  9146. * @param pointsCloud defines if point cloud rendering has to be turned on
  9147. * @param fogEnabled defines if fog has to be turned on
  9148. * @param alphaTest defines if alpha testing has to be turned on
  9149. * @param defines defines the current list of defines
  9150. */
  9151. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  9152. /**
  9153. * Helper used to prepare the list of defines associated with frame values for shader compilation
  9154. * @param scene defines the current scene
  9155. * @param engine defines the current engine
  9156. * @param defines specifies the list of active defines
  9157. * @param useInstances defines if instances have to be turned on
  9158. * @param useClipPlane defines if clip plane have to be turned on
  9159. */
  9160. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  9161. /**
  9162. * Prepares the defines for bones
  9163. * @param mesh The mesh containing the geometry data we will draw
  9164. * @param defines The defines to update
  9165. */
  9166. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  9167. /**
  9168. * Prepares the defines for morph targets
  9169. * @param mesh The mesh containing the geometry data we will draw
  9170. * @param defines The defines to update
  9171. */
  9172. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  9173. /**
  9174. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  9175. * @param mesh The mesh containing the geometry data we will draw
  9176. * @param defines The defines to update
  9177. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  9178. * @param useBones Precise whether bones should be used or not (override mesh info)
  9179. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  9180. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  9181. * @returns false if defines are considered not dirty and have not been checked
  9182. */
  9183. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9184. /**
  9185. * Prepares the defines related to multiview
  9186. * @param scene The scene we are intending to draw
  9187. * @param defines The defines to update
  9188. */
  9189. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  9190. /**
  9191. * Prepares the defines related to the light information passed in parameter
  9192. * @param scene The scene we are intending to draw
  9193. * @param mesh The mesh the effect is compiling for
  9194. * @param light The light the effect is compiling for
  9195. * @param lightIndex The index of the light
  9196. * @param defines The defines to update
  9197. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9198. * @param state Defines the current state regarding what is needed (normals, etc...)
  9199. */
  9200. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  9201. needNormals: boolean;
  9202. needRebuild: boolean;
  9203. shadowEnabled: boolean;
  9204. specularEnabled: boolean;
  9205. lightmapMode: boolean;
  9206. }): void;
  9207. /**
  9208. * Prepares the defines related to the light information passed in parameter
  9209. * @param scene The scene we are intending to draw
  9210. * @param mesh The mesh the effect is compiling for
  9211. * @param defines The defines to update
  9212. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9213. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9214. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9215. * @returns true if normals will be required for the rest of the effect
  9216. */
  9217. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9218. /**
  9219. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  9220. * @param lightIndex defines the light index
  9221. * @param uniformsList The uniform list
  9222. * @param samplersList The sampler list
  9223. * @param projectedLightTexture defines if projected texture must be used
  9224. * @param uniformBuffersList defines an optional list of uniform buffers
  9225. */
  9226. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  9227. /**
  9228. * Prepares the uniforms and samplers list to be used in the effect
  9229. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9230. * @param samplersList The sampler list
  9231. * @param defines The defines helping in the list generation
  9232. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9233. */
  9234. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9235. /**
  9236. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9237. * @param defines The defines to update while falling back
  9238. * @param fallbacks The authorized effect fallbacks
  9239. * @param maxSimultaneousLights The maximum number of lights allowed
  9240. * @param rank the current rank of the Effect
  9241. * @returns The newly affected rank
  9242. */
  9243. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9244. private static _TmpMorphInfluencers;
  9245. /**
  9246. * Prepares the list of attributes required for morph targets according to the effect defines.
  9247. * @param attribs The current list of supported attribs
  9248. * @param mesh The mesh to prepare the morph targets attributes for
  9249. * @param influencers The number of influencers
  9250. */
  9251. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  9252. /**
  9253. * Prepares the list of attributes required for morph targets according to the effect defines.
  9254. * @param attribs The current list of supported attribs
  9255. * @param mesh The mesh to prepare the morph targets attributes for
  9256. * @param defines The current Defines of the effect
  9257. */
  9258. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9259. /**
  9260. * Prepares the list of attributes required for bones according to the effect defines.
  9261. * @param attribs The current list of supported attribs
  9262. * @param mesh The mesh to prepare the bones attributes for
  9263. * @param defines The current Defines of the effect
  9264. * @param fallbacks The current efffect fallback strategy
  9265. */
  9266. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9267. /**
  9268. * Check and prepare the list of attributes required for instances according to the effect defines.
  9269. * @param attribs The current list of supported attribs
  9270. * @param defines The current MaterialDefines of the effect
  9271. */
  9272. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  9273. /**
  9274. * Add the list of attributes required for instances to the attribs array.
  9275. * @param attribs The current list of supported attribs
  9276. */
  9277. static PushAttributesForInstances(attribs: string[]): void;
  9278. /**
  9279. * Binds the light information to the effect.
  9280. * @param light The light containing the generator
  9281. * @param effect The effect we are binding the data to
  9282. * @param lightIndex The light index in the effect used to render
  9283. */
  9284. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9285. /**
  9286. * Binds the lights information from the scene to the effect for the given mesh.
  9287. * @param light Light to bind
  9288. * @param lightIndex Light index
  9289. * @param scene The scene where the light belongs to
  9290. * @param effect The effect we are binding the data to
  9291. * @param useSpecular Defines if specular is supported
  9292. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9293. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9294. */
  9295. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  9296. /**
  9297. * Binds the lights information from the scene to the effect for the given mesh.
  9298. * @param scene The scene the lights belongs to
  9299. * @param mesh The mesh we are binding the information to render
  9300. * @param effect The effect we are binding the data to
  9301. * @param defines The generated defines for the effect
  9302. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9303. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9304. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9305. */
  9306. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  9307. private static _tempFogColor;
  9308. /**
  9309. * Binds the fog information from the scene to the effect for the given mesh.
  9310. * @param scene The scene the lights belongs to
  9311. * @param mesh The mesh we are binding the information to render
  9312. * @param effect The effect we are binding the data to
  9313. * @param linearSpace Defines if the fog effect is applied in linear space
  9314. */
  9315. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9316. /**
  9317. * Binds the bones information from the mesh to the effect.
  9318. * @param mesh The mesh we are binding the information to render
  9319. * @param effect The effect we are binding the data to
  9320. */
  9321. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9322. /**
  9323. * Binds the morph targets information from the mesh to the effect.
  9324. * @param abstractMesh The mesh we are binding the information to render
  9325. * @param effect The effect we are binding the data to
  9326. */
  9327. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9328. /**
  9329. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9330. * @param defines The generated defines used in the effect
  9331. * @param effect The effect we are binding the data to
  9332. * @param scene The scene we are willing to render with logarithmic scale for
  9333. */
  9334. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9335. /**
  9336. * Binds the clip plane information from the scene to the effect.
  9337. * @param scene The scene the clip plane information are extracted from
  9338. * @param effect The effect we are binding the data to
  9339. */
  9340. static BindClipPlane(effect: Effect, scene: Scene): void;
  9341. }
  9342. }
  9343. declare module "babylonjs/Shaders/ShadersInclude/packingFunctions" {
  9344. /** @hidden */
  9345. export var packingFunctions: {
  9346. name: string;
  9347. shader: string;
  9348. };
  9349. }
  9350. declare module "babylonjs/Shaders/shadowMap.fragment" {
  9351. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  9352. /** @hidden */
  9353. export var shadowMapPixelShader: {
  9354. name: string;
  9355. shader: string;
  9356. };
  9357. }
  9358. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  9359. /** @hidden */
  9360. export var bonesDeclaration: {
  9361. name: string;
  9362. shader: string;
  9363. };
  9364. }
  9365. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  9366. /** @hidden */
  9367. export var morphTargetsVertexGlobalDeclaration: {
  9368. name: string;
  9369. shader: string;
  9370. };
  9371. }
  9372. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  9373. /** @hidden */
  9374. export var morphTargetsVertexDeclaration: {
  9375. name: string;
  9376. shader: string;
  9377. };
  9378. }
  9379. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  9380. /** @hidden */
  9381. export var instancesDeclaration: {
  9382. name: string;
  9383. shader: string;
  9384. };
  9385. }
  9386. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  9387. /** @hidden */
  9388. export var helperFunctions: {
  9389. name: string;
  9390. shader: string;
  9391. };
  9392. }
  9393. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  9394. /** @hidden */
  9395. export var morphTargetsVertex: {
  9396. name: string;
  9397. shader: string;
  9398. };
  9399. }
  9400. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  9401. /** @hidden */
  9402. export var instancesVertex: {
  9403. name: string;
  9404. shader: string;
  9405. };
  9406. }
  9407. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  9408. /** @hidden */
  9409. export var bonesVertex: {
  9410. name: string;
  9411. shader: string;
  9412. };
  9413. }
  9414. declare module "babylonjs/Shaders/shadowMap.vertex" {
  9415. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  9416. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  9417. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  9418. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  9419. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  9420. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  9421. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  9422. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  9423. /** @hidden */
  9424. export var shadowMapVertexShader: {
  9425. name: string;
  9426. shader: string;
  9427. };
  9428. }
  9429. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  9430. /** @hidden */
  9431. export var depthBoxBlurPixelShader: {
  9432. name: string;
  9433. shader: string;
  9434. };
  9435. }
  9436. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  9437. import { Nullable } from "babylonjs/types";
  9438. import { Scene } from "babylonjs/scene";
  9439. import { Matrix } from "babylonjs/Maths/math.vector";
  9440. import { SubMesh } from "babylonjs/Meshes/subMesh";
  9441. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9442. import { Mesh } from "babylonjs/Meshes/mesh";
  9443. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  9444. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  9445. import { Effect } from "babylonjs/Materials/effect";
  9446. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  9447. import "babylonjs/Shaders/shadowMap.fragment";
  9448. import "babylonjs/Shaders/shadowMap.vertex";
  9449. import "babylonjs/Shaders/depthBoxBlur.fragment";
  9450. import { Observable } from "babylonjs/Misc/observable";
  9451. /**
  9452. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9453. */
  9454. export interface ICustomShaderOptions {
  9455. /**
  9456. * Gets or sets the custom shader name to use
  9457. */
  9458. shaderName: string;
  9459. /**
  9460. * The list of attribute names used in the shader
  9461. */
  9462. attributes?: string[];
  9463. /**
  9464. * The list of unifrom names used in the shader
  9465. */
  9466. uniforms?: string[];
  9467. /**
  9468. * The list of sampler names used in the shader
  9469. */
  9470. samplers?: string[];
  9471. /**
  9472. * The list of defines used in the shader
  9473. */
  9474. defines?: string[];
  9475. }
  9476. /**
  9477. * Interface to implement to create a shadow generator compatible with BJS.
  9478. */
  9479. export interface IShadowGenerator {
  9480. /**
  9481. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9482. * @returns The render target texture if present otherwise, null
  9483. */
  9484. getShadowMap(): Nullable<RenderTargetTexture>;
  9485. /**
  9486. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9487. * @returns The render target texture if the shadow map is present otherwise, null
  9488. */
  9489. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9490. /**
  9491. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9492. * @param subMesh The submesh we want to render in the shadow map
  9493. * @param useInstances Defines wether will draw in the map using instances
  9494. * @returns true if ready otherwise, false
  9495. */
  9496. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9497. /**
  9498. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9499. * @param defines Defines of the material we want to update
  9500. * @param lightIndex Index of the light in the enabled light list of the material
  9501. */
  9502. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9503. /**
  9504. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9505. * defined in the generator but impacting the effect).
  9506. * It implies the unifroms available on the materials are the standard BJS ones.
  9507. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9508. * @param effect The effect we are binfing the information for
  9509. */
  9510. bindShadowLight(lightIndex: string, effect: Effect): void;
  9511. /**
  9512. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9513. * (eq to shadow prjection matrix * light transform matrix)
  9514. * @returns The transform matrix used to create the shadow map
  9515. */
  9516. getTransformMatrix(): Matrix;
  9517. /**
  9518. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9519. * Cube and 2D textures for instance.
  9520. */
  9521. recreateShadowMap(): void;
  9522. /**
  9523. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9524. * @param onCompiled Callback triggered at the and of the effects compilation
  9525. * @param options Sets of optional options forcing the compilation with different modes
  9526. */
  9527. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9528. useInstances: boolean;
  9529. }>): void;
  9530. /**
  9531. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9532. * @param options Sets of optional options forcing the compilation with different modes
  9533. * @returns A promise that resolves when the compilation completes
  9534. */
  9535. forceCompilationAsync(options?: Partial<{
  9536. useInstances: boolean;
  9537. }>): Promise<void>;
  9538. /**
  9539. * Serializes the shadow generator setup to a json object.
  9540. * @returns The serialized JSON object
  9541. */
  9542. serialize(): any;
  9543. /**
  9544. * Disposes the Shadow map and related Textures and effects.
  9545. */
  9546. dispose(): void;
  9547. }
  9548. /**
  9549. * Default implementation IShadowGenerator.
  9550. * This is the main object responsible of generating shadows in the framework.
  9551. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9552. */
  9553. export class ShadowGenerator implements IShadowGenerator {
  9554. /**
  9555. * Shadow generator mode None: no filtering applied.
  9556. */
  9557. static readonly FILTER_NONE: number;
  9558. /**
  9559. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9560. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9561. */
  9562. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9563. /**
  9564. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9565. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9566. */
  9567. static readonly FILTER_POISSONSAMPLING: number;
  9568. /**
  9569. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9570. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9571. */
  9572. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9573. /**
  9574. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9575. * edge artifacts on steep falloff.
  9576. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9577. */
  9578. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9579. /**
  9580. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9581. * edge artifacts on steep falloff.
  9582. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9583. */
  9584. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9585. /**
  9586. * Shadow generator mode PCF: Percentage Closer Filtering
  9587. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9588. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9589. */
  9590. static readonly FILTER_PCF: number;
  9591. /**
  9592. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9593. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9594. * Contact Hardening
  9595. */
  9596. static readonly FILTER_PCSS: number;
  9597. /**
  9598. * Reserved for PCF and PCSS
  9599. * Highest Quality.
  9600. *
  9601. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9602. *
  9603. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9604. */
  9605. static readonly QUALITY_HIGH: number;
  9606. /**
  9607. * Reserved for PCF and PCSS
  9608. * Good tradeoff for quality/perf cross devices
  9609. *
  9610. * Execute PCF on a 3*3 kernel.
  9611. *
  9612. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9613. */
  9614. static readonly QUALITY_MEDIUM: number;
  9615. /**
  9616. * Reserved for PCF and PCSS
  9617. * The lowest quality but the fastest.
  9618. *
  9619. * Execute PCF on a 1*1 kernel.
  9620. *
  9621. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9622. */
  9623. static readonly QUALITY_LOW: number;
  9624. /** Gets or sets the custom shader name to use */
  9625. customShaderOptions: ICustomShaderOptions;
  9626. /**
  9627. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9628. */
  9629. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9630. /**
  9631. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  9632. */
  9633. onAfterShadowMapRenderObservable: Observable<Effect>;
  9634. /**
  9635. * Observable triggered before a mesh is rendered in the shadow map.
  9636. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  9637. */
  9638. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  9639. /**
  9640. * Observable triggered after a mesh is rendered in the shadow map.
  9641. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  9642. */
  9643. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  9644. private _bias;
  9645. /**
  9646. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  9647. */
  9648. /**
  9649. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  9650. */
  9651. bias: number;
  9652. private _normalBias;
  9653. /**
  9654. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9655. */
  9656. /**
  9657. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9658. */
  9659. normalBias: number;
  9660. private _blurBoxOffset;
  9661. /**
  9662. * Gets the blur box offset: offset applied during the blur pass.
  9663. * Only useful if useKernelBlur = false
  9664. */
  9665. /**
  9666. * Sets the blur box offset: offset applied during the blur pass.
  9667. * Only useful if useKernelBlur = false
  9668. */
  9669. blurBoxOffset: number;
  9670. private _blurScale;
  9671. /**
  9672. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  9673. * 2 means half of the size.
  9674. */
  9675. /**
  9676. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  9677. * 2 means half of the size.
  9678. */
  9679. blurScale: number;
  9680. private _blurKernel;
  9681. /**
  9682. * Gets the blur kernel: kernel size of the blur pass.
  9683. * Only useful if useKernelBlur = true
  9684. */
  9685. /**
  9686. * Sets the blur kernel: kernel size of the blur pass.
  9687. * Only useful if useKernelBlur = true
  9688. */
  9689. blurKernel: number;
  9690. private _useKernelBlur;
  9691. /**
  9692. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  9693. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9694. */
  9695. /**
  9696. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  9697. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9698. */
  9699. useKernelBlur: boolean;
  9700. private _depthScale;
  9701. /**
  9702. * Gets the depth scale used in ESM mode.
  9703. */
  9704. /**
  9705. * Sets the depth scale used in ESM mode.
  9706. * This can override the scale stored on the light.
  9707. */
  9708. depthScale: number;
  9709. private _filter;
  9710. /**
  9711. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  9712. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9713. */
  9714. /**
  9715. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  9716. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9717. */
  9718. filter: number;
  9719. /**
  9720. * Gets if the current filter is set to Poisson Sampling.
  9721. */
  9722. /**
  9723. * Sets the current filter to Poisson Sampling.
  9724. */
  9725. usePoissonSampling: boolean;
  9726. /**
  9727. * Gets if the current filter is set to ESM.
  9728. */
  9729. /**
  9730. * Sets the current filter is to ESM.
  9731. */
  9732. useExponentialShadowMap: boolean;
  9733. /**
  9734. * Gets if the current filter is set to filtered ESM.
  9735. */
  9736. /**
  9737. * Gets if the current filter is set to filtered ESM.
  9738. */
  9739. useBlurExponentialShadowMap: boolean;
  9740. /**
  9741. * Gets if the current filter is set to "close ESM" (using the inverse of the
  9742. * exponential to prevent steep falloff artifacts).
  9743. */
  9744. /**
  9745. * Sets the current filter to "close ESM" (using the inverse of the
  9746. * exponential to prevent steep falloff artifacts).
  9747. */
  9748. useCloseExponentialShadowMap: boolean;
  9749. /**
  9750. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  9751. * exponential to prevent steep falloff artifacts).
  9752. */
  9753. /**
  9754. * Sets the current filter to filtered "close ESM" (using the inverse of the
  9755. * exponential to prevent steep falloff artifacts).
  9756. */
  9757. useBlurCloseExponentialShadowMap: boolean;
  9758. /**
  9759. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  9760. */
  9761. /**
  9762. * Sets the current filter to "PCF" (percentage closer filtering).
  9763. */
  9764. usePercentageCloserFiltering: boolean;
  9765. private _filteringQuality;
  9766. /**
  9767. * Gets the PCF or PCSS Quality.
  9768. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9769. */
  9770. /**
  9771. * Sets the PCF or PCSS Quality.
  9772. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9773. */
  9774. filteringQuality: number;
  9775. /**
  9776. * Gets if the current filter is set to "PCSS" (contact hardening).
  9777. */
  9778. /**
  9779. * Sets the current filter to "PCSS" (contact hardening).
  9780. */
  9781. useContactHardeningShadow: boolean;
  9782. private _contactHardeningLightSizeUVRatio;
  9783. /**
  9784. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9785. * Using a ratio helps keeping shape stability independently of the map size.
  9786. *
  9787. * It does not account for the light projection as it was having too much
  9788. * instability during the light setup or during light position changes.
  9789. *
  9790. * Only valid if useContactHardeningShadow is true.
  9791. */
  9792. /**
  9793. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9794. * Using a ratio helps keeping shape stability independently of the map size.
  9795. *
  9796. * It does not account for the light projection as it was having too much
  9797. * instability during the light setup or during light position changes.
  9798. *
  9799. * Only valid if useContactHardeningShadow is true.
  9800. */
  9801. contactHardeningLightSizeUVRatio: number;
  9802. private _darkness;
  9803. /** Gets or sets the actual darkness of a shadow */
  9804. darkness: number;
  9805. /**
  9806. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  9807. * 0 means strongest and 1 would means no shadow.
  9808. * @returns the darkness.
  9809. */
  9810. getDarkness(): number;
  9811. /**
  9812. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  9813. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  9814. * @returns the shadow generator allowing fluent coding.
  9815. */
  9816. setDarkness(darkness: number): ShadowGenerator;
  9817. private _transparencyShadow;
  9818. /** Gets or sets the ability to have transparent shadow */
  9819. transparencyShadow: boolean;
  9820. /**
  9821. * Sets the ability to have transparent shadow (boolean).
  9822. * @param transparent True if transparent else False
  9823. * @returns the shadow generator allowing fluent coding
  9824. */
  9825. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  9826. private _shadowMap;
  9827. private _shadowMap2;
  9828. /**
  9829. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9830. * @returns The render target texture if present otherwise, null
  9831. */
  9832. getShadowMap(): Nullable<RenderTargetTexture>;
  9833. /**
  9834. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9835. * @returns The render target texture if the shadow map is present otherwise, null
  9836. */
  9837. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9838. /**
  9839. * Gets the class name of that object
  9840. * @returns "ShadowGenerator"
  9841. */
  9842. getClassName(): string;
  9843. /**
  9844. * Helper function to add a mesh and its descendants to the list of shadow casters.
  9845. * @param mesh Mesh to add
  9846. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  9847. * @returns the Shadow Generator itself
  9848. */
  9849. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9850. /**
  9851. * Helper function to remove a mesh and its descendants from the list of shadow casters
  9852. * @param mesh Mesh to remove
  9853. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  9854. * @returns the Shadow Generator itself
  9855. */
  9856. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9857. /**
  9858. * Controls the extent to which the shadows fade out at the edge of the frustum
  9859. * Used only by directionals and spots
  9860. */
  9861. frustumEdgeFalloff: number;
  9862. private _light;
  9863. /**
  9864. * Returns the associated light object.
  9865. * @returns the light generating the shadow
  9866. */
  9867. getLight(): IShadowLight;
  9868. /**
  9869. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  9870. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  9871. * It might on the other hand introduce peter panning.
  9872. */
  9873. forceBackFacesOnly: boolean;
  9874. private _scene;
  9875. private _lightDirection;
  9876. private _effect;
  9877. private _viewMatrix;
  9878. private _projectionMatrix;
  9879. private _transformMatrix;
  9880. private _cachedPosition;
  9881. private _cachedDirection;
  9882. private _cachedDefines;
  9883. private _currentRenderID;
  9884. private _boxBlurPostprocess;
  9885. private _kernelBlurXPostprocess;
  9886. private _kernelBlurYPostprocess;
  9887. private _blurPostProcesses;
  9888. private _mapSize;
  9889. private _currentFaceIndex;
  9890. private _currentFaceIndexCache;
  9891. private _textureType;
  9892. private _defaultTextureMatrix;
  9893. private _storedUniqueId;
  9894. /** @hidden */
  9895. static _SceneComponentInitialization: (scene: Scene) => void;
  9896. /**
  9897. * Creates a ShadowGenerator object.
  9898. * A ShadowGenerator is the required tool to use the shadows.
  9899. * Each light casting shadows needs to use its own ShadowGenerator.
  9900. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  9901. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  9902. * @param light The light object generating the shadows.
  9903. * @param usefulFloatFirst By default the generator will try to use half float textures but if you need precision (for self shadowing for instance), you can use this option to enforce full float texture.
  9904. */
  9905. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  9906. private _initializeGenerator;
  9907. private _initializeShadowMap;
  9908. private _initializeBlurRTTAndPostProcesses;
  9909. private _renderForShadowMap;
  9910. private _renderSubMeshForShadowMap;
  9911. private _applyFilterValues;
  9912. /**
  9913. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9914. * @param onCompiled Callback triggered at the and of the effects compilation
  9915. * @param options Sets of optional options forcing the compilation with different modes
  9916. */
  9917. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9918. useInstances: boolean;
  9919. }>): void;
  9920. /**
  9921. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9922. * @param options Sets of optional options forcing the compilation with different modes
  9923. * @returns A promise that resolves when the compilation completes
  9924. */
  9925. forceCompilationAsync(options?: Partial<{
  9926. useInstances: boolean;
  9927. }>): Promise<void>;
  9928. /**
  9929. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9930. * @param subMesh The submesh we want to render in the shadow map
  9931. * @param useInstances Defines wether will draw in the map using instances
  9932. * @returns true if ready otherwise, false
  9933. */
  9934. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9935. /**
  9936. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9937. * @param defines Defines of the material we want to update
  9938. * @param lightIndex Index of the light in the enabled light list of the material
  9939. */
  9940. prepareDefines(defines: any, lightIndex: number): void;
  9941. /**
  9942. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9943. * defined in the generator but impacting the effect).
  9944. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9945. * @param effect The effect we are binfing the information for
  9946. */
  9947. bindShadowLight(lightIndex: string, effect: Effect): void;
  9948. /**
  9949. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9950. * (eq to shadow prjection matrix * light transform matrix)
  9951. * @returns The transform matrix used to create the shadow map
  9952. */
  9953. getTransformMatrix(): Matrix;
  9954. /**
  9955. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9956. * Cube and 2D textures for instance.
  9957. */
  9958. recreateShadowMap(): void;
  9959. private _disposeBlurPostProcesses;
  9960. private _disposeRTTandPostProcesses;
  9961. /**
  9962. * Disposes the ShadowGenerator.
  9963. * Returns nothing.
  9964. */
  9965. dispose(): void;
  9966. /**
  9967. * Serializes the shadow generator setup to a json object.
  9968. * @returns The serialized JSON object
  9969. */
  9970. serialize(): any;
  9971. /**
  9972. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  9973. * @param parsedShadowGenerator The JSON object to parse
  9974. * @param scene The scene to create the shadow map for
  9975. * @returns The parsed shadow generator
  9976. */
  9977. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  9978. }
  9979. }
  9980. declare module "babylonjs/Lights/light" {
  9981. import { Nullable } from "babylonjs/types";
  9982. import { Scene } from "babylonjs/scene";
  9983. import { Vector3 } from "babylonjs/Maths/math.vector";
  9984. import { Color3 } from "babylonjs/Maths/math.color";
  9985. import { Node } from "babylonjs/node";
  9986. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9987. import { Effect } from "babylonjs/Materials/effect";
  9988. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  9989. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  9990. /**
  9991. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  9992. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  9993. * All meshes allow light to pass through them unless shadow generation is activated. The default number of lights allowed is four but this can be increased.
  9994. */
  9995. export abstract class Light extends Node {
  9996. /**
  9997. * Falloff Default: light is falling off following the material specification:
  9998. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  9999. */
  10000. static readonly FALLOFF_DEFAULT: number;
  10001. /**
  10002. * Falloff Physical: light is falling off following the inverse squared distance law.
  10003. */
  10004. static readonly FALLOFF_PHYSICAL: number;
  10005. /**
  10006. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  10007. * to enhance interoperability with other engines.
  10008. */
  10009. static readonly FALLOFF_GLTF: number;
  10010. /**
  10011. * Falloff Standard: light is falling off like in the standard material
  10012. * to enhance interoperability with other materials.
  10013. */
  10014. static readonly FALLOFF_STANDARD: number;
  10015. /**
  10016. * If every light affecting the material is in this lightmapMode,
  10017. * material.lightmapTexture adds or multiplies
  10018. * (depends on material.useLightmapAsShadowmap)
  10019. * after every other light calculations.
  10020. */
  10021. static readonly LIGHTMAP_DEFAULT: number;
  10022. /**
  10023. * material.lightmapTexture as only diffuse lighting from this light
  10024. * adds only specular lighting from this light
  10025. * adds dynamic shadows
  10026. */
  10027. static readonly LIGHTMAP_SPECULAR: number;
  10028. /**
  10029. * material.lightmapTexture as only lighting
  10030. * no light calculation from this light
  10031. * only adds dynamic shadows from this light
  10032. */
  10033. static readonly LIGHTMAP_SHADOWSONLY: number;
  10034. /**
  10035. * Each light type uses the default quantity according to its type:
  10036. * point/spot lights use luminous intensity
  10037. * directional lights use illuminance
  10038. */
  10039. static readonly INTENSITYMODE_AUTOMATIC: number;
  10040. /**
  10041. * lumen (lm)
  10042. */
  10043. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  10044. /**
  10045. * candela (lm/sr)
  10046. */
  10047. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  10048. /**
  10049. * lux (lm/m^2)
  10050. */
  10051. static readonly INTENSITYMODE_ILLUMINANCE: number;
  10052. /**
  10053. * nit (cd/m^2)
  10054. */
  10055. static readonly INTENSITYMODE_LUMINANCE: number;
  10056. /**
  10057. * Light type const id of the point light.
  10058. */
  10059. static readonly LIGHTTYPEID_POINTLIGHT: number;
  10060. /**
  10061. * Light type const id of the directional light.
  10062. */
  10063. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  10064. /**
  10065. * Light type const id of the spot light.
  10066. */
  10067. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  10068. /**
  10069. * Light type const id of the hemispheric light.
  10070. */
  10071. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  10072. /**
  10073. * Diffuse gives the basic color to an object.
  10074. */
  10075. diffuse: Color3;
  10076. /**
  10077. * Specular produces a highlight color on an object.
  10078. * Note: This is note affecting PBR materials.
  10079. */
  10080. specular: Color3;
  10081. /**
  10082. * Defines the falloff type for this light. This lets overrriding how punctual light are
  10083. * falling off base on range or angle.
  10084. * This can be set to any values in Light.FALLOFF_x.
  10085. *
  10086. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  10087. * other types of materials.
  10088. */
  10089. falloffType: number;
  10090. /**
  10091. * Strength of the light.
  10092. * Note: By default it is define in the framework own unit.
  10093. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  10094. */
  10095. intensity: number;
  10096. private _range;
  10097. protected _inverseSquaredRange: number;
  10098. /**
  10099. * Defines how far from the source the light is impacting in scene units.
  10100. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10101. */
  10102. /**
  10103. * Defines how far from the source the light is impacting in scene units.
  10104. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10105. */
  10106. range: number;
  10107. /**
  10108. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  10109. * of light.
  10110. */
  10111. private _photometricScale;
  10112. private _intensityMode;
  10113. /**
  10114. * Gets the photometric scale used to interpret the intensity.
  10115. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10116. */
  10117. /**
  10118. * Sets the photometric scale used to interpret the intensity.
  10119. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10120. */
  10121. intensityMode: number;
  10122. private _radius;
  10123. /**
  10124. * Gets the light radius used by PBR Materials to simulate soft area lights.
  10125. */
  10126. /**
  10127. * sets the light radius used by PBR Materials to simulate soft area lights.
  10128. */
  10129. radius: number;
  10130. private _renderPriority;
  10131. /**
  10132. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  10133. * exceeding the number allowed of the materials.
  10134. */
  10135. renderPriority: number;
  10136. private _shadowEnabled;
  10137. /**
  10138. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10139. * the current shadow generator.
  10140. */
  10141. /**
  10142. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10143. * the current shadow generator.
  10144. */
  10145. shadowEnabled: boolean;
  10146. private _includedOnlyMeshes;
  10147. /**
  10148. * Gets the only meshes impacted by this light.
  10149. */
  10150. /**
  10151. * Sets the only meshes impacted by this light.
  10152. */
  10153. includedOnlyMeshes: AbstractMesh[];
  10154. private _excludedMeshes;
  10155. /**
  10156. * Gets the meshes not impacted by this light.
  10157. */
  10158. /**
  10159. * Sets the meshes not impacted by this light.
  10160. */
  10161. excludedMeshes: AbstractMesh[];
  10162. private _excludeWithLayerMask;
  10163. /**
  10164. * Gets the layer id use to find what meshes are not impacted by the light.
  10165. * Inactive if 0
  10166. */
  10167. /**
  10168. * Sets the layer id use to find what meshes are not impacted by the light.
  10169. * Inactive if 0
  10170. */
  10171. excludeWithLayerMask: number;
  10172. private _includeOnlyWithLayerMask;
  10173. /**
  10174. * Gets the layer id use to find what meshes are impacted by the light.
  10175. * Inactive if 0
  10176. */
  10177. /**
  10178. * Sets the layer id use to find what meshes are impacted by the light.
  10179. * Inactive if 0
  10180. */
  10181. includeOnlyWithLayerMask: number;
  10182. private _lightmapMode;
  10183. /**
  10184. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10185. */
  10186. /**
  10187. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10188. */
  10189. lightmapMode: number;
  10190. /**
  10191. * Shadow generator associted to the light.
  10192. * @hidden Internal use only.
  10193. */
  10194. _shadowGenerator: Nullable<IShadowGenerator>;
  10195. /**
  10196. * @hidden Internal use only.
  10197. */
  10198. _excludedMeshesIds: string[];
  10199. /**
  10200. * @hidden Internal use only.
  10201. */
  10202. _includedOnlyMeshesIds: string[];
  10203. /**
  10204. * The current light unifom buffer.
  10205. * @hidden Internal use only.
  10206. */
  10207. _uniformBuffer: UniformBuffer;
  10208. /** @hidden */
  10209. _renderId: number;
  10210. /**
  10211. * Creates a Light object in the scene.
  10212. * Documentation : https://doc.babylonjs.com/babylon101/lights
  10213. * @param name The firendly name of the light
  10214. * @param scene The scene the light belongs too
  10215. */
  10216. constructor(name: string, scene: Scene);
  10217. protected abstract _buildUniformLayout(): void;
  10218. /**
  10219. * Sets the passed Effect "effect" with the Light information.
  10220. * @param effect The effect to update
  10221. * @param lightIndex The index of the light in the effect to update
  10222. * @returns The light
  10223. */
  10224. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  10225. /**
  10226. * Sets the passed Effect "effect" with the Light information.
  10227. * @param effect The effect to update
  10228. * @param lightDataUniformName The uniform used to store light data (position or direction)
  10229. * @returns The light
  10230. */
  10231. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  10232. /**
  10233. * Returns the string "Light".
  10234. * @returns the class name
  10235. */
  10236. getClassName(): string;
  10237. /** @hidden */
  10238. readonly _isLight: boolean;
  10239. /**
  10240. * Converts the light information to a readable string for debug purpose.
  10241. * @param fullDetails Supports for multiple levels of logging within scene loading
  10242. * @returns the human readable light info
  10243. */
  10244. toString(fullDetails?: boolean): string;
  10245. /** @hidden */
  10246. protected _syncParentEnabledState(): void;
  10247. /**
  10248. * Set the enabled state of this node.
  10249. * @param value - the new enabled state
  10250. */
  10251. setEnabled(value: boolean): void;
  10252. /**
  10253. * Returns the Light associated shadow generator if any.
  10254. * @return the associated shadow generator.
  10255. */
  10256. getShadowGenerator(): Nullable<IShadowGenerator>;
  10257. /**
  10258. * Returns a Vector3, the absolute light position in the World.
  10259. * @returns the world space position of the light
  10260. */
  10261. getAbsolutePosition(): Vector3;
  10262. /**
  10263. * Specifies if the light will affect the passed mesh.
  10264. * @param mesh The mesh to test against the light
  10265. * @return true the mesh is affected otherwise, false.
  10266. */
  10267. canAffectMesh(mesh: AbstractMesh): boolean;
  10268. /**
  10269. * Sort function to order lights for rendering.
  10270. * @param a First Light object to compare to second.
  10271. * @param b Second Light object to compare first.
  10272. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  10273. */
  10274. static CompareLightsPriority(a: Light, b: Light): number;
  10275. /**
  10276. * Releases resources associated with this node.
  10277. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10278. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10279. */
  10280. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10281. /**
  10282. * Returns the light type ID (integer).
  10283. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10284. */
  10285. getTypeID(): number;
  10286. /**
  10287. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  10288. * @returns the scaled intensity in intensity mode unit
  10289. */
  10290. getScaledIntensity(): number;
  10291. /**
  10292. * Returns a new Light object, named "name", from the current one.
  10293. * @param name The name of the cloned light
  10294. * @returns the new created light
  10295. */
  10296. clone(name: string): Nullable<Light>;
  10297. /**
  10298. * Serializes the current light into a Serialization object.
  10299. * @returns the serialized object.
  10300. */
  10301. serialize(): any;
  10302. /**
  10303. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  10304. * This new light is named "name" and added to the passed scene.
  10305. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  10306. * @param name The friendly name of the light
  10307. * @param scene The scene the new light will belong to
  10308. * @returns the constructor function
  10309. */
  10310. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  10311. /**
  10312. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  10313. * @param parsedLight The JSON representation of the light
  10314. * @param scene The scene to create the parsed light in
  10315. * @returns the created light after parsing
  10316. */
  10317. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  10318. private _hookArrayForExcluded;
  10319. private _hookArrayForIncludedOnly;
  10320. private _resyncMeshes;
  10321. /**
  10322. * Forces the meshes to update their light related information in their rendering used effects
  10323. * @hidden Internal Use Only
  10324. */
  10325. _markMeshesAsLightDirty(): void;
  10326. /**
  10327. * Recomputes the cached photometric scale if needed.
  10328. */
  10329. private _computePhotometricScale;
  10330. /**
  10331. * Returns the Photometric Scale according to the light type and intensity mode.
  10332. */
  10333. private _getPhotometricScale;
  10334. /**
  10335. * Reorder the light in the scene according to their defined priority.
  10336. * @hidden Internal Use Only
  10337. */
  10338. _reorderLightsInScene(): void;
  10339. /**
  10340. * Prepares the list of defines specific to the light type.
  10341. * @param defines the list of defines
  10342. * @param lightIndex defines the index of the light for the effect
  10343. */
  10344. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  10345. }
  10346. }
  10347. declare module "babylonjs/Actions/action" {
  10348. import { Observable } from "babylonjs/Misc/observable";
  10349. import { Condition } from "babylonjs/Actions/condition";
  10350. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10351. import { ActionManager } from "babylonjs/Actions/actionManager";
  10352. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10353. /**
  10354. * Interface used to define Action
  10355. */
  10356. export interface IAction {
  10357. /**
  10358. * Trigger for the action
  10359. */
  10360. trigger: number;
  10361. /** Options of the trigger */
  10362. triggerOptions: any;
  10363. /**
  10364. * Gets the trigger parameters
  10365. * @returns the trigger parameters
  10366. */
  10367. getTriggerParameter(): any;
  10368. /**
  10369. * Internal only - executes current action event
  10370. * @hidden
  10371. */
  10372. _executeCurrent(evt?: ActionEvent): void;
  10373. /**
  10374. * Serialize placeholder for child classes
  10375. * @param parent of child
  10376. * @returns the serialized object
  10377. */
  10378. serialize(parent: any): any;
  10379. /**
  10380. * Internal only
  10381. * @hidden
  10382. */
  10383. _prepare(): void;
  10384. /**
  10385. * Internal only - manager for action
  10386. * @hidden
  10387. */
  10388. _actionManager: AbstractActionManager;
  10389. /**
  10390. * Adds action to chain of actions, may be a DoNothingAction
  10391. * @param action defines the next action to execute
  10392. * @returns The action passed in
  10393. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10394. */
  10395. then(action: IAction): IAction;
  10396. }
  10397. /**
  10398. * The action to be carried out following a trigger
  10399. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10400. */
  10401. export class Action implements IAction {
  10402. /** the trigger, with or without parameters, for the action */
  10403. triggerOptions: any;
  10404. /**
  10405. * Trigger for the action
  10406. */
  10407. trigger: number;
  10408. /**
  10409. * Internal only - manager for action
  10410. * @hidden
  10411. */
  10412. _actionManager: ActionManager;
  10413. private _nextActiveAction;
  10414. private _child;
  10415. private _condition?;
  10416. private _triggerParameter;
  10417. /**
  10418. * An event triggered prior to action being executed.
  10419. */
  10420. onBeforeExecuteObservable: Observable<Action>;
  10421. /**
  10422. * Creates a new Action
  10423. * @param triggerOptions the trigger, with or without parameters, for the action
  10424. * @param condition an optional determinant of action
  10425. */
  10426. constructor(
  10427. /** the trigger, with or without parameters, for the action */
  10428. triggerOptions: any, condition?: Condition);
  10429. /**
  10430. * Internal only
  10431. * @hidden
  10432. */
  10433. _prepare(): void;
  10434. /**
  10435. * Gets the trigger parameters
  10436. * @returns the trigger parameters
  10437. */
  10438. getTriggerParameter(): any;
  10439. /**
  10440. * Internal only - executes current action event
  10441. * @hidden
  10442. */
  10443. _executeCurrent(evt?: ActionEvent): void;
  10444. /**
  10445. * Execute placeholder for child classes
  10446. * @param evt optional action event
  10447. */
  10448. execute(evt?: ActionEvent): void;
  10449. /**
  10450. * Skips to next active action
  10451. */
  10452. skipToNextActiveAction(): void;
  10453. /**
  10454. * Adds action to chain of actions, may be a DoNothingAction
  10455. * @param action defines the next action to execute
  10456. * @returns The action passed in
  10457. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10458. */
  10459. then(action: Action): Action;
  10460. /**
  10461. * Internal only
  10462. * @hidden
  10463. */
  10464. _getProperty(propertyPath: string): string;
  10465. /**
  10466. * Internal only
  10467. * @hidden
  10468. */
  10469. _getEffectiveTarget(target: any, propertyPath: string): any;
  10470. /**
  10471. * Serialize placeholder for child classes
  10472. * @param parent of child
  10473. * @returns the serialized object
  10474. */
  10475. serialize(parent: any): any;
  10476. /**
  10477. * Internal only called by serialize
  10478. * @hidden
  10479. */
  10480. protected _serialize(serializedAction: any, parent?: any): any;
  10481. /**
  10482. * Internal only
  10483. * @hidden
  10484. */
  10485. static _SerializeValueAsString: (value: any) => string;
  10486. /**
  10487. * Internal only
  10488. * @hidden
  10489. */
  10490. static _GetTargetProperty: (target: import("babylonjs/node").Node | import("babylonjs/scene").Scene) => {
  10491. name: string;
  10492. targetType: string;
  10493. value: string;
  10494. };
  10495. }
  10496. }
  10497. declare module "babylonjs/Actions/condition" {
  10498. import { ActionManager } from "babylonjs/Actions/actionManager";
  10499. /**
  10500. * A Condition applied to an Action
  10501. */
  10502. export class Condition {
  10503. /**
  10504. * Internal only - manager for action
  10505. * @hidden
  10506. */
  10507. _actionManager: ActionManager;
  10508. /**
  10509. * Internal only
  10510. * @hidden
  10511. */
  10512. _evaluationId: number;
  10513. /**
  10514. * Internal only
  10515. * @hidden
  10516. */
  10517. _currentResult: boolean;
  10518. /**
  10519. * Creates a new Condition
  10520. * @param actionManager the manager of the action the condition is applied to
  10521. */
  10522. constructor(actionManager: ActionManager);
  10523. /**
  10524. * Check if the current condition is valid
  10525. * @returns a boolean
  10526. */
  10527. isValid(): boolean;
  10528. /**
  10529. * Internal only
  10530. * @hidden
  10531. */
  10532. _getProperty(propertyPath: string): string;
  10533. /**
  10534. * Internal only
  10535. * @hidden
  10536. */
  10537. _getEffectiveTarget(target: any, propertyPath: string): any;
  10538. /**
  10539. * Serialize placeholder for child classes
  10540. * @returns the serialized object
  10541. */
  10542. serialize(): any;
  10543. /**
  10544. * Internal only
  10545. * @hidden
  10546. */
  10547. protected _serialize(serializedCondition: any): any;
  10548. }
  10549. /**
  10550. * Defines specific conditional operators as extensions of Condition
  10551. */
  10552. export class ValueCondition extends Condition {
  10553. /** path to specify the property of the target the conditional operator uses */
  10554. propertyPath: string;
  10555. /** the value compared by the conditional operator against the current value of the property */
  10556. value: any;
  10557. /** the conditional operator, default ValueCondition.IsEqual */
  10558. operator: number;
  10559. /**
  10560. * Internal only
  10561. * @hidden
  10562. */
  10563. private static _IsEqual;
  10564. /**
  10565. * Internal only
  10566. * @hidden
  10567. */
  10568. private static _IsDifferent;
  10569. /**
  10570. * Internal only
  10571. * @hidden
  10572. */
  10573. private static _IsGreater;
  10574. /**
  10575. * Internal only
  10576. * @hidden
  10577. */
  10578. private static _IsLesser;
  10579. /**
  10580. * returns the number for IsEqual
  10581. */
  10582. static readonly IsEqual: number;
  10583. /**
  10584. * Returns the number for IsDifferent
  10585. */
  10586. static readonly IsDifferent: number;
  10587. /**
  10588. * Returns the number for IsGreater
  10589. */
  10590. static readonly IsGreater: number;
  10591. /**
  10592. * Returns the number for IsLesser
  10593. */
  10594. static readonly IsLesser: number;
  10595. /**
  10596. * Internal only The action manager for the condition
  10597. * @hidden
  10598. */
  10599. _actionManager: ActionManager;
  10600. /**
  10601. * Internal only
  10602. * @hidden
  10603. */
  10604. private _target;
  10605. /**
  10606. * Internal only
  10607. * @hidden
  10608. */
  10609. private _effectiveTarget;
  10610. /**
  10611. * Internal only
  10612. * @hidden
  10613. */
  10614. private _property;
  10615. /**
  10616. * Creates a new ValueCondition
  10617. * @param actionManager manager for the action the condition applies to
  10618. * @param target for the action
  10619. * @param propertyPath path to specify the property of the target the conditional operator uses
  10620. * @param value the value compared by the conditional operator against the current value of the property
  10621. * @param operator the conditional operator, default ValueCondition.IsEqual
  10622. */
  10623. constructor(actionManager: ActionManager, target: any,
  10624. /** path to specify the property of the target the conditional operator uses */
  10625. propertyPath: string,
  10626. /** the value compared by the conditional operator against the current value of the property */
  10627. value: any,
  10628. /** the conditional operator, default ValueCondition.IsEqual */
  10629. operator?: number);
  10630. /**
  10631. * Compares the given value with the property value for the specified conditional operator
  10632. * @returns the result of the comparison
  10633. */
  10634. isValid(): boolean;
  10635. /**
  10636. * Serialize the ValueCondition into a JSON compatible object
  10637. * @returns serialization object
  10638. */
  10639. serialize(): any;
  10640. /**
  10641. * Gets the name of the conditional operator for the ValueCondition
  10642. * @param operator the conditional operator
  10643. * @returns the name
  10644. */
  10645. static GetOperatorName(operator: number): string;
  10646. }
  10647. /**
  10648. * Defines a predicate condition as an extension of Condition
  10649. */
  10650. export class PredicateCondition extends Condition {
  10651. /** defines the predicate function used to validate the condition */
  10652. predicate: () => boolean;
  10653. /**
  10654. * Internal only - manager for action
  10655. * @hidden
  10656. */
  10657. _actionManager: ActionManager;
  10658. /**
  10659. * Creates a new PredicateCondition
  10660. * @param actionManager manager for the action the condition applies to
  10661. * @param predicate defines the predicate function used to validate the condition
  10662. */
  10663. constructor(actionManager: ActionManager,
  10664. /** defines the predicate function used to validate the condition */
  10665. predicate: () => boolean);
  10666. /**
  10667. * @returns the validity of the predicate condition
  10668. */
  10669. isValid(): boolean;
  10670. }
  10671. /**
  10672. * Defines a state condition as an extension of Condition
  10673. */
  10674. export class StateCondition extends Condition {
  10675. /** Value to compare with target state */
  10676. value: string;
  10677. /**
  10678. * Internal only - manager for action
  10679. * @hidden
  10680. */
  10681. _actionManager: ActionManager;
  10682. /**
  10683. * Internal only
  10684. * @hidden
  10685. */
  10686. private _target;
  10687. /**
  10688. * Creates a new StateCondition
  10689. * @param actionManager manager for the action the condition applies to
  10690. * @param target of the condition
  10691. * @param value to compare with target state
  10692. */
  10693. constructor(actionManager: ActionManager, target: any,
  10694. /** Value to compare with target state */
  10695. value: string);
  10696. /**
  10697. * Gets a boolean indicating if the current condition is met
  10698. * @returns the validity of the state
  10699. */
  10700. isValid(): boolean;
  10701. /**
  10702. * Serialize the StateCondition into a JSON compatible object
  10703. * @returns serialization object
  10704. */
  10705. serialize(): any;
  10706. }
  10707. }
  10708. declare module "babylonjs/Actions/directActions" {
  10709. import { Action } from "babylonjs/Actions/action";
  10710. import { Condition } from "babylonjs/Actions/condition";
  10711. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10712. /**
  10713. * This defines an action responsible to toggle a boolean once triggered.
  10714. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10715. */
  10716. export class SwitchBooleanAction extends Action {
  10717. /**
  10718. * The path to the boolean property in the target object
  10719. */
  10720. propertyPath: string;
  10721. private _target;
  10722. private _effectiveTarget;
  10723. private _property;
  10724. /**
  10725. * Instantiate the action
  10726. * @param triggerOptions defines the trigger options
  10727. * @param target defines the object containing the boolean
  10728. * @param propertyPath defines the path to the boolean property in the target object
  10729. * @param condition defines the trigger related conditions
  10730. */
  10731. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10732. /** @hidden */
  10733. _prepare(): void;
  10734. /**
  10735. * Execute the action toggle the boolean value.
  10736. */
  10737. execute(): void;
  10738. /**
  10739. * Serializes the actions and its related information.
  10740. * @param parent defines the object to serialize in
  10741. * @returns the serialized object
  10742. */
  10743. serialize(parent: any): any;
  10744. }
  10745. /**
  10746. * This defines an action responsible to set a the state field of the target
  10747. * to a desired value once triggered.
  10748. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10749. */
  10750. export class SetStateAction extends Action {
  10751. /**
  10752. * The value to store in the state field.
  10753. */
  10754. value: string;
  10755. private _target;
  10756. /**
  10757. * Instantiate the action
  10758. * @param triggerOptions defines the trigger options
  10759. * @param target defines the object containing the state property
  10760. * @param value defines the value to store in the state field
  10761. * @param condition defines the trigger related conditions
  10762. */
  10763. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10764. /**
  10765. * Execute the action and store the value on the target state property.
  10766. */
  10767. execute(): void;
  10768. /**
  10769. * Serializes the actions and its related information.
  10770. * @param parent defines the object to serialize in
  10771. * @returns the serialized object
  10772. */
  10773. serialize(parent: any): any;
  10774. }
  10775. /**
  10776. * This defines an action responsible to set a property of the target
  10777. * to a desired value once triggered.
  10778. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10779. */
  10780. export class SetValueAction extends Action {
  10781. /**
  10782. * The path of the property to set in the target.
  10783. */
  10784. propertyPath: string;
  10785. /**
  10786. * The value to set in the property
  10787. */
  10788. value: any;
  10789. private _target;
  10790. private _effectiveTarget;
  10791. private _property;
  10792. /**
  10793. * Instantiate the action
  10794. * @param triggerOptions defines the trigger options
  10795. * @param target defines the object containing the property
  10796. * @param propertyPath defines the path of the property to set in the target
  10797. * @param value defines the value to set in the property
  10798. * @param condition defines the trigger related conditions
  10799. */
  10800. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10801. /** @hidden */
  10802. _prepare(): void;
  10803. /**
  10804. * Execute the action and set the targetted property to the desired value.
  10805. */
  10806. execute(): void;
  10807. /**
  10808. * Serializes the actions and its related information.
  10809. * @param parent defines the object to serialize in
  10810. * @returns the serialized object
  10811. */
  10812. serialize(parent: any): any;
  10813. }
  10814. /**
  10815. * This defines an action responsible to increment the target value
  10816. * to a desired value once triggered.
  10817. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10818. */
  10819. export class IncrementValueAction extends Action {
  10820. /**
  10821. * The path of the property to increment in the target.
  10822. */
  10823. propertyPath: string;
  10824. /**
  10825. * The value we should increment the property by.
  10826. */
  10827. value: any;
  10828. private _target;
  10829. private _effectiveTarget;
  10830. private _property;
  10831. /**
  10832. * Instantiate the action
  10833. * @param triggerOptions defines the trigger options
  10834. * @param target defines the object containing the property
  10835. * @param propertyPath defines the path of the property to increment in the target
  10836. * @param value defines the value value we should increment the property by
  10837. * @param condition defines the trigger related conditions
  10838. */
  10839. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10840. /** @hidden */
  10841. _prepare(): void;
  10842. /**
  10843. * Execute the action and increment the target of the value amount.
  10844. */
  10845. execute(): void;
  10846. /**
  10847. * Serializes the actions and its related information.
  10848. * @param parent defines the object to serialize in
  10849. * @returns the serialized object
  10850. */
  10851. serialize(parent: any): any;
  10852. }
  10853. /**
  10854. * This defines an action responsible to start an animation once triggered.
  10855. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10856. */
  10857. export class PlayAnimationAction extends Action {
  10858. /**
  10859. * Where the animation should start (animation frame)
  10860. */
  10861. from: number;
  10862. /**
  10863. * Where the animation should stop (animation frame)
  10864. */
  10865. to: number;
  10866. /**
  10867. * Define if the animation should loop or stop after the first play.
  10868. */
  10869. loop?: boolean;
  10870. private _target;
  10871. /**
  10872. * Instantiate the action
  10873. * @param triggerOptions defines the trigger options
  10874. * @param target defines the target animation or animation name
  10875. * @param from defines from where the animation should start (animation frame)
  10876. * @param end defines where the animation should stop (animation frame)
  10877. * @param loop defines if the animation should loop or stop after the first play
  10878. * @param condition defines the trigger related conditions
  10879. */
  10880. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10881. /** @hidden */
  10882. _prepare(): void;
  10883. /**
  10884. * Execute the action and play the animation.
  10885. */
  10886. execute(): void;
  10887. /**
  10888. * Serializes the actions and its related information.
  10889. * @param parent defines the object to serialize in
  10890. * @returns the serialized object
  10891. */
  10892. serialize(parent: any): any;
  10893. }
  10894. /**
  10895. * This defines an action responsible to stop an animation once triggered.
  10896. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10897. */
  10898. export class StopAnimationAction extends Action {
  10899. private _target;
  10900. /**
  10901. * Instantiate the action
  10902. * @param triggerOptions defines the trigger options
  10903. * @param target defines the target animation or animation name
  10904. * @param condition defines the trigger related conditions
  10905. */
  10906. constructor(triggerOptions: any, target: any, condition?: Condition);
  10907. /** @hidden */
  10908. _prepare(): void;
  10909. /**
  10910. * Execute the action and stop the animation.
  10911. */
  10912. execute(): void;
  10913. /**
  10914. * Serializes the actions and its related information.
  10915. * @param parent defines the object to serialize in
  10916. * @returns the serialized object
  10917. */
  10918. serialize(parent: any): any;
  10919. }
  10920. /**
  10921. * This defines an action responsible that does nothing once triggered.
  10922. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10923. */
  10924. export class DoNothingAction extends Action {
  10925. /**
  10926. * Instantiate the action
  10927. * @param triggerOptions defines the trigger options
  10928. * @param condition defines the trigger related conditions
  10929. */
  10930. constructor(triggerOptions?: any, condition?: Condition);
  10931. /**
  10932. * Execute the action and do nothing.
  10933. */
  10934. execute(): void;
  10935. /**
  10936. * Serializes the actions and its related information.
  10937. * @param parent defines the object to serialize in
  10938. * @returns the serialized object
  10939. */
  10940. serialize(parent: any): any;
  10941. }
  10942. /**
  10943. * This defines an action responsible to trigger several actions once triggered.
  10944. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10945. */
  10946. export class CombineAction extends Action {
  10947. /**
  10948. * The list of aggregated animations to run.
  10949. */
  10950. children: Action[];
  10951. /**
  10952. * Instantiate the action
  10953. * @param triggerOptions defines the trigger options
  10954. * @param children defines the list of aggregated animations to run
  10955. * @param condition defines the trigger related conditions
  10956. */
  10957. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10958. /** @hidden */
  10959. _prepare(): void;
  10960. /**
  10961. * Execute the action and executes all the aggregated actions.
  10962. */
  10963. execute(evt: ActionEvent): void;
  10964. /**
  10965. * Serializes the actions and its related information.
  10966. * @param parent defines the object to serialize in
  10967. * @returns the serialized object
  10968. */
  10969. serialize(parent: any): any;
  10970. }
  10971. /**
  10972. * This defines an action responsible to run code (external event) once triggered.
  10973. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10974. */
  10975. export class ExecuteCodeAction extends Action {
  10976. /**
  10977. * The callback function to run.
  10978. */
  10979. func: (evt: ActionEvent) => void;
  10980. /**
  10981. * Instantiate the action
  10982. * @param triggerOptions defines the trigger options
  10983. * @param func defines the callback function to run
  10984. * @param condition defines the trigger related conditions
  10985. */
  10986. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10987. /**
  10988. * Execute the action and run the attached code.
  10989. */
  10990. execute(evt: ActionEvent): void;
  10991. }
  10992. /**
  10993. * This defines an action responsible to set the parent property of the target once triggered.
  10994. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10995. */
  10996. export class SetParentAction extends Action {
  10997. private _parent;
  10998. private _target;
  10999. /**
  11000. * Instantiate the action
  11001. * @param triggerOptions defines the trigger options
  11002. * @param target defines the target containing the parent property
  11003. * @param parent defines from where the animation should start (animation frame)
  11004. * @param condition defines the trigger related conditions
  11005. */
  11006. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  11007. /** @hidden */
  11008. _prepare(): void;
  11009. /**
  11010. * Execute the action and set the parent property.
  11011. */
  11012. execute(): void;
  11013. /**
  11014. * Serializes the actions and its related information.
  11015. * @param parent defines the object to serialize in
  11016. * @returns the serialized object
  11017. */
  11018. serialize(parent: any): any;
  11019. }
  11020. }
  11021. declare module "babylonjs/Actions/actionManager" {
  11022. import { Nullable } from "babylonjs/types";
  11023. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11024. import { Scene } from "babylonjs/scene";
  11025. import { IAction } from "babylonjs/Actions/action";
  11026. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  11027. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  11028. /**
  11029. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  11030. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  11031. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11032. */
  11033. export class ActionManager extends AbstractActionManager {
  11034. /**
  11035. * Nothing
  11036. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11037. */
  11038. static readonly NothingTrigger: number;
  11039. /**
  11040. * On pick
  11041. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11042. */
  11043. static readonly OnPickTrigger: number;
  11044. /**
  11045. * On left pick
  11046. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11047. */
  11048. static readonly OnLeftPickTrigger: number;
  11049. /**
  11050. * On right pick
  11051. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11052. */
  11053. static readonly OnRightPickTrigger: number;
  11054. /**
  11055. * On center pick
  11056. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11057. */
  11058. static readonly OnCenterPickTrigger: number;
  11059. /**
  11060. * On pick down
  11061. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11062. */
  11063. static readonly OnPickDownTrigger: number;
  11064. /**
  11065. * On double pick
  11066. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11067. */
  11068. static readonly OnDoublePickTrigger: number;
  11069. /**
  11070. * On pick up
  11071. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11072. */
  11073. static readonly OnPickUpTrigger: number;
  11074. /**
  11075. * On pick out.
  11076. * This trigger will only be raised if you also declared a OnPickDown
  11077. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11078. */
  11079. static readonly OnPickOutTrigger: number;
  11080. /**
  11081. * On long press
  11082. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11083. */
  11084. static readonly OnLongPressTrigger: number;
  11085. /**
  11086. * On pointer over
  11087. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11088. */
  11089. static readonly OnPointerOverTrigger: number;
  11090. /**
  11091. * On pointer out
  11092. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11093. */
  11094. static readonly OnPointerOutTrigger: number;
  11095. /**
  11096. * On every frame
  11097. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11098. */
  11099. static readonly OnEveryFrameTrigger: number;
  11100. /**
  11101. * On intersection enter
  11102. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11103. */
  11104. static readonly OnIntersectionEnterTrigger: number;
  11105. /**
  11106. * On intersection exit
  11107. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11108. */
  11109. static readonly OnIntersectionExitTrigger: number;
  11110. /**
  11111. * On key down
  11112. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11113. */
  11114. static readonly OnKeyDownTrigger: number;
  11115. /**
  11116. * On key up
  11117. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11118. */
  11119. static readonly OnKeyUpTrigger: number;
  11120. private _scene;
  11121. /**
  11122. * Creates a new action manager
  11123. * @param scene defines the hosting scene
  11124. */
  11125. constructor(scene: Scene);
  11126. /**
  11127. * Releases all associated resources
  11128. */
  11129. dispose(): void;
  11130. /**
  11131. * Gets hosting scene
  11132. * @returns the hosting scene
  11133. */
  11134. getScene(): Scene;
  11135. /**
  11136. * Does this action manager handles actions of any of the given triggers
  11137. * @param triggers defines the triggers to be tested
  11138. * @return a boolean indicating whether one (or more) of the triggers is handled
  11139. */
  11140. hasSpecificTriggers(triggers: number[]): boolean;
  11141. /**
  11142. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  11143. * speed.
  11144. * @param triggerA defines the trigger to be tested
  11145. * @param triggerB defines the trigger to be tested
  11146. * @return a boolean indicating whether one (or more) of the triggers is handled
  11147. */
  11148. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  11149. /**
  11150. * Does this action manager handles actions of a given trigger
  11151. * @param trigger defines the trigger to be tested
  11152. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  11153. * @return whether the trigger is handled
  11154. */
  11155. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  11156. /**
  11157. * Does this action manager has pointer triggers
  11158. */
  11159. readonly hasPointerTriggers: boolean;
  11160. /**
  11161. * Does this action manager has pick triggers
  11162. */
  11163. readonly hasPickTriggers: boolean;
  11164. /**
  11165. * Registers an action to this action manager
  11166. * @param action defines the action to be registered
  11167. * @return the action amended (prepared) after registration
  11168. */
  11169. registerAction(action: IAction): Nullable<IAction>;
  11170. /**
  11171. * Unregisters an action to this action manager
  11172. * @param action defines the action to be unregistered
  11173. * @return a boolean indicating whether the action has been unregistered
  11174. */
  11175. unregisterAction(action: IAction): Boolean;
  11176. /**
  11177. * Process a specific trigger
  11178. * @param trigger defines the trigger to process
  11179. * @param evt defines the event details to be processed
  11180. */
  11181. processTrigger(trigger: number, evt?: IActionEvent): void;
  11182. /** @hidden */
  11183. _getEffectiveTarget(target: any, propertyPath: string): any;
  11184. /** @hidden */
  11185. _getProperty(propertyPath: string): string;
  11186. /**
  11187. * Serialize this manager to a JSON object
  11188. * @param name defines the property name to store this manager
  11189. * @returns a JSON representation of this manager
  11190. */
  11191. serialize(name: string): any;
  11192. /**
  11193. * Creates a new ActionManager from a JSON data
  11194. * @param parsedActions defines the JSON data to read from
  11195. * @param object defines the hosting mesh
  11196. * @param scene defines the hosting scene
  11197. */
  11198. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  11199. /**
  11200. * Get a trigger name by index
  11201. * @param trigger defines the trigger index
  11202. * @returns a trigger name
  11203. */
  11204. static GetTriggerName(trigger: number): string;
  11205. }
  11206. }
  11207. declare module "babylonjs/Culling/ray" {
  11208. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  11209. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  11210. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11211. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11212. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  11213. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  11214. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  11215. import { Plane } from "babylonjs/Maths/math.plane";
  11216. /**
  11217. * Class representing a ray with position and direction
  11218. */
  11219. export class Ray {
  11220. /** origin point */
  11221. origin: Vector3;
  11222. /** direction */
  11223. direction: Vector3;
  11224. /** length of the ray */
  11225. length: number;
  11226. private static readonly TmpVector3;
  11227. private _tmpRay;
  11228. /**
  11229. * Creates a new ray
  11230. * @param origin origin point
  11231. * @param direction direction
  11232. * @param length length of the ray
  11233. */
  11234. constructor(
  11235. /** origin point */
  11236. origin: Vector3,
  11237. /** direction */
  11238. direction: Vector3,
  11239. /** length of the ray */
  11240. length?: number);
  11241. /**
  11242. * Checks if the ray intersects a box
  11243. * @param minimum bound of the box
  11244. * @param maximum bound of the box
  11245. * @param intersectionTreshold extra extend to be added to the box in all direction
  11246. * @returns if the box was hit
  11247. */
  11248. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  11249. /**
  11250. * Checks if the ray intersects a box
  11251. * @param box the bounding box to check
  11252. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  11253. * @returns if the box was hit
  11254. */
  11255. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  11256. /**
  11257. * If the ray hits a sphere
  11258. * @param sphere the bounding sphere to check
  11259. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  11260. * @returns true if it hits the sphere
  11261. */
  11262. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  11263. /**
  11264. * If the ray hits a triange
  11265. * @param vertex0 triangle vertex
  11266. * @param vertex1 triangle vertex
  11267. * @param vertex2 triangle vertex
  11268. * @returns intersection information if hit
  11269. */
  11270. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  11271. /**
  11272. * Checks if ray intersects a plane
  11273. * @param plane the plane to check
  11274. * @returns the distance away it was hit
  11275. */
  11276. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  11277. /**
  11278. * Calculate the intercept of a ray on a given axis
  11279. * @param axis to check 'x' | 'y' | 'z'
  11280. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  11281. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  11282. */
  11283. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  11284. /**
  11285. * Checks if ray intersects a mesh
  11286. * @param mesh the mesh to check
  11287. * @param fastCheck if only the bounding box should checked
  11288. * @returns picking info of the intersecton
  11289. */
  11290. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  11291. /**
  11292. * Checks if ray intersects a mesh
  11293. * @param meshes the meshes to check
  11294. * @param fastCheck if only the bounding box should checked
  11295. * @param results array to store result in
  11296. * @returns Array of picking infos
  11297. */
  11298. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  11299. private _comparePickingInfo;
  11300. private static smallnum;
  11301. private static rayl;
  11302. /**
  11303. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  11304. * @param sega the first point of the segment to test the intersection against
  11305. * @param segb the second point of the segment to test the intersection against
  11306. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  11307. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  11308. */
  11309. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  11310. /**
  11311. * Update the ray from viewport position
  11312. * @param x position
  11313. * @param y y position
  11314. * @param viewportWidth viewport width
  11315. * @param viewportHeight viewport height
  11316. * @param world world matrix
  11317. * @param view view matrix
  11318. * @param projection projection matrix
  11319. * @returns this ray updated
  11320. */
  11321. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11322. /**
  11323. * Creates a ray with origin and direction of 0,0,0
  11324. * @returns the new ray
  11325. */
  11326. static Zero(): Ray;
  11327. /**
  11328. * Creates a new ray from screen space and viewport
  11329. * @param x position
  11330. * @param y y position
  11331. * @param viewportWidth viewport width
  11332. * @param viewportHeight viewport height
  11333. * @param world world matrix
  11334. * @param view view matrix
  11335. * @param projection projection matrix
  11336. * @returns new ray
  11337. */
  11338. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11339. /**
  11340. * Function will create a new transformed ray starting from origin and ending at the end point. Ray's length will be set, and ray will be
  11341. * transformed to the given world matrix.
  11342. * @param origin The origin point
  11343. * @param end The end point
  11344. * @param world a matrix to transform the ray to. Default is the identity matrix.
  11345. * @returns the new ray
  11346. */
  11347. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  11348. /**
  11349. * Transforms a ray by a matrix
  11350. * @param ray ray to transform
  11351. * @param matrix matrix to apply
  11352. * @returns the resulting new ray
  11353. */
  11354. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  11355. /**
  11356. * Transforms a ray by a matrix
  11357. * @param ray ray to transform
  11358. * @param matrix matrix to apply
  11359. * @param result ray to store result in
  11360. */
  11361. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  11362. /**
  11363. * Unproject a ray from screen space to object space
  11364. * @param sourceX defines the screen space x coordinate to use
  11365. * @param sourceY defines the screen space y coordinate to use
  11366. * @param viewportWidth defines the current width of the viewport
  11367. * @param viewportHeight defines the current height of the viewport
  11368. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11369. * @param view defines the view matrix to use
  11370. * @param projection defines the projection matrix to use
  11371. */
  11372. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11373. }
  11374. /**
  11375. * Type used to define predicate used to select faces when a mesh intersection is detected
  11376. */
  11377. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  11378. module "babylonjs/scene" {
  11379. interface Scene {
  11380. /** @hidden */
  11381. _tempPickingRay: Nullable<Ray>;
  11382. /** @hidden */
  11383. _cachedRayForTransform: Ray;
  11384. /** @hidden */
  11385. _pickWithRayInverseMatrix: Matrix;
  11386. /** @hidden */
  11387. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  11388. /** @hidden */
  11389. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  11390. }
  11391. }
  11392. }
  11393. declare module "babylonjs/sceneComponent" {
  11394. import { Scene } from "babylonjs/scene";
  11395. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11396. import { SubMesh } from "babylonjs/Meshes/subMesh";
  11397. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  11398. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  11399. import { Nullable } from "babylonjs/types";
  11400. import { Camera } from "babylonjs/Cameras/camera";
  11401. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  11402. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11403. import { AbstractScene } from "babylonjs/abstractScene";
  11404. import { Mesh } from "babylonjs/Meshes/mesh";
  11405. /**
  11406. * Groups all the scene component constants in one place to ease maintenance.
  11407. * @hidden
  11408. */
  11409. export class SceneComponentConstants {
  11410. static readonly NAME_EFFECTLAYER: string;
  11411. static readonly NAME_LAYER: string;
  11412. static readonly NAME_LENSFLARESYSTEM: string;
  11413. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11414. static readonly NAME_PARTICLESYSTEM: string;
  11415. static readonly NAME_GAMEPAD: string;
  11416. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11417. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11418. static readonly NAME_DEPTHRENDERER: string;
  11419. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11420. static readonly NAME_SPRITE: string;
  11421. static readonly NAME_OUTLINERENDERER: string;
  11422. static readonly NAME_PROCEDURALTEXTURE: string;
  11423. static readonly NAME_SHADOWGENERATOR: string;
  11424. static readonly NAME_OCTREE: string;
  11425. static readonly NAME_PHYSICSENGINE: string;
  11426. static readonly NAME_AUDIO: string;
  11427. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11428. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11429. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11430. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11431. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11432. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11433. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11434. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11435. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11436. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11437. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11438. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11439. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11440. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11441. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11442. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11443. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11444. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11445. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11446. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11447. static readonly STEP_AFTERRENDER_AUDIO: number;
  11448. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11449. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11450. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11451. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11452. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11453. static readonly STEP_POINTERMOVE_SPRITE: number;
  11454. static readonly STEP_POINTERDOWN_SPRITE: number;
  11455. static readonly STEP_POINTERUP_SPRITE: number;
  11456. }
  11457. /**
  11458. * This represents a scene component.
  11459. *
  11460. * This is used to decouple the dependency the scene is having on the different workloads like
  11461. * layers, post processes...
  11462. */
  11463. export interface ISceneComponent {
  11464. /**
  11465. * The name of the component. Each component must have a unique name.
  11466. */
  11467. name: string;
  11468. /**
  11469. * The scene the component belongs to.
  11470. */
  11471. scene: Scene;
  11472. /**
  11473. * Register the component to one instance of a scene.
  11474. */
  11475. register(): void;
  11476. /**
  11477. * Rebuilds the elements related to this component in case of
  11478. * context lost for instance.
  11479. */
  11480. rebuild(): void;
  11481. /**
  11482. * Disposes the component and the associated ressources.
  11483. */
  11484. dispose(): void;
  11485. }
  11486. /**
  11487. * This represents a SERIALIZABLE scene component.
  11488. *
  11489. * This extends Scene Component to add Serialization methods on top.
  11490. */
  11491. export interface ISceneSerializableComponent extends ISceneComponent {
  11492. /**
  11493. * Adds all the elements from the container to the scene
  11494. * @param container the container holding the elements
  11495. */
  11496. addFromContainer(container: AbstractScene): void;
  11497. /**
  11498. * Removes all the elements in the container from the scene
  11499. * @param container contains the elements to remove
  11500. * @param dispose if the removed element should be disposed (default: false)
  11501. */
  11502. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  11503. /**
  11504. * Serializes the component data to the specified json object
  11505. * @param serializationObject The object to serialize to
  11506. */
  11507. serialize(serializationObject: any): void;
  11508. }
  11509. /**
  11510. * Strong typing of a Mesh related stage step action
  11511. */
  11512. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11513. /**
  11514. * Strong typing of a Evaluate Sub Mesh related stage step action
  11515. */
  11516. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11517. /**
  11518. * Strong typing of a Active Mesh related stage step action
  11519. */
  11520. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11521. /**
  11522. * Strong typing of a Camera related stage step action
  11523. */
  11524. export type CameraStageAction = (camera: Camera) => void;
  11525. /**
  11526. * Strong typing of a Camera Frame buffer related stage step action
  11527. */
  11528. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  11529. /**
  11530. * Strong typing of a Render Target related stage step action
  11531. */
  11532. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11533. /**
  11534. * Strong typing of a RenderingGroup related stage step action
  11535. */
  11536. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11537. /**
  11538. * Strong typing of a Mesh Render related stage step action
  11539. */
  11540. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11541. /**
  11542. * Strong typing of a simple stage step action
  11543. */
  11544. export type SimpleStageAction = () => void;
  11545. /**
  11546. * Strong typing of a render target action.
  11547. */
  11548. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11549. /**
  11550. * Strong typing of a pointer move action.
  11551. */
  11552. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  11553. /**
  11554. * Strong typing of a pointer up/down action.
  11555. */
  11556. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11557. /**
  11558. * Representation of a stage in the scene (Basically a list of ordered steps)
  11559. * @hidden
  11560. */
  11561. export class Stage<T extends Function> extends Array<{
  11562. index: number;
  11563. component: ISceneComponent;
  11564. action: T;
  11565. }> {
  11566. /**
  11567. * Hide ctor from the rest of the world.
  11568. * @param items The items to add.
  11569. */
  11570. private constructor();
  11571. /**
  11572. * Creates a new Stage.
  11573. * @returns A new instance of a Stage
  11574. */
  11575. static Create<T extends Function>(): Stage<T>;
  11576. /**
  11577. * Registers a step in an ordered way in the targeted stage.
  11578. * @param index Defines the position to register the step in
  11579. * @param component Defines the component attached to the step
  11580. * @param action Defines the action to launch during the step
  11581. */
  11582. registerStep(index: number, component: ISceneComponent, action: T): void;
  11583. /**
  11584. * Clears all the steps from the stage.
  11585. */
  11586. clear(): void;
  11587. }
  11588. }
  11589. declare module "babylonjs/Sprites/spriteSceneComponent" {
  11590. import { Nullable } from "babylonjs/types";
  11591. import { Observable } from "babylonjs/Misc/observable";
  11592. import { Scene } from "babylonjs/scene";
  11593. import { Sprite } from "babylonjs/Sprites/sprite";
  11594. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11595. import { Ray } from "babylonjs/Culling/ray";
  11596. import { Camera } from "babylonjs/Cameras/camera";
  11597. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11598. import { ISceneComponent } from "babylonjs/sceneComponent";
  11599. module "babylonjs/scene" {
  11600. interface Scene {
  11601. /** @hidden */
  11602. _pointerOverSprite: Nullable<Sprite>;
  11603. /** @hidden */
  11604. _pickedDownSprite: Nullable<Sprite>;
  11605. /** @hidden */
  11606. _tempSpritePickingRay: Nullable<Ray>;
  11607. /**
  11608. * All of the sprite managers added to this scene
  11609. * @see http://doc.babylonjs.com/babylon101/sprites
  11610. */
  11611. spriteManagers: Array<ISpriteManager>;
  11612. /**
  11613. * An event triggered when sprites rendering is about to start
  11614. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11615. */
  11616. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11617. /**
  11618. * An event triggered when sprites rendering is done
  11619. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11620. */
  11621. onAfterSpritesRenderingObservable: Observable<Scene>;
  11622. /** @hidden */
  11623. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11624. /** Launch a ray to try to pick a sprite in the scene
  11625. * @param x position on screen
  11626. * @param y position on screen
  11627. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  11628. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11629. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11630. * @returns a PickingInfo
  11631. */
  11632. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11633. /** Use the given ray to pick a sprite in the scene
  11634. * @param ray The ray (in world space) to use to pick meshes
  11635. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  11636. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11637. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11638. * @returns a PickingInfo
  11639. */
  11640. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11641. /** @hidden */
  11642. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11643. /** Launch a ray to try to pick sprites in the scene
  11644. * @param x position on screen
  11645. * @param y position on screen
  11646. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  11647. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11648. * @returns a PickingInfo array
  11649. */
  11650. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11651. /** Use the given ray to pick sprites in the scene
  11652. * @param ray The ray (in world space) to use to pick meshes
  11653. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  11654. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11655. * @returns a PickingInfo array
  11656. */
  11657. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11658. /**
  11659. * Force the sprite under the pointer
  11660. * @param sprite defines the sprite to use
  11661. */
  11662. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11663. /**
  11664. * Gets the sprite under the pointer
  11665. * @returns a Sprite or null if no sprite is under the pointer
  11666. */
  11667. getPointerOverSprite(): Nullable<Sprite>;
  11668. }
  11669. }
  11670. /**
  11671. * Defines the sprite scene component responsible to manage sprites
  11672. * in a given scene.
  11673. */
  11674. export class SpriteSceneComponent implements ISceneComponent {
  11675. /**
  11676. * The component name helpfull to identify the component in the list of scene components.
  11677. */
  11678. readonly name: string;
  11679. /**
  11680. * The scene the component belongs to.
  11681. */
  11682. scene: Scene;
  11683. /** @hidden */
  11684. private _spritePredicate;
  11685. /**
  11686. * Creates a new instance of the component for the given scene
  11687. * @param scene Defines the scene to register the component in
  11688. */
  11689. constructor(scene: Scene);
  11690. /**
  11691. * Registers the component in a given scene
  11692. */
  11693. register(): void;
  11694. /**
  11695. * Rebuilds the elements related to this component in case of
  11696. * context lost for instance.
  11697. */
  11698. rebuild(): void;
  11699. /**
  11700. * Disposes the component and the associated ressources.
  11701. */
  11702. dispose(): void;
  11703. private _pickSpriteButKeepRay;
  11704. private _pointerMove;
  11705. private _pointerDown;
  11706. private _pointerUp;
  11707. }
  11708. }
  11709. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  11710. /** @hidden */
  11711. export var fogFragmentDeclaration: {
  11712. name: string;
  11713. shader: string;
  11714. };
  11715. }
  11716. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  11717. /** @hidden */
  11718. export var fogFragment: {
  11719. name: string;
  11720. shader: string;
  11721. };
  11722. }
  11723. declare module "babylonjs/Shaders/sprites.fragment" {
  11724. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  11725. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  11726. /** @hidden */
  11727. export var spritesPixelShader: {
  11728. name: string;
  11729. shader: string;
  11730. };
  11731. }
  11732. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  11733. /** @hidden */
  11734. export var fogVertexDeclaration: {
  11735. name: string;
  11736. shader: string;
  11737. };
  11738. }
  11739. declare module "babylonjs/Shaders/sprites.vertex" {
  11740. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  11741. /** @hidden */
  11742. export var spritesVertexShader: {
  11743. name: string;
  11744. shader: string;
  11745. };
  11746. }
  11747. declare module "babylonjs/Sprites/spriteManager" {
  11748. import { IDisposable, Scene } from "babylonjs/scene";
  11749. import { Nullable } from "babylonjs/types";
  11750. import { Observable } from "babylonjs/Misc/observable";
  11751. import { Sprite } from "babylonjs/Sprites/sprite";
  11752. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11753. import { Camera } from "babylonjs/Cameras/camera";
  11754. import { Texture } from "babylonjs/Materials/Textures/texture";
  11755. import "babylonjs/Shaders/sprites.fragment";
  11756. import "babylonjs/Shaders/sprites.vertex";
  11757. import { Ray } from "babylonjs/Culling/ray";
  11758. /**
  11759. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11760. */
  11761. export interface ISpriteManager extends IDisposable {
  11762. /**
  11763. * Restricts the camera to viewing objects with the same layerMask.
  11764. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11765. */
  11766. layerMask: number;
  11767. /**
  11768. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11769. */
  11770. isPickable: boolean;
  11771. /**
  11772. * Specifies the rendering group id for this mesh (0 by default)
  11773. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11774. */
  11775. renderingGroupId: number;
  11776. /**
  11777. * Defines the list of sprites managed by the manager.
  11778. */
  11779. sprites: Array<Sprite>;
  11780. /**
  11781. * Tests the intersection of a sprite with a specific ray.
  11782. * @param ray The ray we are sending to test the collision
  11783. * @param camera The camera space we are sending rays in
  11784. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11785. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  11786. * @returns picking info or null.
  11787. */
  11788. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11789. /**
  11790. * Intersects the sprites with a ray
  11791. * @param ray defines the ray to intersect with
  11792. * @param camera defines the current active camera
  11793. * @param predicate defines a predicate used to select candidate sprites
  11794. * @returns null if no hit or a PickingInfo array
  11795. */
  11796. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11797. /**
  11798. * Renders the list of sprites on screen.
  11799. */
  11800. render(): void;
  11801. }
  11802. /**
  11803. * Class used to manage multiple sprites on the same spritesheet
  11804. * @see http://doc.babylonjs.com/babylon101/sprites
  11805. */
  11806. export class SpriteManager implements ISpriteManager {
  11807. /** defines the manager's name */
  11808. name: string;
  11809. /** Gets the list of sprites */
  11810. sprites: Sprite[];
  11811. /** Gets or sets the rendering group id (0 by default) */
  11812. renderingGroupId: number;
  11813. /** Gets or sets camera layer mask */
  11814. layerMask: number;
  11815. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11816. fogEnabled: boolean;
  11817. /** Gets or sets a boolean indicating if the sprites are pickable */
  11818. isPickable: boolean;
  11819. /** Defines the default width of a cell in the spritesheet */
  11820. cellWidth: number;
  11821. /** Defines the default height of a cell in the spritesheet */
  11822. cellHeight: number;
  11823. /** Associative array from JSON sprite data file */
  11824. private _cellData;
  11825. /** Array of sprite names from JSON sprite data file */
  11826. private _spriteMap;
  11827. /** True when packed cell data from JSON file is ready*/
  11828. private _packedAndReady;
  11829. /**
  11830. * An event triggered when the manager is disposed.
  11831. */
  11832. onDisposeObservable: Observable<SpriteManager>;
  11833. private _onDisposeObserver;
  11834. /**
  11835. * Callback called when the manager is disposed
  11836. */
  11837. onDispose: () => void;
  11838. private _capacity;
  11839. private _fromPacked;
  11840. private _spriteTexture;
  11841. private _epsilon;
  11842. private _scene;
  11843. private _vertexData;
  11844. private _buffer;
  11845. private _vertexBuffers;
  11846. private _indexBuffer;
  11847. private _effectBase;
  11848. private _effectFog;
  11849. /**
  11850. * Gets or sets the spritesheet texture
  11851. */
  11852. texture: Texture;
  11853. /**
  11854. * Creates a new sprite manager
  11855. * @param name defines the manager's name
  11856. * @param imgUrl defines the sprite sheet url
  11857. * @param capacity defines the maximum allowed number of sprites
  11858. * @param cellSize defines the size of a sprite cell
  11859. * @param scene defines the hosting scene
  11860. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11861. * @param samplingMode defines the smapling mode to use with spritesheet
  11862. * @param fromPacked set to false; do not alter
  11863. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  11864. */
  11865. constructor(
  11866. /** defines the manager's name */
  11867. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: string | null);
  11868. private _makePacked;
  11869. private _appendSpriteVertex;
  11870. /**
  11871. * Intersects the sprites with a ray
  11872. * @param ray defines the ray to intersect with
  11873. * @param camera defines the current active camera
  11874. * @param predicate defines a predicate used to select candidate sprites
  11875. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11876. * @returns null if no hit or a PickingInfo
  11877. */
  11878. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11879. /**
  11880. * Intersects the sprites with a ray
  11881. * @param ray defines the ray to intersect with
  11882. * @param camera defines the current active camera
  11883. * @param predicate defines a predicate used to select candidate sprites
  11884. * @returns null if no hit or a PickingInfo array
  11885. */
  11886. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11887. /**
  11888. * Render all child sprites
  11889. */
  11890. render(): void;
  11891. /**
  11892. * Release associated resources
  11893. */
  11894. dispose(): void;
  11895. }
  11896. }
  11897. declare module "babylonjs/Sprites/sprite" {
  11898. import { Vector3 } from "babylonjs/Maths/math.vector";
  11899. import { Nullable } from "babylonjs/types";
  11900. import { ActionManager } from "babylonjs/Actions/actionManager";
  11901. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11902. import { Color4 } from "babylonjs/Maths/math.color";
  11903. /**
  11904. * Class used to represent a sprite
  11905. * @see http://doc.babylonjs.com/babylon101/sprites
  11906. */
  11907. export class Sprite {
  11908. /** defines the name */
  11909. name: string;
  11910. /** Gets or sets the current world position */
  11911. position: Vector3;
  11912. /** Gets or sets the main color */
  11913. color: Color4;
  11914. /** Gets or sets the width */
  11915. width: number;
  11916. /** Gets or sets the height */
  11917. height: number;
  11918. /** Gets or sets rotation angle */
  11919. angle: number;
  11920. /** Gets or sets the cell index in the sprite sheet */
  11921. cellIndex: number;
  11922. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  11923. cellRef: string;
  11924. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  11925. invertU: number;
  11926. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  11927. invertV: number;
  11928. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  11929. disposeWhenFinishedAnimating: boolean;
  11930. /** Gets the list of attached animations */
  11931. animations: Animation[];
  11932. /** Gets or sets a boolean indicating if the sprite can be picked */
  11933. isPickable: boolean;
  11934. /**
  11935. * Gets or sets the associated action manager
  11936. */
  11937. actionManager: Nullable<ActionManager>;
  11938. private _animationStarted;
  11939. private _loopAnimation;
  11940. private _fromIndex;
  11941. private _toIndex;
  11942. private _delay;
  11943. private _direction;
  11944. private _manager;
  11945. private _time;
  11946. private _onAnimationEnd;
  11947. /**
  11948. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  11949. */
  11950. isVisible: boolean;
  11951. /**
  11952. * Gets or sets the sprite size
  11953. */
  11954. size: number;
  11955. /**
  11956. * Creates a new Sprite
  11957. * @param name defines the name
  11958. * @param manager defines the manager
  11959. */
  11960. constructor(
  11961. /** defines the name */
  11962. name: string, manager: ISpriteManager);
  11963. /**
  11964. * Starts an animation
  11965. * @param from defines the initial key
  11966. * @param to defines the end key
  11967. * @param loop defines if the animation must loop
  11968. * @param delay defines the start delay (in ms)
  11969. * @param onAnimationEnd defines a callback to call when animation ends
  11970. */
  11971. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  11972. /** Stops current animation (if any) */
  11973. stopAnimation(): void;
  11974. /** @hidden */
  11975. _animate(deltaTime: number): void;
  11976. /** Release associated resources */
  11977. dispose(): void;
  11978. }
  11979. }
  11980. declare module "babylonjs/Collisions/pickingInfo" {
  11981. import { Nullable } from "babylonjs/types";
  11982. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  11983. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11984. import { Sprite } from "babylonjs/Sprites/sprite";
  11985. import { Ray } from "babylonjs/Culling/ray";
  11986. /**
  11987. * Information about the result of picking within a scene
  11988. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  11989. */
  11990. export class PickingInfo {
  11991. /** @hidden */
  11992. _pickingUnavailable: boolean;
  11993. /**
  11994. * If the pick collided with an object
  11995. */
  11996. hit: boolean;
  11997. /**
  11998. * Distance away where the pick collided
  11999. */
  12000. distance: number;
  12001. /**
  12002. * The location of pick collision
  12003. */
  12004. pickedPoint: Nullable<Vector3>;
  12005. /**
  12006. * The mesh corresponding the the pick collision
  12007. */
  12008. pickedMesh: Nullable<AbstractMesh>;
  12009. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  12010. bu: number;
  12011. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  12012. bv: number;
  12013. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  12014. faceId: number;
  12015. /** Id of the the submesh that was picked */
  12016. subMeshId: number;
  12017. /** If a sprite was picked, this will be the sprite the pick collided with */
  12018. pickedSprite: Nullable<Sprite>;
  12019. /**
  12020. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  12021. */
  12022. originMesh: Nullable<AbstractMesh>;
  12023. /**
  12024. * The ray that was used to perform the picking.
  12025. */
  12026. ray: Nullable<Ray>;
  12027. /**
  12028. * Gets the normal correspodning to the face the pick collided with
  12029. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  12030. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  12031. * @returns The normal correspodning to the face the pick collided with
  12032. */
  12033. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  12034. /**
  12035. * Gets the texture coordinates of where the pick occured
  12036. * @returns the vector containing the coordnates of the texture
  12037. */
  12038. getTextureCoordinates(): Nullable<Vector2>;
  12039. }
  12040. }
  12041. declare module "babylonjs/Events/pointerEvents" {
  12042. import { Nullable } from "babylonjs/types";
  12043. import { Vector2 } from "babylonjs/Maths/math.vector";
  12044. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  12045. import { Ray } from "babylonjs/Culling/ray";
  12046. /**
  12047. * Gather the list of pointer event types as constants.
  12048. */
  12049. export class PointerEventTypes {
  12050. /**
  12051. * The pointerdown event is fired when a pointer becomes active. For mouse, it is fired when the device transitions from no buttons depressed to at least one button depressed. For touch, it is fired when physical contact is made with the digitizer. For pen, it is fired when the stylus makes physical contact with the digitizer.
  12052. */
  12053. static readonly POINTERDOWN: number;
  12054. /**
  12055. * The pointerup event is fired when a pointer is no longer active.
  12056. */
  12057. static readonly POINTERUP: number;
  12058. /**
  12059. * The pointermove event is fired when a pointer changes coordinates.
  12060. */
  12061. static readonly POINTERMOVE: number;
  12062. /**
  12063. * The pointerwheel event is fired when a mouse wheel has been rotated.
  12064. */
  12065. static readonly POINTERWHEEL: number;
  12066. /**
  12067. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  12068. */
  12069. static readonly POINTERPICK: number;
  12070. /**
  12071. * The pointertap event is fired when a the object has been touched and released without drag.
  12072. */
  12073. static readonly POINTERTAP: number;
  12074. /**
  12075. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  12076. */
  12077. static readonly POINTERDOUBLETAP: number;
  12078. }
  12079. /**
  12080. * Base class of pointer info types.
  12081. */
  12082. export class PointerInfoBase {
  12083. /**
  12084. * Defines the type of event (PointerEventTypes)
  12085. */
  12086. type: number;
  12087. /**
  12088. * Defines the related dom event
  12089. */
  12090. event: PointerEvent | MouseWheelEvent;
  12091. /**
  12092. * Instantiates the base class of pointers info.
  12093. * @param type Defines the type of event (PointerEventTypes)
  12094. * @param event Defines the related dom event
  12095. */
  12096. constructor(
  12097. /**
  12098. * Defines the type of event (PointerEventTypes)
  12099. */
  12100. type: number,
  12101. /**
  12102. * Defines the related dom event
  12103. */
  12104. event: PointerEvent | MouseWheelEvent);
  12105. }
  12106. /**
  12107. * This class is used to store pointer related info for the onPrePointerObservable event.
  12108. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  12109. */
  12110. export class PointerInfoPre extends PointerInfoBase {
  12111. /**
  12112. * Ray from a pointer if availible (eg. 6dof controller)
  12113. */
  12114. ray: Nullable<Ray>;
  12115. /**
  12116. * Defines the local position of the pointer on the canvas.
  12117. */
  12118. localPosition: Vector2;
  12119. /**
  12120. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  12121. */
  12122. skipOnPointerObservable: boolean;
  12123. /**
  12124. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  12125. * @param type Defines the type of event (PointerEventTypes)
  12126. * @param event Defines the related dom event
  12127. * @param localX Defines the local x coordinates of the pointer when the event occured
  12128. * @param localY Defines the local y coordinates of the pointer when the event occured
  12129. */
  12130. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  12131. }
  12132. /**
  12133. * This type contains all the data related to a pointer event in Babylon.js.
  12134. * The event member is an instance of PointerEvent for all types except PointerWheel and is of type MouseWheelEvent when type equals PointerWheel. The different event types can be found in the PointerEventTypes class.
  12135. */
  12136. export class PointerInfo extends PointerInfoBase {
  12137. /**
  12138. * Defines the picking info associated to the info (if any)\
  12139. */
  12140. pickInfo: Nullable<PickingInfo>;
  12141. /**
  12142. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  12143. * @param type Defines the type of event (PointerEventTypes)
  12144. * @param event Defines the related dom event
  12145. * @param pickInfo Defines the picking info associated to the info (if any)\
  12146. */
  12147. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  12148. /**
  12149. * Defines the picking info associated to the info (if any)\
  12150. */
  12151. pickInfo: Nullable<PickingInfo>);
  12152. }
  12153. /**
  12154. * Data relating to a touch event on the screen.
  12155. */
  12156. export interface PointerTouch {
  12157. /**
  12158. * X coordinate of touch.
  12159. */
  12160. x: number;
  12161. /**
  12162. * Y coordinate of touch.
  12163. */
  12164. y: number;
  12165. /**
  12166. * Id of touch. Unique for each finger.
  12167. */
  12168. pointerId: number;
  12169. /**
  12170. * Event type passed from DOM.
  12171. */
  12172. type: any;
  12173. }
  12174. }
  12175. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  12176. import { Observable } from "babylonjs/Misc/observable";
  12177. import { Nullable } from "babylonjs/types";
  12178. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12179. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12180. /**
  12181. * Manage the mouse inputs to control the movement of a free camera.
  12182. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12183. */
  12184. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  12185. /**
  12186. * Define if touch is enabled in the mouse input
  12187. */
  12188. touchEnabled: boolean;
  12189. /**
  12190. * Defines the camera the input is attached to.
  12191. */
  12192. camera: FreeCamera;
  12193. /**
  12194. * Defines the buttons associated with the input to handle camera move.
  12195. */
  12196. buttons: number[];
  12197. /**
  12198. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  12199. */
  12200. angularSensibility: number;
  12201. private _pointerInput;
  12202. private _onMouseMove;
  12203. private _observer;
  12204. private previousPosition;
  12205. /**
  12206. * Observable for when a pointer move event occurs containing the move offset
  12207. */
  12208. onPointerMovedObservable: Observable<{
  12209. offsetX: number;
  12210. offsetY: number;
  12211. }>;
  12212. /**
  12213. * @hidden
  12214. * If the camera should be rotated automatically based on pointer movement
  12215. */
  12216. _allowCameraRotation: boolean;
  12217. /**
  12218. * Manage the mouse inputs to control the movement of a free camera.
  12219. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12220. * @param touchEnabled Defines if touch is enabled or not
  12221. */
  12222. constructor(
  12223. /**
  12224. * Define if touch is enabled in the mouse input
  12225. */
  12226. touchEnabled?: boolean);
  12227. /**
  12228. * Attach the input controls to a specific dom element to get the input from.
  12229. * @param element Defines the element the controls should be listened from
  12230. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12231. */
  12232. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12233. /**
  12234. * Called on JS contextmenu event.
  12235. * Override this method to provide functionality.
  12236. */
  12237. protected onContextMenu(evt: PointerEvent): void;
  12238. /**
  12239. * Detach the current controls from the specified dom element.
  12240. * @param element Defines the element to stop listening the inputs from
  12241. */
  12242. detachControl(element: Nullable<HTMLElement>): void;
  12243. /**
  12244. * Gets the class name of the current intput.
  12245. * @returns the class name
  12246. */
  12247. getClassName(): string;
  12248. /**
  12249. * Get the friendly name associated with the input class.
  12250. * @returns the input friendly name
  12251. */
  12252. getSimpleName(): string;
  12253. }
  12254. }
  12255. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  12256. import { Nullable } from "babylonjs/types";
  12257. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12258. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12259. /**
  12260. * Manage the touch inputs to control the movement of a free camera.
  12261. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12262. */
  12263. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  12264. /**
  12265. * Defines the camera the input is attached to.
  12266. */
  12267. camera: FreeCamera;
  12268. /**
  12269. * Defines the touch sensibility for rotation.
  12270. * The higher the faster.
  12271. */
  12272. touchAngularSensibility: number;
  12273. /**
  12274. * Defines the touch sensibility for move.
  12275. * The higher the faster.
  12276. */
  12277. touchMoveSensibility: number;
  12278. private _offsetX;
  12279. private _offsetY;
  12280. private _pointerPressed;
  12281. private _pointerInput;
  12282. private _observer;
  12283. private _onLostFocus;
  12284. /**
  12285. * Attach the input controls to a specific dom element to get the input from.
  12286. * @param element Defines the element the controls should be listened from
  12287. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12288. */
  12289. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12290. /**
  12291. * Detach the current controls from the specified dom element.
  12292. * @param element Defines the element to stop listening the inputs from
  12293. */
  12294. detachControl(element: Nullable<HTMLElement>): void;
  12295. /**
  12296. * Update the current camera state depending on the inputs that have been used this frame.
  12297. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12298. */
  12299. checkInputs(): void;
  12300. /**
  12301. * Gets the class name of the current intput.
  12302. * @returns the class name
  12303. */
  12304. getClassName(): string;
  12305. /**
  12306. * Get the friendly name associated with the input class.
  12307. * @returns the input friendly name
  12308. */
  12309. getSimpleName(): string;
  12310. }
  12311. }
  12312. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  12313. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12314. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  12315. import { FreeCameraMouseInput } from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  12316. import { Nullable } from "babylonjs/types";
  12317. /**
  12318. * Default Inputs manager for the FreeCamera.
  12319. * It groups all the default supported inputs for ease of use.
  12320. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12321. */
  12322. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  12323. /**
  12324. * @hidden
  12325. */
  12326. _mouseInput: Nullable<FreeCameraMouseInput>;
  12327. /**
  12328. * Instantiates a new FreeCameraInputsManager.
  12329. * @param camera Defines the camera the inputs belong to
  12330. */
  12331. constructor(camera: FreeCamera);
  12332. /**
  12333. * Add keyboard input support to the input manager.
  12334. * @returns the current input manager
  12335. */
  12336. addKeyboard(): FreeCameraInputsManager;
  12337. /**
  12338. * Add mouse input support to the input manager.
  12339. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  12340. * @returns the current input manager
  12341. */
  12342. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  12343. /**
  12344. * Removes the mouse input support from the manager
  12345. * @returns the current input manager
  12346. */
  12347. removeMouse(): FreeCameraInputsManager;
  12348. /**
  12349. * Add touch input support to the input manager.
  12350. * @returns the current input manager
  12351. */
  12352. addTouch(): FreeCameraInputsManager;
  12353. /**
  12354. * Remove all attached input methods from a camera
  12355. */
  12356. clear(): void;
  12357. }
  12358. }
  12359. declare module "babylonjs/Cameras/freeCamera" {
  12360. import { Vector3 } from "babylonjs/Maths/math.vector";
  12361. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12362. import { Scene } from "babylonjs/scene";
  12363. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  12364. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  12365. /**
  12366. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12367. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  12368. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12369. */
  12370. export class FreeCamera extends TargetCamera {
  12371. /**
  12372. * Define the collision ellipsoid of the camera.
  12373. * This is helpful to simulate a camera body like the player body around the camera
  12374. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  12375. */
  12376. ellipsoid: Vector3;
  12377. /**
  12378. * Define an offset for the position of the ellipsoid around the camera.
  12379. * This can be helpful to determine the center of the body near the gravity center of the body
  12380. * instead of its head.
  12381. */
  12382. ellipsoidOffset: Vector3;
  12383. /**
  12384. * Enable or disable collisions of the camera with the rest of the scene objects.
  12385. */
  12386. checkCollisions: boolean;
  12387. /**
  12388. * Enable or disable gravity on the camera.
  12389. */
  12390. applyGravity: boolean;
  12391. /**
  12392. * Define the input manager associated to the camera.
  12393. */
  12394. inputs: FreeCameraInputsManager;
  12395. /**
  12396. * Gets the input sensibility for a mouse input. (default is 2000.0)
  12397. * Higher values reduce sensitivity.
  12398. */
  12399. /**
  12400. * Sets the input sensibility for a mouse input. (default is 2000.0)
  12401. * Higher values reduce sensitivity.
  12402. */
  12403. angularSensibility: number;
  12404. /**
  12405. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  12406. */
  12407. keysUp: number[];
  12408. /**
  12409. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  12410. */
  12411. keysDown: number[];
  12412. /**
  12413. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  12414. */
  12415. keysLeft: number[];
  12416. /**
  12417. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  12418. */
  12419. keysRight: number[];
  12420. /**
  12421. * Event raised when the camera collide with a mesh in the scene.
  12422. */
  12423. onCollide: (collidedMesh: AbstractMesh) => void;
  12424. private _collider;
  12425. private _needMoveForGravity;
  12426. private _oldPosition;
  12427. private _diffPosition;
  12428. private _newPosition;
  12429. /** @hidden */
  12430. _localDirection: Vector3;
  12431. /** @hidden */
  12432. _transformedDirection: Vector3;
  12433. /**
  12434. * Instantiates a Free Camera.
  12435. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12436. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  12437. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12438. * @param name Define the name of the camera in the scene
  12439. * @param position Define the start position of the camera in the scene
  12440. * @param scene Define the scene the camera belongs to
  12441. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  12442. */
  12443. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  12444. /**
  12445. * Attached controls to the current camera.
  12446. * @param element Defines the element the controls should be listened from
  12447. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12448. */
  12449. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12450. /**
  12451. * Detach the current controls from the camera.
  12452. * The camera will stop reacting to inputs.
  12453. * @param element Defines the element to stop listening the inputs from
  12454. */
  12455. detachControl(element: HTMLElement): void;
  12456. private _collisionMask;
  12457. /**
  12458. * Define a collision mask to limit the list of object the camera can collide with
  12459. */
  12460. collisionMask: number;
  12461. /** @hidden */
  12462. _collideWithWorld(displacement: Vector3): void;
  12463. private _onCollisionPositionChange;
  12464. /** @hidden */
  12465. _checkInputs(): void;
  12466. /** @hidden */
  12467. _decideIfNeedsToMove(): boolean;
  12468. /** @hidden */
  12469. _updatePosition(): void;
  12470. /**
  12471. * Destroy the camera and release the current resources hold by it.
  12472. */
  12473. dispose(): void;
  12474. /**
  12475. * Gets the current object class name.
  12476. * @return the class name
  12477. */
  12478. getClassName(): string;
  12479. }
  12480. }
  12481. declare module "babylonjs/Gamepads/gamepad" {
  12482. import { Observable } from "babylonjs/Misc/observable";
  12483. /**
  12484. * Represents a gamepad control stick position
  12485. */
  12486. export class StickValues {
  12487. /**
  12488. * The x component of the control stick
  12489. */
  12490. x: number;
  12491. /**
  12492. * The y component of the control stick
  12493. */
  12494. y: number;
  12495. /**
  12496. * Initializes the gamepad x and y control stick values
  12497. * @param x The x component of the gamepad control stick value
  12498. * @param y The y component of the gamepad control stick value
  12499. */
  12500. constructor(
  12501. /**
  12502. * The x component of the control stick
  12503. */
  12504. x: number,
  12505. /**
  12506. * The y component of the control stick
  12507. */
  12508. y: number);
  12509. }
  12510. /**
  12511. * An interface which manages callbacks for gamepad button changes
  12512. */
  12513. export interface GamepadButtonChanges {
  12514. /**
  12515. * Called when a gamepad has been changed
  12516. */
  12517. changed: boolean;
  12518. /**
  12519. * Called when a gamepad press event has been triggered
  12520. */
  12521. pressChanged: boolean;
  12522. /**
  12523. * Called when a touch event has been triggered
  12524. */
  12525. touchChanged: boolean;
  12526. /**
  12527. * Called when a value has changed
  12528. */
  12529. valueChanged: boolean;
  12530. }
  12531. /**
  12532. * Represents a gamepad
  12533. */
  12534. export class Gamepad {
  12535. /**
  12536. * The id of the gamepad
  12537. */
  12538. id: string;
  12539. /**
  12540. * The index of the gamepad
  12541. */
  12542. index: number;
  12543. /**
  12544. * The browser gamepad
  12545. */
  12546. browserGamepad: any;
  12547. /**
  12548. * Specifies what type of gamepad this represents
  12549. */
  12550. type: number;
  12551. private _leftStick;
  12552. private _rightStick;
  12553. /** @hidden */
  12554. _isConnected: boolean;
  12555. private _leftStickAxisX;
  12556. private _leftStickAxisY;
  12557. private _rightStickAxisX;
  12558. private _rightStickAxisY;
  12559. /**
  12560. * Triggered when the left control stick has been changed
  12561. */
  12562. private _onleftstickchanged;
  12563. /**
  12564. * Triggered when the right control stick has been changed
  12565. */
  12566. private _onrightstickchanged;
  12567. /**
  12568. * Represents a gamepad controller
  12569. */
  12570. static GAMEPAD: number;
  12571. /**
  12572. * Represents a generic controller
  12573. */
  12574. static GENERIC: number;
  12575. /**
  12576. * Represents an XBox controller
  12577. */
  12578. static XBOX: number;
  12579. /**
  12580. * Represents a pose-enabled controller
  12581. */
  12582. static POSE_ENABLED: number;
  12583. /**
  12584. * Represents an Dual Shock controller
  12585. */
  12586. static DUALSHOCK: number;
  12587. /**
  12588. * Specifies whether the left control stick should be Y-inverted
  12589. */
  12590. protected _invertLeftStickY: boolean;
  12591. /**
  12592. * Specifies if the gamepad has been connected
  12593. */
  12594. readonly isConnected: boolean;
  12595. /**
  12596. * Initializes the gamepad
  12597. * @param id The id of the gamepad
  12598. * @param index The index of the gamepad
  12599. * @param browserGamepad The browser gamepad
  12600. * @param leftStickX The x component of the left joystick
  12601. * @param leftStickY The y component of the left joystick
  12602. * @param rightStickX The x component of the right joystick
  12603. * @param rightStickY The y component of the right joystick
  12604. */
  12605. constructor(
  12606. /**
  12607. * The id of the gamepad
  12608. */
  12609. id: string,
  12610. /**
  12611. * The index of the gamepad
  12612. */
  12613. index: number,
  12614. /**
  12615. * The browser gamepad
  12616. */
  12617. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12618. /**
  12619. * Callback triggered when the left joystick has changed
  12620. * @param callback
  12621. */
  12622. onleftstickchanged(callback: (values: StickValues) => void): void;
  12623. /**
  12624. * Callback triggered when the right joystick has changed
  12625. * @param callback
  12626. */
  12627. onrightstickchanged(callback: (values: StickValues) => void): void;
  12628. /**
  12629. * Gets the left joystick
  12630. */
  12631. /**
  12632. * Sets the left joystick values
  12633. */
  12634. leftStick: StickValues;
  12635. /**
  12636. * Gets the right joystick
  12637. */
  12638. /**
  12639. * Sets the right joystick value
  12640. */
  12641. rightStick: StickValues;
  12642. /**
  12643. * Updates the gamepad joystick positions
  12644. */
  12645. update(): void;
  12646. /**
  12647. * Disposes the gamepad
  12648. */
  12649. dispose(): void;
  12650. }
  12651. /**
  12652. * Represents a generic gamepad
  12653. */
  12654. export class GenericPad extends Gamepad {
  12655. private _buttons;
  12656. private _onbuttondown;
  12657. private _onbuttonup;
  12658. /**
  12659. * Observable triggered when a button has been pressed
  12660. */
  12661. onButtonDownObservable: Observable<number>;
  12662. /**
  12663. * Observable triggered when a button has been released
  12664. */
  12665. onButtonUpObservable: Observable<number>;
  12666. /**
  12667. * Callback triggered when a button has been pressed
  12668. * @param callback Called when a button has been pressed
  12669. */
  12670. onbuttondown(callback: (buttonPressed: number) => void): void;
  12671. /**
  12672. * Callback triggered when a button has been released
  12673. * @param callback Called when a button has been released
  12674. */
  12675. onbuttonup(callback: (buttonReleased: number) => void): void;
  12676. /**
  12677. * Initializes the generic gamepad
  12678. * @param id The id of the generic gamepad
  12679. * @param index The index of the generic gamepad
  12680. * @param browserGamepad The browser gamepad
  12681. */
  12682. constructor(id: string, index: number, browserGamepad: any);
  12683. private _setButtonValue;
  12684. /**
  12685. * Updates the generic gamepad
  12686. */
  12687. update(): void;
  12688. /**
  12689. * Disposes the generic gamepad
  12690. */
  12691. dispose(): void;
  12692. }
  12693. }
  12694. declare module "babylonjs/Engines/Extensions/engine.rawTexture" {
  12695. import { Nullable } from "babylonjs/types";
  12696. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  12697. import { Scene } from "babylonjs/scene";
  12698. module "babylonjs/Engines/engine" {
  12699. interface Engine {
  12700. /**
  12701. * Creates a raw texture
  12702. * @param data defines the data to store in the texture
  12703. * @param width defines the width of the texture
  12704. * @param height defines the height of the texture
  12705. * @param format defines the format of the data
  12706. * @param generateMipMaps defines if the engine should generate the mip levels
  12707. * @param invertY defines if data must be stored with Y axis inverted
  12708. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  12709. * @param compression defines the compression used (null by default)
  12710. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12711. * @returns the raw texture inside an InternalTexture
  12712. */
  12713. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  12714. /**
  12715. * Update a raw texture
  12716. * @param texture defines the texture to update
  12717. * @param data defines the data to store in the texture
  12718. * @param format defines the format of the data
  12719. * @param invertY defines if data must be stored with Y axis inverted
  12720. */
  12721. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12722. /**
  12723. * Update a raw texture
  12724. * @param texture defines the texture to update
  12725. * @param data defines the data to store in the texture
  12726. * @param format defines the format of the data
  12727. * @param invertY defines if data must be stored with Y axis inverted
  12728. * @param compression defines the compression used (null by default)
  12729. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12730. */
  12731. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  12732. /**
  12733. * Creates a new raw cube texture
  12734. * @param data defines the array of data to use to create each face
  12735. * @param size defines the size of the textures
  12736. * @param format defines the format of the data
  12737. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12738. * @param generateMipMaps defines if the engine should generate the mip levels
  12739. * @param invertY defines if data must be stored with Y axis inverted
  12740. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12741. * @param compression defines the compression used (null by default)
  12742. * @returns the cube texture as an InternalTexture
  12743. */
  12744. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  12745. /**
  12746. * Update a raw cube texture
  12747. * @param texture defines the texture to udpdate
  12748. * @param data defines the data to store
  12749. * @param format defines the data format
  12750. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12751. * @param invertY defines if data must be stored with Y axis inverted
  12752. */
  12753. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  12754. /**
  12755. * Update a raw cube texture
  12756. * @param texture defines the texture to udpdate
  12757. * @param data defines the data to store
  12758. * @param format defines the data format
  12759. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12760. * @param invertY defines if data must be stored with Y axis inverted
  12761. * @param compression defines the compression used (null by default)
  12762. */
  12763. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  12764. /**
  12765. * Update a raw cube texture
  12766. * @param texture defines the texture to udpdate
  12767. * @param data defines the data to store
  12768. * @param format defines the data format
  12769. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12770. * @param invertY defines if data must be stored with Y axis inverted
  12771. * @param compression defines the compression used (null by default)
  12772. * @param level defines which level of the texture to update
  12773. */
  12774. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  12775. /**
  12776. * Creates a new raw cube texture from a specified url
  12777. * @param url defines the url where the data is located
  12778. * @param scene defines the current scene
  12779. * @param size defines the size of the textures
  12780. * @param format defines the format of the data
  12781. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12782. * @param noMipmap defines if the engine should avoid generating the mip levels
  12783. * @param callback defines a callback used to extract texture data from loaded data
  12784. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12785. * @param onLoad defines a callback called when texture is loaded
  12786. * @param onError defines a callback called if there is an error
  12787. * @returns the cube texture as an InternalTexture
  12788. */
  12789. createRawCubeTextureFromUrl(url: string, scene: Scene, size: number, format: number, type: number, noMipmap: boolean, callback: (ArrayBuffer: ArrayBuffer) => Nullable<ArrayBufferView[]>, mipmapGenerator: Nullable<((faces: ArrayBufferView[]) => ArrayBufferView[][])>, onLoad: Nullable<() => void>, onError: Nullable<(message?: string, exception?: any) => void>): InternalTexture;
  12790. /**
  12791. * Creates a new raw cube texture from a specified url
  12792. * @param url defines the url where the data is located
  12793. * @param scene defines the current scene
  12794. * @param size defines the size of the textures
  12795. * @param format defines the format of the data
  12796. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12797. * @param noMipmap defines if the engine should avoid generating the mip levels
  12798. * @param callback defines a callback used to extract texture data from loaded data
  12799. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12800. * @param onLoad defines a callback called when texture is loaded
  12801. * @param onError defines a callback called if there is an error
  12802. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12803. * @param invertY defines if data must be stored with Y axis inverted
  12804. * @returns the cube texture as an InternalTexture
  12805. */
  12806. createRawCubeTextureFromUrl(url: string, scene: Scene, size: number, format: number, type: number, noMipmap: boolean, callback: (ArrayBuffer: ArrayBuffer) => Nullable<ArrayBufferView[]>, mipmapGenerator: Nullable<((faces: ArrayBufferView[]) => ArrayBufferView[][])>, onLoad: Nullable<() => void>, onError: Nullable<(message?: string, exception?: any) => void>, samplingMode: number, invertY: boolean): InternalTexture;
  12807. /**
  12808. * Creates a new raw 3D texture
  12809. * @param data defines the data used to create the texture
  12810. * @param width defines the width of the texture
  12811. * @param height defines the height of the texture
  12812. * @param depth defines the depth of the texture
  12813. * @param format defines the format of the texture
  12814. * @param generateMipMaps defines if the engine must generate mip levels
  12815. * @param invertY defines if data must be stored with Y axis inverted
  12816. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12817. * @param compression defines the compressed used (can be null)
  12818. * @param textureType defines the compressed used (can be null)
  12819. * @returns a new raw 3D texture (stored in an InternalTexture)
  12820. */
  12821. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  12822. /**
  12823. * Update a raw 3D texture
  12824. * @param texture defines the texture to update
  12825. * @param data defines the data to store
  12826. * @param format defines the data format
  12827. * @param invertY defines if data must be stored with Y axis inverted
  12828. */
  12829. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12830. /**
  12831. * Update a raw 3D texture
  12832. * @param texture defines the texture to update
  12833. * @param data defines the data to store
  12834. * @param format defines the data format
  12835. * @param invertY defines if data must be stored with Y axis inverted
  12836. * @param compression defines the used compression (can be null)
  12837. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  12838. */
  12839. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  12840. /**
  12841. * Creates a new raw 2D array texture
  12842. * @param data defines the data used to create the texture
  12843. * @param width defines the width of the texture
  12844. * @param height defines the height of the texture
  12845. * @param depth defines the number of layers of the texture
  12846. * @param format defines the format of the texture
  12847. * @param generateMipMaps defines if the engine must generate mip levels
  12848. * @param invertY defines if data must be stored with Y axis inverted
  12849. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12850. * @param compression defines the compressed used (can be null)
  12851. * @param textureType defines the compressed used (can be null)
  12852. * @returns a new raw 2D array texture (stored in an InternalTexture)
  12853. */
  12854. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  12855. /**
  12856. * Update a raw 2D array texture
  12857. * @param texture defines the texture to update
  12858. * @param data defines the data to store
  12859. * @param format defines the data format
  12860. * @param invertY defines if data must be stored with Y axis inverted
  12861. */
  12862. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12863. /**
  12864. * Update a raw 2D array texture
  12865. * @param texture defines the texture to update
  12866. * @param data defines the data to store
  12867. * @param format defines the data format
  12868. * @param invertY defines if data must be stored with Y axis inverted
  12869. * @param compression defines the used compression (can be null)
  12870. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  12871. */
  12872. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  12873. }
  12874. }
  12875. }
  12876. declare module "babylonjs/Materials/Textures/rawTexture" {
  12877. import { Scene } from "babylonjs/scene";
  12878. import { Texture } from "babylonjs/Materials/Textures/texture";
  12879. import "babylonjs/Engines/Extensions/engine.rawTexture";
  12880. /**
  12881. * Raw texture can help creating a texture directly from an array of data.
  12882. * This can be super useful if you either get the data from an uncompressed source or
  12883. * if you wish to create your texture pixel by pixel.
  12884. */
  12885. export class RawTexture extends Texture {
  12886. /**
  12887. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12888. */
  12889. format: number;
  12890. private _engine;
  12891. /**
  12892. * Instantiates a new RawTexture.
  12893. * Raw texture can help creating a texture directly from an array of data.
  12894. * This can be super useful if you either get the data from an uncompressed source or
  12895. * if you wish to create your texture pixel by pixel.
  12896. * @param data define the array of data to use to create the texture
  12897. * @param width define the width of the texture
  12898. * @param height define the height of the texture
  12899. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12900. * @param scene define the scene the texture belongs to
  12901. * @param generateMipMaps define whether mip maps should be generated or not
  12902. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12903. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12904. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12905. */
  12906. constructor(data: ArrayBufferView, width: number, height: number,
  12907. /**
  12908. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12909. */
  12910. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  12911. /**
  12912. * Updates the texture underlying data.
  12913. * @param data Define the new data of the texture
  12914. */
  12915. update(data: ArrayBufferView): void;
  12916. /**
  12917. * Creates a luminance texture from some data.
  12918. * @param data Define the texture data
  12919. * @param width Define the width of the texture
  12920. * @param height Define the height of the texture
  12921. * @param scene Define the scene the texture belongs to
  12922. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12923. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12924. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12925. * @returns the luminance texture
  12926. */
  12927. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12928. /**
  12929. * Creates a luminance alpha texture from some data.
  12930. * @param data Define the texture data
  12931. * @param width Define the width of the texture
  12932. * @param height Define the height of the texture
  12933. * @param scene Define the scene the texture belongs to
  12934. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12935. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12936. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12937. * @returns the luminance alpha texture
  12938. */
  12939. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12940. /**
  12941. * Creates an alpha texture from some data.
  12942. * @param data Define the texture data
  12943. * @param width Define the width of the texture
  12944. * @param height Define the height of the texture
  12945. * @param scene Define the scene the texture belongs to
  12946. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12947. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12948. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12949. * @returns the alpha texture
  12950. */
  12951. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12952. /**
  12953. * Creates a RGB texture from some data.
  12954. * @param data Define the texture data
  12955. * @param width Define the width of the texture
  12956. * @param height Define the height of the texture
  12957. * @param scene Define the scene the texture belongs to
  12958. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12959. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12960. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12961. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12962. * @returns the RGB alpha texture
  12963. */
  12964. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12965. /**
  12966. * Creates a RGBA texture from some data.
  12967. * @param data Define the texture data
  12968. * @param width Define the width of the texture
  12969. * @param height Define the height of the texture
  12970. * @param scene Define the scene the texture belongs to
  12971. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12972. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12973. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12974. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12975. * @returns the RGBA texture
  12976. */
  12977. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12978. /**
  12979. * Creates a R texture from some data.
  12980. * @param data Define the texture data
  12981. * @param width Define the width of the texture
  12982. * @param height Define the height of the texture
  12983. * @param scene Define the scene the texture belongs to
  12984. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12985. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12986. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12987. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12988. * @returns the R texture
  12989. */
  12990. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12991. }
  12992. }
  12993. declare module "babylonjs/Maths/math.size" {
  12994. /**
  12995. * Interface for the size containing width and height
  12996. */
  12997. export interface ISize {
  12998. /**
  12999. * Width
  13000. */
  13001. width: number;
  13002. /**
  13003. * Heighht
  13004. */
  13005. height: number;
  13006. }
  13007. /**
  13008. * Size containing widht and height
  13009. */
  13010. export class Size implements ISize {
  13011. /**
  13012. * Width
  13013. */
  13014. width: number;
  13015. /**
  13016. * Height
  13017. */
  13018. height: number;
  13019. /**
  13020. * Creates a Size object from the given width and height (floats).
  13021. * @param width width of the new size
  13022. * @param height height of the new size
  13023. */
  13024. constructor(width: number, height: number);
  13025. /**
  13026. * Returns a string with the Size width and height
  13027. * @returns a string with the Size width and height
  13028. */
  13029. toString(): string;
  13030. /**
  13031. * "Size"
  13032. * @returns the string "Size"
  13033. */
  13034. getClassName(): string;
  13035. /**
  13036. * Returns the Size hash code.
  13037. * @returns a hash code for a unique width and height
  13038. */
  13039. getHashCode(): number;
  13040. /**
  13041. * Updates the current size from the given one.
  13042. * @param src the given size
  13043. */
  13044. copyFrom(src: Size): void;
  13045. /**
  13046. * Updates in place the current Size from the given floats.
  13047. * @param width width of the new size
  13048. * @param height height of the new size
  13049. * @returns the updated Size.
  13050. */
  13051. copyFromFloats(width: number, height: number): Size;
  13052. /**
  13053. * Updates in place the current Size from the given floats.
  13054. * @param width width to set
  13055. * @param height height to set
  13056. * @returns the updated Size.
  13057. */
  13058. set(width: number, height: number): Size;
  13059. /**
  13060. * Multiplies the width and height by numbers
  13061. * @param w factor to multiple the width by
  13062. * @param h factor to multiple the height by
  13063. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  13064. */
  13065. multiplyByFloats(w: number, h: number): Size;
  13066. /**
  13067. * Clones the size
  13068. * @returns a new Size copied from the given one.
  13069. */
  13070. clone(): Size;
  13071. /**
  13072. * True if the current Size and the given one width and height are strictly equal.
  13073. * @param other the other size to compare against
  13074. * @returns True if the current Size and the given one width and height are strictly equal.
  13075. */
  13076. equals(other: Size): boolean;
  13077. /**
  13078. * The surface of the Size : width * height (float).
  13079. */
  13080. readonly surface: number;
  13081. /**
  13082. * Create a new size of zero
  13083. * @returns a new Size set to (0.0, 0.0)
  13084. */
  13085. static Zero(): Size;
  13086. /**
  13087. * Sums the width and height of two sizes
  13088. * @param otherSize size to add to this size
  13089. * @returns a new Size set as the addition result of the current Size and the given one.
  13090. */
  13091. add(otherSize: Size): Size;
  13092. /**
  13093. * Subtracts the width and height of two
  13094. * @param otherSize size to subtract to this size
  13095. * @returns a new Size set as the subtraction result of the given one from the current Size.
  13096. */
  13097. subtract(otherSize: Size): Size;
  13098. /**
  13099. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  13100. * @param start starting size to lerp between
  13101. * @param end end size to lerp between
  13102. * @param amount amount to lerp between the start and end values
  13103. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  13104. */
  13105. static Lerp(start: Size, end: Size, amount: number): Size;
  13106. }
  13107. }
  13108. declare module "babylonjs/Animations/runtimeAnimation" {
  13109. import { Animation, _IAnimationState } from "babylonjs/Animations/animation";
  13110. import { Animatable } from "babylonjs/Animations/animatable";
  13111. import { Scene } from "babylonjs/scene";
  13112. /**
  13113. * Defines a runtime animation
  13114. */
  13115. export class RuntimeAnimation {
  13116. private _events;
  13117. /**
  13118. * The current frame of the runtime animation
  13119. */
  13120. private _currentFrame;
  13121. /**
  13122. * The animation used by the runtime animation
  13123. */
  13124. private _animation;
  13125. /**
  13126. * The target of the runtime animation
  13127. */
  13128. private _target;
  13129. /**
  13130. * The initiating animatable
  13131. */
  13132. private _host;
  13133. /**
  13134. * The original value of the runtime animation
  13135. */
  13136. private _originalValue;
  13137. /**
  13138. * The original blend value of the runtime animation
  13139. */
  13140. private _originalBlendValue;
  13141. /**
  13142. * The offsets cache of the runtime animation
  13143. */
  13144. private _offsetsCache;
  13145. /**
  13146. * The high limits cache of the runtime animation
  13147. */
  13148. private _highLimitsCache;
  13149. /**
  13150. * Specifies if the runtime animation has been stopped
  13151. */
  13152. private _stopped;
  13153. /**
  13154. * The blending factor of the runtime animation
  13155. */
  13156. private _blendingFactor;
  13157. /**
  13158. * The BabylonJS scene
  13159. */
  13160. private _scene;
  13161. /**
  13162. * The current value of the runtime animation
  13163. */
  13164. private _currentValue;
  13165. /** @hidden */
  13166. _animationState: _IAnimationState;
  13167. /**
  13168. * The active target of the runtime animation
  13169. */
  13170. private _activeTargets;
  13171. private _currentActiveTarget;
  13172. private _directTarget;
  13173. /**
  13174. * The target path of the runtime animation
  13175. */
  13176. private _targetPath;
  13177. /**
  13178. * The weight of the runtime animation
  13179. */
  13180. private _weight;
  13181. /**
  13182. * The ratio offset of the runtime animation
  13183. */
  13184. private _ratioOffset;
  13185. /**
  13186. * The previous delay of the runtime animation
  13187. */
  13188. private _previousDelay;
  13189. /**
  13190. * The previous ratio of the runtime animation
  13191. */
  13192. private _previousRatio;
  13193. private _enableBlending;
  13194. private _keys;
  13195. private _minFrame;
  13196. private _maxFrame;
  13197. private _minValue;
  13198. private _maxValue;
  13199. private _targetIsArray;
  13200. /**
  13201. * Gets the current frame of the runtime animation
  13202. */
  13203. readonly currentFrame: number;
  13204. /**
  13205. * Gets the weight of the runtime animation
  13206. */
  13207. readonly weight: number;
  13208. /**
  13209. * Gets the current value of the runtime animation
  13210. */
  13211. readonly currentValue: any;
  13212. /**
  13213. * Gets the target path of the runtime animation
  13214. */
  13215. readonly targetPath: string;
  13216. /**
  13217. * Gets the actual target of the runtime animation
  13218. */
  13219. readonly target: any;
  13220. /** @hidden */
  13221. _onLoop: () => void;
  13222. /**
  13223. * Create a new RuntimeAnimation object
  13224. * @param target defines the target of the animation
  13225. * @param animation defines the source animation object
  13226. * @param scene defines the hosting scene
  13227. * @param host defines the initiating Animatable
  13228. */
  13229. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  13230. private _preparePath;
  13231. /**
  13232. * Gets the animation from the runtime animation
  13233. */
  13234. readonly animation: Animation;
  13235. /**
  13236. * Resets the runtime animation to the beginning
  13237. * @param restoreOriginal defines whether to restore the target property to the original value
  13238. */
  13239. reset(restoreOriginal?: boolean): void;
  13240. /**
  13241. * Specifies if the runtime animation is stopped
  13242. * @returns Boolean specifying if the runtime animation is stopped
  13243. */
  13244. isStopped(): boolean;
  13245. /**
  13246. * Disposes of the runtime animation
  13247. */
  13248. dispose(): void;
  13249. /**
  13250. * Apply the interpolated value to the target
  13251. * @param currentValue defines the value computed by the animation
  13252. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  13253. */
  13254. setValue(currentValue: any, weight: number): void;
  13255. private _getOriginalValues;
  13256. private _setValue;
  13257. /**
  13258. * Gets the loop pmode of the runtime animation
  13259. * @returns Loop Mode
  13260. */
  13261. private _getCorrectLoopMode;
  13262. /**
  13263. * Move the current animation to a given frame
  13264. * @param frame defines the frame to move to
  13265. */
  13266. goToFrame(frame: number): void;
  13267. /**
  13268. * @hidden Internal use only
  13269. */
  13270. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  13271. /**
  13272. * Execute the current animation
  13273. * @param delay defines the delay to add to the current frame
  13274. * @param from defines the lower bound of the animation range
  13275. * @param to defines the upper bound of the animation range
  13276. * @param loop defines if the current animation must loop
  13277. * @param speedRatio defines the current speed ratio
  13278. * @param weight defines the weight of the animation (default is -1 so no weight)
  13279. * @param onLoop optional callback called when animation loops
  13280. * @returns a boolean indicating if the animation is running
  13281. */
  13282. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  13283. }
  13284. }
  13285. declare module "babylonjs/Animations/animatable" {
  13286. import { Animation } from "babylonjs/Animations/animation";
  13287. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  13288. import { Nullable } from "babylonjs/types";
  13289. import { Observable } from "babylonjs/Misc/observable";
  13290. import { Scene } from "babylonjs/scene";
  13291. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  13292. import { Node } from "babylonjs/node";
  13293. /**
  13294. * Class used to store an actual running animation
  13295. */
  13296. export class Animatable {
  13297. /** defines the target object */
  13298. target: any;
  13299. /** defines the starting frame number (default is 0) */
  13300. fromFrame: number;
  13301. /** defines the ending frame number (default is 100) */
  13302. toFrame: number;
  13303. /** defines if the animation must loop (default is false) */
  13304. loopAnimation: boolean;
  13305. /** defines a callback to call when animation ends if it is not looping */
  13306. onAnimationEnd?: (() => void) | null | undefined;
  13307. /** defines a callback to call when animation loops */
  13308. onAnimationLoop?: (() => void) | null | undefined;
  13309. private _localDelayOffset;
  13310. private _pausedDelay;
  13311. private _runtimeAnimations;
  13312. private _paused;
  13313. private _scene;
  13314. private _speedRatio;
  13315. private _weight;
  13316. private _syncRoot;
  13317. /**
  13318. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  13319. * This will only apply for non looping animation (default is true)
  13320. */
  13321. disposeOnEnd: boolean;
  13322. /**
  13323. * Gets a boolean indicating if the animation has started
  13324. */
  13325. animationStarted: boolean;
  13326. /**
  13327. * Observer raised when the animation ends
  13328. */
  13329. onAnimationEndObservable: Observable<Animatable>;
  13330. /**
  13331. * Observer raised when the animation loops
  13332. */
  13333. onAnimationLoopObservable: Observable<Animatable>;
  13334. /**
  13335. * Gets the root Animatable used to synchronize and normalize animations
  13336. */
  13337. readonly syncRoot: Nullable<Animatable>;
  13338. /**
  13339. * Gets the current frame of the first RuntimeAnimation
  13340. * Used to synchronize Animatables
  13341. */
  13342. readonly masterFrame: number;
  13343. /**
  13344. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  13345. */
  13346. weight: number;
  13347. /**
  13348. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  13349. */
  13350. speedRatio: number;
  13351. /**
  13352. * Creates a new Animatable
  13353. * @param scene defines the hosting scene
  13354. * @param target defines the target object
  13355. * @param fromFrame defines the starting frame number (default is 0)
  13356. * @param toFrame defines the ending frame number (default is 100)
  13357. * @param loopAnimation defines if the animation must loop (default is false)
  13358. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  13359. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  13360. * @param animations defines a group of animation to add to the new Animatable
  13361. * @param onAnimationLoop defines a callback to call when animation loops
  13362. */
  13363. constructor(scene: Scene,
  13364. /** defines the target object */
  13365. target: any,
  13366. /** defines the starting frame number (default is 0) */
  13367. fromFrame?: number,
  13368. /** defines the ending frame number (default is 100) */
  13369. toFrame?: number,
  13370. /** defines if the animation must loop (default is false) */
  13371. loopAnimation?: boolean, speedRatio?: number,
  13372. /** defines a callback to call when animation ends if it is not looping */
  13373. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  13374. /** defines a callback to call when animation loops */
  13375. onAnimationLoop?: (() => void) | null | undefined);
  13376. /**
  13377. * Synchronize and normalize current Animatable with a source Animatable
  13378. * This is useful when using animation weights and when animations are not of the same length
  13379. * @param root defines the root Animatable to synchronize with
  13380. * @returns the current Animatable
  13381. */
  13382. syncWith(root: Animatable): Animatable;
  13383. /**
  13384. * Gets the list of runtime animations
  13385. * @returns an array of RuntimeAnimation
  13386. */
  13387. getAnimations(): RuntimeAnimation[];
  13388. /**
  13389. * Adds more animations to the current animatable
  13390. * @param target defines the target of the animations
  13391. * @param animations defines the new animations to add
  13392. */
  13393. appendAnimations(target: any, animations: Animation[]): void;
  13394. /**
  13395. * Gets the source animation for a specific property
  13396. * @param property defines the propertyu to look for
  13397. * @returns null or the source animation for the given property
  13398. */
  13399. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  13400. /**
  13401. * Gets the runtime animation for a specific property
  13402. * @param property defines the propertyu to look for
  13403. * @returns null or the runtime animation for the given property
  13404. */
  13405. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  13406. /**
  13407. * Resets the animatable to its original state
  13408. */
  13409. reset(): void;
  13410. /**
  13411. * Allows the animatable to blend with current running animations
  13412. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13413. * @param blendingSpeed defines the blending speed to use
  13414. */
  13415. enableBlending(blendingSpeed: number): void;
  13416. /**
  13417. * Disable animation blending
  13418. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13419. */
  13420. disableBlending(): void;
  13421. /**
  13422. * Jump directly to a given frame
  13423. * @param frame defines the frame to jump to
  13424. */
  13425. goToFrame(frame: number): void;
  13426. /**
  13427. * Pause the animation
  13428. */
  13429. pause(): void;
  13430. /**
  13431. * Restart the animation
  13432. */
  13433. restart(): void;
  13434. private _raiseOnAnimationEnd;
  13435. /**
  13436. * Stop and delete the current animation
  13437. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  13438. * @param targetMask - a function that determines if the animation should be stopped based on its target (all animations will be stopped if both this and animationName are empty)
  13439. */
  13440. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  13441. /**
  13442. * Wait asynchronously for the animation to end
  13443. * @returns a promise which will be fullfilled when the animation ends
  13444. */
  13445. waitAsync(): Promise<Animatable>;
  13446. /** @hidden */
  13447. _animate(delay: number): boolean;
  13448. }
  13449. module "babylonjs/scene" {
  13450. interface Scene {
  13451. /** @hidden */
  13452. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  13453. /** @hidden */
  13454. _processLateAnimationBindingsForMatrices(holder: {
  13455. totalWeight: number;
  13456. animations: RuntimeAnimation[];
  13457. originalValue: Matrix;
  13458. }): any;
  13459. /** @hidden */
  13460. _processLateAnimationBindingsForQuaternions(holder: {
  13461. totalWeight: number;
  13462. animations: RuntimeAnimation[];
  13463. originalValue: Quaternion;
  13464. }, refQuaternion: Quaternion): Quaternion;
  13465. /** @hidden */
  13466. _processLateAnimationBindings(): void;
  13467. /**
  13468. * Will start the animation sequence of a given target
  13469. * @param target defines the target
  13470. * @param from defines from which frame should animation start
  13471. * @param to defines until which frame should animation run.
  13472. * @param weight defines the weight to apply to the animation (1.0 by default)
  13473. * @param loop defines if the animation loops
  13474. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13475. * @param onAnimationEnd defines the function to be executed when the animation ends
  13476. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13477. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13478. * @param onAnimationLoop defines the callback to call when an animation loops
  13479. * @returns the animatable object created for this animation
  13480. */
  13481. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13482. /**
  13483. * Will start the animation sequence of a given target
  13484. * @param target defines the target
  13485. * @param from defines from which frame should animation start
  13486. * @param to defines until which frame should animation run.
  13487. * @param loop defines if the animation loops
  13488. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13489. * @param onAnimationEnd defines the function to be executed when the animation ends
  13490. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13491. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13492. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  13493. * @param onAnimationLoop defines the callback to call when an animation loops
  13494. * @returns the animatable object created for this animation
  13495. */
  13496. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13497. /**
  13498. * Will start the animation sequence of a given target and its hierarchy
  13499. * @param target defines the target
  13500. * @param directDescendantsOnly if true only direct descendants will be used, if false direct and also indirect (children of children, an so on in a recursive manner) descendants will be used.
  13501. * @param from defines from which frame should animation start
  13502. * @param to defines until which frame should animation run.
  13503. * @param loop defines if the animation loops
  13504. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13505. * @param onAnimationEnd defines the function to be executed when the animation ends
  13506. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13507. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13508. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13509. * @param onAnimationLoop defines the callback to call when an animation loops
  13510. * @returns the list of created animatables
  13511. */
  13512. beginHierarchyAnimation(target: any, directDescendantsOnly: boolean, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable[];
  13513. /**
  13514. * Begin a new animation on a given node
  13515. * @param target defines the target where the animation will take place
  13516. * @param animations defines the list of animations to start
  13517. * @param from defines the initial value
  13518. * @param to defines the final value
  13519. * @param loop defines if you want animation to loop (off by default)
  13520. * @param speedRatio defines the speed ratio to apply to all animations
  13521. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13522. * @param onAnimationLoop defines the callback to call when an animation loops
  13523. * @returns the list of created animatables
  13524. */
  13525. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  13526. /**
  13527. * Begin a new animation on a given node and its hierarchy
  13528. * @param target defines the root node where the animation will take place
  13529. * @param directDescendantsOnly if true only direct descendants will be used, if false direct and also indirect (children of children, an so on in a recursive manner) descendants will be used.
  13530. * @param animations defines the list of animations to start
  13531. * @param from defines the initial value
  13532. * @param to defines the final value
  13533. * @param loop defines if you want animation to loop (off by default)
  13534. * @param speedRatio defines the speed ratio to apply to all animations
  13535. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13536. * @param onAnimationLoop defines the callback to call when an animation loops
  13537. * @returns the list of animatables created for all nodes
  13538. */
  13539. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  13540. /**
  13541. * Gets the animatable associated with a specific target
  13542. * @param target defines the target of the animatable
  13543. * @returns the required animatable if found
  13544. */
  13545. getAnimatableByTarget(target: any): Nullable<Animatable>;
  13546. /**
  13547. * Gets all animatables associated with a given target
  13548. * @param target defines the target to look animatables for
  13549. * @returns an array of Animatables
  13550. */
  13551. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  13552. /**
  13553. * Stops and removes all animations that have been applied to the scene
  13554. */
  13555. stopAllAnimations(): void;
  13556. /**
  13557. * Gets the current delta time used by animation engine
  13558. */
  13559. deltaTime: number;
  13560. }
  13561. }
  13562. module "babylonjs/Bones/bone" {
  13563. interface Bone {
  13564. /**
  13565. * Copy an animation range from another bone
  13566. * @param source defines the source bone
  13567. * @param rangeName defines the range name to copy
  13568. * @param frameOffset defines the frame offset
  13569. * @param rescaleAsRequired defines if rescaling must be applied if required
  13570. * @param skelDimensionsRatio defines the scaling ratio
  13571. * @returns true if operation was successful
  13572. */
  13573. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  13574. }
  13575. }
  13576. }
  13577. declare module "babylonjs/Animations/animationPropertiesOverride" {
  13578. /**
  13579. * Class used to override all child animations of a given target
  13580. */
  13581. export class AnimationPropertiesOverride {
  13582. /**
  13583. * Gets or sets a value indicating if animation blending must be used
  13584. */
  13585. enableBlending: boolean;
  13586. /**
  13587. * Gets or sets the blending speed to use when enableBlending is true
  13588. */
  13589. blendingSpeed: number;
  13590. /**
  13591. * Gets or sets the default loop mode to use
  13592. */
  13593. loopMode: number;
  13594. }
  13595. }
  13596. declare module "babylonjs/Bones/skeleton" {
  13597. import { Bone } from "babylonjs/Bones/bone";
  13598. import { Observable } from "babylonjs/Misc/observable";
  13599. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13600. import { Scene } from "babylonjs/scene";
  13601. import { Nullable } from "babylonjs/types";
  13602. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13603. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  13604. import { Animatable } from "babylonjs/Animations/animatable";
  13605. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  13606. import { Animation } from "babylonjs/Animations/animation";
  13607. import { AnimationRange } from "babylonjs/Animations/animationRange";
  13608. import { IInspectable } from "babylonjs/Misc/iInspectable";
  13609. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  13610. /**
  13611. * Class used to handle skinning animations
  13612. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13613. */
  13614. export class Skeleton implements IAnimatable {
  13615. /** defines the skeleton name */
  13616. name: string;
  13617. /** defines the skeleton Id */
  13618. id: string;
  13619. /**
  13620. * Defines the list of child bones
  13621. */
  13622. bones: Bone[];
  13623. /**
  13624. * Defines an estimate of the dimension of the skeleton at rest
  13625. */
  13626. dimensionsAtRest: Vector3;
  13627. /**
  13628. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  13629. */
  13630. needInitialSkinMatrix: boolean;
  13631. /**
  13632. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  13633. */
  13634. overrideMesh: Nullable<AbstractMesh>;
  13635. /**
  13636. * Gets the list of animations attached to this skeleton
  13637. */
  13638. animations: Array<Animation>;
  13639. private _scene;
  13640. private _isDirty;
  13641. private _transformMatrices;
  13642. private _transformMatrixTexture;
  13643. private _meshesWithPoseMatrix;
  13644. private _animatables;
  13645. private _identity;
  13646. private _synchronizedWithMesh;
  13647. private _ranges;
  13648. private _lastAbsoluteTransformsUpdateId;
  13649. private _canUseTextureForBones;
  13650. private _uniqueId;
  13651. /** @hidden */
  13652. _numBonesWithLinkedTransformNode: number;
  13653. /** @hidden */
  13654. _hasWaitingData: Nullable<boolean>;
  13655. /**
  13656. * Specifies if the skeleton should be serialized
  13657. */
  13658. doNotSerialize: boolean;
  13659. private _useTextureToStoreBoneMatrices;
  13660. /**
  13661. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  13662. * Please note that this option is not available if the hardware does not support it
  13663. */
  13664. useTextureToStoreBoneMatrices: boolean;
  13665. private _animationPropertiesOverride;
  13666. /**
  13667. * Gets or sets the animation properties override
  13668. */
  13669. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13670. /**
  13671. * List of inspectable custom properties (used by the Inspector)
  13672. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  13673. */
  13674. inspectableCustomProperties: IInspectable[];
  13675. /**
  13676. * An observable triggered before computing the skeleton's matrices
  13677. */
  13678. onBeforeComputeObservable: Observable<Skeleton>;
  13679. /**
  13680. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  13681. */
  13682. readonly isUsingTextureForMatrices: boolean;
  13683. /**
  13684. * Gets the unique ID of this skeleton
  13685. */
  13686. readonly uniqueId: number;
  13687. /**
  13688. * Creates a new skeleton
  13689. * @param name defines the skeleton name
  13690. * @param id defines the skeleton Id
  13691. * @param scene defines the hosting scene
  13692. */
  13693. constructor(
  13694. /** defines the skeleton name */
  13695. name: string,
  13696. /** defines the skeleton Id */
  13697. id: string, scene: Scene);
  13698. /**
  13699. * Gets the current object class name.
  13700. * @return the class name
  13701. */
  13702. getClassName(): string;
  13703. /**
  13704. * Returns an array containing the root bones
  13705. * @returns an array containing the root bones
  13706. */
  13707. getChildren(): Array<Bone>;
  13708. /**
  13709. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  13710. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13711. * @returns a Float32Array containing matrices data
  13712. */
  13713. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  13714. /**
  13715. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  13716. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13717. * @returns a raw texture containing the data
  13718. */
  13719. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  13720. /**
  13721. * Gets the current hosting scene
  13722. * @returns a scene object
  13723. */
  13724. getScene(): Scene;
  13725. /**
  13726. * Gets a string representing the current skeleton data
  13727. * @param fullDetails defines a boolean indicating if we want a verbose version
  13728. * @returns a string representing the current skeleton data
  13729. */
  13730. toString(fullDetails?: boolean): string;
  13731. /**
  13732. * Get bone's index searching by name
  13733. * @param name defines bone's name to search for
  13734. * @return the indice of the bone. Returns -1 if not found
  13735. */
  13736. getBoneIndexByName(name: string): number;
  13737. /**
  13738. * Creater a new animation range
  13739. * @param name defines the name of the range
  13740. * @param from defines the start key
  13741. * @param to defines the end key
  13742. */
  13743. createAnimationRange(name: string, from: number, to: number): void;
  13744. /**
  13745. * Delete a specific animation range
  13746. * @param name defines the name of the range
  13747. * @param deleteFrames defines if frames must be removed as well
  13748. */
  13749. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  13750. /**
  13751. * Gets a specific animation range
  13752. * @param name defines the name of the range to look for
  13753. * @returns the requested animation range or null if not found
  13754. */
  13755. getAnimationRange(name: string): Nullable<AnimationRange>;
  13756. /**
  13757. * Gets the list of all animation ranges defined on this skeleton
  13758. * @returns an array
  13759. */
  13760. getAnimationRanges(): Nullable<AnimationRange>[];
  13761. /**
  13762. * Copy animation range from a source skeleton.
  13763. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  13764. * @param source defines the source skeleton
  13765. * @param name defines the name of the range to copy
  13766. * @param rescaleAsRequired defines if rescaling must be applied if required
  13767. * @returns true if operation was successful
  13768. */
  13769. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  13770. /**
  13771. * Forces the skeleton to go to rest pose
  13772. */
  13773. returnToRest(): void;
  13774. private _getHighestAnimationFrame;
  13775. /**
  13776. * Begin a specific animation range
  13777. * @param name defines the name of the range to start
  13778. * @param loop defines if looping must be turned on (false by default)
  13779. * @param speedRatio defines the speed ratio to apply (1 by default)
  13780. * @param onAnimationEnd defines a callback which will be called when animation will end
  13781. * @returns a new animatable
  13782. */
  13783. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  13784. /** @hidden */
  13785. _markAsDirty(): void;
  13786. /** @hidden */
  13787. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13788. /** @hidden */
  13789. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13790. private _computeTransformMatrices;
  13791. /**
  13792. * Build all resources required to render a skeleton
  13793. */
  13794. prepare(): void;
  13795. /**
  13796. * Gets the list of animatables currently running for this skeleton
  13797. * @returns an array of animatables
  13798. */
  13799. getAnimatables(): IAnimatable[];
  13800. /**
  13801. * Clone the current skeleton
  13802. * @param name defines the name of the new skeleton
  13803. * @param id defines the id of the new skeleton
  13804. * @returns the new skeleton
  13805. */
  13806. clone(name: string, id?: string): Skeleton;
  13807. /**
  13808. * Enable animation blending for this skeleton
  13809. * @param blendingSpeed defines the blending speed to apply
  13810. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13811. */
  13812. enableBlending(blendingSpeed?: number): void;
  13813. /**
  13814. * Releases all resources associated with the current skeleton
  13815. */
  13816. dispose(): void;
  13817. /**
  13818. * Serialize the skeleton in a JSON object
  13819. * @returns a JSON object
  13820. */
  13821. serialize(): any;
  13822. /**
  13823. * Creates a new skeleton from serialized data
  13824. * @param parsedSkeleton defines the serialized data
  13825. * @param scene defines the hosting scene
  13826. * @returns a new skeleton
  13827. */
  13828. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  13829. /**
  13830. * Compute all node absolute transforms
  13831. * @param forceUpdate defines if computation must be done even if cache is up to date
  13832. */
  13833. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  13834. /**
  13835. * Gets the root pose matrix
  13836. * @returns a matrix
  13837. */
  13838. getPoseMatrix(): Nullable<Matrix>;
  13839. /**
  13840. * Sorts bones per internal index
  13841. */
  13842. sortBones(): void;
  13843. private _sortBones;
  13844. }
  13845. }
  13846. declare module "babylonjs/Bones/bone" {
  13847. import { Skeleton } from "babylonjs/Bones/skeleton";
  13848. import { Vector3, Quaternion, Matrix } from "babylonjs/Maths/math.vector";
  13849. import { Nullable } from "babylonjs/types";
  13850. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13851. import { TransformNode } from "babylonjs/Meshes/transformNode";
  13852. import { Node } from "babylonjs/node";
  13853. import { Space } from "babylonjs/Maths/math.axis";
  13854. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  13855. /**
  13856. * Class used to store bone information
  13857. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13858. */
  13859. export class Bone extends Node {
  13860. /**
  13861. * defines the bone name
  13862. */
  13863. name: string;
  13864. private static _tmpVecs;
  13865. private static _tmpQuat;
  13866. private static _tmpMats;
  13867. /**
  13868. * Gets the list of child bones
  13869. */
  13870. children: Bone[];
  13871. /** Gets the animations associated with this bone */
  13872. animations: import("babylonjs/Animations/animation").Animation[];
  13873. /**
  13874. * Gets or sets bone length
  13875. */
  13876. length: number;
  13877. /**
  13878. * @hidden Internal only
  13879. * Set this value to map this bone to a different index in the transform matrices
  13880. * Set this value to -1 to exclude the bone from the transform matrices
  13881. */
  13882. _index: Nullable<number>;
  13883. private _skeleton;
  13884. private _localMatrix;
  13885. private _restPose;
  13886. private _baseMatrix;
  13887. private _absoluteTransform;
  13888. private _invertedAbsoluteTransform;
  13889. private _parent;
  13890. private _scalingDeterminant;
  13891. private _worldTransform;
  13892. private _localScaling;
  13893. private _localRotation;
  13894. private _localPosition;
  13895. private _needToDecompose;
  13896. private _needToCompose;
  13897. /** @hidden */
  13898. _linkedTransformNode: Nullable<TransformNode>;
  13899. /** @hidden */
  13900. _waitingTransformNodeId: Nullable<string>;
  13901. /** @hidden */
  13902. /** @hidden */
  13903. _matrix: Matrix;
  13904. /**
  13905. * Create a new bone
  13906. * @param name defines the bone name
  13907. * @param skeleton defines the parent skeleton
  13908. * @param parentBone defines the parent (can be null if the bone is the root)
  13909. * @param localMatrix defines the local matrix
  13910. * @param restPose defines the rest pose matrix
  13911. * @param baseMatrix defines the base matrix
  13912. * @param index defines index of the bone in the hiearchy
  13913. */
  13914. constructor(
  13915. /**
  13916. * defines the bone name
  13917. */
  13918. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  13919. /**
  13920. * Gets the current object class name.
  13921. * @return the class name
  13922. */
  13923. getClassName(): string;
  13924. /**
  13925. * Gets the parent skeleton
  13926. * @returns a skeleton
  13927. */
  13928. getSkeleton(): Skeleton;
  13929. /**
  13930. * Gets parent bone
  13931. * @returns a bone or null if the bone is the root of the bone hierarchy
  13932. */
  13933. getParent(): Nullable<Bone>;
  13934. /**
  13935. * Returns an array containing the root bones
  13936. * @returns an array containing the root bones
  13937. */
  13938. getChildren(): Array<Bone>;
  13939. /**
  13940. * Gets the node index in matrix array generated for rendering
  13941. * @returns the node index
  13942. */
  13943. getIndex(): number;
  13944. /**
  13945. * Sets the parent bone
  13946. * @param parent defines the parent (can be null if the bone is the root)
  13947. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13948. */
  13949. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  13950. /**
  13951. * Gets the local matrix
  13952. * @returns a matrix
  13953. */
  13954. getLocalMatrix(): Matrix;
  13955. /**
  13956. * Gets the base matrix (initial matrix which remains unchanged)
  13957. * @returns a matrix
  13958. */
  13959. getBaseMatrix(): Matrix;
  13960. /**
  13961. * Gets the rest pose matrix
  13962. * @returns a matrix
  13963. */
  13964. getRestPose(): Matrix;
  13965. /**
  13966. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  13967. */
  13968. getWorldMatrix(): Matrix;
  13969. /**
  13970. * Sets the local matrix to rest pose matrix
  13971. */
  13972. returnToRest(): void;
  13973. /**
  13974. * Gets the inverse of the absolute transform matrix.
  13975. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  13976. * @returns a matrix
  13977. */
  13978. getInvertedAbsoluteTransform(): Matrix;
  13979. /**
  13980. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  13981. * @returns a matrix
  13982. */
  13983. getAbsoluteTransform(): Matrix;
  13984. /**
  13985. * Links with the given transform node.
  13986. * The local matrix of this bone is copied from the transform node every frame.
  13987. * @param transformNode defines the transform node to link to
  13988. */
  13989. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  13990. /**
  13991. * Gets the node used to drive the bone's transformation
  13992. * @returns a transform node or null
  13993. */
  13994. getTransformNode(): Nullable<TransformNode>;
  13995. /** Gets or sets current position (in local space) */
  13996. position: Vector3;
  13997. /** Gets or sets current rotation (in local space) */
  13998. rotation: Vector3;
  13999. /** Gets or sets current rotation quaternion (in local space) */
  14000. rotationQuaternion: Quaternion;
  14001. /** Gets or sets current scaling (in local space) */
  14002. scaling: Vector3;
  14003. /**
  14004. * Gets the animation properties override
  14005. */
  14006. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  14007. private _decompose;
  14008. private _compose;
  14009. /**
  14010. * Update the base and local matrices
  14011. * @param matrix defines the new base or local matrix
  14012. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  14013. * @param updateLocalMatrix defines if the local matrix should be updated
  14014. */
  14015. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  14016. /** @hidden */
  14017. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  14018. /**
  14019. * Flag the bone as dirty (Forcing it to update everything)
  14020. */
  14021. markAsDirty(): void;
  14022. /** @hidden */
  14023. _markAsDirtyAndCompose(): void;
  14024. private _markAsDirtyAndDecompose;
  14025. /**
  14026. * Translate the bone in local or world space
  14027. * @param vec The amount to translate the bone
  14028. * @param space The space that the translation is in
  14029. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14030. */
  14031. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14032. /**
  14033. * Set the postion of the bone in local or world space
  14034. * @param position The position to set the bone
  14035. * @param space The space that the position is in
  14036. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14037. */
  14038. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14039. /**
  14040. * Set the absolute position of the bone (world space)
  14041. * @param position The position to set the bone
  14042. * @param mesh The mesh that this bone is attached to
  14043. */
  14044. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  14045. /**
  14046. * Scale the bone on the x, y and z axes (in local space)
  14047. * @param x The amount to scale the bone on the x axis
  14048. * @param y The amount to scale the bone on the y axis
  14049. * @param z The amount to scale the bone on the z axis
  14050. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  14051. */
  14052. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  14053. /**
  14054. * Set the bone scaling in local space
  14055. * @param scale defines the scaling vector
  14056. */
  14057. setScale(scale: Vector3): void;
  14058. /**
  14059. * Gets the current scaling in local space
  14060. * @returns the current scaling vector
  14061. */
  14062. getScale(): Vector3;
  14063. /**
  14064. * Gets the current scaling in local space and stores it in a target vector
  14065. * @param result defines the target vector
  14066. */
  14067. getScaleToRef(result: Vector3): void;
  14068. /**
  14069. * Set the yaw, pitch, and roll of the bone in local or world space
  14070. * @param yaw The rotation of the bone on the y axis
  14071. * @param pitch The rotation of the bone on the x axis
  14072. * @param roll The rotation of the bone on the z axis
  14073. * @param space The space that the axes of rotation are in
  14074. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14075. */
  14076. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  14077. /**
  14078. * Add a rotation to the bone on an axis in local or world space
  14079. * @param axis The axis to rotate the bone on
  14080. * @param amount The amount to rotate the bone
  14081. * @param space The space that the axis is in
  14082. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14083. */
  14084. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  14085. /**
  14086. * Set the rotation of the bone to a particular axis angle in local or world space
  14087. * @param axis The axis to rotate the bone on
  14088. * @param angle The angle that the bone should be rotated to
  14089. * @param space The space that the axis is in
  14090. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14091. */
  14092. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  14093. /**
  14094. * Set the euler rotation of the bone in local of world space
  14095. * @param rotation The euler rotation that the bone should be set to
  14096. * @param space The space that the rotation is in
  14097. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14098. */
  14099. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14100. /**
  14101. * Set the quaternion rotation of the bone in local of world space
  14102. * @param quat The quaternion rotation that the bone should be set to
  14103. * @param space The space that the rotation is in
  14104. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14105. */
  14106. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  14107. /**
  14108. * Set the rotation matrix of the bone in local of world space
  14109. * @param rotMat The rotation matrix that the bone should be set to
  14110. * @param space The space that the rotation is in
  14111. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14112. */
  14113. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  14114. private _rotateWithMatrix;
  14115. private _getNegativeRotationToRef;
  14116. /**
  14117. * Get the position of the bone in local or world space
  14118. * @param space The space that the returned position is in
  14119. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14120. * @returns The position of the bone
  14121. */
  14122. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14123. /**
  14124. * Copy the position of the bone to a vector3 in local or world space
  14125. * @param space The space that the returned position is in
  14126. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14127. * @param result The vector3 to copy the position to
  14128. */
  14129. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  14130. /**
  14131. * Get the absolute position of the bone (world space)
  14132. * @param mesh The mesh that this bone is attached to
  14133. * @returns The absolute position of the bone
  14134. */
  14135. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  14136. /**
  14137. * Copy the absolute position of the bone (world space) to the result param
  14138. * @param mesh The mesh that this bone is attached to
  14139. * @param result The vector3 to copy the absolute position to
  14140. */
  14141. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  14142. /**
  14143. * Compute the absolute transforms of this bone and its children
  14144. */
  14145. computeAbsoluteTransforms(): void;
  14146. /**
  14147. * Get the world direction from an axis that is in the local space of the bone
  14148. * @param localAxis The local direction that is used to compute the world direction
  14149. * @param mesh The mesh that this bone is attached to
  14150. * @returns The world direction
  14151. */
  14152. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14153. /**
  14154. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  14155. * @param localAxis The local direction that is used to compute the world direction
  14156. * @param mesh The mesh that this bone is attached to
  14157. * @param result The vector3 that the world direction will be copied to
  14158. */
  14159. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14160. /**
  14161. * Get the euler rotation of the bone in local or world space
  14162. * @param space The space that the rotation should be in
  14163. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14164. * @returns The euler rotation
  14165. */
  14166. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14167. /**
  14168. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  14169. * @param space The space that the rotation should be in
  14170. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14171. * @param result The vector3 that the rotation should be copied to
  14172. */
  14173. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14174. /**
  14175. * Get the quaternion rotation of the bone in either local or world space
  14176. * @param space The space that the rotation should be in
  14177. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14178. * @returns The quaternion rotation
  14179. */
  14180. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  14181. /**
  14182. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  14183. * @param space The space that the rotation should be in
  14184. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14185. * @param result The quaternion that the rotation should be copied to
  14186. */
  14187. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  14188. /**
  14189. * Get the rotation matrix of the bone in local or world space
  14190. * @param space The space that the rotation should be in
  14191. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14192. * @returns The rotation matrix
  14193. */
  14194. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  14195. /**
  14196. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  14197. * @param space The space that the rotation should be in
  14198. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14199. * @param result The quaternion that the rotation should be copied to
  14200. */
  14201. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  14202. /**
  14203. * Get the world position of a point that is in the local space of the bone
  14204. * @param position The local position
  14205. * @param mesh The mesh that this bone is attached to
  14206. * @returns The world position
  14207. */
  14208. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14209. /**
  14210. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  14211. * @param position The local position
  14212. * @param mesh The mesh that this bone is attached to
  14213. * @param result The vector3 that the world position should be copied to
  14214. */
  14215. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14216. /**
  14217. * Get the local position of a point that is in world space
  14218. * @param position The world position
  14219. * @param mesh The mesh that this bone is attached to
  14220. * @returns The local position
  14221. */
  14222. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14223. /**
  14224. * Get the local position of a point that is in world space and copy it to the result param
  14225. * @param position The world position
  14226. * @param mesh The mesh that this bone is attached to
  14227. * @param result The vector3 that the local position should be copied to
  14228. */
  14229. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14230. }
  14231. }
  14232. declare module "babylonjs/Meshes/transformNode" {
  14233. import { DeepImmutable } from "babylonjs/types";
  14234. import { Observable } from "babylonjs/Misc/observable";
  14235. import { Nullable } from "babylonjs/types";
  14236. import { Camera } from "babylonjs/Cameras/camera";
  14237. import { Scene } from "babylonjs/scene";
  14238. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14239. import { Node } from "babylonjs/node";
  14240. import { Bone } from "babylonjs/Bones/bone";
  14241. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14242. import { Space } from "babylonjs/Maths/math.axis";
  14243. /**
  14244. * A TransformNode is an object that is not rendered but can be used as a center of transformation. This can decrease memory usage and increase rendering speed compared to using an empty mesh as a parent and is less complicated than using a pivot matrix.
  14245. * @see https://doc.babylonjs.com/how_to/transformnode
  14246. */
  14247. export class TransformNode extends Node {
  14248. /**
  14249. * Object will not rotate to face the camera
  14250. */
  14251. static BILLBOARDMODE_NONE: number;
  14252. /**
  14253. * Object will rotate to face the camera but only on the x axis
  14254. */
  14255. static BILLBOARDMODE_X: number;
  14256. /**
  14257. * Object will rotate to face the camera but only on the y axis
  14258. */
  14259. static BILLBOARDMODE_Y: number;
  14260. /**
  14261. * Object will rotate to face the camera but only on the z axis
  14262. */
  14263. static BILLBOARDMODE_Z: number;
  14264. /**
  14265. * Object will rotate to face the camera
  14266. */
  14267. static BILLBOARDMODE_ALL: number;
  14268. /**
  14269. * Object will rotate to face the camera's position instead of orientation
  14270. */
  14271. static BILLBOARDMODE_USE_POSITION: number;
  14272. private _forward;
  14273. private _forwardInverted;
  14274. private _up;
  14275. private _right;
  14276. private _rightInverted;
  14277. private _position;
  14278. private _rotation;
  14279. private _rotationQuaternion;
  14280. protected _scaling: Vector3;
  14281. protected _isDirty: boolean;
  14282. private _transformToBoneReferal;
  14283. private _isAbsoluteSynced;
  14284. private _billboardMode;
  14285. /**
  14286. * Gets or sets the billboard mode. Default is 0.
  14287. *
  14288. * | Value | Type | Description |
  14289. * | --- | --- | --- |
  14290. * | 0 | BILLBOARDMODE_NONE | |
  14291. * | 1 | BILLBOARDMODE_X | |
  14292. * | 2 | BILLBOARDMODE_Y | |
  14293. * | 4 | BILLBOARDMODE_Z | |
  14294. * | 7 | BILLBOARDMODE_ALL | |
  14295. *
  14296. */
  14297. billboardMode: number;
  14298. private _preserveParentRotationForBillboard;
  14299. /**
  14300. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  14301. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  14302. */
  14303. preserveParentRotationForBillboard: boolean;
  14304. /**
  14305. * Multiplication factor on scale x/y/z when computing the world matrix. Eg. for a 1x1x1 cube setting this to 2 will make it a 2x2x2 cube
  14306. */
  14307. scalingDeterminant: number;
  14308. private _infiniteDistance;
  14309. /**
  14310. * Gets or sets the distance of the object to max, often used by skybox
  14311. */
  14312. infiniteDistance: boolean;
  14313. /**
  14314. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  14315. * By default the system will update normals to compensate
  14316. */
  14317. ignoreNonUniformScaling: boolean;
  14318. /**
  14319. * Gets or sets a boolean indicating that even if rotationQuaternion is defined, you can keep updating rotation property and Babylon.js will just mix both
  14320. */
  14321. reIntegrateRotationIntoRotationQuaternion: boolean;
  14322. /** @hidden */
  14323. _poseMatrix: Nullable<Matrix>;
  14324. /** @hidden */
  14325. _localMatrix: Matrix;
  14326. private _usePivotMatrix;
  14327. private _absolutePosition;
  14328. private _absoluteScaling;
  14329. private _absoluteRotationQuaternion;
  14330. private _pivotMatrix;
  14331. private _pivotMatrixInverse;
  14332. protected _postMultiplyPivotMatrix: boolean;
  14333. protected _isWorldMatrixFrozen: boolean;
  14334. /** @hidden */
  14335. _indexInSceneTransformNodesArray: number;
  14336. /**
  14337. * An event triggered after the world matrix is updated
  14338. */
  14339. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  14340. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  14341. /**
  14342. * Gets a string identifying the name of the class
  14343. * @returns "TransformNode" string
  14344. */
  14345. getClassName(): string;
  14346. /**
  14347. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  14348. */
  14349. position: Vector3;
  14350. /**
  14351. * Gets or sets the rotation property : a Vector3 defining the rotation value in radians around each local axis X, Y, Z (default is (0.0, 0.0, 0.0)).
  14352. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  14353. */
  14354. rotation: Vector3;
  14355. /**
  14356. * Gets or sets the scaling property : a Vector3 defining the node scaling along each local axis X, Y, Z (default is (0.0, 0.0, 0.0)).
  14357. */
  14358. scaling: Vector3;
  14359. /**
  14360. * Gets or sets the rotation Quaternion property : this a Quaternion object defining the node rotation by using a unit quaternion (undefined by default, but can be null).
  14361. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  14362. */
  14363. rotationQuaternion: Nullable<Quaternion>;
  14364. /**
  14365. * The forward direction of that transform in world space.
  14366. */
  14367. readonly forward: Vector3;
  14368. /**
  14369. * The up direction of that transform in world space.
  14370. */
  14371. readonly up: Vector3;
  14372. /**
  14373. * The right direction of that transform in world space.
  14374. */
  14375. readonly right: Vector3;
  14376. /**
  14377. * Copies the parameter passed Matrix into the mesh Pose matrix.
  14378. * @param matrix the matrix to copy the pose from
  14379. * @returns this TransformNode.
  14380. */
  14381. updatePoseMatrix(matrix: Matrix): TransformNode;
  14382. /**
  14383. * Returns the mesh Pose matrix.
  14384. * @returns the pose matrix
  14385. */
  14386. getPoseMatrix(): Matrix;
  14387. /** @hidden */
  14388. _isSynchronized(): boolean;
  14389. /** @hidden */
  14390. _initCache(): void;
  14391. /**
  14392. * Flag the transform node as dirty (Forcing it to update everything)
  14393. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  14394. * @returns this transform node
  14395. */
  14396. markAsDirty(property: string): TransformNode;
  14397. /**
  14398. * Returns the current mesh absolute position.
  14399. * Returns a Vector3.
  14400. */
  14401. readonly absolutePosition: Vector3;
  14402. /**
  14403. * Returns the current mesh absolute scaling.
  14404. * Returns a Vector3.
  14405. */
  14406. readonly absoluteScaling: Vector3;
  14407. /**
  14408. * Returns the current mesh absolute rotation.
  14409. * Returns a Quaternion.
  14410. */
  14411. readonly absoluteRotationQuaternion: Quaternion;
  14412. /**
  14413. * Sets a new matrix to apply before all other transformation
  14414. * @param matrix defines the transform matrix
  14415. * @returns the current TransformNode
  14416. */
  14417. setPreTransformMatrix(matrix: Matrix): TransformNode;
  14418. /**
  14419. * Sets a new pivot matrix to the current node
  14420. * @param matrix defines the new pivot matrix to use
  14421. * @param postMultiplyPivotMatrix defines if the pivot matrix must be cancelled in the world matrix. When this parameter is set to true (default), the inverse of the pivot matrix is also applied at the end to cancel the transformation effect
  14422. * @returns the current TransformNode
  14423. */
  14424. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  14425. /**
  14426. * Returns the mesh pivot matrix.
  14427. * Default : Identity.
  14428. * @returns the matrix
  14429. */
  14430. getPivotMatrix(): Matrix;
  14431. /**
  14432. * Instantiate (when possible) or clone that node with its hierarchy
  14433. * @param newParent defines the new parent to use for the instance (or clone)
  14434. * @param options defines options to configure how copy is done
  14435. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  14436. * @returns an instance (or a clone) of the current node with its hiearchy
  14437. */
  14438. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  14439. doNotInstantiate: boolean;
  14440. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  14441. /**
  14442. * Prevents the World matrix to be computed any longer
  14443. * @param newWorldMatrix defines an optional matrix to use as world matrix
  14444. * @returns the TransformNode.
  14445. */
  14446. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  14447. /**
  14448. * Allows back the World matrix computation.
  14449. * @returns the TransformNode.
  14450. */
  14451. unfreezeWorldMatrix(): this;
  14452. /**
  14453. * True if the World matrix has been frozen.
  14454. */
  14455. readonly isWorldMatrixFrozen: boolean;
  14456. /**
  14457. * Retuns the mesh absolute position in the World.
  14458. * @returns a Vector3.
  14459. */
  14460. getAbsolutePosition(): Vector3;
  14461. /**
  14462. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  14463. * @param absolutePosition the absolute position to set
  14464. * @returns the TransformNode.
  14465. */
  14466. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  14467. /**
  14468. * Sets the mesh position in its local space.
  14469. * @param vector3 the position to set in localspace
  14470. * @returns the TransformNode.
  14471. */
  14472. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  14473. /**
  14474. * Returns the mesh position in the local space from the current World matrix values.
  14475. * @returns a new Vector3.
  14476. */
  14477. getPositionExpressedInLocalSpace(): Vector3;
  14478. /**
  14479. * Translates the mesh along the passed Vector3 in its local space.
  14480. * @param vector3 the distance to translate in localspace
  14481. * @returns the TransformNode.
  14482. */
  14483. locallyTranslate(vector3: Vector3): TransformNode;
  14484. private static _lookAtVectorCache;
  14485. /**
  14486. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  14487. * @param targetPoint the position (must be in same space as current mesh) to look at
  14488. * @param yawCor optional yaw (y-axis) correction in radians
  14489. * @param pitchCor optional pitch (x-axis) correction in radians
  14490. * @param rollCor optional roll (z-axis) correction in radians
  14491. * @param space the choosen space of the target
  14492. * @returns the TransformNode.
  14493. */
  14494. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  14495. /**
  14496. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14497. * This Vector3 is expressed in the World space.
  14498. * @param localAxis axis to rotate
  14499. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14500. */
  14501. getDirection(localAxis: Vector3): Vector3;
  14502. /**
  14503. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  14504. * localAxis is expressed in the mesh local space.
  14505. * result is computed in the Wordl space from the mesh World matrix.
  14506. * @param localAxis axis to rotate
  14507. * @param result the resulting transformnode
  14508. * @returns this TransformNode.
  14509. */
  14510. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  14511. /**
  14512. * Sets this transform node rotation to the given local axis.
  14513. * @param localAxis the axis in local space
  14514. * @param yawCor optional yaw (y-axis) correction in radians
  14515. * @param pitchCor optional pitch (x-axis) correction in radians
  14516. * @param rollCor optional roll (z-axis) correction in radians
  14517. * @returns this TransformNode
  14518. */
  14519. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  14520. /**
  14521. * Sets a new pivot point to the current node
  14522. * @param point defines the new pivot point to use
  14523. * @param space defines if the point is in world or local space (local by default)
  14524. * @returns the current TransformNode
  14525. */
  14526. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  14527. /**
  14528. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  14529. * @returns the pivot point
  14530. */
  14531. getPivotPoint(): Vector3;
  14532. /**
  14533. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  14534. * @param result the vector3 to store the result
  14535. * @returns this TransformNode.
  14536. */
  14537. getPivotPointToRef(result: Vector3): TransformNode;
  14538. /**
  14539. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  14540. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  14541. */
  14542. getAbsolutePivotPoint(): Vector3;
  14543. /**
  14544. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  14545. * @param result vector3 to store the result
  14546. * @returns this TransformNode.
  14547. */
  14548. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  14549. /**
  14550. * Defines the passed node as the parent of the current node.
  14551. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  14552. * @see https://doc.babylonjs.com/how_to/parenting
  14553. * @param node the node ot set as the parent
  14554. * @returns this TransformNode.
  14555. */
  14556. setParent(node: Nullable<Node>): TransformNode;
  14557. private _nonUniformScaling;
  14558. /**
  14559. * True if the scaling property of this object is non uniform eg. (1,2,1)
  14560. */
  14561. readonly nonUniformScaling: boolean;
  14562. /** @hidden */
  14563. _updateNonUniformScalingState(value: boolean): boolean;
  14564. /**
  14565. * Attach the current TransformNode to another TransformNode associated with a bone
  14566. * @param bone Bone affecting the TransformNode
  14567. * @param affectedTransformNode TransformNode associated with the bone
  14568. * @returns this object
  14569. */
  14570. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  14571. /**
  14572. * Detach the transform node if its associated with a bone
  14573. * @returns this object
  14574. */
  14575. detachFromBone(): TransformNode;
  14576. private static _rotationAxisCache;
  14577. /**
  14578. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  14579. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14580. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14581. * The passed axis is also normalized.
  14582. * @param axis the axis to rotate around
  14583. * @param amount the amount to rotate in radians
  14584. * @param space Space to rotate in (Default: local)
  14585. * @returns the TransformNode.
  14586. */
  14587. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  14588. /**
  14589. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  14590. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14591. * The passed axis is also normalized. .
  14592. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  14593. * @param point the point to rotate around
  14594. * @param axis the axis to rotate around
  14595. * @param amount the amount to rotate in radians
  14596. * @returns the TransformNode
  14597. */
  14598. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  14599. /**
  14600. * Translates the mesh along the axis vector for the passed distance in the given space.
  14601. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14602. * @param axis the axis to translate in
  14603. * @param distance the distance to translate
  14604. * @param space Space to rotate in (Default: local)
  14605. * @returns the TransformNode.
  14606. */
  14607. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  14608. /**
  14609. * Adds a rotation step to the mesh current rotation.
  14610. * x, y, z are Euler angles expressed in radians.
  14611. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  14612. * This means this rotation is made in the mesh local space only.
  14613. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  14614. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  14615. * ```javascript
  14616. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  14617. * ```
  14618. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  14619. * Under the hood, only quaternions are used. So it's a little faster is you use .rotationQuaternion because it doesn't need to translate them back to Euler angles.
  14620. * @param x Rotation to add
  14621. * @param y Rotation to add
  14622. * @param z Rotation to add
  14623. * @returns the TransformNode.
  14624. */
  14625. addRotation(x: number, y: number, z: number): TransformNode;
  14626. /**
  14627. * @hidden
  14628. */
  14629. protected _getEffectiveParent(): Nullable<Node>;
  14630. /**
  14631. * Computes the world matrix of the node
  14632. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14633. * @returns the world matrix
  14634. */
  14635. computeWorldMatrix(force?: boolean): Matrix;
  14636. protected _afterComputeWorldMatrix(): void;
  14637. /**
  14638. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  14639. * @param func callback function to add
  14640. *
  14641. * @returns the TransformNode.
  14642. */
  14643. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14644. /**
  14645. * Removes a registered callback function.
  14646. * @param func callback function to remove
  14647. * @returns the TransformNode.
  14648. */
  14649. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14650. /**
  14651. * Gets the position of the current mesh in camera space
  14652. * @param camera defines the camera to use
  14653. * @returns a position
  14654. */
  14655. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14656. /**
  14657. * Returns the distance from the mesh to the active camera
  14658. * @param camera defines the camera to use
  14659. * @returns the distance
  14660. */
  14661. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14662. /**
  14663. * Clone the current transform node
  14664. * @param name Name of the new clone
  14665. * @param newParent New parent for the clone
  14666. * @param doNotCloneChildren Do not clone children hierarchy
  14667. * @returns the new transform node
  14668. */
  14669. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  14670. /**
  14671. * Serializes the objects information.
  14672. * @param currentSerializationObject defines the object to serialize in
  14673. * @returns the serialized object
  14674. */
  14675. serialize(currentSerializationObject?: any): any;
  14676. /**
  14677. * Returns a new TransformNode object parsed from the source provided.
  14678. * @param parsedTransformNode is the source.
  14679. * @param scene the scne the object belongs to
  14680. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14681. * @returns a new TransformNode object parsed from the source provided.
  14682. */
  14683. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  14684. /**
  14685. * Get all child-transformNodes of this node
  14686. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered
  14687. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  14688. * @returns an array of TransformNode
  14689. */
  14690. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  14691. /**
  14692. * Releases resources associated with this transform node.
  14693. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14694. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14695. */
  14696. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14697. /**
  14698. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14699. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14700. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14701. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14702. * @returns the current mesh
  14703. */
  14704. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14705. private _syncAbsoluteScalingAndRotation;
  14706. }
  14707. }
  14708. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  14709. import { Observable } from "babylonjs/Misc/observable";
  14710. import { Nullable } from "babylonjs/types";
  14711. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14712. import { TransformNode } from "babylonjs/Meshes/transformNode";
  14713. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14714. import { Ray } from "babylonjs/Culling/ray";
  14715. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  14716. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  14717. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  14718. /**
  14719. * Defines the types of pose enabled controllers that are supported
  14720. */
  14721. export enum PoseEnabledControllerType {
  14722. /**
  14723. * HTC Vive
  14724. */
  14725. VIVE = 0,
  14726. /**
  14727. * Oculus Rift
  14728. */
  14729. OCULUS = 1,
  14730. /**
  14731. * Windows mixed reality
  14732. */
  14733. WINDOWS = 2,
  14734. /**
  14735. * Samsung gear VR
  14736. */
  14737. GEAR_VR = 3,
  14738. /**
  14739. * Google Daydream
  14740. */
  14741. DAYDREAM = 4,
  14742. /**
  14743. * Generic
  14744. */
  14745. GENERIC = 5
  14746. }
  14747. /**
  14748. * Defines the MutableGamepadButton interface for the state of a gamepad button
  14749. */
  14750. export interface MutableGamepadButton {
  14751. /**
  14752. * Value of the button/trigger
  14753. */
  14754. value: number;
  14755. /**
  14756. * If the button/trigger is currently touched
  14757. */
  14758. touched: boolean;
  14759. /**
  14760. * If the button/trigger is currently pressed
  14761. */
  14762. pressed: boolean;
  14763. }
  14764. /**
  14765. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  14766. * @hidden
  14767. */
  14768. export interface ExtendedGamepadButton extends GamepadButton {
  14769. /**
  14770. * If the button/trigger is currently pressed
  14771. */
  14772. readonly pressed: boolean;
  14773. /**
  14774. * If the button/trigger is currently touched
  14775. */
  14776. readonly touched: boolean;
  14777. /**
  14778. * Value of the button/trigger
  14779. */
  14780. readonly value: number;
  14781. }
  14782. /** @hidden */
  14783. export interface _GamePadFactory {
  14784. /**
  14785. * Returns wether or not the current gamepad can be created for this type of controller.
  14786. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14787. * @returns true if it can be created, otherwise false
  14788. */
  14789. canCreate(gamepadInfo: any): boolean;
  14790. /**
  14791. * Creates a new instance of the Gamepad.
  14792. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14793. * @returns the new gamepad instance
  14794. */
  14795. create(gamepadInfo: any): Gamepad;
  14796. }
  14797. /**
  14798. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14799. */
  14800. export class PoseEnabledControllerHelper {
  14801. /** @hidden */
  14802. static _ControllerFactories: _GamePadFactory[];
  14803. /** @hidden */
  14804. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  14805. /**
  14806. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14807. * @param vrGamepad the gamepad to initialized
  14808. * @returns a vr controller of the type the gamepad identified as
  14809. */
  14810. static InitiateController(vrGamepad: any): Gamepad;
  14811. }
  14812. /**
  14813. * Defines the PoseEnabledController object that contains state of a vr capable controller
  14814. */
  14815. export class PoseEnabledController extends Gamepad implements PoseControlled {
  14816. /**
  14817. * If the controller is used in a webXR session
  14818. */
  14819. isXR: boolean;
  14820. private _deviceRoomPosition;
  14821. private _deviceRoomRotationQuaternion;
  14822. /**
  14823. * The device position in babylon space
  14824. */
  14825. devicePosition: Vector3;
  14826. /**
  14827. * The device rotation in babylon space
  14828. */
  14829. deviceRotationQuaternion: Quaternion;
  14830. /**
  14831. * The scale factor of the device in babylon space
  14832. */
  14833. deviceScaleFactor: number;
  14834. /**
  14835. * (Likely devicePosition should be used instead) The device position in its room space
  14836. */
  14837. position: Vector3;
  14838. /**
  14839. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  14840. */
  14841. rotationQuaternion: Quaternion;
  14842. /**
  14843. * The type of controller (Eg. Windows mixed reality)
  14844. */
  14845. controllerType: PoseEnabledControllerType;
  14846. protected _calculatedPosition: Vector3;
  14847. private _calculatedRotation;
  14848. /**
  14849. * The raw pose from the device
  14850. */
  14851. rawPose: DevicePose;
  14852. private _trackPosition;
  14853. private _maxRotationDistFromHeadset;
  14854. private _draggedRoomRotation;
  14855. /**
  14856. * @hidden
  14857. */
  14858. _disableTrackPosition(fixedPosition: Vector3): void;
  14859. /**
  14860. * Internal, the mesh attached to the controller
  14861. * @hidden
  14862. */
  14863. _mesh: Nullable<AbstractMesh>;
  14864. private _poseControlledCamera;
  14865. private _leftHandSystemQuaternion;
  14866. /**
  14867. * Internal, matrix used to convert room space to babylon space
  14868. * @hidden
  14869. */
  14870. _deviceToWorld: Matrix;
  14871. /**
  14872. * Node to be used when casting a ray from the controller
  14873. * @hidden
  14874. */
  14875. _pointingPoseNode: Nullable<TransformNode>;
  14876. /**
  14877. * Name of the child mesh that can be used to cast a ray from the controller
  14878. */
  14879. static readonly POINTING_POSE: string;
  14880. /**
  14881. * Creates a new PoseEnabledController from a gamepad
  14882. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  14883. */
  14884. constructor(browserGamepad: any);
  14885. private _workingMatrix;
  14886. /**
  14887. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  14888. */
  14889. update(): void;
  14890. /**
  14891. * Updates only the pose device and mesh without doing any button event checking
  14892. */
  14893. protected _updatePoseAndMesh(): void;
  14894. /**
  14895. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  14896. * @param poseData raw pose fromthe device
  14897. */
  14898. updateFromDevice(poseData: DevicePose): void;
  14899. /**
  14900. * @hidden
  14901. */
  14902. _meshAttachedObservable: Observable<AbstractMesh>;
  14903. /**
  14904. * Attaches a mesh to the controller
  14905. * @param mesh the mesh to be attached
  14906. */
  14907. attachToMesh(mesh: AbstractMesh): void;
  14908. /**
  14909. * Attaches the controllers mesh to a camera
  14910. * @param camera the camera the mesh should be attached to
  14911. */
  14912. attachToPoseControlledCamera(camera: TargetCamera): void;
  14913. /**
  14914. * Disposes of the controller
  14915. */
  14916. dispose(): void;
  14917. /**
  14918. * The mesh that is attached to the controller
  14919. */
  14920. readonly mesh: Nullable<AbstractMesh>;
  14921. /**
  14922. * Gets the ray of the controller in the direction the controller is pointing
  14923. * @param length the length the resulting ray should be
  14924. * @returns a ray in the direction the controller is pointing
  14925. */
  14926. getForwardRay(length?: number): Ray;
  14927. }
  14928. }
  14929. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  14930. import { Observable } from "babylonjs/Misc/observable";
  14931. import { Scene } from "babylonjs/scene";
  14932. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14933. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  14934. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  14935. import { Nullable } from "babylonjs/types";
  14936. /**
  14937. * Defines the WebVRController object that represents controllers tracked in 3D space
  14938. */
  14939. export abstract class WebVRController extends PoseEnabledController {
  14940. /**
  14941. * Internal, the default controller model for the controller
  14942. */
  14943. protected _defaultModel: Nullable<AbstractMesh>;
  14944. /**
  14945. * Fired when the trigger state has changed
  14946. */
  14947. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  14948. /**
  14949. * Fired when the main button state has changed
  14950. */
  14951. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14952. /**
  14953. * Fired when the secondary button state has changed
  14954. */
  14955. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14956. /**
  14957. * Fired when the pad state has changed
  14958. */
  14959. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  14960. /**
  14961. * Fired when controllers stick values have changed
  14962. */
  14963. onPadValuesChangedObservable: Observable<StickValues>;
  14964. /**
  14965. * Array of button availible on the controller
  14966. */
  14967. protected _buttons: Array<MutableGamepadButton>;
  14968. private _onButtonStateChange;
  14969. /**
  14970. * Fired when a controller button's state has changed
  14971. * @param callback the callback containing the button that was modified
  14972. */
  14973. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  14974. /**
  14975. * X and Y axis corresponding to the controllers joystick
  14976. */
  14977. pad: StickValues;
  14978. /**
  14979. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  14980. */
  14981. hand: string;
  14982. /**
  14983. * The default controller model for the controller
  14984. */
  14985. readonly defaultModel: Nullable<AbstractMesh>;
  14986. /**
  14987. * Creates a new WebVRController from a gamepad
  14988. * @param vrGamepad the gamepad that the WebVRController should be created from
  14989. */
  14990. constructor(vrGamepad: any);
  14991. /**
  14992. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  14993. */
  14994. update(): void;
  14995. /**
  14996. * Function to be called when a button is modified
  14997. */
  14998. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  14999. /**
  15000. * Loads a mesh and attaches it to the controller
  15001. * @param scene the scene the mesh should be added to
  15002. * @param meshLoaded callback for when the mesh has been loaded
  15003. */
  15004. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  15005. private _setButtonValue;
  15006. private _changes;
  15007. private _checkChanges;
  15008. /**
  15009. * Disposes of th webVRCOntroller
  15010. */
  15011. dispose(): void;
  15012. }
  15013. }
  15014. declare module "babylonjs/Lights/hemisphericLight" {
  15015. import { Nullable } from "babylonjs/types";
  15016. import { Scene } from "babylonjs/scene";
  15017. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  15018. import { Color3 } from "babylonjs/Maths/math.color";
  15019. import { Effect } from "babylonjs/Materials/effect";
  15020. import { Light } from "babylonjs/Lights/light";
  15021. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  15022. /**
  15023. * The HemisphericLight simulates the ambient environment light,
  15024. * so the passed direction is the light reflection direction, not the incoming direction.
  15025. */
  15026. export class HemisphericLight extends Light {
  15027. /**
  15028. * The groundColor is the light in the opposite direction to the one specified during creation.
  15029. * You can think of the diffuse and specular light as coming from the centre of the object in the given direction and the groundColor light in the opposite direction.
  15030. */
  15031. groundColor: Color3;
  15032. /**
  15033. * The light reflection direction, not the incoming direction.
  15034. */
  15035. direction: Vector3;
  15036. /**
  15037. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  15038. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  15039. * The HemisphericLight can't cast shadows.
  15040. * Documentation : https://doc.babylonjs.com/babylon101/lights
  15041. * @param name The friendly name of the light
  15042. * @param direction The direction of the light reflection
  15043. * @param scene The scene the light belongs to
  15044. */
  15045. constructor(name: string, direction: Vector3, scene: Scene);
  15046. protected _buildUniformLayout(): void;
  15047. /**
  15048. * Returns the string "HemisphericLight".
  15049. * @return The class name
  15050. */
  15051. getClassName(): string;
  15052. /**
  15053. * Sets the HemisphericLight direction towards the passed target (Vector3).
  15054. * Returns the updated direction.
  15055. * @param target The target the direction should point to
  15056. * @return The computed direction
  15057. */
  15058. setDirectionToTarget(target: Vector3): Vector3;
  15059. /**
  15060. * Returns the shadow generator associated to the light.
  15061. * @returns Always null for hemispheric lights because it does not support shadows.
  15062. */
  15063. getShadowGenerator(): Nullable<IShadowGenerator>;
  15064. /**
  15065. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  15066. * @param effect The effect to update
  15067. * @param lightIndex The index of the light in the effect to update
  15068. * @returns The hemispheric light
  15069. */
  15070. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  15071. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  15072. /**
  15073. * Computes the world matrix of the node
  15074. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  15075. * @param useWasUpdatedFlag defines a reserved property
  15076. * @returns the world matrix
  15077. */
  15078. computeWorldMatrix(): Matrix;
  15079. /**
  15080. * Returns the integer 3.
  15081. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  15082. */
  15083. getTypeID(): number;
  15084. /**
  15085. * Prepares the list of defines specific to the light type.
  15086. * @param defines the list of defines
  15087. * @param lightIndex defines the index of the light for the effect
  15088. */
  15089. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  15090. }
  15091. }
  15092. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  15093. /** @hidden */
  15094. export var vrMultiviewToSingleviewPixelShader: {
  15095. name: string;
  15096. shader: string;
  15097. };
  15098. }
  15099. declare module "babylonjs/Materials/Textures/MultiviewRenderTarget" {
  15100. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  15101. import { Scene } from "babylonjs/scene";
  15102. /**
  15103. * Renders to multiple views with a single draw call
  15104. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  15105. */
  15106. export class MultiviewRenderTarget extends RenderTargetTexture {
  15107. /**
  15108. * Creates a multiview render target
  15109. * @param scene scene used with the render target
  15110. * @param size the size of the render target (used for each view)
  15111. */
  15112. constructor(scene: Scene, size?: number | {
  15113. width: number;
  15114. height: number;
  15115. } | {
  15116. ratio: number;
  15117. });
  15118. /**
  15119. * @hidden
  15120. * @param faceIndex the face index, if its a cube texture
  15121. */
  15122. _bindFrameBuffer(faceIndex?: number): void;
  15123. /**
  15124. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  15125. * @returns the view count
  15126. */
  15127. getViewCount(): number;
  15128. }
  15129. }
  15130. declare module "babylonjs/Maths/math.frustum" {
  15131. import { Matrix } from "babylonjs/Maths/math.vector";
  15132. import { DeepImmutable } from "babylonjs/types";
  15133. import { Plane } from "babylonjs/Maths/math.plane";
  15134. /**
  15135. * Represents a camera frustum
  15136. */
  15137. export class Frustum {
  15138. /**
  15139. * Gets the planes representing the frustum
  15140. * @param transform matrix to be applied to the returned planes
  15141. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  15142. */
  15143. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  15144. /**
  15145. * Gets the near frustum plane transformed by the transform matrix
  15146. * @param transform transformation matrix to be applied to the resulting frustum plane
  15147. * @param frustumPlane the resuling frustum plane
  15148. */
  15149. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15150. /**
  15151. * Gets the far frustum plane transformed by the transform matrix
  15152. * @param transform transformation matrix to be applied to the resulting frustum plane
  15153. * @param frustumPlane the resuling frustum plane
  15154. */
  15155. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15156. /**
  15157. * Gets the left frustum plane transformed by the transform matrix
  15158. * @param transform transformation matrix to be applied to the resulting frustum plane
  15159. * @param frustumPlane the resuling frustum plane
  15160. */
  15161. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15162. /**
  15163. * Gets the right frustum plane transformed by the transform matrix
  15164. * @param transform transformation matrix to be applied to the resulting frustum plane
  15165. * @param frustumPlane the resuling frustum plane
  15166. */
  15167. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15168. /**
  15169. * Gets the top frustum plane transformed by the transform matrix
  15170. * @param transform transformation matrix to be applied to the resulting frustum plane
  15171. * @param frustumPlane the resuling frustum plane
  15172. */
  15173. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15174. /**
  15175. * Gets the bottom frustum plane transformed by the transform matrix
  15176. * @param transform transformation matrix to be applied to the resulting frustum plane
  15177. * @param frustumPlane the resuling frustum plane
  15178. */
  15179. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15180. /**
  15181. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  15182. * @param transform transformation matrix to be applied to the resulting frustum planes
  15183. * @param frustumPlanes the resuling frustum planes
  15184. */
  15185. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  15186. }
  15187. }
  15188. declare module "babylonjs/Engines/Extensions/engine.multiview" {
  15189. import { Camera } from "babylonjs/Cameras/camera";
  15190. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  15191. import { Nullable } from "babylonjs/types";
  15192. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  15193. import { Matrix } from "babylonjs/Maths/math.vector";
  15194. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  15195. module "babylonjs/Engines/engine" {
  15196. interface Engine {
  15197. /**
  15198. * Creates a new multiview render target
  15199. * @param width defines the width of the texture
  15200. * @param height defines the height of the texture
  15201. * @returns the created multiview texture
  15202. */
  15203. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  15204. /**
  15205. * Binds a multiview framebuffer to be drawn to
  15206. * @param multiviewTexture texture to bind
  15207. */
  15208. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  15209. }
  15210. }
  15211. module "babylonjs/Cameras/camera" {
  15212. interface Camera {
  15213. /**
  15214. * @hidden
  15215. * For cameras that cannot use multiview images to display directly. (e.g. webVR camera will render to multiview texture, then copy to each eye texture and go from there)
  15216. */
  15217. _useMultiviewToSingleView: boolean;
  15218. /**
  15219. * @hidden
  15220. * For cameras that cannot use multiview images to display directly. (e.g. webVR camera will render to multiview texture, then copy to each eye texture and go from there)
  15221. */
  15222. _multiviewTexture: Nullable<RenderTargetTexture>;
  15223. /**
  15224. * @hidden
  15225. * ensures the multiview texture of the camera exists and has the specified width/height
  15226. * @param width height to set on the multiview texture
  15227. * @param height width to set on the multiview texture
  15228. */
  15229. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  15230. }
  15231. }
  15232. module "babylonjs/scene" {
  15233. interface Scene {
  15234. /** @hidden */
  15235. _transformMatrixR: Matrix;
  15236. /** @hidden */
  15237. _multiviewSceneUbo: Nullable<UniformBuffer>;
  15238. /** @hidden */
  15239. _createMultiviewUbo(): void;
  15240. /** @hidden */
  15241. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  15242. /** @hidden */
  15243. _renderMultiviewToSingleView(camera: Camera): void;
  15244. }
  15245. }
  15246. }
  15247. declare module "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess" {
  15248. import { Camera } from "babylonjs/Cameras/camera";
  15249. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  15250. import "babylonjs/Shaders/vrMultiviewToSingleview.fragment";
  15251. import "babylonjs/Engines/Extensions/engine.multiview";
  15252. /**
  15253. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  15254. * This will not be used for webXR as it supports displaying texture arrays directly
  15255. */
  15256. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  15257. /**
  15258. * Initializes a VRMultiviewToSingleview
  15259. * @param name name of the post process
  15260. * @param camera camera to be applied to
  15261. * @param scaleFactor scaling factor to the size of the output texture
  15262. */
  15263. constructor(name: string, camera: Camera, scaleFactor: number);
  15264. }
  15265. }
  15266. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  15267. declare module "babylonjs/Engines/Extensions/engine.webVR" {
  15268. import { Nullable } from "babylonjs/types";
  15269. import { Size } from "babylonjs/Maths/math.size";
  15270. import { Observable } from "babylonjs/Misc/observable";
  15271. import { WebVROptions } from "babylonjs/Cameras/VR/webVRCamera";
  15272. /**
  15273. * Interface used to define additional presentation attributes
  15274. */
  15275. export interface IVRPresentationAttributes {
  15276. /**
  15277. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  15278. */
  15279. highRefreshRate: boolean;
  15280. /**
  15281. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  15282. */
  15283. foveationLevel: number;
  15284. }
  15285. module "babylonjs/Engines/engine" {
  15286. interface Engine {
  15287. /** @hidden */
  15288. _vrDisplay: any;
  15289. /** @hidden */
  15290. _vrSupported: boolean;
  15291. /** @hidden */
  15292. _oldSize: Size;
  15293. /** @hidden */
  15294. _oldHardwareScaleFactor: number;
  15295. /** @hidden */
  15296. _vrExclusivePointerMode: boolean;
  15297. /** @hidden */
  15298. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  15299. /** @hidden */
  15300. _onVRDisplayPointerRestricted: () => void;
  15301. /** @hidden */
  15302. _onVRDisplayPointerUnrestricted: () => void;
  15303. /** @hidden */
  15304. _onVrDisplayConnect: Nullable<(display: any) => void>;
  15305. /** @hidden */
  15306. _onVrDisplayDisconnect: Nullable<() => void>;
  15307. /** @hidden */
  15308. _onVrDisplayPresentChange: Nullable<() => void>;
  15309. /**
  15310. * Observable signaled when VR display mode changes
  15311. */
  15312. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  15313. /**
  15314. * Observable signaled when VR request present is complete
  15315. */
  15316. onVRRequestPresentComplete: Observable<boolean>;
  15317. /**
  15318. * Observable signaled when VR request present starts
  15319. */
  15320. onVRRequestPresentStart: Observable<Engine>;
  15321. /**
  15322. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  15323. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  15324. */
  15325. isInVRExclusivePointerMode: boolean;
  15326. /**
  15327. * Gets a boolean indicating if a webVR device was detected
  15328. * @returns true if a webVR device was detected
  15329. */
  15330. isVRDevicePresent(): boolean;
  15331. /**
  15332. * Gets the current webVR device
  15333. * @returns the current webVR device (or null)
  15334. */
  15335. getVRDevice(): any;
  15336. /**
  15337. * Initializes a webVR display and starts listening to display change events
  15338. * The onVRDisplayChangedObservable will be notified upon these changes
  15339. * @returns A promise containing a VRDisplay and if vr is supported
  15340. */
  15341. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  15342. /** @hidden */
  15343. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  15344. /**
  15345. * Gets or sets the presentation attributes used to configure VR rendering
  15346. */
  15347. vrPresentationAttributes?: IVRPresentationAttributes;
  15348. /**
  15349. * Call this function to switch to webVR mode
  15350. * Will do nothing if webVR is not supported or if there is no webVR device
  15351. * @param options the webvr options provided to the camera. mainly used for multiview
  15352. * @see http://doc.babylonjs.com/how_to/webvr_camera
  15353. */
  15354. enableVR(options: WebVROptions): void;
  15355. /** @hidden */
  15356. _onVRFullScreenTriggered(): void;
  15357. }
  15358. }
  15359. }
  15360. declare module "babylonjs/Cameras/VR/webVRCamera" {
  15361. import { Nullable } from "babylonjs/types";
  15362. import { Observable } from "babylonjs/Misc/observable";
  15363. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  15364. import { Scene } from "babylonjs/scene";
  15365. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  15366. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  15367. import { Node } from "babylonjs/node";
  15368. import { Ray } from "babylonjs/Culling/ray";
  15369. import "babylonjs/Cameras/RigModes/webVRRigMode";
  15370. import "babylonjs/Engines/Extensions/engine.webVR";
  15371. /**
  15372. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  15373. * IMPORTANT!! The data is right-hand data.
  15374. * @export
  15375. * @interface DevicePose
  15376. */
  15377. export interface DevicePose {
  15378. /**
  15379. * The position of the device, values in array are [x,y,z].
  15380. */
  15381. readonly position: Nullable<Float32Array>;
  15382. /**
  15383. * The linearVelocity of the device, values in array are [x,y,z].
  15384. */
  15385. readonly linearVelocity: Nullable<Float32Array>;
  15386. /**
  15387. * The linearAcceleration of the device, values in array are [x,y,z].
  15388. */
  15389. readonly linearAcceleration: Nullable<Float32Array>;
  15390. /**
  15391. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  15392. */
  15393. readonly orientation: Nullable<Float32Array>;
  15394. /**
  15395. * The angularVelocity of the device, values in array are [x,y,z].
  15396. */
  15397. readonly angularVelocity: Nullable<Float32Array>;
  15398. /**
  15399. * The angularAcceleration of the device, values in array are [x,y,z].
  15400. */
  15401. readonly angularAcceleration: Nullable<Float32Array>;
  15402. }
  15403. /**
  15404. * Interface representing a pose controlled object in Babylon.
  15405. * A pose controlled object has both regular pose values as well as pose values
  15406. * from an external device such as a VR head mounted display
  15407. */
  15408. export interface PoseControlled {
  15409. /**
  15410. * The position of the object in babylon space.
  15411. */
  15412. position: Vector3;
  15413. /**
  15414. * The rotation quaternion of the object in babylon space.
  15415. */
  15416. rotationQuaternion: Quaternion;
  15417. /**
  15418. * The position of the device in babylon space.
  15419. */
  15420. devicePosition?: Vector3;
  15421. /**
  15422. * The rotation quaternion of the device in babylon space.
  15423. */
  15424. deviceRotationQuaternion: Quaternion;
  15425. /**
  15426. * The raw pose coming from the device.
  15427. */
  15428. rawPose: Nullable<DevicePose>;
  15429. /**
  15430. * The scale of the device to be used when translating from device space to babylon space.
  15431. */
  15432. deviceScaleFactor: number;
  15433. /**
  15434. * Updates the poseControlled values based on the input device pose.
  15435. * @param poseData the pose data to update the object with
  15436. */
  15437. updateFromDevice(poseData: DevicePose): void;
  15438. }
  15439. /**
  15440. * Set of options to customize the webVRCamera
  15441. */
  15442. export interface WebVROptions {
  15443. /**
  15444. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  15445. */
  15446. trackPosition?: boolean;
  15447. /**
  15448. * Sets the scale of the vrDevice in babylon space. (default: 1)
  15449. */
  15450. positionScale?: number;
  15451. /**
  15452. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  15453. */
  15454. displayName?: string;
  15455. /**
  15456. * Should the native controller meshes be initialized. (default: true)
  15457. */
  15458. controllerMeshes?: boolean;
  15459. /**
  15460. * Creating a default HemiLight only on controllers. (default: true)
  15461. */
  15462. defaultLightingOnControllers?: boolean;
  15463. /**
  15464. * If you don't want to use the default VR button of the helper. (default: false)
  15465. */
  15466. useCustomVRButton?: boolean;
  15467. /**
  15468. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  15469. */
  15470. customVRButton?: HTMLButtonElement;
  15471. /**
  15472. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  15473. */
  15474. rayLength?: number;
  15475. /**
  15476. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  15477. */
  15478. defaultHeight?: number;
  15479. /**
  15480. * If multiview should be used if availible (default: false)
  15481. */
  15482. useMultiview?: boolean;
  15483. }
  15484. /**
  15485. * This represents a WebVR camera.
  15486. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  15487. * @example http://doc.babylonjs.com/how_to/webvr_camera
  15488. */
  15489. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  15490. private webVROptions;
  15491. /**
  15492. * @hidden
  15493. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  15494. */
  15495. _vrDevice: any;
  15496. /**
  15497. * The rawPose of the vrDevice.
  15498. */
  15499. rawPose: Nullable<DevicePose>;
  15500. private _onVREnabled;
  15501. private _specsVersion;
  15502. private _attached;
  15503. private _frameData;
  15504. protected _descendants: Array<Node>;
  15505. private _deviceRoomPosition;
  15506. /** @hidden */
  15507. _deviceRoomRotationQuaternion: Quaternion;
  15508. private _standingMatrix;
  15509. /**
  15510. * Represents device position in babylon space.
  15511. */
  15512. devicePosition: Vector3;
  15513. /**
  15514. * Represents device rotation in babylon space.
  15515. */
  15516. deviceRotationQuaternion: Quaternion;
  15517. /**
  15518. * The scale of the device to be used when translating from device space to babylon space.
  15519. */
  15520. deviceScaleFactor: number;
  15521. private _deviceToWorld;
  15522. private _worldToDevice;
  15523. /**
  15524. * References to the webVR controllers for the vrDevice.
  15525. */
  15526. controllers: Array<WebVRController>;
  15527. /**
  15528. * Emits an event when a controller is attached.
  15529. */
  15530. onControllersAttachedObservable: Observable<WebVRController[]>;
  15531. /**
  15532. * Emits an event when a controller's mesh has been loaded;
  15533. */
  15534. onControllerMeshLoadedObservable: Observable<WebVRController>;
  15535. /**
  15536. * Emits an event when the HMD's pose has been updated.
  15537. */
  15538. onPoseUpdatedFromDeviceObservable: Observable<any>;
  15539. private _poseSet;
  15540. /**
  15541. * If the rig cameras be used as parent instead of this camera.
  15542. */
  15543. rigParenting: boolean;
  15544. private _lightOnControllers;
  15545. private _defaultHeight?;
  15546. /**
  15547. * Instantiates a WebVRFreeCamera.
  15548. * @param name The name of the WebVRFreeCamera
  15549. * @param position The starting anchor position for the camera
  15550. * @param scene The scene the camera belongs to
  15551. * @param webVROptions a set of customizable options for the webVRCamera
  15552. */
  15553. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  15554. /**
  15555. * Gets the device distance from the ground in meters.
  15556. * @returns the distance in meters from the vrDevice to ground in device space. If standing matrix is not supported for the vrDevice 0 is returned.
  15557. */
  15558. deviceDistanceToRoomGround(): number;
  15559. /**
  15560. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15561. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  15562. */
  15563. useStandingMatrix(callback?: (bool: boolean) => void): void;
  15564. /**
  15565. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15566. * @returns A promise with a boolean set to if the standing matrix is supported.
  15567. */
  15568. useStandingMatrixAsync(): Promise<boolean>;
  15569. /**
  15570. * Disposes the camera
  15571. */
  15572. dispose(): void;
  15573. /**
  15574. * Gets a vrController by name.
  15575. * @param name The name of the controller to retreive
  15576. * @returns the controller matching the name specified or null if not found
  15577. */
  15578. getControllerByName(name: string): Nullable<WebVRController>;
  15579. private _leftController;
  15580. /**
  15581. * The controller corresponding to the users left hand.
  15582. */
  15583. readonly leftController: Nullable<WebVRController>;
  15584. private _rightController;
  15585. /**
  15586. * The controller corresponding to the users right hand.
  15587. */
  15588. readonly rightController: Nullable<WebVRController>;
  15589. /**
  15590. * Casts a ray forward from the vrCamera's gaze.
  15591. * @param length Length of the ray (default: 100)
  15592. * @returns the ray corresponding to the gaze
  15593. */
  15594. getForwardRay(length?: number): Ray;
  15595. /**
  15596. * @hidden
  15597. * Updates the camera based on device's frame data
  15598. */
  15599. _checkInputs(): void;
  15600. /**
  15601. * Updates the poseControlled values based on the input device pose.
  15602. * @param poseData Pose coming from the device
  15603. */
  15604. updateFromDevice(poseData: DevicePose): void;
  15605. private _htmlElementAttached;
  15606. private _detachIfAttached;
  15607. /**
  15608. * WebVR's attach control will start broadcasting frames to the device.
  15609. * Note that in certain browsers (chrome for example) this function must be called
  15610. * within a user-interaction callback. Example:
  15611. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  15612. *
  15613. * @param element html element to attach the vrDevice to
  15614. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  15615. */
  15616. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  15617. /**
  15618. * Detaches the camera from the html element and disables VR
  15619. *
  15620. * @param element html element to detach from
  15621. */
  15622. detachControl(element: HTMLElement): void;
  15623. /**
  15624. * @returns the name of this class
  15625. */
  15626. getClassName(): string;
  15627. /**
  15628. * Calls resetPose on the vrDisplay
  15629. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  15630. */
  15631. resetToCurrentRotation(): void;
  15632. /**
  15633. * @hidden
  15634. * Updates the rig cameras (left and right eye)
  15635. */
  15636. _updateRigCameras(): void;
  15637. private _workingVector;
  15638. private _oneVector;
  15639. private _workingMatrix;
  15640. private updateCacheCalled;
  15641. private _correctPositionIfNotTrackPosition;
  15642. /**
  15643. * @hidden
  15644. * Updates the cached values of the camera
  15645. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  15646. */
  15647. _updateCache(ignoreParentClass?: boolean): void;
  15648. /**
  15649. * @hidden
  15650. * Get current device position in babylon world
  15651. */
  15652. _computeDevicePosition(): void;
  15653. /**
  15654. * Updates the current device position and rotation in the babylon world
  15655. */
  15656. update(): void;
  15657. /**
  15658. * @hidden
  15659. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  15660. * @returns an identity matrix
  15661. */
  15662. _getViewMatrix(): Matrix;
  15663. private _tmpMatrix;
  15664. /**
  15665. * This function is called by the two RIG cameras.
  15666. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  15667. * @hidden
  15668. */
  15669. _getWebVRViewMatrix(): Matrix;
  15670. /** @hidden */
  15671. _getWebVRProjectionMatrix(): Matrix;
  15672. private _onGamepadConnectedObserver;
  15673. private _onGamepadDisconnectedObserver;
  15674. private _updateCacheWhenTrackingDisabledObserver;
  15675. /**
  15676. * Initializes the controllers and their meshes
  15677. */
  15678. initControllers(): void;
  15679. }
  15680. }
  15681. declare module "babylonjs/PostProcesses/postProcess" {
  15682. import { Nullable } from "babylonjs/types";
  15683. import { SmartArray } from "babylonjs/Misc/smartArray";
  15684. import { Observable } from "babylonjs/Misc/observable";
  15685. import { Vector2 } from "babylonjs/Maths/math.vector";
  15686. import { Camera } from "babylonjs/Cameras/camera";
  15687. import { Effect } from "babylonjs/Materials/effect";
  15688. import "babylonjs/Shaders/postprocess.vertex";
  15689. import { IInspectable } from "babylonjs/Misc/iInspectable";
  15690. import { Engine } from "babylonjs/Engines/engine";
  15691. import { Color4 } from "babylonjs/Maths/math.color";
  15692. import "babylonjs/Engines/Extensions/engine.renderTarget";
  15693. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  15694. /**
  15695. * Size options for a post process
  15696. */
  15697. export type PostProcessOptions = {
  15698. width: number;
  15699. height: number;
  15700. };
  15701. /**
  15702. * PostProcess can be used to apply a shader to a texture after it has been rendered
  15703. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  15704. */
  15705. export class PostProcess {
  15706. /** Name of the PostProcess. */
  15707. name: string;
  15708. /**
  15709. * Gets or sets the unique id of the post process
  15710. */
  15711. uniqueId: number;
  15712. /**
  15713. * Width of the texture to apply the post process on
  15714. */
  15715. width: number;
  15716. /**
  15717. * Height of the texture to apply the post process on
  15718. */
  15719. height: number;
  15720. /**
  15721. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  15722. * @hidden
  15723. */
  15724. _outputTexture: Nullable<InternalTexture>;
  15725. /**
  15726. * Sampling mode used by the shader
  15727. * See https://doc.babylonjs.com/classes/3.1/texture
  15728. */
  15729. renderTargetSamplingMode: number;
  15730. /**
  15731. * Clear color to use when screen clearing
  15732. */
  15733. clearColor: Color4;
  15734. /**
  15735. * If the buffer needs to be cleared before applying the post process. (default: true)
  15736. * Should be set to false if shader will overwrite all previous pixels.
  15737. */
  15738. autoClear: boolean;
  15739. /**
  15740. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  15741. */
  15742. alphaMode: number;
  15743. /**
  15744. * Sets the setAlphaBlendConstants of the babylon engine
  15745. */
  15746. alphaConstants: Color4;
  15747. /**
  15748. * Animations to be used for the post processing
  15749. */
  15750. animations: import("babylonjs/Animations/animation").Animation[];
  15751. /**
  15752. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  15753. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  15754. */
  15755. enablePixelPerfectMode: boolean;
  15756. /**
  15757. * Force the postprocess to be applied without taking in account viewport
  15758. */
  15759. forceFullscreenViewport: boolean;
  15760. /**
  15761. * List of inspectable custom properties (used by the Inspector)
  15762. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15763. */
  15764. inspectableCustomProperties: IInspectable[];
  15765. /**
  15766. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  15767. *
  15768. * | Value | Type | Description |
  15769. * | ----- | ----------------------------------- | ----------- |
  15770. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  15771. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  15772. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  15773. *
  15774. */
  15775. scaleMode: number;
  15776. /**
  15777. * Force textures to be a power of two (default: false)
  15778. */
  15779. alwaysForcePOT: boolean;
  15780. private _samples;
  15781. /**
  15782. * Number of sample textures (default: 1)
  15783. */
  15784. samples: number;
  15785. /**
  15786. * Modify the scale of the post process to be the same as the viewport (default: false)
  15787. */
  15788. adaptScaleToCurrentViewport: boolean;
  15789. private _camera;
  15790. private _scene;
  15791. private _engine;
  15792. private _options;
  15793. private _reusable;
  15794. private _textureType;
  15795. /**
  15796. * Smart array of input and output textures for the post process.
  15797. * @hidden
  15798. */
  15799. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  15800. /**
  15801. * The index in _textures that corresponds to the output texture.
  15802. * @hidden
  15803. */
  15804. _currentRenderTextureInd: number;
  15805. private _effect;
  15806. private _samplers;
  15807. private _fragmentUrl;
  15808. private _vertexUrl;
  15809. private _parameters;
  15810. private _scaleRatio;
  15811. protected _indexParameters: any;
  15812. private _shareOutputWithPostProcess;
  15813. private _texelSize;
  15814. private _forcedOutputTexture;
  15815. /**
  15816. * Returns the fragment url or shader name used in the post process.
  15817. * @returns the fragment url or name in the shader store.
  15818. */
  15819. getEffectName(): string;
  15820. /**
  15821. * An event triggered when the postprocess is activated.
  15822. */
  15823. onActivateObservable: Observable<Camera>;
  15824. private _onActivateObserver;
  15825. /**
  15826. * A function that is added to the onActivateObservable
  15827. */
  15828. onActivate: Nullable<(camera: Camera) => void>;
  15829. /**
  15830. * An event triggered when the postprocess changes its size.
  15831. */
  15832. onSizeChangedObservable: Observable<PostProcess>;
  15833. private _onSizeChangedObserver;
  15834. /**
  15835. * A function that is added to the onSizeChangedObservable
  15836. */
  15837. onSizeChanged: (postProcess: PostProcess) => void;
  15838. /**
  15839. * An event triggered when the postprocess applies its effect.
  15840. */
  15841. onApplyObservable: Observable<Effect>;
  15842. private _onApplyObserver;
  15843. /**
  15844. * A function that is added to the onApplyObservable
  15845. */
  15846. onApply: (effect: Effect) => void;
  15847. /**
  15848. * An event triggered before rendering the postprocess
  15849. */
  15850. onBeforeRenderObservable: Observable<Effect>;
  15851. private _onBeforeRenderObserver;
  15852. /**
  15853. * A function that is added to the onBeforeRenderObservable
  15854. */
  15855. onBeforeRender: (effect: Effect) => void;
  15856. /**
  15857. * An event triggered after rendering the postprocess
  15858. */
  15859. onAfterRenderObservable: Observable<Effect>;
  15860. private _onAfterRenderObserver;
  15861. /**
  15862. * A function that is added to the onAfterRenderObservable
  15863. */
  15864. onAfterRender: (efect: Effect) => void;
  15865. /**
  15866. * The input texture for this post process and the output texture of the previous post process. When added to a pipeline the previous post process will
  15867. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  15868. */
  15869. inputTexture: InternalTexture;
  15870. /**
  15871. * Gets the camera which post process is applied to.
  15872. * @returns The camera the post process is applied to.
  15873. */
  15874. getCamera(): Camera;
  15875. /**
  15876. * Gets the texel size of the postprocess.
  15877. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  15878. */
  15879. readonly texelSize: Vector2;
  15880. /**
  15881. * Creates a new instance PostProcess
  15882. * @param name The name of the PostProcess.
  15883. * @param fragmentUrl The url of the fragment shader to be used.
  15884. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  15885. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  15886. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15887. * @param camera The camera to apply the render pass to.
  15888. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15889. * @param engine The engine which the post process will be applied. (default: current engine)
  15890. * @param reusable If the post process can be reused on the same frame. (default: false)
  15891. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  15892. * @param textureType Type of textures used when performing the post process. (default: 0)
  15893. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  15894. * @param indexParameters The index parameters to be used for babylons include syntax "#include<kernelBlurVaryingDeclaration>[0..varyingCount]". (default: undefined) See usage in babylon.blurPostProcess.ts and kernelBlur.vertex.fx
  15895. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  15896. */
  15897. constructor(
  15898. /** Name of the PostProcess. */
  15899. name: string, fragmentUrl: string, parameters: Nullable<string[]>, samplers: Nullable<string[]>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, defines?: Nullable<string>, textureType?: number, vertexUrl?: string, indexParameters?: any, blockCompilation?: boolean);
  15900. /**
  15901. * Gets a string idenfifying the name of the class
  15902. * @returns "PostProcess" string
  15903. */
  15904. getClassName(): string;
  15905. /**
  15906. * Gets the engine which this post process belongs to.
  15907. * @returns The engine the post process was enabled with.
  15908. */
  15909. getEngine(): Engine;
  15910. /**
  15911. * The effect that is created when initializing the post process.
  15912. * @returns The created effect corresponding the the postprocess.
  15913. */
  15914. getEffect(): Effect;
  15915. /**
  15916. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  15917. * @param postProcess The post process to share the output with.
  15918. * @returns This post process.
  15919. */
  15920. shareOutputWith(postProcess: PostProcess): PostProcess;
  15921. /**
  15922. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  15923. * This should be called if the post process that shares output with this post process is disabled/disposed.
  15924. */
  15925. useOwnOutput(): void;
  15926. /**
  15927. * Updates the effect with the current post process compile time values and recompiles the shader.
  15928. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15929. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15930. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15931. * @param indexParameters The index parameters to be used for babylons include syntax "#include<kernelBlurVaryingDeclaration>[0..varyingCount]". (default: undefined) See usage in babylon.blurPostProcess.ts and kernelBlur.vertex.fx
  15932. * @param onCompiled Called when the shader has been compiled.
  15933. * @param onError Called if there is an error when compiling a shader.
  15934. */
  15935. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15936. /**
  15937. * The post process is reusable if it can be used multiple times within one frame.
  15938. * @returns If the post process is reusable
  15939. */
  15940. isReusable(): boolean;
  15941. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  15942. markTextureDirty(): void;
  15943. /**
  15944. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  15945. * When this post process is used in a pipeline, this is call will bind the input texture of this post process to the output of the previous.
  15946. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  15947. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  15948. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  15949. * @returns The target texture that was bound to be written to.
  15950. */
  15951. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  15952. /**
  15953. * If the post process is supported.
  15954. */
  15955. readonly isSupported: boolean;
  15956. /**
  15957. * The aspect ratio of the output texture.
  15958. */
  15959. readonly aspectRatio: number;
  15960. /**
  15961. * Get a value indicating if the post-process is ready to be used
  15962. * @returns true if the post-process is ready (shader is compiled)
  15963. */
  15964. isReady(): boolean;
  15965. /**
  15966. * Binds all textures and uniforms to the shader, this will be run on every pass.
  15967. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  15968. */
  15969. apply(): Nullable<Effect>;
  15970. private _disposeTextures;
  15971. /**
  15972. * Disposes the post process.
  15973. * @param camera The camera to dispose the post process on.
  15974. */
  15975. dispose(camera?: Camera): void;
  15976. }
  15977. }
  15978. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  15979. /** @hidden */
  15980. export var kernelBlurVaryingDeclaration: {
  15981. name: string;
  15982. shader: string;
  15983. };
  15984. }
  15985. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  15986. /** @hidden */
  15987. export var kernelBlurFragment: {
  15988. name: string;
  15989. shader: string;
  15990. };
  15991. }
  15992. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  15993. /** @hidden */
  15994. export var kernelBlurFragment2: {
  15995. name: string;
  15996. shader: string;
  15997. };
  15998. }
  15999. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  16000. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  16001. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  16002. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  16003. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  16004. /** @hidden */
  16005. export var kernelBlurPixelShader: {
  16006. name: string;
  16007. shader: string;
  16008. };
  16009. }
  16010. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  16011. /** @hidden */
  16012. export var kernelBlurVertex: {
  16013. name: string;
  16014. shader: string;
  16015. };
  16016. }
  16017. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  16018. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  16019. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  16020. /** @hidden */
  16021. export var kernelBlurVertexShader: {
  16022. name: string;
  16023. shader: string;
  16024. };
  16025. }
  16026. declare module "babylonjs/PostProcesses/blurPostProcess" {
  16027. import { Vector2 } from "babylonjs/Maths/math.vector";
  16028. import { Nullable } from "babylonjs/types";
  16029. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  16030. import { Camera } from "babylonjs/Cameras/camera";
  16031. import { Effect } from "babylonjs/Materials/effect";
  16032. import { Engine } from "babylonjs/Engines/engine";
  16033. import "babylonjs/Shaders/kernelBlur.fragment";
  16034. import "babylonjs/Shaders/kernelBlur.vertex";
  16035. /**
  16036. * The Blur Post Process which blurs an image based on a kernel and direction.
  16037. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  16038. */
  16039. export class BlurPostProcess extends PostProcess {
  16040. /** The direction in which to blur the image. */
  16041. direction: Vector2;
  16042. private blockCompilation;
  16043. protected _kernel: number;
  16044. protected _idealKernel: number;
  16045. protected _packedFloat: boolean;
  16046. private _staticDefines;
  16047. /**
  16048. * Sets the length in pixels of the blur sample region
  16049. */
  16050. /**
  16051. * Gets the length in pixels of the blur sample region
  16052. */
  16053. kernel: number;
  16054. /**
  16055. * Sets wether or not the blur needs to unpack/repack floats
  16056. */
  16057. /**
  16058. * Gets wether or not the blur is unpacking/repacking floats
  16059. */
  16060. packedFloat: boolean;
  16061. /**
  16062. * Creates a new instance BlurPostProcess
  16063. * @param name The name of the effect.
  16064. * @param direction The direction in which to blur the image.
  16065. * @param kernel The size of the kernel to be used when computing the blur. eg. Size of 3 will blur the center pixel by 2 pixels surrounding it.
  16066. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  16067. * @param camera The camera to apply the render pass to.
  16068. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  16069. * @param engine The engine which the post process will be applied. (default: current engine)
  16070. * @param reusable If the post process can be reused on the same frame. (default: false)
  16071. * @param textureType Type of textures used when performing the post process. (default: 0)
  16072. * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)
  16073. */
  16074. constructor(name: string,
  16075. /** The direction in which to blur the image. */
  16076. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  16077. /**
  16078. * Updates the effect with the current post process compile time values and recompiles the shader.
  16079. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  16080. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  16081. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  16082. * @param indexParameters The index parameters to be used for babylons include syntax "#include<kernelBlurVaryingDeclaration>[0..varyingCount]". (default: undefined) See usage in babylon.blurPostProcess.ts and kernelBlur.vertex.fx
  16083. * @param onCompiled Called when the shader has been compiled.
  16084. * @param onError Called if there is an error when compiling a shader.
  16085. */
  16086. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  16087. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  16088. /**
  16089. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  16090. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  16091. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  16092. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  16093. * The gaps between physical kernels are compensated for in the weighting of the samples
  16094. * @param idealKernel Ideal blur kernel.
  16095. * @return Nearest best kernel.
  16096. */
  16097. protected _nearestBestKernel(idealKernel: number): number;
  16098. /**
  16099. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  16100. * @param x The point on the Gaussian distribution to sample.
  16101. * @return the value of the Gaussian function at x.
  16102. */
  16103. protected _gaussianWeight(x: number): number;
  16104. /**
  16105. * Generates a string that can be used as a floating point number in GLSL.
  16106. * @param x Value to print.
  16107. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  16108. * @return GLSL float string.
  16109. */
  16110. protected _glslFloat(x: number, decimalFigures?: number): string;
  16111. }
  16112. }
  16113. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  16114. import { Scene } from "babylonjs/scene";
  16115. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  16116. import { Plane } from "babylonjs/Maths/math.plane";
  16117. /**
  16118. * Mirror texture can be used to simulate the view from a mirror in a scene.
  16119. * It will dynamically be rendered every frame to adapt to the camera point of view.
  16120. * You can then easily use it as a reflectionTexture on a flat surface.
  16121. * In case the surface is not a plane, please consider relying on reflection probes.
  16122. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  16123. */
  16124. export class MirrorTexture extends RenderTargetTexture {
  16125. private scene;
  16126. /**
  16127. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  16128. * It is possible to directly set the mirrorPlane by directly using a Plane(a, b, c, d) where a, b and c give the plane normal vector (a, b, c) and d is a scalar displacement from the mirrorPlane to the origin. However in all but the very simplest of situations it is more straight forward to set it to the reflector as stated in the doc.
  16129. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  16130. */
  16131. mirrorPlane: Plane;
  16132. /**
  16133. * Define the blur ratio used to blur the reflection if needed.
  16134. */
  16135. blurRatio: number;
  16136. /**
  16137. * Define the adaptive blur kernel used to blur the reflection if needed.
  16138. * This will autocompute the closest best match for the `blurKernel`
  16139. */
  16140. adaptiveBlurKernel: number;
  16141. /**
  16142. * Define the blur kernel used to blur the reflection if needed.
  16143. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  16144. */
  16145. blurKernel: number;
  16146. /**
  16147. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  16148. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  16149. */
  16150. blurKernelX: number;
  16151. /**
  16152. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  16153. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  16154. */
  16155. blurKernelY: number;
  16156. private _autoComputeBlurKernel;
  16157. protected _onRatioRescale(): void;
  16158. private _updateGammaSpace;
  16159. private _imageProcessingConfigChangeObserver;
  16160. private _transformMatrix;
  16161. private _mirrorMatrix;
  16162. private _savedViewMatrix;
  16163. private _blurX;
  16164. private _blurY;
  16165. private _adaptiveBlurKernel;
  16166. private _blurKernelX;
  16167. private _blurKernelY;
  16168. private _blurRatio;
  16169. /**
  16170. * Instantiates a Mirror Texture.
  16171. * Mirror texture can be used to simulate the view from a mirror in a scene.
  16172. * It will dynamically be rendered every frame to adapt to the camera point of view.
  16173. * You can then easily use it as a reflectionTexture on a flat surface.
  16174. * In case the surface is not a plane, please consider relying on reflection probes.
  16175. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  16176. * @param name
  16177. * @param size
  16178. * @param scene
  16179. * @param generateMipMaps
  16180. * @param type
  16181. * @param samplingMode
  16182. * @param generateDepthBuffer
  16183. */
  16184. constructor(name: string, size: number | {
  16185. width: number;
  16186. height: number;
  16187. } | {
  16188. ratio: number;
  16189. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  16190. private _preparePostProcesses;
  16191. /**
  16192. * Clone the mirror texture.
  16193. * @returns the cloned texture
  16194. */
  16195. clone(): MirrorTexture;
  16196. /**
  16197. * Serialize the texture to a JSON representation you could use in Parse later on
  16198. * @returns the serialized JSON representation
  16199. */
  16200. serialize(): any;
  16201. /**
  16202. * Dispose the texture and release its associated resources.
  16203. */
  16204. dispose(): void;
  16205. }
  16206. }
  16207. declare module "babylonjs/Materials/Textures/texture" {
  16208. import { Observable } from "babylonjs/Misc/observable";
  16209. import { Nullable } from "babylonjs/types";
  16210. import { Matrix } from "babylonjs/Maths/math.vector";
  16211. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  16212. import { IInspectable } from "babylonjs/Misc/iInspectable";
  16213. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  16214. import { Scene } from "babylonjs/scene";
  16215. /**
  16216. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  16217. * @see http://doc.babylonjs.com/babylon101/materials#texture
  16218. */
  16219. export class Texture extends BaseTexture {
  16220. /**
  16221. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  16222. */
  16223. static SerializeBuffers: boolean;
  16224. /** @hidden */
  16225. static _CubeTextureParser: (jsonTexture: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => import("babylonjs/Materials/Textures/cubeTexture").CubeTexture;
  16226. /** @hidden */
  16227. static _CreateMirror: (name: string, renderTargetSize: number, scene: import("babylonjs/scene").Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/mirrorTexture").MirrorTexture;
  16228. /** @hidden */
  16229. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: import("babylonjs/scene").Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture;
  16230. /** nearest is mag = nearest and min = nearest and mip = linear */
  16231. static readonly NEAREST_SAMPLINGMODE: number;
  16232. /** nearest is mag = nearest and min = nearest and mip = linear */
  16233. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  16234. /** Bilinear is mag = linear and min = linear and mip = nearest */
  16235. static readonly BILINEAR_SAMPLINGMODE: number;
  16236. /** Bilinear is mag = linear and min = linear and mip = nearest */
  16237. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  16238. /** Trilinear is mag = linear and min = linear and mip = linear */
  16239. static readonly TRILINEAR_SAMPLINGMODE: number;
  16240. /** Trilinear is mag = linear and min = linear and mip = linear */
  16241. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  16242. /** mag = nearest and min = nearest and mip = nearest */
  16243. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  16244. /** mag = nearest and min = linear and mip = nearest */
  16245. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  16246. /** mag = nearest and min = linear and mip = linear */
  16247. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  16248. /** mag = nearest and min = linear and mip = none */
  16249. static readonly NEAREST_LINEAR: number;
  16250. /** mag = nearest and min = nearest and mip = none */
  16251. static readonly NEAREST_NEAREST: number;
  16252. /** mag = linear and min = nearest and mip = nearest */
  16253. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  16254. /** mag = linear and min = nearest and mip = linear */
  16255. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  16256. /** mag = linear and min = linear and mip = none */
  16257. static readonly LINEAR_LINEAR: number;
  16258. /** mag = linear and min = nearest and mip = none */
  16259. static readonly LINEAR_NEAREST: number;
  16260. /** Explicit coordinates mode */
  16261. static readonly EXPLICIT_MODE: number;
  16262. /** Spherical coordinates mode */
  16263. static readonly SPHERICAL_MODE: number;
  16264. /** Planar coordinates mode */
  16265. static readonly PLANAR_MODE: number;
  16266. /** Cubic coordinates mode */
  16267. static readonly CUBIC_MODE: number;
  16268. /** Projection coordinates mode */
  16269. static readonly PROJECTION_MODE: number;
  16270. /** Inverse Cubic coordinates mode */
  16271. static readonly SKYBOX_MODE: number;
  16272. /** Inverse Cubic coordinates mode */
  16273. static readonly INVCUBIC_MODE: number;
  16274. /** Equirectangular coordinates mode */
  16275. static readonly EQUIRECTANGULAR_MODE: number;
  16276. /** Equirectangular Fixed coordinates mode */
  16277. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  16278. /** Equirectangular Fixed Mirrored coordinates mode */
  16279. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  16280. /** Texture is not repeating outside of 0..1 UVs */
  16281. static readonly CLAMP_ADDRESSMODE: number;
  16282. /** Texture is repeating outside of 0..1 UVs */
  16283. static readonly WRAP_ADDRESSMODE: number;
  16284. /** Texture is repeating and mirrored */
  16285. static readonly MIRROR_ADDRESSMODE: number;
  16286. /**
  16287. * Gets or sets a boolean which defines if the texture url must be build from the serialized URL instead of just using the name and loading them side by side with the scene file
  16288. */
  16289. static UseSerializedUrlIfAny: boolean;
  16290. /**
  16291. * Define the url of the texture.
  16292. */
  16293. url: Nullable<string>;
  16294. /**
  16295. * Define an offset on the texture to offset the u coordinates of the UVs
  16296. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  16297. */
  16298. uOffset: number;
  16299. /**
  16300. * Define an offset on the texture to offset the v coordinates of the UVs
  16301. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  16302. */
  16303. vOffset: number;
  16304. /**
  16305. * Define an offset on the texture to scale the u coordinates of the UVs
  16306. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  16307. */
  16308. uScale: number;
  16309. /**
  16310. * Define an offset on the texture to scale the v coordinates of the UVs
  16311. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  16312. */
  16313. vScale: number;
  16314. /**
  16315. * Define an offset on the texture to rotate around the u coordinates of the UVs
  16316. * @see http://doc.babylonjs.com/how_to/more_materials
  16317. */
  16318. uAng: number;
  16319. /**
  16320. * Define an offset on the texture to rotate around the v coordinates of the UVs
  16321. * @see http://doc.babylonjs.com/how_to/more_materials
  16322. */
  16323. vAng: number;
  16324. /**
  16325. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  16326. * @see http://doc.babylonjs.com/how_to/more_materials
  16327. */
  16328. wAng: number;
  16329. /**
  16330. * Defines the center of rotation (U)
  16331. */
  16332. uRotationCenter: number;
  16333. /**
  16334. * Defines the center of rotation (V)
  16335. */
  16336. vRotationCenter: number;
  16337. /**
  16338. * Defines the center of rotation (W)
  16339. */
  16340. wRotationCenter: number;
  16341. /**
  16342. * Are mip maps generated for this texture or not.
  16343. */
  16344. readonly noMipmap: boolean;
  16345. /**
  16346. * List of inspectable custom properties (used by the Inspector)
  16347. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  16348. */
  16349. inspectableCustomProperties: Nullable<IInspectable[]>;
  16350. private _noMipmap;
  16351. /** @hidden */
  16352. _invertY: boolean;
  16353. private _rowGenerationMatrix;
  16354. private _cachedTextureMatrix;
  16355. private _projectionModeMatrix;
  16356. private _t0;
  16357. private _t1;
  16358. private _t2;
  16359. private _cachedUOffset;
  16360. private _cachedVOffset;
  16361. private _cachedUScale;
  16362. private _cachedVScale;
  16363. private _cachedUAng;
  16364. private _cachedVAng;
  16365. private _cachedWAng;
  16366. private _cachedProjectionMatrixId;
  16367. private _cachedCoordinatesMode;
  16368. /** @hidden */
  16369. protected _initialSamplingMode: number;
  16370. /** @hidden */
  16371. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  16372. private _deleteBuffer;
  16373. protected _format: Nullable<number>;
  16374. private _delayedOnLoad;
  16375. private _delayedOnError;
  16376. private _mimeType?;
  16377. /**
  16378. * Observable triggered once the texture has been loaded.
  16379. */
  16380. onLoadObservable: Observable<Texture>;
  16381. protected _isBlocking: boolean;
  16382. /**
  16383. * Is the texture preventing material to render while loading.
  16384. * If false, a default texture will be used instead of the loading one during the preparation step.
  16385. */
  16386. isBlocking: boolean;
  16387. /**
  16388. * Get the current sampling mode associated with the texture.
  16389. */
  16390. readonly samplingMode: number;
  16391. /**
  16392. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  16393. */
  16394. readonly invertY: boolean;
  16395. /**
  16396. * Instantiates a new texture.
  16397. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  16398. * @see http://doc.babylonjs.com/babylon101/materials#texture
  16399. * @param url defines the url of the picture to load as a texture
  16400. * @param scene defines the scene or engine the texture will belong to
  16401. * @param noMipmap defines if the texture will require mip maps or not
  16402. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  16403. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16404. * @param onLoad defines a callback triggered when the texture has been loaded
  16405. * @param onError defines a callback triggered when an error occurred during the loading session
  16406. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  16407. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  16408. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16409. * @param mimeType defines an optional mime type information
  16410. */
  16411. constructor(url: Nullable<string>, sceneOrEngine: Nullable<Scene | ThinEngine>, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, deleteBuffer?: boolean, format?: number, mimeType?: string);
  16412. /**
  16413. * Update the url (and optional buffer) of this texture if url was null during construction.
  16414. * @param url the url of the texture
  16415. * @param buffer the buffer of the texture (defaults to null)
  16416. * @param onLoad callback called when the texture is loaded (defaults to null)
  16417. */
  16418. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  16419. /**
  16420. * Finish the loading sequence of a texture flagged as delayed load.
  16421. * @hidden
  16422. */
  16423. delayLoad(): void;
  16424. private _prepareRowForTextureGeneration;
  16425. /**
  16426. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  16427. * @returns the transform matrix of the texture.
  16428. */
  16429. getTextureMatrix(uBase?: number): Matrix;
  16430. /**
  16431. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  16432. * @returns The reflection texture transform
  16433. */
  16434. getReflectionTextureMatrix(): Matrix;
  16435. /**
  16436. * Clones the texture.
  16437. * @returns the cloned texture
  16438. */
  16439. clone(): Texture;
  16440. /**
  16441. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  16442. * @returns The JSON representation of the texture
  16443. */
  16444. serialize(): any;
  16445. /**
  16446. * Get the current class name of the texture useful for serialization or dynamic coding.
  16447. * @returns "Texture"
  16448. */
  16449. getClassName(): string;
  16450. /**
  16451. * Dispose the texture and release its associated resources.
  16452. */
  16453. dispose(): void;
  16454. /**
  16455. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  16456. * @param parsedTexture Define the JSON representation of the texture
  16457. * @param scene Define the scene the parsed texture should be instantiated in
  16458. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  16459. * @returns The parsed texture if successful
  16460. */
  16461. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  16462. /**
  16463. * Creates a texture from its base 64 representation.
  16464. * @param data Define the base64 payload without the data: prefix
  16465. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  16466. * @param scene Define the scene the texture should belong to
  16467. * @param noMipmap Forces the texture to not create mip map information if true
  16468. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16469. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16470. * @param onLoad define a callback triggered when the texture has been loaded
  16471. * @param onError define a callback triggered when an error occurred during the loading session
  16472. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16473. * @returns the created texture
  16474. */
  16475. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  16476. /**
  16477. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  16478. * @param data Define the base64 payload without the data: prefix
  16479. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  16480. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  16481. * @param scene Define the scene the texture should belong to
  16482. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  16483. * @param noMipmap Forces the texture to not create mip map information if true
  16484. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16485. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16486. * @param onLoad define a callback triggered when the texture has been loaded
  16487. * @param onError define a callback triggered when an error occurred during the loading session
  16488. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16489. * @returns the created texture
  16490. */
  16491. static LoadFromDataString(name: string, buffer: any, scene: Scene, deleteBuffer?: boolean, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number): Texture;
  16492. }
  16493. }
  16494. declare module "babylonjs/PostProcesses/postProcessManager" {
  16495. import { Nullable } from "babylonjs/types";
  16496. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16497. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  16498. import { Scene } from "babylonjs/scene";
  16499. /**
  16500. * PostProcessManager is used to manage one or more post processes or post process pipelines
  16501. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  16502. */
  16503. export class PostProcessManager {
  16504. private _scene;
  16505. private _indexBuffer;
  16506. private _vertexBuffers;
  16507. /**
  16508. * Creates a new instance PostProcess
  16509. * @param scene The scene that the post process is associated with.
  16510. */
  16511. constructor(scene: Scene);
  16512. private _prepareBuffers;
  16513. private _buildIndexBuffer;
  16514. /**
  16515. * Rebuilds the vertex buffers of the manager.
  16516. * @hidden
  16517. */
  16518. _rebuild(): void;
  16519. /**
  16520. * Prepares a frame to be run through a post process.
  16521. * @param sourceTexture The input texture to the post procesess. (default: null)
  16522. * @param postProcesses An array of post processes to be run. (default: null)
  16523. * @returns True if the post processes were able to be run.
  16524. * @hidden
  16525. */
  16526. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  16527. /**
  16528. * Manually render a set of post processes to a texture.
  16529. * @param postProcesses An array of post processes to be run.
  16530. * @param targetTexture The target texture to render to.
  16531. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  16532. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  16533. * @param lodLevel defines which lod of the texture to render to
  16534. */
  16535. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  16536. /**
  16537. * Finalize the result of the output of the postprocesses.
  16538. * @param doNotPresent If true the result will not be displayed to the screen.
  16539. * @param targetTexture The target texture to render to.
  16540. * @param faceIndex The index of the face to bind the target texture to.
  16541. * @param postProcesses The array of post processes to render.
  16542. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  16543. * @hidden
  16544. */
  16545. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  16546. /**
  16547. * Disposes of the post process manager.
  16548. */
  16549. dispose(): void;
  16550. }
  16551. }
  16552. declare module "babylonjs/Misc/gradients" {
  16553. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  16554. /** Interface used by value gradients (color, factor, ...) */
  16555. export interface IValueGradient {
  16556. /**
  16557. * Gets or sets the gradient value (between 0 and 1)
  16558. */
  16559. gradient: number;
  16560. }
  16561. /** Class used to store color4 gradient */
  16562. export class ColorGradient implements IValueGradient {
  16563. /**
  16564. * Gets or sets the gradient value (between 0 and 1)
  16565. */
  16566. gradient: number;
  16567. /**
  16568. * Gets or sets first associated color
  16569. */
  16570. color1: Color4;
  16571. /**
  16572. * Gets or sets second associated color
  16573. */
  16574. color2?: Color4;
  16575. /**
  16576. * Will get a color picked randomly between color1 and color2.
  16577. * If color2 is undefined then color1 will be used
  16578. * @param result defines the target Color4 to store the result in
  16579. */
  16580. getColorToRef(result: Color4): void;
  16581. }
  16582. /** Class used to store color 3 gradient */
  16583. export class Color3Gradient implements IValueGradient {
  16584. /**
  16585. * Gets or sets the gradient value (between 0 and 1)
  16586. */
  16587. gradient: number;
  16588. /**
  16589. * Gets or sets the associated color
  16590. */
  16591. color: Color3;
  16592. }
  16593. /** Class used to store factor gradient */
  16594. export class FactorGradient implements IValueGradient {
  16595. /**
  16596. * Gets or sets the gradient value (between 0 and 1)
  16597. */
  16598. gradient: number;
  16599. /**
  16600. * Gets or sets first associated factor
  16601. */
  16602. factor1: number;
  16603. /**
  16604. * Gets or sets second associated factor
  16605. */
  16606. factor2?: number;
  16607. /**
  16608. * Will get a number picked randomly between factor1 and factor2.
  16609. * If factor2 is undefined then factor1 will be used
  16610. * @returns the picked number
  16611. */
  16612. getFactor(): number;
  16613. }
  16614. /**
  16615. * Helper used to simplify some generic gradient tasks
  16616. */
  16617. export class GradientHelper {
  16618. /**
  16619. * Gets the current gradient from an array of IValueGradient
  16620. * @param ratio defines the current ratio to get
  16621. * @param gradients defines the array of IValueGradient
  16622. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  16623. */
  16624. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  16625. }
  16626. }
  16627. declare module "babylonjs/Engines/Extensions/engine.dynamicTexture" {
  16628. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16629. import { Nullable } from "babylonjs/types";
  16630. module "babylonjs/Engines/thinEngine" {
  16631. interface ThinEngine {
  16632. /**
  16633. * Creates a dynamic texture
  16634. * @param width defines the width of the texture
  16635. * @param height defines the height of the texture
  16636. * @param generateMipMaps defines if the engine should generate the mip levels
  16637. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  16638. * @returns the dynamic texture inside an InternalTexture
  16639. */
  16640. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  16641. /**
  16642. * Update the content of a dynamic texture
  16643. * @param texture defines the texture to update
  16644. * @param canvas defines the canvas containing the source
  16645. * @param invertY defines if data must be stored with Y axis inverted
  16646. * @param premulAlpha defines if alpha is stored as premultiplied
  16647. * @param format defines the format of the data
  16648. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  16649. */
  16650. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  16651. }
  16652. }
  16653. }
  16654. declare module "babylonjs/Misc/canvasGenerator" {
  16655. /**
  16656. * Helper class used to generate a canvas to manipulate images
  16657. */
  16658. export class CanvasGenerator {
  16659. /**
  16660. * Create a new canvas (or offscreen canvas depending on the context)
  16661. * @param width defines the expected width
  16662. * @param height defines the expected height
  16663. * @return a new canvas or offscreen canvas
  16664. */
  16665. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  16666. }
  16667. }
  16668. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  16669. import { Scene } from "babylonjs/scene";
  16670. import { Texture } from "babylonjs/Materials/Textures/texture";
  16671. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  16672. /**
  16673. * A class extending Texture allowing drawing on a texture
  16674. * @see http://doc.babylonjs.com/how_to/dynamictexture
  16675. */
  16676. export class DynamicTexture extends Texture {
  16677. private _generateMipMaps;
  16678. private _canvas;
  16679. private _context;
  16680. private _engine;
  16681. /**
  16682. * Creates a DynamicTexture
  16683. * @param name defines the name of the texture
  16684. * @param options provides 3 alternatives for width and height of texture, a canvas, object with width and height properties, number for both width and height
  16685. * @param scene defines the scene where you want the texture
  16686. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  16687. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  16688. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  16689. */
  16690. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  16691. /**
  16692. * Get the current class name of the texture useful for serialization or dynamic coding.
  16693. * @returns "DynamicTexture"
  16694. */
  16695. getClassName(): string;
  16696. /**
  16697. * Gets the current state of canRescale
  16698. */
  16699. readonly canRescale: boolean;
  16700. private _recreate;
  16701. /**
  16702. * Scales the texture
  16703. * @param ratio the scale factor to apply to both width and height
  16704. */
  16705. scale(ratio: number): void;
  16706. /**
  16707. * Resizes the texture
  16708. * @param width the new width
  16709. * @param height the new height
  16710. */
  16711. scaleTo(width: number, height: number): void;
  16712. /**
  16713. * Gets the context of the canvas used by the texture
  16714. * @returns the canvas context of the dynamic texture
  16715. */
  16716. getContext(): CanvasRenderingContext2D;
  16717. /**
  16718. * Clears the texture
  16719. */
  16720. clear(): void;
  16721. /**
  16722. * Updates the texture
  16723. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  16724. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  16725. */
  16726. update(invertY?: boolean, premulAlpha?: boolean): void;
  16727. /**
  16728. * Draws text onto the texture
  16729. * @param text defines the text to be drawn
  16730. * @param x defines the placement of the text from the left
  16731. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  16732. * @param font defines the font to be used with font-style, font-size, font-name
  16733. * @param color defines the color used for the text
  16734. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  16735. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  16736. * @param update defines whether texture is immediately update (default is true)
  16737. */
  16738. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  16739. /**
  16740. * Clones the texture
  16741. * @returns the clone of the texture.
  16742. */
  16743. clone(): DynamicTexture;
  16744. /**
  16745. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  16746. * @returns a serialized dynamic texture object
  16747. */
  16748. serialize(): any;
  16749. /** @hidden */
  16750. _rebuild(): void;
  16751. }
  16752. }
  16753. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  16754. import { Scene } from "babylonjs/scene";
  16755. import { ISceneComponent } from "babylonjs/sceneComponent";
  16756. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  16757. module "babylonjs/abstractScene" {
  16758. interface AbstractScene {
  16759. /**
  16760. * The list of procedural textures added to the scene
  16761. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16762. */
  16763. proceduralTextures: Array<ProceduralTexture>;
  16764. }
  16765. }
  16766. /**
  16767. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  16768. * in a given scene.
  16769. */
  16770. export class ProceduralTextureSceneComponent implements ISceneComponent {
  16771. /**
  16772. * The component name helpfull to identify the component in the list of scene components.
  16773. */
  16774. readonly name: string;
  16775. /**
  16776. * The scene the component belongs to.
  16777. */
  16778. scene: Scene;
  16779. /**
  16780. * Creates a new instance of the component for the given scene
  16781. * @param scene Defines the scene to register the component in
  16782. */
  16783. constructor(scene: Scene);
  16784. /**
  16785. * Registers the component in a given scene
  16786. */
  16787. register(): void;
  16788. /**
  16789. * Rebuilds the elements related to this component in case of
  16790. * context lost for instance.
  16791. */
  16792. rebuild(): void;
  16793. /**
  16794. * Disposes the component and the associated ressources.
  16795. */
  16796. dispose(): void;
  16797. private _beforeClear;
  16798. }
  16799. }
  16800. declare module "babylonjs/Engines/Extensions/engine.renderTargetCube" {
  16801. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16802. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  16803. module "babylonjs/Engines/thinEngine" {
  16804. interface ThinEngine {
  16805. /**
  16806. * Creates a new render target cube texture
  16807. * @param size defines the size of the texture
  16808. * @param options defines the options used to create the texture
  16809. * @returns a new render target cube texture stored in an InternalTexture
  16810. */
  16811. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  16812. }
  16813. }
  16814. }
  16815. declare module "babylonjs/Shaders/procedural.vertex" {
  16816. /** @hidden */
  16817. export var proceduralVertexShader: {
  16818. name: string;
  16819. shader: string;
  16820. };
  16821. }
  16822. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  16823. import { Observable } from "babylonjs/Misc/observable";
  16824. import { Nullable } from "babylonjs/types";
  16825. import { Scene } from "babylonjs/scene";
  16826. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  16827. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  16828. import { Effect } from "babylonjs/Materials/effect";
  16829. import { Texture } from "babylonjs/Materials/Textures/texture";
  16830. import "babylonjs/Engines/Extensions/engine.renderTarget";
  16831. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  16832. import "babylonjs/Shaders/procedural.vertex";
  16833. /**
  16834. * Procedural texturing is a way to programmatically create a texture. There are 2 types of procedural textures: code-only, and code that references some classic 2D images, sometimes calmpler' images.
  16835. * This is the base class of any Procedural texture and contains most of the shareable code.
  16836. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16837. */
  16838. export class ProceduralTexture extends Texture {
  16839. isCube: boolean;
  16840. /**
  16841. * Define if the texture is enabled or not (disabled texture will not render)
  16842. */
  16843. isEnabled: boolean;
  16844. /**
  16845. * Define if the texture must be cleared before rendering (default is true)
  16846. */
  16847. autoClear: boolean;
  16848. /**
  16849. * Callback called when the texture is generated
  16850. */
  16851. onGenerated: () => void;
  16852. /**
  16853. * Event raised when the texture is generated
  16854. */
  16855. onGeneratedObservable: Observable<ProceduralTexture>;
  16856. /** @hidden */
  16857. _generateMipMaps: boolean;
  16858. /** @hidden **/
  16859. _effect: Effect;
  16860. /** @hidden */
  16861. _textures: {
  16862. [key: string]: Texture;
  16863. };
  16864. private _size;
  16865. private _currentRefreshId;
  16866. private _refreshRate;
  16867. private _vertexBuffers;
  16868. private _indexBuffer;
  16869. private _uniforms;
  16870. private _samplers;
  16871. private _fragment;
  16872. private _floats;
  16873. private _ints;
  16874. private _floatsArrays;
  16875. private _colors3;
  16876. private _colors4;
  16877. private _vectors2;
  16878. private _vectors3;
  16879. private _matrices;
  16880. private _fallbackTexture;
  16881. private _fallbackTextureUsed;
  16882. private _engine;
  16883. private _cachedDefines;
  16884. private _contentUpdateId;
  16885. private _contentData;
  16886. /**
  16887. * Instantiates a new procedural texture.
  16888. * Procedural texturing is a way to programmatically create a texture. There are 2 types of procedural textures: code-only, and code that references some classic 2D images, sometimes called 'refMaps' or 'sampler' images.
  16889. * This is the base class of any Procedural texture and contains most of the shareable code.
  16890. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16891. * @param name Define the name of the texture
  16892. * @param size Define the size of the texture to create
  16893. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  16894. * @param scene Define the scene the texture belongs to
  16895. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  16896. * @param generateMipMaps Define if the texture should creates mip maps or not
  16897. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  16898. */
  16899. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  16900. /**
  16901. * The effect that is created when initializing the post process.
  16902. * @returns The created effect corresponding the the postprocess.
  16903. */
  16904. getEffect(): Effect;
  16905. /**
  16906. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  16907. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  16908. */
  16909. getContent(): Nullable<ArrayBufferView>;
  16910. private _createIndexBuffer;
  16911. /** @hidden */
  16912. _rebuild(): void;
  16913. /**
  16914. * Resets the texture in order to recreate its associated resources.
  16915. * This can be called in case of context loss
  16916. */
  16917. reset(): void;
  16918. protected _getDefines(): string;
  16919. /**
  16920. * Is the texture ready to be used ? (rendered at least once)
  16921. * @returns true if ready, otherwise, false.
  16922. */
  16923. isReady(): boolean;
  16924. /**
  16925. * Resets the refresh counter of the texture and start bak from scratch.
  16926. * Could be useful to regenerate the texture if it is setup to render only once.
  16927. */
  16928. resetRefreshCounter(): void;
  16929. /**
  16930. * Set the fragment shader to use in order to render the texture.
  16931. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  16932. */
  16933. setFragment(fragment: any): void;
  16934. /**
  16935. * Define the refresh rate of the texture or the rendering frequency.
  16936. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  16937. */
  16938. refreshRate: number;
  16939. /** @hidden */
  16940. _shouldRender(): boolean;
  16941. /**
  16942. * Get the size the texture is rendering at.
  16943. * @returns the size (texture is always squared)
  16944. */
  16945. getRenderSize(): number;
  16946. /**
  16947. * Resize the texture to new value.
  16948. * @param size Define the new size the texture should have
  16949. * @param generateMipMaps Define whether the new texture should create mip maps
  16950. */
  16951. resize(size: number, generateMipMaps: boolean): void;
  16952. private _checkUniform;
  16953. /**
  16954. * Set a texture in the shader program used to render.
  16955. * @param name Define the name of the uniform samplers as defined in the shader
  16956. * @param texture Define the texture to bind to this sampler
  16957. * @return the texture itself allowing "fluent" like uniform updates
  16958. */
  16959. setTexture(name: string, texture: Texture): ProceduralTexture;
  16960. /**
  16961. * Set a float in the shader.
  16962. * @param name Define the name of the uniform as defined in the shader
  16963. * @param value Define the value to give to the uniform
  16964. * @return the texture itself allowing "fluent" like uniform updates
  16965. */
  16966. setFloat(name: string, value: number): ProceduralTexture;
  16967. /**
  16968. * Set a int in the shader.
  16969. * @param name Define the name of the uniform as defined in the shader
  16970. * @param value Define the value to give to the uniform
  16971. * @return the texture itself allowing "fluent" like uniform updates
  16972. */
  16973. setInt(name: string, value: number): ProceduralTexture;
  16974. /**
  16975. * Set an array of floats in the shader.
  16976. * @param name Define the name of the uniform as defined in the shader
  16977. * @param value Define the value to give to the uniform
  16978. * @return the texture itself allowing "fluent" like uniform updates
  16979. */
  16980. setFloats(name: string, value: number[]): ProceduralTexture;
  16981. /**
  16982. * Set a vec3 in the shader from a Color3.
  16983. * @param name Define the name of the uniform as defined in the shader
  16984. * @param value Define the value to give to the uniform
  16985. * @return the texture itself allowing "fluent" like uniform updates
  16986. */
  16987. setColor3(name: string, value: Color3): ProceduralTexture;
  16988. /**
  16989. * Set a vec4 in the shader from a Color4.
  16990. * @param name Define the name of the uniform as defined in the shader
  16991. * @param value Define the value to give to the uniform
  16992. * @return the texture itself allowing "fluent" like uniform updates
  16993. */
  16994. setColor4(name: string, value: Color4): ProceduralTexture;
  16995. /**
  16996. * Set a vec2 in the shader from a Vector2.
  16997. * @param name Define the name of the uniform as defined in the shader
  16998. * @param value Define the value to give to the uniform
  16999. * @return the texture itself allowing "fluent" like uniform updates
  17000. */
  17001. setVector2(name: string, value: Vector2): ProceduralTexture;
  17002. /**
  17003. * Set a vec3 in the shader from a Vector3.
  17004. * @param name Define the name of the uniform as defined in the shader
  17005. * @param value Define the value to give to the uniform
  17006. * @return the texture itself allowing "fluent" like uniform updates
  17007. */
  17008. setVector3(name: string, value: Vector3): ProceduralTexture;
  17009. /**
  17010. * Set a mat4 in the shader from a MAtrix.
  17011. * @param name Define the name of the uniform as defined in the shader
  17012. * @param value Define the value to give to the uniform
  17013. * @return the texture itself allowing "fluent" like uniform updates
  17014. */
  17015. setMatrix(name: string, value: Matrix): ProceduralTexture;
  17016. /**
  17017. * Render the texture to its associated render target.
  17018. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  17019. */
  17020. render(useCameraPostProcess?: boolean): void;
  17021. /**
  17022. * Clone the texture.
  17023. * @returns the cloned texture
  17024. */
  17025. clone(): ProceduralTexture;
  17026. /**
  17027. * Dispose the texture and release its asoociated resources.
  17028. */
  17029. dispose(): void;
  17030. }
  17031. }
  17032. declare module "babylonjs/Particles/baseParticleSystem" {
  17033. import { Nullable } from "babylonjs/types";
  17034. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  17035. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17036. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  17037. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  17038. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  17039. import { Scene } from "babylonjs/scene";
  17040. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  17041. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  17042. import { Texture } from "babylonjs/Materials/Textures/texture";
  17043. import { Color4 } from "babylonjs/Maths/math.color";
  17044. import { Animation } from "babylonjs/Animations/animation";
  17045. /**
  17046. * This represents the base class for particle system in Babylon.
  17047. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
  17048. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  17049. * @example https://doc.babylonjs.com/babylon101/particles
  17050. */
  17051. export class BaseParticleSystem {
  17052. /**
  17053. * Source color is added to the destination color without alpha affecting the result
  17054. */
  17055. static BLENDMODE_ONEONE: number;
  17056. /**
  17057. * Blend current color and particle color using particle’s alpha
  17058. */
  17059. static BLENDMODE_STANDARD: number;
  17060. /**
  17061. * Add current color and particle color multiplied by particle’s alpha
  17062. */
  17063. static BLENDMODE_ADD: number;
  17064. /**
  17065. * Multiply current color with particle color
  17066. */
  17067. static BLENDMODE_MULTIPLY: number;
  17068. /**
  17069. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  17070. */
  17071. static BLENDMODE_MULTIPLYADD: number;
  17072. /**
  17073. * List of animations used by the particle system.
  17074. */
  17075. animations: Animation[];
  17076. /**
  17077. * The id of the Particle system.
  17078. */
  17079. id: string;
  17080. /**
  17081. * The friendly name of the Particle system.
  17082. */
  17083. name: string;
  17084. /**
  17085. * The rendering group used by the Particle system to chose when to render.
  17086. */
  17087. renderingGroupId: number;
  17088. /**
  17089. * The emitter represents the Mesh or position we are attaching the particle system to.
  17090. */
  17091. emitter: Nullable<AbstractMesh | Vector3>;
  17092. /**
  17093. * The maximum number of particles to emit per frame
  17094. */
  17095. emitRate: number;
  17096. /**
  17097. * If you want to launch only a few particles at once, that can be done, as well.
  17098. */
  17099. manualEmitCount: number;
  17100. /**
  17101. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  17102. */
  17103. updateSpeed: number;
  17104. /**
  17105. * The amount of time the particle system is running (depends of the overall update speed).
  17106. */
  17107. targetStopDuration: number;
  17108. /**
  17109. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  17110. */
  17111. disposeOnStop: boolean;
  17112. /**
  17113. * Minimum power of emitting particles.
  17114. */
  17115. minEmitPower: number;
  17116. /**
  17117. * Maximum power of emitting particles.
  17118. */
  17119. maxEmitPower: number;
  17120. /**
  17121. * Minimum life time of emitting particles.
  17122. */
  17123. minLifeTime: number;
  17124. /**
  17125. * Maximum life time of emitting particles.
  17126. */
  17127. maxLifeTime: number;
  17128. /**
  17129. * Minimum Size of emitting particles.
  17130. */
  17131. minSize: number;
  17132. /**
  17133. * Maximum Size of emitting particles.
  17134. */
  17135. maxSize: number;
  17136. /**
  17137. * Minimum scale of emitting particles on X axis.
  17138. */
  17139. minScaleX: number;
  17140. /**
  17141. * Maximum scale of emitting particles on X axis.
  17142. */
  17143. maxScaleX: number;
  17144. /**
  17145. * Minimum scale of emitting particles on Y axis.
  17146. */
  17147. minScaleY: number;
  17148. /**
  17149. * Maximum scale of emitting particles on Y axis.
  17150. */
  17151. maxScaleY: number;
  17152. /**
  17153. * Gets or sets the minimal initial rotation in radians.
  17154. */
  17155. minInitialRotation: number;
  17156. /**
  17157. * Gets or sets the maximal initial rotation in radians.
  17158. */
  17159. maxInitialRotation: number;
  17160. /**
  17161. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  17162. */
  17163. minAngularSpeed: number;
  17164. /**
  17165. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  17166. */
  17167. maxAngularSpeed: number;
  17168. /**
  17169. * The texture used to render each particle. (this can be a spritesheet)
  17170. */
  17171. particleTexture: Nullable<Texture>;
  17172. /**
  17173. * The layer mask we are rendering the particles through.
  17174. */
  17175. layerMask: number;
  17176. /**
  17177. * This can help using your own shader to render the particle system.
  17178. * The according effect will be created
  17179. */
  17180. customShader: any;
  17181. /**
  17182. * By default particle system starts as soon as they are created. This prevents the
  17183. * automatic start to happen and let you decide when to start emitting particles.
  17184. */
  17185. preventAutoStart: boolean;
  17186. private _noiseTexture;
  17187. /**
  17188. * Gets or sets a texture used to add random noise to particle positions
  17189. */
  17190. noiseTexture: Nullable<ProceduralTexture>;
  17191. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  17192. noiseStrength: Vector3;
  17193. /**
  17194. * Callback triggered when the particle animation is ending.
  17195. */
  17196. onAnimationEnd: Nullable<() => void>;
  17197. /**
  17198. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  17199. */
  17200. blendMode: number;
  17201. /**
  17202. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  17203. * to override the particles.
  17204. */
  17205. forceDepthWrite: boolean;
  17206. /** Gets or sets a value indicating how many cycles (or frames) must be executed before first rendering (this value has to be set before starting the system). Default is 0 */
  17207. preWarmCycles: number;
  17208. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  17209. preWarmStepOffset: number;
  17210. /**
  17211. * If using a spritesheet (isAnimationSheetEnabled) defines the speed of the sprite loop (default is 1 meaning the animation will play once during the entire particle lifetime)
  17212. */
  17213. spriteCellChangeSpeed: number;
  17214. /**
  17215. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  17216. */
  17217. startSpriteCellID: number;
  17218. /**
  17219. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  17220. */
  17221. endSpriteCellID: number;
  17222. /**
  17223. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  17224. */
  17225. spriteCellWidth: number;
  17226. /**
  17227. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  17228. */
  17229. spriteCellHeight: number;
  17230. /**
  17231. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  17232. */
  17233. spriteRandomStartCell: boolean;
  17234. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  17235. translationPivot: Vector2;
  17236. /** @hidden */
  17237. protected _isAnimationSheetEnabled: boolean;
  17238. /**
  17239. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  17240. */
  17241. beginAnimationOnStart: boolean;
  17242. /**
  17243. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  17244. */
  17245. beginAnimationFrom: number;
  17246. /**
  17247. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  17248. */
  17249. beginAnimationTo: number;
  17250. /**
  17251. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  17252. */
  17253. beginAnimationLoop: boolean;
  17254. /**
  17255. * Gets or sets a world offset applied to all particles
  17256. */
  17257. worldOffset: Vector3;
  17258. /**
  17259. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  17260. */
  17261. isAnimationSheetEnabled: boolean;
  17262. /**
  17263. * Get hosting scene
  17264. * @returns the scene
  17265. */
  17266. getScene(): Scene;
  17267. /**
  17268. * You can use gravity if you want to give an orientation to your particles.
  17269. */
  17270. gravity: Vector3;
  17271. protected _colorGradients: Nullable<Array<ColorGradient>>;
  17272. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  17273. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  17274. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  17275. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  17276. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  17277. protected _dragGradients: Nullable<Array<FactorGradient>>;
  17278. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  17279. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  17280. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  17281. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  17282. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  17283. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  17284. /**
  17285. * Defines the delay in milliseconds before starting the system (0 by default)
  17286. */
  17287. startDelay: number;
  17288. /**
  17289. * Gets the current list of drag gradients.
  17290. * You must use addDragGradient and removeDragGradient to udpate this list
  17291. * @returns the list of drag gradients
  17292. */
  17293. getDragGradients(): Nullable<Array<FactorGradient>>;
  17294. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  17295. limitVelocityDamping: number;
  17296. /**
  17297. * Gets the current list of limit velocity gradients.
  17298. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  17299. * @returns the list of limit velocity gradients
  17300. */
  17301. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  17302. /**
  17303. * Gets the current list of color gradients.
  17304. * You must use addColorGradient and removeColorGradient to udpate this list
  17305. * @returns the list of color gradients
  17306. */
  17307. getColorGradients(): Nullable<Array<ColorGradient>>;
  17308. /**
  17309. * Gets the current list of size gradients.
  17310. * You must use addSizeGradient and removeSizeGradient to udpate this list
  17311. * @returns the list of size gradients
  17312. */
  17313. getSizeGradients(): Nullable<Array<FactorGradient>>;
  17314. /**
  17315. * Gets the current list of color remap gradients.
  17316. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  17317. * @returns the list of color remap gradients
  17318. */
  17319. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  17320. /**
  17321. * Gets the current list of alpha remap gradients.
  17322. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  17323. * @returns the list of alpha remap gradients
  17324. */
  17325. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  17326. /**
  17327. * Gets the current list of life time gradients.
  17328. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  17329. * @returns the list of life time gradients
  17330. */
  17331. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  17332. /**
  17333. * Gets the current list of angular speed gradients.
  17334. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  17335. * @returns the list of angular speed gradients
  17336. */
  17337. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  17338. /**
  17339. * Gets the current list of velocity gradients.
  17340. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  17341. * @returns the list of velocity gradients
  17342. */
  17343. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  17344. /**
  17345. * Gets the current list of start size gradients.
  17346. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  17347. * @returns the list of start size gradients
  17348. */
  17349. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  17350. /**
  17351. * Gets the current list of emit rate gradients.
  17352. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  17353. * @returns the list of emit rate gradients
  17354. */
  17355. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  17356. /**
  17357. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17358. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17359. */
  17360. direction1: Vector3;
  17361. /**
  17362. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17363. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17364. */
  17365. direction2: Vector3;
  17366. /**
  17367. * Minimum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
  17368. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17369. */
  17370. minEmitBox: Vector3;
  17371. /**
  17372. * Maximum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
  17373. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17374. */
  17375. maxEmitBox: Vector3;
  17376. /**
  17377. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  17378. */
  17379. color1: Color4;
  17380. /**
  17381. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  17382. */
  17383. color2: Color4;
  17384. /**
  17385. * Color the particle will have at the end of its lifetime
  17386. */
  17387. colorDead: Color4;
  17388. /**
  17389. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  17390. */
  17391. textureMask: Color4;
  17392. /**
  17393. * The particle emitter type defines the emitter used by the particle system.
  17394. * It can be for example box, sphere, or cone...
  17395. */
  17396. particleEmitterType: IParticleEmitterType;
  17397. /** @hidden */
  17398. _isSubEmitter: boolean;
  17399. /**
  17400. * Gets or sets the billboard mode to use when isBillboardBased = true.
  17401. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  17402. */
  17403. billboardMode: number;
  17404. protected _isBillboardBased: boolean;
  17405. /**
  17406. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  17407. */
  17408. isBillboardBased: boolean;
  17409. /**
  17410. * The scene the particle system belongs to.
  17411. */
  17412. protected _scene: Scene;
  17413. /**
  17414. * Local cache of defines for image processing.
  17415. */
  17416. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  17417. /**
  17418. * Default configuration related to image processing available in the standard Material.
  17419. */
  17420. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  17421. /**
  17422. * Gets the image processing configuration used either in this material.
  17423. */
  17424. /**
  17425. * Sets the Default image processing configuration used either in the this material.
  17426. *
  17427. * If sets to null, the scene one is in use.
  17428. */
  17429. imageProcessingConfiguration: ImageProcessingConfiguration;
  17430. /**
  17431. * Attaches a new image processing configuration to the Standard Material.
  17432. * @param configuration
  17433. */
  17434. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  17435. /** @hidden */
  17436. protected _reset(): void;
  17437. /** @hidden */
  17438. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  17439. /**
  17440. * Instantiates a particle system.
  17441. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
  17442. * @param name The name of the particle system
  17443. */
  17444. constructor(name: string);
  17445. /**
  17446. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  17447. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17448. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17449. * @returns the emitter
  17450. */
  17451. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  17452. /**
  17453. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  17454. * @param radius The radius of the hemisphere to emit from
  17455. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17456. * @returns the emitter
  17457. */
  17458. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  17459. /**
  17460. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  17461. * @param radius The radius of the sphere to emit from
  17462. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17463. * @returns the emitter
  17464. */
  17465. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  17466. /**
  17467. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  17468. * @param radius The radius of the sphere to emit from
  17469. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  17470. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  17471. * @returns the emitter
  17472. */
  17473. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  17474. /**
  17475. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  17476. * @param radius The radius of the emission cylinder
  17477. * @param height The height of the emission cylinder
  17478. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  17479. * @param directionRandomizer How much to randomize the particle direction [0-1]
  17480. * @returns the emitter
  17481. */
  17482. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  17483. /**
  17484. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  17485. * @param radius The radius of the cylinder to emit from
  17486. * @param height The height of the emission cylinder
  17487. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17488. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  17489. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  17490. * @returns the emitter
  17491. */
  17492. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  17493. /**
  17494. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  17495. * @param radius The radius of the cone to emit from
  17496. * @param angle The base angle of the cone
  17497. * @returns the emitter
  17498. */
  17499. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  17500. /**
  17501. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  17502. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17503. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17504. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17505. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17506. * @returns the emitter
  17507. */
  17508. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  17509. }
  17510. }
  17511. declare module "babylonjs/Particles/subEmitter" {
  17512. import { Scene } from "babylonjs/scene";
  17513. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  17514. /**
  17515. * Type of sub emitter
  17516. */
  17517. export enum SubEmitterType {
  17518. /**
  17519. * Attached to the particle over it's lifetime
  17520. */
  17521. ATTACHED = 0,
  17522. /**
  17523. * Created when the particle dies
  17524. */
  17525. END = 1
  17526. }
  17527. /**
  17528. * Sub emitter class used to emit particles from an existing particle
  17529. */
  17530. export class SubEmitter {
  17531. /**
  17532. * the particle system to be used by the sub emitter
  17533. */
  17534. particleSystem: ParticleSystem;
  17535. /**
  17536. * Type of the submitter (Default: END)
  17537. */
  17538. type: SubEmitterType;
  17539. /**
  17540. * If the particle should inherit the direction from the particle it's attached to. (+Y will face the direction the particle is moving) (Default: false)
  17541. * Note: This only is supported when using an emitter of type Mesh
  17542. */
  17543. inheritDirection: boolean;
  17544. /**
  17545. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  17546. */
  17547. inheritedVelocityAmount: number;
  17548. /**
  17549. * Creates a sub emitter
  17550. * @param particleSystem the particle system to be used by the sub emitter
  17551. */
  17552. constructor(
  17553. /**
  17554. * the particle system to be used by the sub emitter
  17555. */
  17556. particleSystem: ParticleSystem);
  17557. /**
  17558. * Clones the sub emitter
  17559. * @returns the cloned sub emitter
  17560. */
  17561. clone(): SubEmitter;
  17562. /**
  17563. * Serialize current object to a JSON object
  17564. * @returns the serialized object
  17565. */
  17566. serialize(): any;
  17567. /** @hidden */
  17568. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  17569. /**
  17570. * Creates a new SubEmitter from a serialized JSON version
  17571. * @param serializationObject defines the JSON object to read from
  17572. * @param scene defines the hosting scene
  17573. * @param rootUrl defines the rootUrl for data loading
  17574. * @returns a new SubEmitter
  17575. */
  17576. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  17577. /** Release associated resources */
  17578. dispose(): void;
  17579. }
  17580. }
  17581. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  17582. /** @hidden */
  17583. export var clipPlaneFragmentDeclaration: {
  17584. name: string;
  17585. shader: string;
  17586. };
  17587. }
  17588. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  17589. /** @hidden */
  17590. export var imageProcessingDeclaration: {
  17591. name: string;
  17592. shader: string;
  17593. };
  17594. }
  17595. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  17596. /** @hidden */
  17597. export var imageProcessingFunctions: {
  17598. name: string;
  17599. shader: string;
  17600. };
  17601. }
  17602. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  17603. /** @hidden */
  17604. export var clipPlaneFragment: {
  17605. name: string;
  17606. shader: string;
  17607. };
  17608. }
  17609. declare module "babylonjs/Shaders/particles.fragment" {
  17610. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  17611. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  17612. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  17613. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  17614. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  17615. /** @hidden */
  17616. export var particlesPixelShader: {
  17617. name: string;
  17618. shader: string;
  17619. };
  17620. }
  17621. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  17622. /** @hidden */
  17623. export var clipPlaneVertexDeclaration: {
  17624. name: string;
  17625. shader: string;
  17626. };
  17627. }
  17628. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  17629. /** @hidden */
  17630. export var clipPlaneVertex: {
  17631. name: string;
  17632. shader: string;
  17633. };
  17634. }
  17635. declare module "babylonjs/Shaders/particles.vertex" {
  17636. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  17637. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  17638. /** @hidden */
  17639. export var particlesVertexShader: {
  17640. name: string;
  17641. shader: string;
  17642. };
  17643. }
  17644. declare module "babylonjs/Particles/particleSystem" {
  17645. import { Nullable } from "babylonjs/types";
  17646. import { FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  17647. import { Observable } from "babylonjs/Misc/observable";
  17648. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17649. import { Effect } from "babylonjs/Materials/effect";
  17650. import { Scene, IDisposable } from "babylonjs/scene";
  17651. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17652. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  17653. import { Particle } from "babylonjs/Particles/particle";
  17654. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  17655. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  17656. import "babylonjs/Shaders/particles.fragment";
  17657. import "babylonjs/Shaders/particles.vertex";
  17658. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  17659. /**
  17660. * This represents a particle system in Babylon.
  17661. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
  17662. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  17663. * @example https://doc.babylonjs.com/babylon101/particles
  17664. */
  17665. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  17666. /**
  17667. * Billboard mode will only apply to Y axis
  17668. */
  17669. static readonly BILLBOARDMODE_Y: number;
  17670. /**
  17671. * Billboard mode will apply to all axes
  17672. */
  17673. static readonly BILLBOARDMODE_ALL: number;
  17674. /**
  17675. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  17676. */
  17677. static readonly BILLBOARDMODE_STRETCHED: number;
  17678. /**
  17679. * This function can be defined to provide custom update for active particles.
  17680. * This function will be called instead of regular update (age, position, color, etc.).
  17681. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  17682. */
  17683. updateFunction: (particles: Particle[]) => void;
  17684. private _emitterWorldMatrix;
  17685. /**
  17686. * This function can be defined to specify initial direction for every new particle.
  17687. * It by default use the emitterType defined function
  17688. */
  17689. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  17690. /**
  17691. * This function can be defined to specify initial position for every new particle.
  17692. * It by default use the emitterType defined function
  17693. */
  17694. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  17695. /**
  17696. * @hidden
  17697. */
  17698. _inheritedVelocityOffset: Vector3;
  17699. /**
  17700. * An event triggered when the system is disposed
  17701. */
  17702. onDisposeObservable: Observable<ParticleSystem>;
  17703. private _onDisposeObserver;
  17704. /**
  17705. * Sets a callback that will be triggered when the system is disposed
  17706. */
  17707. onDispose: () => void;
  17708. private _particles;
  17709. private _epsilon;
  17710. private _capacity;
  17711. private _stockParticles;
  17712. private _newPartsExcess;
  17713. private _vertexData;
  17714. private _vertexBuffer;
  17715. private _vertexBuffers;
  17716. private _spriteBuffer;
  17717. private _indexBuffer;
  17718. private _effect;
  17719. private _customEffect;
  17720. private _cachedDefines;
  17721. private _scaledColorStep;
  17722. private _colorDiff;
  17723. private _scaledDirection;
  17724. private _scaledGravity;
  17725. private _currentRenderId;
  17726. private _alive;
  17727. private _useInstancing;
  17728. private _started;
  17729. private _stopped;
  17730. private _actualFrame;
  17731. private _scaledUpdateSpeed;
  17732. private _vertexBufferSize;
  17733. /** @hidden */
  17734. _currentEmitRateGradient: Nullable<FactorGradient>;
  17735. /** @hidden */
  17736. _currentEmitRate1: number;
  17737. /** @hidden */
  17738. _currentEmitRate2: number;
  17739. /** @hidden */
  17740. _currentStartSizeGradient: Nullable<FactorGradient>;
  17741. /** @hidden */
  17742. _currentStartSize1: number;
  17743. /** @hidden */
  17744. _currentStartSize2: number;
  17745. private readonly _rawTextureWidth;
  17746. private _rampGradientsTexture;
  17747. private _useRampGradients;
  17748. /** Gets or sets a boolean indicating that ramp gradients must be used
  17749. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  17750. */
  17751. useRampGradients: boolean;
  17752. /**
  17753. * The Sub-emitters templates that will be used to generate the sub particle system to be associated with the system, this property is used by the root particle system only.
  17754. * When a particle is spawned, an array will be chosen at random and all the emitters in that array will be attached to the particle. (Default: [])
  17755. */
  17756. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  17757. private _subEmitters;
  17758. /**
  17759. * @hidden
  17760. * If the particle systems emitter should be disposed when the particle system is disposed
  17761. */
  17762. _disposeEmitterOnDispose: boolean;
  17763. /**
  17764. * The current active Sub-systems, this property is used by the root particle system only.
  17765. */
  17766. activeSubSystems: Array<ParticleSystem>;
  17767. private _rootParticleSystem;
  17768. /**
  17769. * Gets the current list of active particles
  17770. */
  17771. readonly particles: Particle[];
  17772. /**
  17773. * Returns the string "ParticleSystem"
  17774. * @returns a string containing the class name
  17775. */
  17776. getClassName(): string;
  17777. /**
  17778. * Instantiates a particle system.
  17779. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
  17780. * @param name The name of the particle system
  17781. * @param capacity The max number of particles alive at the same time
  17782. * @param scene The scene the particle system belongs to
  17783. * @param customEffect a custom effect used to change the way particles are rendered by default
  17784. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  17785. * @param epsilon Offset used to render the particles
  17786. */
  17787. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  17788. private _addFactorGradient;
  17789. private _removeFactorGradient;
  17790. /**
  17791. * Adds a new life time gradient
  17792. * @param gradient defines the gradient to use (between 0 and 1)
  17793. * @param factor defines the life time factor to affect to the specified gradient
  17794. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17795. * @returns the current particle system
  17796. */
  17797. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17798. /**
  17799. * Remove a specific life time gradient
  17800. * @param gradient defines the gradient to remove
  17801. * @returns the current particle system
  17802. */
  17803. removeLifeTimeGradient(gradient: number): IParticleSystem;
  17804. /**
  17805. * Adds a new size gradient
  17806. * @param gradient defines the gradient to use (between 0 and 1)
  17807. * @param factor defines the size factor to affect to the specified gradient
  17808. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17809. * @returns the current particle system
  17810. */
  17811. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17812. /**
  17813. * Remove a specific size gradient
  17814. * @param gradient defines the gradient to remove
  17815. * @returns the current particle system
  17816. */
  17817. removeSizeGradient(gradient: number): IParticleSystem;
  17818. /**
  17819. * Adds a new color remap gradient
  17820. * @param gradient defines the gradient to use (between 0 and 1)
  17821. * @param min defines the color remap minimal range
  17822. * @param max defines the color remap maximal range
  17823. * @returns the current particle system
  17824. */
  17825. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17826. /**
  17827. * Remove a specific color remap gradient
  17828. * @param gradient defines the gradient to remove
  17829. * @returns the current particle system
  17830. */
  17831. removeColorRemapGradient(gradient: number): IParticleSystem;
  17832. /**
  17833. * Adds a new alpha remap gradient
  17834. * @param gradient defines the gradient to use (between 0 and 1)
  17835. * @param min defines the alpha remap minimal range
  17836. * @param max defines the alpha remap maximal range
  17837. * @returns the current particle system
  17838. */
  17839. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17840. /**
  17841. * Remove a specific alpha remap gradient
  17842. * @param gradient defines the gradient to remove
  17843. * @returns the current particle system
  17844. */
  17845. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  17846. /**
  17847. * Adds a new angular speed gradient
  17848. * @param gradient defines the gradient to use (between 0 and 1)
  17849. * @param factor defines the angular speed to affect to the specified gradient
  17850. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17851. * @returns the current particle system
  17852. */
  17853. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17854. /**
  17855. * Remove a specific angular speed gradient
  17856. * @param gradient defines the gradient to remove
  17857. * @returns the current particle system
  17858. */
  17859. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  17860. /**
  17861. * Adds a new velocity gradient
  17862. * @param gradient defines the gradient to use (between 0 and 1)
  17863. * @param factor defines the velocity to affect to the specified gradient
  17864. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17865. * @returns the current particle system
  17866. */
  17867. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17868. /**
  17869. * Remove a specific velocity gradient
  17870. * @param gradient defines the gradient to remove
  17871. * @returns the current particle system
  17872. */
  17873. removeVelocityGradient(gradient: number): IParticleSystem;
  17874. /**
  17875. * Adds a new limit velocity gradient
  17876. * @param gradient defines the gradient to use (between 0 and 1)
  17877. * @param factor defines the limit velocity value to affect to the specified gradient
  17878. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17879. * @returns the current particle system
  17880. */
  17881. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17882. /**
  17883. * Remove a specific limit velocity gradient
  17884. * @param gradient defines the gradient to remove
  17885. * @returns the current particle system
  17886. */
  17887. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  17888. /**
  17889. * Adds a new drag gradient
  17890. * @param gradient defines the gradient to use (between 0 and 1)
  17891. * @param factor defines the drag value to affect to the specified gradient
  17892. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17893. * @returns the current particle system
  17894. */
  17895. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17896. /**
  17897. * Remove a specific drag gradient
  17898. * @param gradient defines the gradient to remove
  17899. * @returns the current particle system
  17900. */
  17901. removeDragGradient(gradient: number): IParticleSystem;
  17902. /**
  17903. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  17904. * @param gradient defines the gradient to use (between 0 and 1)
  17905. * @param factor defines the emit rate value to affect to the specified gradient
  17906. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17907. * @returns the current particle system
  17908. */
  17909. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17910. /**
  17911. * Remove a specific emit rate gradient
  17912. * @param gradient defines the gradient to remove
  17913. * @returns the current particle system
  17914. */
  17915. removeEmitRateGradient(gradient: number): IParticleSystem;
  17916. /**
  17917. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  17918. * @param gradient defines the gradient to use (between 0 and 1)
  17919. * @param factor defines the start size value to affect to the specified gradient
  17920. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17921. * @returns the current particle system
  17922. */
  17923. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17924. /**
  17925. * Remove a specific start size gradient
  17926. * @param gradient defines the gradient to remove
  17927. * @returns the current particle system
  17928. */
  17929. removeStartSizeGradient(gradient: number): IParticleSystem;
  17930. private _createRampGradientTexture;
  17931. /**
  17932. * Gets the current list of ramp gradients.
  17933. * You must use addRampGradient and removeRampGradient to udpate this list
  17934. * @returns the list of ramp gradients
  17935. */
  17936. getRampGradients(): Nullable<Array<Color3Gradient>>;
  17937. /**
  17938. * Adds a new ramp gradient used to remap particle colors
  17939. * @param gradient defines the gradient to use (between 0 and 1)
  17940. * @param color defines the color to affect to the specified gradient
  17941. * @returns the current particle system
  17942. */
  17943. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  17944. /**
  17945. * Remove a specific ramp gradient
  17946. * @param gradient defines the gradient to remove
  17947. * @returns the current particle system
  17948. */
  17949. removeRampGradient(gradient: number): ParticleSystem;
  17950. /**
  17951. * Adds a new color gradient
  17952. * @param gradient defines the gradient to use (between 0 and 1)
  17953. * @param color1 defines the color to affect to the specified gradient
  17954. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  17955. * @returns this particle system
  17956. */
  17957. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  17958. /**
  17959. * Remove a specific color gradient
  17960. * @param gradient defines the gradient to remove
  17961. * @returns this particle system
  17962. */
  17963. removeColorGradient(gradient: number): IParticleSystem;
  17964. private _fetchR;
  17965. protected _reset(): void;
  17966. private _resetEffect;
  17967. private _createVertexBuffers;
  17968. private _createIndexBuffer;
  17969. /**
  17970. * Gets the maximum number of particles active at the same time.
  17971. * @returns The max number of active particles.
  17972. */
  17973. getCapacity(): number;
  17974. /**
  17975. * Gets whether there are still active particles in the system.
  17976. * @returns True if it is alive, otherwise false.
  17977. */
  17978. isAlive(): boolean;
  17979. /**
  17980. * Gets if the system has been started. (Note: this will still be true after stop is called)
  17981. * @returns True if it has been started, otherwise false.
  17982. */
  17983. isStarted(): boolean;
  17984. private _prepareSubEmitterInternalArray;
  17985. /**
  17986. * Starts the particle system and begins to emit
  17987. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  17988. */
  17989. start(delay?: number): void;
  17990. /**
  17991. * Stops the particle system.
  17992. * @param stopSubEmitters if true it will stop the current system and all created sub-Systems if false it will stop the current root system only, this param is used by the root particle system only. the default value is true.
  17993. */
  17994. stop(stopSubEmitters?: boolean): void;
  17995. /**
  17996. * Remove all active particles
  17997. */
  17998. reset(): void;
  17999. /**
  18000. * @hidden (for internal use only)
  18001. */
  18002. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  18003. /**
  18004. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  18005. * Its lifetime will start back at 0.
  18006. */
  18007. recycleParticle: (particle: Particle) => void;
  18008. private _stopSubEmitters;
  18009. private _createParticle;
  18010. private _removeFromRoot;
  18011. private _emitFromParticle;
  18012. private _update;
  18013. /** @hidden */
  18014. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  18015. /** @hidden */
  18016. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  18017. /** @hidden */
  18018. private _getEffect;
  18019. /**
  18020. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  18021. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  18022. */
  18023. animate(preWarmOnly?: boolean): void;
  18024. private _appendParticleVertices;
  18025. /**
  18026. * Rebuilds the particle system.
  18027. */
  18028. rebuild(): void;
  18029. /**
  18030. * Is this system ready to be used/rendered
  18031. * @return true if the system is ready
  18032. */
  18033. isReady(): boolean;
  18034. private _render;
  18035. /**
  18036. * Renders the particle system in its current state.
  18037. * @returns the current number of particles
  18038. */
  18039. render(): number;
  18040. /**
  18041. * Disposes the particle system and free the associated resources
  18042. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  18043. */
  18044. dispose(disposeTexture?: boolean): void;
  18045. /**
  18046. * Clones the particle system.
  18047. * @param name The name of the cloned object
  18048. * @param newEmitter The new emitter to use
  18049. * @returns the cloned particle system
  18050. */
  18051. clone(name: string, newEmitter: any): ParticleSystem;
  18052. /**
  18053. * Serializes the particle system to a JSON object.
  18054. * @returns the JSON object
  18055. */
  18056. serialize(): any;
  18057. /** @hidden */
  18058. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  18059. /** @hidden */
  18060. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  18061. /**
  18062. * Parses a JSON object to create a particle system.
  18063. * @param parsedParticleSystem The JSON object to parse
  18064. * @param scene The scene to create the particle system in
  18065. * @param rootUrl The root url to use to load external dependencies like texture
  18066. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  18067. * @returns the Parsed particle system
  18068. */
  18069. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  18070. }
  18071. }
  18072. declare module "babylonjs/Particles/particle" {
  18073. import { Nullable } from "babylonjs/types";
  18074. import { Vector2, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  18075. import { Color4 } from "babylonjs/Maths/math.color";
  18076. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  18077. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  18078. import { ColorGradient, FactorGradient } from "babylonjs/Misc/gradients";
  18079. /**
  18080. * A particle represents one of the element emitted by a particle system.
  18081. * This is mainly define by its coordinates, direction, velocity and age.
  18082. */
  18083. export class Particle {
  18084. /**
  18085. * The particle system the particle belongs to.
  18086. */
  18087. particleSystem: ParticleSystem;
  18088. private static _Count;
  18089. /**
  18090. * Unique ID of the particle
  18091. */
  18092. id: number;
  18093. /**
  18094. * The world position of the particle in the scene.
  18095. */
  18096. position: Vector3;
  18097. /**
  18098. * The world direction of the particle in the scene.
  18099. */
  18100. direction: Vector3;
  18101. /**
  18102. * The color of the particle.
  18103. */
  18104. color: Color4;
  18105. /**
  18106. * The color change of the particle per step.
  18107. */
  18108. colorStep: Color4;
  18109. /**
  18110. * Defines how long will the life of the particle be.
  18111. */
  18112. lifeTime: number;
  18113. /**
  18114. * The current age of the particle.
  18115. */
  18116. age: number;
  18117. /**
  18118. * The current size of the particle.
  18119. */
  18120. size: number;
  18121. /**
  18122. * The current scale of the particle.
  18123. */
  18124. scale: Vector2;
  18125. /**
  18126. * The current angle of the particle.
  18127. */
  18128. angle: number;
  18129. /**
  18130. * Defines how fast is the angle changing.
  18131. */
  18132. angularSpeed: number;
  18133. /**
  18134. * Defines the cell index used by the particle to be rendered from a sprite.
  18135. */
  18136. cellIndex: number;
  18137. /**
  18138. * The information required to support color remapping
  18139. */
  18140. remapData: Vector4;
  18141. /** @hidden */
  18142. _randomCellOffset?: number;
  18143. /** @hidden */
  18144. _initialDirection: Nullable<Vector3>;
  18145. /** @hidden */
  18146. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  18147. /** @hidden */
  18148. _initialStartSpriteCellID: number;
  18149. /** @hidden */
  18150. _initialEndSpriteCellID: number;
  18151. /** @hidden */
  18152. _currentColorGradient: Nullable<ColorGradient>;
  18153. /** @hidden */
  18154. _currentColor1: Color4;
  18155. /** @hidden */
  18156. _currentColor2: Color4;
  18157. /** @hidden */
  18158. _currentSizeGradient: Nullable<FactorGradient>;
  18159. /** @hidden */
  18160. _currentSize1: number;
  18161. /** @hidden */
  18162. _currentSize2: number;
  18163. /** @hidden */
  18164. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  18165. /** @hidden */
  18166. _currentAngularSpeed1: number;
  18167. /** @hidden */
  18168. _currentAngularSpeed2: number;
  18169. /** @hidden */
  18170. _currentVelocityGradient: Nullable<FactorGradient>;
  18171. /** @hidden */
  18172. _currentVelocity1: number;
  18173. /** @hidden */
  18174. _currentVelocity2: number;
  18175. /** @hidden */
  18176. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  18177. /** @hidden */
  18178. _currentLimitVelocity1: number;
  18179. /** @hidden */
  18180. _currentLimitVelocity2: number;
  18181. /** @hidden */
  18182. _currentDragGradient: Nullable<FactorGradient>;
  18183. /** @hidden */
  18184. _currentDrag1: number;
  18185. /** @hidden */
  18186. _currentDrag2: number;
  18187. /** @hidden */
  18188. _randomNoiseCoordinates1: Vector3;
  18189. /** @hidden */
  18190. _randomNoiseCoordinates2: Vector3;
  18191. /**
  18192. * Creates a new instance Particle
  18193. * @param particleSystem the particle system the particle belongs to
  18194. */
  18195. constructor(
  18196. /**
  18197. * The particle system the particle belongs to.
  18198. */
  18199. particleSystem: ParticleSystem);
  18200. private updateCellInfoFromSystem;
  18201. /**
  18202. * Defines how the sprite cell index is updated for the particle
  18203. */
  18204. updateCellIndex(): void;
  18205. /** @hidden */
  18206. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  18207. /** @hidden */
  18208. _inheritParticleInfoToSubEmitters(): void;
  18209. /** @hidden */
  18210. _reset(): void;
  18211. /**
  18212. * Copy the properties of particle to another one.
  18213. * @param other the particle to copy the information to.
  18214. */
  18215. copyTo(other: Particle): void;
  18216. }
  18217. }
  18218. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  18219. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18220. import { Effect } from "babylonjs/Materials/effect";
  18221. import { Particle } from "babylonjs/Particles/particle";
  18222. /**
  18223. * Particle emitter represents a volume emitting particles.
  18224. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  18225. */
  18226. export interface IParticleEmitterType {
  18227. /**
  18228. * Called by the particle System when the direction is computed for the created particle.
  18229. * @param worldMatrix is the world matrix of the particle system
  18230. * @param directionToUpdate is the direction vector to update with the result
  18231. * @param particle is the particle we are computed the direction for
  18232. */
  18233. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18234. /**
  18235. * Called by the particle System when the position is computed for the created particle.
  18236. * @param worldMatrix is the world matrix of the particle system
  18237. * @param positionToUpdate is the position vector to update with the result
  18238. * @param particle is the particle we are computed the position for
  18239. */
  18240. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18241. /**
  18242. * Clones the current emitter and returns a copy of it
  18243. * @returns the new emitter
  18244. */
  18245. clone(): IParticleEmitterType;
  18246. /**
  18247. * Called by the GPUParticleSystem to setup the update shader
  18248. * @param effect defines the update shader
  18249. */
  18250. applyToShader(effect: Effect): void;
  18251. /**
  18252. * Returns a string to use to update the GPU particles update shader
  18253. * @returns the effect defines string
  18254. */
  18255. getEffectDefines(): string;
  18256. /**
  18257. * Returns a string representing the class name
  18258. * @returns a string containing the class name
  18259. */
  18260. getClassName(): string;
  18261. /**
  18262. * Serializes the particle system to a JSON object.
  18263. * @returns the JSON object
  18264. */
  18265. serialize(): any;
  18266. /**
  18267. * Parse properties from a JSON object
  18268. * @param serializationObject defines the JSON object
  18269. */
  18270. parse(serializationObject: any): void;
  18271. }
  18272. }
  18273. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  18274. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18275. import { Effect } from "babylonjs/Materials/effect";
  18276. import { Particle } from "babylonjs/Particles/particle";
  18277. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18278. /**
  18279. * Particle emitter emitting particles from the inside of a box.
  18280. * It emits the particles randomly between 2 given directions.
  18281. */
  18282. export class BoxParticleEmitter implements IParticleEmitterType {
  18283. /**
  18284. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18285. */
  18286. direction1: Vector3;
  18287. /**
  18288. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18289. */
  18290. direction2: Vector3;
  18291. /**
  18292. * Minimum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
  18293. */
  18294. minEmitBox: Vector3;
  18295. /**
  18296. * Maximum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
  18297. */
  18298. maxEmitBox: Vector3;
  18299. /**
  18300. * Creates a new instance BoxParticleEmitter
  18301. */
  18302. constructor();
  18303. /**
  18304. * Called by the particle System when the direction is computed for the created particle.
  18305. * @param worldMatrix is the world matrix of the particle system
  18306. * @param directionToUpdate is the direction vector to update with the result
  18307. * @param particle is the particle we are computed the direction for
  18308. */
  18309. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18310. /**
  18311. * Called by the particle System when the position is computed for the created particle.
  18312. * @param worldMatrix is the world matrix of the particle system
  18313. * @param positionToUpdate is the position vector to update with the result
  18314. * @param particle is the particle we are computed the position for
  18315. */
  18316. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18317. /**
  18318. * Clones the current emitter and returns a copy of it
  18319. * @returns the new emitter
  18320. */
  18321. clone(): BoxParticleEmitter;
  18322. /**
  18323. * Called by the GPUParticleSystem to setup the update shader
  18324. * @param effect defines the update shader
  18325. */
  18326. applyToShader(effect: Effect): void;
  18327. /**
  18328. * Returns a string to use to update the GPU particles update shader
  18329. * @returns a string containng the defines string
  18330. */
  18331. getEffectDefines(): string;
  18332. /**
  18333. * Returns the string "BoxParticleEmitter"
  18334. * @returns a string containing the class name
  18335. */
  18336. getClassName(): string;
  18337. /**
  18338. * Serializes the particle system to a JSON object.
  18339. * @returns the JSON object
  18340. */
  18341. serialize(): any;
  18342. /**
  18343. * Parse properties from a JSON object
  18344. * @param serializationObject defines the JSON object
  18345. */
  18346. parse(serializationObject: any): void;
  18347. }
  18348. }
  18349. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  18350. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18351. import { Effect } from "babylonjs/Materials/effect";
  18352. import { Particle } from "babylonjs/Particles/particle";
  18353. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18354. /**
  18355. * Particle emitter emitting particles from the inside of a cone.
  18356. * It emits the particles alongside the cone volume from the base to the particle.
  18357. * The emission direction might be randomized.
  18358. */
  18359. export class ConeParticleEmitter implements IParticleEmitterType {
  18360. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  18361. directionRandomizer: number;
  18362. private _radius;
  18363. private _angle;
  18364. private _height;
  18365. /**
  18366. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  18367. */
  18368. radiusRange: number;
  18369. /**
  18370. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  18371. */
  18372. heightRange: number;
  18373. /**
  18374. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  18375. */
  18376. emitFromSpawnPointOnly: boolean;
  18377. /**
  18378. * Gets or sets the radius of the emission cone
  18379. */
  18380. radius: number;
  18381. /**
  18382. * Gets or sets the angle of the emission cone
  18383. */
  18384. angle: number;
  18385. private _buildHeight;
  18386. /**
  18387. * Creates a new instance ConeParticleEmitter
  18388. * @param radius the radius of the emission cone (1 by default)
  18389. * @param angle the cone base angle (PI by default)
  18390. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  18391. */
  18392. constructor(radius?: number, angle?: number,
  18393. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  18394. directionRandomizer?: number);
  18395. /**
  18396. * Called by the particle System when the direction is computed for the created particle.
  18397. * @param worldMatrix is the world matrix of the particle system
  18398. * @param directionToUpdate is the direction vector to update with the result
  18399. * @param particle is the particle we are computed the direction for
  18400. */
  18401. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18402. /**
  18403. * Called by the particle System when the position is computed for the created particle.
  18404. * @param worldMatrix is the world matrix of the particle system
  18405. * @param positionToUpdate is the position vector to update with the result
  18406. * @param particle is the particle we are computed the position for
  18407. */
  18408. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18409. /**
  18410. * Clones the current emitter and returns a copy of it
  18411. * @returns the new emitter
  18412. */
  18413. clone(): ConeParticleEmitter;
  18414. /**
  18415. * Called by the GPUParticleSystem to setup the update shader
  18416. * @param effect defines the update shader
  18417. */
  18418. applyToShader(effect: Effect): void;
  18419. /**
  18420. * Returns a string to use to update the GPU particles update shader
  18421. * @returns a string containng the defines string
  18422. */
  18423. getEffectDefines(): string;
  18424. /**
  18425. * Returns the string "ConeParticleEmitter"
  18426. * @returns a string containing the class name
  18427. */
  18428. getClassName(): string;
  18429. /**
  18430. * Serializes the particle system to a JSON object.
  18431. * @returns the JSON object
  18432. */
  18433. serialize(): any;
  18434. /**
  18435. * Parse properties from a JSON object
  18436. * @param serializationObject defines the JSON object
  18437. */
  18438. parse(serializationObject: any): void;
  18439. }
  18440. }
  18441. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  18442. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18443. import { Effect } from "babylonjs/Materials/effect";
  18444. import { Particle } from "babylonjs/Particles/particle";
  18445. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18446. /**
  18447. * Particle emitter emitting particles from the inside of a cylinder.
  18448. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  18449. */
  18450. export class CylinderParticleEmitter implements IParticleEmitterType {
  18451. /**
  18452. * The radius of the emission cylinder.
  18453. */
  18454. radius: number;
  18455. /**
  18456. * The height of the emission cylinder.
  18457. */
  18458. height: number;
  18459. /**
  18460. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18461. */
  18462. radiusRange: number;
  18463. /**
  18464. * How much to randomize the particle direction [0-1].
  18465. */
  18466. directionRandomizer: number;
  18467. /**
  18468. * Creates a new instance CylinderParticleEmitter
  18469. * @param radius the radius of the emission cylinder (1 by default)
  18470. * @param height the height of the emission cylinder (1 by default)
  18471. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18472. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18473. */
  18474. constructor(
  18475. /**
  18476. * The radius of the emission cylinder.
  18477. */
  18478. radius?: number,
  18479. /**
  18480. * The height of the emission cylinder.
  18481. */
  18482. height?: number,
  18483. /**
  18484. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18485. */
  18486. radiusRange?: number,
  18487. /**
  18488. * How much to randomize the particle direction [0-1].
  18489. */
  18490. directionRandomizer?: number);
  18491. /**
  18492. * Called by the particle System when the direction is computed for the created particle.
  18493. * @param worldMatrix is the world matrix of the particle system
  18494. * @param directionToUpdate is the direction vector to update with the result
  18495. * @param particle is the particle we are computed the direction for
  18496. */
  18497. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18498. /**
  18499. * Called by the particle System when the position is computed for the created particle.
  18500. * @param worldMatrix is the world matrix of the particle system
  18501. * @param positionToUpdate is the position vector to update with the result
  18502. * @param particle is the particle we are computed the position for
  18503. */
  18504. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18505. /**
  18506. * Clones the current emitter and returns a copy of it
  18507. * @returns the new emitter
  18508. */
  18509. clone(): CylinderParticleEmitter;
  18510. /**
  18511. * Called by the GPUParticleSystem to setup the update shader
  18512. * @param effect defines the update shader
  18513. */
  18514. applyToShader(effect: Effect): void;
  18515. /**
  18516. * Returns a string to use to update the GPU particles update shader
  18517. * @returns a string containng the defines string
  18518. */
  18519. getEffectDefines(): string;
  18520. /**
  18521. * Returns the string "CylinderParticleEmitter"
  18522. * @returns a string containing the class name
  18523. */
  18524. getClassName(): string;
  18525. /**
  18526. * Serializes the particle system to a JSON object.
  18527. * @returns the JSON object
  18528. */
  18529. serialize(): any;
  18530. /**
  18531. * Parse properties from a JSON object
  18532. * @param serializationObject defines the JSON object
  18533. */
  18534. parse(serializationObject: any): void;
  18535. }
  18536. /**
  18537. * Particle emitter emitting particles from the inside of a cylinder.
  18538. * It emits the particles randomly between two vectors.
  18539. */
  18540. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  18541. /**
  18542. * The min limit of the emission direction.
  18543. */
  18544. direction1: Vector3;
  18545. /**
  18546. * The max limit of the emission direction.
  18547. */
  18548. direction2: Vector3;
  18549. /**
  18550. * Creates a new instance CylinderDirectedParticleEmitter
  18551. * @param radius the radius of the emission cylinder (1 by default)
  18552. * @param height the height of the emission cylinder (1 by default)
  18553. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18554. * @param direction1 the min limit of the emission direction (up vector by default)
  18555. * @param direction2 the max limit of the emission direction (up vector by default)
  18556. */
  18557. constructor(radius?: number, height?: number, radiusRange?: number,
  18558. /**
  18559. * The min limit of the emission direction.
  18560. */
  18561. direction1?: Vector3,
  18562. /**
  18563. * The max limit of the emission direction.
  18564. */
  18565. direction2?: Vector3);
  18566. /**
  18567. * Called by the particle System when the direction is computed for the created particle.
  18568. * @param worldMatrix is the world matrix of the particle system
  18569. * @param directionToUpdate is the direction vector to update with the result
  18570. * @param particle is the particle we are computed the direction for
  18571. */
  18572. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18573. /**
  18574. * Clones the current emitter and returns a copy of it
  18575. * @returns the new emitter
  18576. */
  18577. clone(): CylinderDirectedParticleEmitter;
  18578. /**
  18579. * Called by the GPUParticleSystem to setup the update shader
  18580. * @param effect defines the update shader
  18581. */
  18582. applyToShader(effect: Effect): void;
  18583. /**
  18584. * Returns a string to use to update the GPU particles update shader
  18585. * @returns a string containng the defines string
  18586. */
  18587. getEffectDefines(): string;
  18588. /**
  18589. * Returns the string "CylinderDirectedParticleEmitter"
  18590. * @returns a string containing the class name
  18591. */
  18592. getClassName(): string;
  18593. /**
  18594. * Serializes the particle system to a JSON object.
  18595. * @returns the JSON object
  18596. */
  18597. serialize(): any;
  18598. /**
  18599. * Parse properties from a JSON object
  18600. * @param serializationObject defines the JSON object
  18601. */
  18602. parse(serializationObject: any): void;
  18603. }
  18604. }
  18605. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  18606. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18607. import { Effect } from "babylonjs/Materials/effect";
  18608. import { Particle } from "babylonjs/Particles/particle";
  18609. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18610. /**
  18611. * Particle emitter emitting particles from the inside of a hemisphere.
  18612. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  18613. */
  18614. export class HemisphericParticleEmitter implements IParticleEmitterType {
  18615. /**
  18616. * The radius of the emission hemisphere.
  18617. */
  18618. radius: number;
  18619. /**
  18620. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18621. */
  18622. radiusRange: number;
  18623. /**
  18624. * How much to randomize the particle direction [0-1].
  18625. */
  18626. directionRandomizer: number;
  18627. /**
  18628. * Creates a new instance HemisphericParticleEmitter
  18629. * @param radius the radius of the emission hemisphere (1 by default)
  18630. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18631. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18632. */
  18633. constructor(
  18634. /**
  18635. * The radius of the emission hemisphere.
  18636. */
  18637. radius?: number,
  18638. /**
  18639. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18640. */
  18641. radiusRange?: number,
  18642. /**
  18643. * How much to randomize the particle direction [0-1].
  18644. */
  18645. directionRandomizer?: number);
  18646. /**
  18647. * Called by the particle System when the direction is computed for the created particle.
  18648. * @param worldMatrix is the world matrix of the particle system
  18649. * @param directionToUpdate is the direction vector to update with the result
  18650. * @param particle is the particle we are computed the direction for
  18651. */
  18652. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18653. /**
  18654. * Called by the particle System when the position is computed for the created particle.
  18655. * @param worldMatrix is the world matrix of the particle system
  18656. * @param positionToUpdate is the position vector to update with the result
  18657. * @param particle is the particle we are computed the position for
  18658. */
  18659. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18660. /**
  18661. * Clones the current emitter and returns a copy of it
  18662. * @returns the new emitter
  18663. */
  18664. clone(): HemisphericParticleEmitter;
  18665. /**
  18666. * Called by the GPUParticleSystem to setup the update shader
  18667. * @param effect defines the update shader
  18668. */
  18669. applyToShader(effect: Effect): void;
  18670. /**
  18671. * Returns a string to use to update the GPU particles update shader
  18672. * @returns a string containng the defines string
  18673. */
  18674. getEffectDefines(): string;
  18675. /**
  18676. * Returns the string "HemisphericParticleEmitter"
  18677. * @returns a string containing the class name
  18678. */
  18679. getClassName(): string;
  18680. /**
  18681. * Serializes the particle system to a JSON object.
  18682. * @returns the JSON object
  18683. */
  18684. serialize(): any;
  18685. /**
  18686. * Parse properties from a JSON object
  18687. * @param serializationObject defines the JSON object
  18688. */
  18689. parse(serializationObject: any): void;
  18690. }
  18691. }
  18692. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  18693. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18694. import { Effect } from "babylonjs/Materials/effect";
  18695. import { Particle } from "babylonjs/Particles/particle";
  18696. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18697. /**
  18698. * Particle emitter emitting particles from a point.
  18699. * It emits the particles randomly between 2 given directions.
  18700. */
  18701. export class PointParticleEmitter implements IParticleEmitterType {
  18702. /**
  18703. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18704. */
  18705. direction1: Vector3;
  18706. /**
  18707. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18708. */
  18709. direction2: Vector3;
  18710. /**
  18711. * Creates a new instance PointParticleEmitter
  18712. */
  18713. constructor();
  18714. /**
  18715. * Called by the particle System when the direction is computed for the created particle.
  18716. * @param worldMatrix is the world matrix of the particle system
  18717. * @param directionToUpdate is the direction vector to update with the result
  18718. * @param particle is the particle we are computed the direction for
  18719. */
  18720. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18721. /**
  18722. * Called by the particle System when the position is computed for the created particle.
  18723. * @param worldMatrix is the world matrix of the particle system
  18724. * @param positionToUpdate is the position vector to update with the result
  18725. * @param particle is the particle we are computed the position for
  18726. */
  18727. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18728. /**
  18729. * Clones the current emitter and returns a copy of it
  18730. * @returns the new emitter
  18731. */
  18732. clone(): PointParticleEmitter;
  18733. /**
  18734. * Called by the GPUParticleSystem to setup the update shader
  18735. * @param effect defines the update shader
  18736. */
  18737. applyToShader(effect: Effect): void;
  18738. /**
  18739. * Returns a string to use to update the GPU particles update shader
  18740. * @returns a string containng the defines string
  18741. */
  18742. getEffectDefines(): string;
  18743. /**
  18744. * Returns the string "PointParticleEmitter"
  18745. * @returns a string containing the class name
  18746. */
  18747. getClassName(): string;
  18748. /**
  18749. * Serializes the particle system to a JSON object.
  18750. * @returns the JSON object
  18751. */
  18752. serialize(): any;
  18753. /**
  18754. * Parse properties from a JSON object
  18755. * @param serializationObject defines the JSON object
  18756. */
  18757. parse(serializationObject: any): void;
  18758. }
  18759. }
  18760. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  18761. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18762. import { Effect } from "babylonjs/Materials/effect";
  18763. import { Particle } from "babylonjs/Particles/particle";
  18764. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18765. /**
  18766. * Particle emitter emitting particles from the inside of a sphere.
  18767. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  18768. */
  18769. export class SphereParticleEmitter implements IParticleEmitterType {
  18770. /**
  18771. * The radius of the emission sphere.
  18772. */
  18773. radius: number;
  18774. /**
  18775. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18776. */
  18777. radiusRange: number;
  18778. /**
  18779. * How much to randomize the particle direction [0-1].
  18780. */
  18781. directionRandomizer: number;
  18782. /**
  18783. * Creates a new instance SphereParticleEmitter
  18784. * @param radius the radius of the emission sphere (1 by default)
  18785. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18786. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18787. */
  18788. constructor(
  18789. /**
  18790. * The radius of the emission sphere.
  18791. */
  18792. radius?: number,
  18793. /**
  18794. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18795. */
  18796. radiusRange?: number,
  18797. /**
  18798. * How much to randomize the particle direction [0-1].
  18799. */
  18800. directionRandomizer?: number);
  18801. /**
  18802. * Called by the particle System when the direction is computed for the created particle.
  18803. * @param worldMatrix is the world matrix of the particle system
  18804. * @param directionToUpdate is the direction vector to update with the result
  18805. * @param particle is the particle we are computed the direction for
  18806. */
  18807. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18808. /**
  18809. * Called by the particle System when the position is computed for the created particle.
  18810. * @param worldMatrix is the world matrix of the particle system
  18811. * @param positionToUpdate is the position vector to update with the result
  18812. * @param particle is the particle we are computed the position for
  18813. */
  18814. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18815. /**
  18816. * Clones the current emitter and returns a copy of it
  18817. * @returns the new emitter
  18818. */
  18819. clone(): SphereParticleEmitter;
  18820. /**
  18821. * Called by the GPUParticleSystem to setup the update shader
  18822. * @param effect defines the update shader
  18823. */
  18824. applyToShader(effect: Effect): void;
  18825. /**
  18826. * Returns a string to use to update the GPU particles update shader
  18827. * @returns a string containng the defines string
  18828. */
  18829. getEffectDefines(): string;
  18830. /**
  18831. * Returns the string "SphereParticleEmitter"
  18832. * @returns a string containing the class name
  18833. */
  18834. getClassName(): string;
  18835. /**
  18836. * Serializes the particle system to a JSON object.
  18837. * @returns the JSON object
  18838. */
  18839. serialize(): any;
  18840. /**
  18841. * Parse properties from a JSON object
  18842. * @param serializationObject defines the JSON object
  18843. */
  18844. parse(serializationObject: any): void;
  18845. }
  18846. /**
  18847. * Particle emitter emitting particles from the inside of a sphere.
  18848. * It emits the particles randomly between two vectors.
  18849. */
  18850. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  18851. /**
  18852. * The min limit of the emission direction.
  18853. */
  18854. direction1: Vector3;
  18855. /**
  18856. * The max limit of the emission direction.
  18857. */
  18858. direction2: Vector3;
  18859. /**
  18860. * Creates a new instance SphereDirectedParticleEmitter
  18861. * @param radius the radius of the emission sphere (1 by default)
  18862. * @param direction1 the min limit of the emission direction (up vector by default)
  18863. * @param direction2 the max limit of the emission direction (up vector by default)
  18864. */
  18865. constructor(radius?: number,
  18866. /**
  18867. * The min limit of the emission direction.
  18868. */
  18869. direction1?: Vector3,
  18870. /**
  18871. * The max limit of the emission direction.
  18872. */
  18873. direction2?: Vector3);
  18874. /**
  18875. * Called by the particle System when the direction is computed for the created particle.
  18876. * @param worldMatrix is the world matrix of the particle system
  18877. * @param directionToUpdate is the direction vector to update with the result
  18878. * @param particle is the particle we are computed the direction for
  18879. */
  18880. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18881. /**
  18882. * Clones the current emitter and returns a copy of it
  18883. * @returns the new emitter
  18884. */
  18885. clone(): SphereDirectedParticleEmitter;
  18886. /**
  18887. * Called by the GPUParticleSystem to setup the update shader
  18888. * @param effect defines the update shader
  18889. */
  18890. applyToShader(effect: Effect): void;
  18891. /**
  18892. * Returns a string to use to update the GPU particles update shader
  18893. * @returns a string containng the defines string
  18894. */
  18895. getEffectDefines(): string;
  18896. /**
  18897. * Returns the string "SphereDirectedParticleEmitter"
  18898. * @returns a string containing the class name
  18899. */
  18900. getClassName(): string;
  18901. /**
  18902. * Serializes the particle system to a JSON object.
  18903. * @returns the JSON object
  18904. */
  18905. serialize(): any;
  18906. /**
  18907. * Parse properties from a JSON object
  18908. * @param serializationObject defines the JSON object
  18909. */
  18910. parse(serializationObject: any): void;
  18911. }
  18912. }
  18913. declare module "babylonjs/Particles/EmitterTypes/index" {
  18914. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  18915. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  18916. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  18917. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  18918. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18919. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  18920. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  18921. }
  18922. declare module "babylonjs/Particles/IParticleSystem" {
  18923. import { Nullable } from "babylonjs/types";
  18924. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  18925. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  18926. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18927. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  18928. import { Texture } from "babylonjs/Materials/Textures/texture";
  18929. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  18930. import { Scene } from "babylonjs/scene";
  18931. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  18932. import { Animation } from "babylonjs/Animations/animation";
  18933. /**
  18934. * Interface representing a particle system in Babylon.js.
  18935. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  18936. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  18937. */
  18938. export interface IParticleSystem {
  18939. /**
  18940. * List of animations used by the particle system.
  18941. */
  18942. animations: Animation[];
  18943. /**
  18944. * The id of the Particle system.
  18945. */
  18946. id: string;
  18947. /**
  18948. * The name of the Particle system.
  18949. */
  18950. name: string;
  18951. /**
  18952. * The emitter represents the Mesh or position we are attaching the particle system to.
  18953. */
  18954. emitter: Nullable<AbstractMesh | Vector3>;
  18955. /**
  18956. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  18957. */
  18958. isBillboardBased: boolean;
  18959. /**
  18960. * The rendering group used by the Particle system to chose when to render.
  18961. */
  18962. renderingGroupId: number;
  18963. /**
  18964. * The layer mask we are rendering the particles through.
  18965. */
  18966. layerMask: number;
  18967. /**
  18968. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  18969. */
  18970. updateSpeed: number;
  18971. /**
  18972. * The amount of time the particle system is running (depends of the overall update speed).
  18973. */
  18974. targetStopDuration: number;
  18975. /**
  18976. * The texture used to render each particle. (this can be a spritesheet)
  18977. */
  18978. particleTexture: Nullable<Texture>;
  18979. /**
  18980. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  18981. */
  18982. blendMode: number;
  18983. /**
  18984. * Minimum life time of emitting particles.
  18985. */
  18986. minLifeTime: number;
  18987. /**
  18988. * Maximum life time of emitting particles.
  18989. */
  18990. maxLifeTime: number;
  18991. /**
  18992. * Minimum Size of emitting particles.
  18993. */
  18994. minSize: number;
  18995. /**
  18996. * Maximum Size of emitting particles.
  18997. */
  18998. maxSize: number;
  18999. /**
  19000. * Minimum scale of emitting particles on X axis.
  19001. */
  19002. minScaleX: number;
  19003. /**
  19004. * Maximum scale of emitting particles on X axis.
  19005. */
  19006. maxScaleX: number;
  19007. /**
  19008. * Minimum scale of emitting particles on Y axis.
  19009. */
  19010. minScaleY: number;
  19011. /**
  19012. * Maximum scale of emitting particles on Y axis.
  19013. */
  19014. maxScaleY: number;
  19015. /**
  19016. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  19017. */
  19018. color1: Color4;
  19019. /**
  19020. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  19021. */
  19022. color2: Color4;
  19023. /**
  19024. * Color the particle will have at the end of its lifetime.
  19025. */
  19026. colorDead: Color4;
  19027. /**
  19028. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  19029. */
  19030. emitRate: number;
  19031. /**
  19032. * You can use gravity if you want to give an orientation to your particles.
  19033. */
  19034. gravity: Vector3;
  19035. /**
  19036. * Minimum power of emitting particles.
  19037. */
  19038. minEmitPower: number;
  19039. /**
  19040. * Maximum power of emitting particles.
  19041. */
  19042. maxEmitPower: number;
  19043. /**
  19044. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  19045. */
  19046. minAngularSpeed: number;
  19047. /**
  19048. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  19049. */
  19050. maxAngularSpeed: number;
  19051. /**
  19052. * Gets or sets the minimal initial rotation in radians.
  19053. */
  19054. minInitialRotation: number;
  19055. /**
  19056. * Gets or sets the maximal initial rotation in radians.
  19057. */
  19058. maxInitialRotation: number;
  19059. /**
  19060. * The particle emitter type defines the emitter used by the particle system.
  19061. * It can be for example box, sphere, or cone...
  19062. */
  19063. particleEmitterType: Nullable<IParticleEmitterType>;
  19064. /**
  19065. * Defines the delay in milliseconds before starting the system (0 by default)
  19066. */
  19067. startDelay: number;
  19068. /**
  19069. * Gets or sets a value indicating how many cycles (or frames) must be executed before first rendering (this value has to be set before starting the system). Default is 0
  19070. */
  19071. preWarmCycles: number;
  19072. /**
  19073. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  19074. */
  19075. preWarmStepOffset: number;
  19076. /**
  19077. * If using a spritesheet (isAnimationSheetEnabled) defines the speed of the sprite loop (default is 1 meaning the animation will play once during the entire particle lifetime)
  19078. */
  19079. spriteCellChangeSpeed: number;
  19080. /**
  19081. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  19082. */
  19083. startSpriteCellID: number;
  19084. /**
  19085. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  19086. */
  19087. endSpriteCellID: number;
  19088. /**
  19089. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  19090. */
  19091. spriteCellWidth: number;
  19092. /**
  19093. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  19094. */
  19095. spriteCellHeight: number;
  19096. /**
  19097. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  19098. */
  19099. spriteRandomStartCell: boolean;
  19100. /**
  19101. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  19102. */
  19103. isAnimationSheetEnabled: boolean;
  19104. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  19105. translationPivot: Vector2;
  19106. /**
  19107. * Gets or sets a texture used to add random noise to particle positions
  19108. */
  19109. noiseTexture: Nullable<BaseTexture>;
  19110. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  19111. noiseStrength: Vector3;
  19112. /**
  19113. * Gets or sets the billboard mode to use when isBillboardBased = true.
  19114. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  19115. */
  19116. billboardMode: number;
  19117. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  19118. limitVelocityDamping: number;
  19119. /**
  19120. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  19121. */
  19122. beginAnimationOnStart: boolean;
  19123. /**
  19124. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  19125. */
  19126. beginAnimationFrom: number;
  19127. /**
  19128. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  19129. */
  19130. beginAnimationTo: number;
  19131. /**
  19132. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  19133. */
  19134. beginAnimationLoop: boolean;
  19135. /**
  19136. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  19137. */
  19138. disposeOnStop: boolean;
  19139. /**
  19140. * Gets the maximum number of particles active at the same time.
  19141. * @returns The max number of active particles.
  19142. */
  19143. getCapacity(): number;
  19144. /**
  19145. * Gets if the system has been started. (Note: this will still be true after stop is called)
  19146. * @returns True if it has been started, otherwise false.
  19147. */
  19148. isStarted(): boolean;
  19149. /**
  19150. * Animates the particle system for this frame.
  19151. */
  19152. animate(): void;
  19153. /**
  19154. * Renders the particle system in its current state.
  19155. * @returns the current number of particles
  19156. */
  19157. render(): number;
  19158. /**
  19159. * Dispose the particle system and frees its associated resources.
  19160. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  19161. */
  19162. dispose(disposeTexture?: boolean): void;
  19163. /**
  19164. * Clones the particle system.
  19165. * @param name The name of the cloned object
  19166. * @param newEmitter The new emitter to use
  19167. * @returns the cloned particle system
  19168. */
  19169. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  19170. /**
  19171. * Serializes the particle system to a JSON object.
  19172. * @returns the JSON object
  19173. */
  19174. serialize(): any;
  19175. /**
  19176. * Rebuild the particle system
  19177. */
  19178. rebuild(): void;
  19179. /**
  19180. * Starts the particle system and begins to emit
  19181. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  19182. */
  19183. start(delay?: number): void;
  19184. /**
  19185. * Stops the particle system.
  19186. */
  19187. stop(): void;
  19188. /**
  19189. * Remove all active particles
  19190. */
  19191. reset(): void;
  19192. /**
  19193. * Is this system ready to be used/rendered
  19194. * @return true if the system is ready
  19195. */
  19196. isReady(): boolean;
  19197. /**
  19198. * Adds a new color gradient
  19199. * @param gradient defines the gradient to use (between 0 and 1)
  19200. * @param color1 defines the color to affect to the specified gradient
  19201. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  19202. * @returns the current particle system
  19203. */
  19204. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  19205. /**
  19206. * Remove a specific color gradient
  19207. * @param gradient defines the gradient to remove
  19208. * @returns the current particle system
  19209. */
  19210. removeColorGradient(gradient: number): IParticleSystem;
  19211. /**
  19212. * Adds a new size gradient
  19213. * @param gradient defines the gradient to use (between 0 and 1)
  19214. * @param factor defines the size factor to affect to the specified gradient
  19215. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19216. * @returns the current particle system
  19217. */
  19218. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19219. /**
  19220. * Remove a specific size gradient
  19221. * @param gradient defines the gradient to remove
  19222. * @returns the current particle system
  19223. */
  19224. removeSizeGradient(gradient: number): IParticleSystem;
  19225. /**
  19226. * Gets the current list of color gradients.
  19227. * You must use addColorGradient and removeColorGradient to udpate this list
  19228. * @returns the list of color gradients
  19229. */
  19230. getColorGradients(): Nullable<Array<ColorGradient>>;
  19231. /**
  19232. * Gets the current list of size gradients.
  19233. * You must use addSizeGradient and removeSizeGradient to udpate this list
  19234. * @returns the list of size gradients
  19235. */
  19236. getSizeGradients(): Nullable<Array<FactorGradient>>;
  19237. /**
  19238. * Gets the current list of angular speed gradients.
  19239. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  19240. * @returns the list of angular speed gradients
  19241. */
  19242. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  19243. /**
  19244. * Adds a new angular speed gradient
  19245. * @param gradient defines the gradient to use (between 0 and 1)
  19246. * @param factor defines the angular speed to affect to the specified gradient
  19247. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19248. * @returns the current particle system
  19249. */
  19250. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19251. /**
  19252. * Remove a specific angular speed gradient
  19253. * @param gradient defines the gradient to remove
  19254. * @returns the current particle system
  19255. */
  19256. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  19257. /**
  19258. * Gets the current list of velocity gradients.
  19259. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  19260. * @returns the list of velocity gradients
  19261. */
  19262. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  19263. /**
  19264. * Adds a new velocity gradient
  19265. * @param gradient defines the gradient to use (between 0 and 1)
  19266. * @param factor defines the velocity to affect to the specified gradient
  19267. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19268. * @returns the current particle system
  19269. */
  19270. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19271. /**
  19272. * Remove a specific velocity gradient
  19273. * @param gradient defines the gradient to remove
  19274. * @returns the current particle system
  19275. */
  19276. removeVelocityGradient(gradient: number): IParticleSystem;
  19277. /**
  19278. * Gets the current list of limit velocity gradients.
  19279. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  19280. * @returns the list of limit velocity gradients
  19281. */
  19282. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  19283. /**
  19284. * Adds a new limit velocity gradient
  19285. * @param gradient defines the gradient to use (between 0 and 1)
  19286. * @param factor defines the limit velocity to affect to the specified gradient
  19287. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19288. * @returns the current particle system
  19289. */
  19290. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19291. /**
  19292. * Remove a specific limit velocity gradient
  19293. * @param gradient defines the gradient to remove
  19294. * @returns the current particle system
  19295. */
  19296. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  19297. /**
  19298. * Adds a new drag gradient
  19299. * @param gradient defines the gradient to use (between 0 and 1)
  19300. * @param factor defines the drag to affect to the specified gradient
  19301. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19302. * @returns the current particle system
  19303. */
  19304. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19305. /**
  19306. * Remove a specific drag gradient
  19307. * @param gradient defines the gradient to remove
  19308. * @returns the current particle system
  19309. */
  19310. removeDragGradient(gradient: number): IParticleSystem;
  19311. /**
  19312. * Gets the current list of drag gradients.
  19313. * You must use addDragGradient and removeDragGradient to udpate this list
  19314. * @returns the list of drag gradients
  19315. */
  19316. getDragGradients(): Nullable<Array<FactorGradient>>;
  19317. /**
  19318. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  19319. * @param gradient defines the gradient to use (between 0 and 1)
  19320. * @param factor defines the emit rate to affect to the specified gradient
  19321. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19322. * @returns the current particle system
  19323. */
  19324. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19325. /**
  19326. * Remove a specific emit rate gradient
  19327. * @param gradient defines the gradient to remove
  19328. * @returns the current particle system
  19329. */
  19330. removeEmitRateGradient(gradient: number): IParticleSystem;
  19331. /**
  19332. * Gets the current list of emit rate gradients.
  19333. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  19334. * @returns the list of emit rate gradients
  19335. */
  19336. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  19337. /**
  19338. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  19339. * @param gradient defines the gradient to use (between 0 and 1)
  19340. * @param factor defines the start size to affect to the specified gradient
  19341. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19342. * @returns the current particle system
  19343. */
  19344. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19345. /**
  19346. * Remove a specific start size gradient
  19347. * @param gradient defines the gradient to remove
  19348. * @returns the current particle system
  19349. */
  19350. removeStartSizeGradient(gradient: number): IParticleSystem;
  19351. /**
  19352. * Gets the current list of start size gradients.
  19353. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  19354. * @returns the list of start size gradients
  19355. */
  19356. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  19357. /**
  19358. * Adds a new life time gradient
  19359. * @param gradient defines the gradient to use (between 0 and 1)
  19360. * @param factor defines the life time factor to affect to the specified gradient
  19361. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19362. * @returns the current particle system
  19363. */
  19364. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19365. /**
  19366. * Remove a specific life time gradient
  19367. * @param gradient defines the gradient to remove
  19368. * @returns the current particle system
  19369. */
  19370. removeLifeTimeGradient(gradient: number): IParticleSystem;
  19371. /**
  19372. * Gets the current list of life time gradients.
  19373. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  19374. * @returns the list of life time gradients
  19375. */
  19376. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  19377. /**
  19378. * Gets the current list of color gradients.
  19379. * You must use addColorGradient and removeColorGradient to udpate this list
  19380. * @returns the list of color gradients
  19381. */
  19382. getColorGradients(): Nullable<Array<ColorGradient>>;
  19383. /**
  19384. * Adds a new ramp gradient used to remap particle colors
  19385. * @param gradient defines the gradient to use (between 0 and 1)
  19386. * @param color defines the color to affect to the specified gradient
  19387. * @returns the current particle system
  19388. */
  19389. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  19390. /**
  19391. * Gets the current list of ramp gradients.
  19392. * You must use addRampGradient and removeRampGradient to udpate this list
  19393. * @returns the list of ramp gradients
  19394. */
  19395. getRampGradients(): Nullable<Array<Color3Gradient>>;
  19396. /** Gets or sets a boolean indicating that ramp gradients must be used
  19397. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  19398. */
  19399. useRampGradients: boolean;
  19400. /**
  19401. * Adds a new color remap gradient
  19402. * @param gradient defines the gradient to use (between 0 and 1)
  19403. * @param min defines the color remap minimal range
  19404. * @param max defines the color remap maximal range
  19405. * @returns the current particle system
  19406. */
  19407. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  19408. /**
  19409. * Gets the current list of color remap gradients.
  19410. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  19411. * @returns the list of color remap gradients
  19412. */
  19413. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  19414. /**
  19415. * Adds a new alpha remap gradient
  19416. * @param gradient defines the gradient to use (between 0 and 1)
  19417. * @param min defines the alpha remap minimal range
  19418. * @param max defines the alpha remap maximal range
  19419. * @returns the current particle system
  19420. */
  19421. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  19422. /**
  19423. * Gets the current list of alpha remap gradients.
  19424. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  19425. * @returns the list of alpha remap gradients
  19426. */
  19427. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  19428. /**
  19429. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  19430. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  19431. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  19432. * @returns the emitter
  19433. */
  19434. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  19435. /**
  19436. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  19437. * @param radius The radius of the hemisphere to emit from
  19438. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  19439. * @returns the emitter
  19440. */
  19441. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  19442. /**
  19443. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  19444. * @param radius The radius of the sphere to emit from
  19445. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  19446. * @returns the emitter
  19447. */
  19448. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  19449. /**
  19450. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  19451. * @param radius The radius of the sphere to emit from
  19452. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  19453. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  19454. * @returns the emitter
  19455. */
  19456. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  19457. /**
  19458. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  19459. * @param radius The radius of the emission cylinder
  19460. * @param height The height of the emission cylinder
  19461. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  19462. * @param directionRandomizer How much to randomize the particle direction [0-1]
  19463. * @returns the emitter
  19464. */
  19465. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  19466. /**
  19467. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  19468. * @param radius The radius of the cylinder to emit from
  19469. * @param height The height of the emission cylinder
  19470. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  19471. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  19472. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  19473. * @returns the emitter
  19474. */
  19475. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  19476. /**
  19477. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  19478. * @param radius The radius of the cone to emit from
  19479. * @param angle The base angle of the cone
  19480. * @returns the emitter
  19481. */
  19482. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  19483. /**
  19484. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  19485. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  19486. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  19487. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19488. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19489. * @returns the emitter
  19490. */
  19491. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  19492. /**
  19493. * Get hosting scene
  19494. * @returns the scene
  19495. */
  19496. getScene(): Scene;
  19497. }
  19498. }
  19499. declare module "babylonjs/Meshes/instancedMesh" {
  19500. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  19501. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  19502. import { Camera } from "babylonjs/Cameras/camera";
  19503. import { Node } from "babylonjs/node";
  19504. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19505. import { Mesh } from "babylonjs/Meshes/mesh";
  19506. import { Material } from "babylonjs/Materials/material";
  19507. import { Skeleton } from "babylonjs/Bones/skeleton";
  19508. import { Light } from "babylonjs/Lights/light";
  19509. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  19510. /**
  19511. * Creates an instance based on a source mesh.
  19512. */
  19513. export class InstancedMesh extends AbstractMesh {
  19514. private _sourceMesh;
  19515. private _currentLOD;
  19516. /** @hidden */
  19517. _indexInSourceMeshInstanceArray: number;
  19518. constructor(name: string, source: Mesh);
  19519. /**
  19520. * Returns the string "InstancedMesh".
  19521. */
  19522. getClassName(): string;
  19523. /** Gets the list of lights affecting that mesh */
  19524. readonly lightSources: Light[];
  19525. _resyncLightSources(): void;
  19526. _resyncLighSource(light: Light): void;
  19527. _removeLightSource(light: Light, dispose: boolean): void;
  19528. /**
  19529. * If the source mesh receives shadows
  19530. */
  19531. readonly receiveShadows: boolean;
  19532. /**
  19533. * The material of the source mesh
  19534. */
  19535. readonly material: Nullable<Material>;
  19536. /**
  19537. * Visibility of the source mesh
  19538. */
  19539. readonly visibility: number;
  19540. /**
  19541. * Skeleton of the source mesh
  19542. */
  19543. readonly skeleton: Nullable<Skeleton>;
  19544. /**
  19545. * Rendering ground id of the source mesh
  19546. */
  19547. renderingGroupId: number;
  19548. /**
  19549. * Returns the total number of vertices (integer).
  19550. */
  19551. getTotalVertices(): number;
  19552. /**
  19553. * Returns a positive integer : the total number of indices in this mesh geometry.
  19554. * @returns the numner of indices or zero if the mesh has no geometry.
  19555. */
  19556. getTotalIndices(): number;
  19557. /**
  19558. * The source mesh of the instance
  19559. */
  19560. readonly sourceMesh: Mesh;
  19561. /**
  19562. * Is this node ready to be used/rendered
  19563. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  19564. * @return {boolean} is it ready
  19565. */
  19566. isReady(completeCheck?: boolean): boolean;
  19567. /**
  19568. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  19569. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  19570. * @param copyWhenShared If true (default false) and and if the mesh geometry is shared among some other meshes, the returned array is a copy of the internal one.
  19571. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  19572. */
  19573. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  19574. /**
  19575. * Sets the vertex data of the mesh geometry for the requested `kind`.
  19576. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  19577. * The `data` are either a numeric array either a Float32Array.
  19578. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  19579. * The parameter `stride` is an optional positive integer, it is usually automatically deducted from the `kind` (3 for positions or normals, 2 for UV, etc).
  19580. * Note that a new underlying VertexBuffer object is created each call.
  19581. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  19582. *
  19583. * Possible `kind` values :
  19584. * - VertexBuffer.PositionKind
  19585. * - VertexBuffer.UVKind
  19586. * - VertexBuffer.UV2Kind
  19587. * - VertexBuffer.UV3Kind
  19588. * - VertexBuffer.UV4Kind
  19589. * - VertexBuffer.UV5Kind
  19590. * - VertexBuffer.UV6Kind
  19591. * - VertexBuffer.ColorKind
  19592. * - VertexBuffer.MatricesIndicesKind
  19593. * - VertexBuffer.MatricesIndicesExtraKind
  19594. * - VertexBuffer.MatricesWeightsKind
  19595. * - VertexBuffer.MatricesWeightsExtraKind
  19596. *
  19597. * Returns the Mesh.
  19598. */
  19599. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  19600. /**
  19601. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  19602. * If the mesh has no geometry, it is simply returned as it is.
  19603. * The `data` are either a numeric array either a Float32Array.
  19604. * No new underlying VertexBuffer object is created.
  19605. * If the `kind` is the `PositionKind` and if `updateExtends` is true, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  19606. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  19607. *
  19608. * Possible `kind` values :
  19609. * - VertexBuffer.PositionKind
  19610. * - VertexBuffer.UVKind
  19611. * - VertexBuffer.UV2Kind
  19612. * - VertexBuffer.UV3Kind
  19613. * - VertexBuffer.UV4Kind
  19614. * - VertexBuffer.UV5Kind
  19615. * - VertexBuffer.UV6Kind
  19616. * - VertexBuffer.ColorKind
  19617. * - VertexBuffer.MatricesIndicesKind
  19618. * - VertexBuffer.MatricesIndicesExtraKind
  19619. * - VertexBuffer.MatricesWeightsKind
  19620. * - VertexBuffer.MatricesWeightsExtraKind
  19621. *
  19622. * Returns the Mesh.
  19623. */
  19624. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  19625. /**
  19626. * Sets the mesh indices.
  19627. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  19628. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  19629. * This method creates a new index buffer each call.
  19630. * Returns the Mesh.
  19631. */
  19632. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  19633. /**
  19634. * Boolean : True if the mesh owns the requested kind of data.
  19635. */
  19636. isVerticesDataPresent(kind: string): boolean;
  19637. /**
  19638. * Returns an array of indices (IndicesArray).
  19639. */
  19640. getIndices(): Nullable<IndicesArray>;
  19641. readonly _positions: Nullable<Vector3[]>;
  19642. /**
  19643. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  19644. * This means the mesh underlying bounding box and sphere are recomputed.
  19645. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  19646. * @returns the current mesh
  19647. */
  19648. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  19649. /** @hidden */
  19650. _preActivate(): InstancedMesh;
  19651. /** @hidden */
  19652. _activate(renderId: number, intermediateRendering: boolean): boolean;
  19653. /** @hidden */
  19654. _postActivate(): void;
  19655. getWorldMatrix(): Matrix;
  19656. readonly isAnInstance: boolean;
  19657. /**
  19658. * Returns the current associated LOD AbstractMesh.
  19659. */
  19660. getLOD(camera: Camera): AbstractMesh;
  19661. /** @hidden */
  19662. _syncSubMeshes(): InstancedMesh;
  19663. /** @hidden */
  19664. _generatePointsArray(): boolean;
  19665. /**
  19666. * Creates a new InstancedMesh from the current mesh.
  19667. * - name (string) : the cloned mesh name
  19668. * - newParent (optional Node) : the optional Node to parent the clone to.
  19669. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  19670. *
  19671. * Returns the clone.
  19672. */
  19673. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  19674. /**
  19675. * Disposes the InstancedMesh.
  19676. * Returns nothing.
  19677. */
  19678. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  19679. }
  19680. module "babylonjs/Meshes/mesh" {
  19681. interface Mesh {
  19682. /**
  19683. * Register a custom buffer that will be instanced
  19684. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  19685. * @param kind defines the buffer kind
  19686. * @param stride defines the stride in floats
  19687. */
  19688. registerInstancedBuffer(kind: string, stride: number): void;
  19689. /** @hidden */
  19690. _userInstancedBuffersStorage: {
  19691. data: {
  19692. [key: string]: Float32Array;
  19693. };
  19694. sizes: {
  19695. [key: string]: number;
  19696. };
  19697. vertexBuffers: {
  19698. [key: string]: Nullable<VertexBuffer>;
  19699. };
  19700. strides: {
  19701. [key: string]: number;
  19702. };
  19703. };
  19704. }
  19705. }
  19706. module "babylonjs/Meshes/abstractMesh" {
  19707. interface AbstractMesh {
  19708. /**
  19709. * Object used to store instanced buffers defined by user
  19710. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  19711. */
  19712. instancedBuffers: {
  19713. [key: string]: any;
  19714. };
  19715. }
  19716. }
  19717. }
  19718. declare module "babylonjs/Materials/shaderMaterial" {
  19719. import { Scene } from "babylonjs/scene";
  19720. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  19721. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19722. import { Mesh } from "babylonjs/Meshes/mesh";
  19723. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  19724. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  19725. import { Texture } from "babylonjs/Materials/Textures/texture";
  19726. import { Material } from "babylonjs/Materials/material";
  19727. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  19728. /**
  19729. * Defines the options associated with the creation of a shader material.
  19730. */
  19731. export interface IShaderMaterialOptions {
  19732. /**
  19733. * Does the material work in alpha blend mode
  19734. */
  19735. needAlphaBlending: boolean;
  19736. /**
  19737. * Does the material work in alpha test mode
  19738. */
  19739. needAlphaTesting: boolean;
  19740. /**
  19741. * The list of attribute names used in the shader
  19742. */
  19743. attributes: string[];
  19744. /**
  19745. * The list of unifrom names used in the shader
  19746. */
  19747. uniforms: string[];
  19748. /**
  19749. * The list of UBO names used in the shader
  19750. */
  19751. uniformBuffers: string[];
  19752. /**
  19753. * The list of sampler names used in the shader
  19754. */
  19755. samplers: string[];
  19756. /**
  19757. * The list of defines used in the shader
  19758. */
  19759. defines: string[];
  19760. }
  19761. /**
  19762. * The ShaderMaterial object has the necessary methods to pass data from your scene to the Vertex and Fragment Shaders and returns a material that can be applied to any mesh.
  19763. *
  19764. * This returned material effects how the mesh will look based on the code in the shaders.
  19765. *
  19766. * @see http://doc.babylonjs.com/how_to/shader_material
  19767. */
  19768. export class ShaderMaterial extends Material {
  19769. private _shaderPath;
  19770. private _options;
  19771. private _textures;
  19772. private _textureArrays;
  19773. private _floats;
  19774. private _ints;
  19775. private _floatsArrays;
  19776. private _colors3;
  19777. private _colors3Arrays;
  19778. private _colors4;
  19779. private _colors4Arrays;
  19780. private _vectors2;
  19781. private _vectors3;
  19782. private _vectors4;
  19783. private _matrices;
  19784. private _matrixArrays;
  19785. private _matrices3x3;
  19786. private _matrices2x2;
  19787. private _vectors2Arrays;
  19788. private _vectors3Arrays;
  19789. private _vectors4Arrays;
  19790. private _cachedWorldViewMatrix;
  19791. private _cachedWorldViewProjectionMatrix;
  19792. private _renderId;
  19793. private _multiview;
  19794. /**
  19795. * Instantiate a new shader material.
  19796. * The ShaderMaterial object has the necessary methods to pass data from your scene to the Vertex and Fragment Shaders and returns a material that can be applied to any mesh.
  19797. * This returned material effects how the mesh will look based on the code in the shaders.
  19798. * @see http://doc.babylonjs.com/how_to/shader_material
  19799. * @param name Define the name of the material in the scene
  19800. * @param scene Define the scene the material belongs to
  19801. * @param shaderPath Defines the route to the shader code in one of three ways:
  19802. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  19803. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  19804. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  19805. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  19806. * @param options Define the options used to create the shader
  19807. */
  19808. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  19809. /**
  19810. * Gets the shader path used to define the shader code
  19811. * It can be modified to trigger a new compilation
  19812. */
  19813. /**
  19814. * Sets the shader path used to define the shader code
  19815. * It can be modified to trigger a new compilation
  19816. */
  19817. shaderPath: any;
  19818. /**
  19819. * Gets the options used to compile the shader.
  19820. * They can be modified to trigger a new compilation
  19821. */
  19822. readonly options: IShaderMaterialOptions;
  19823. /**
  19824. * Gets the current class name of the material e.g. "ShaderMaterial"
  19825. * Mainly use in serialization.
  19826. * @returns the class name
  19827. */
  19828. getClassName(): string;
  19829. /**
  19830. * Specifies if the material will require alpha blending
  19831. * @returns a boolean specifying if alpha blending is needed
  19832. */
  19833. needAlphaBlending(): boolean;
  19834. /**
  19835. * Specifies if this material should be rendered in alpha test mode
  19836. * @returns a boolean specifying if an alpha test is needed.
  19837. */
  19838. needAlphaTesting(): boolean;
  19839. private _checkUniform;
  19840. /**
  19841. * Set a texture in the shader.
  19842. * @param name Define the name of the uniform samplers as defined in the shader
  19843. * @param texture Define the texture to bind to this sampler
  19844. * @return the material itself allowing "fluent" like uniform updates
  19845. */
  19846. setTexture(name: string, texture: Texture): ShaderMaterial;
  19847. /**
  19848. * Set a texture array in the shader.
  19849. * @param name Define the name of the uniform sampler array as defined in the shader
  19850. * @param textures Define the list of textures to bind to this sampler
  19851. * @return the material itself allowing "fluent" like uniform updates
  19852. */
  19853. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  19854. /**
  19855. * Set a float in the shader.
  19856. * @param name Define the name of the uniform as defined in the shader
  19857. * @param value Define the value to give to the uniform
  19858. * @return the material itself allowing "fluent" like uniform updates
  19859. */
  19860. setFloat(name: string, value: number): ShaderMaterial;
  19861. /**
  19862. * Set a int in the shader.
  19863. * @param name Define the name of the uniform as defined in the shader
  19864. * @param value Define the value to give to the uniform
  19865. * @return the material itself allowing "fluent" like uniform updates
  19866. */
  19867. setInt(name: string, value: number): ShaderMaterial;
  19868. /**
  19869. * Set an array of floats in the shader.
  19870. * @param name Define the name of the uniform as defined in the shader
  19871. * @param value Define the value to give to the uniform
  19872. * @return the material itself allowing "fluent" like uniform updates
  19873. */
  19874. setFloats(name: string, value: number[]): ShaderMaterial;
  19875. /**
  19876. * Set a vec3 in the shader from a Color3.
  19877. * @param name Define the name of the uniform as defined in the shader
  19878. * @param value Define the value to give to the uniform
  19879. * @return the material itself allowing "fluent" like uniform updates
  19880. */
  19881. setColor3(name: string, value: Color3): ShaderMaterial;
  19882. /**
  19883. * Set a vec3 array in the shader from a Color3 array.
  19884. * @param name Define the name of the uniform as defined in the shader
  19885. * @param value Define the value to give to the uniform
  19886. * @return the material itself allowing "fluent" like uniform updates
  19887. */
  19888. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  19889. /**
  19890. * Set a vec4 in the shader from a Color4.
  19891. * @param name Define the name of the uniform as defined in the shader
  19892. * @param value Define the value to give to the uniform
  19893. * @return the material itself allowing "fluent" like uniform updates
  19894. */
  19895. setColor4(name: string, value: Color4): ShaderMaterial;
  19896. /**
  19897. * Set a vec4 array in the shader from a Color4 array.
  19898. * @param name Define the name of the uniform as defined in the shader
  19899. * @param value Define the value to give to the uniform
  19900. * @return the material itself allowing "fluent" like uniform updates
  19901. */
  19902. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  19903. /**
  19904. * Set a vec2 in the shader from a Vector2.
  19905. * @param name Define the name of the uniform as defined in the shader
  19906. * @param value Define the value to give to the uniform
  19907. * @return the material itself allowing "fluent" like uniform updates
  19908. */
  19909. setVector2(name: string, value: Vector2): ShaderMaterial;
  19910. /**
  19911. * Set a vec3 in the shader from a Vector3.
  19912. * @param name Define the name of the uniform as defined in the shader
  19913. * @param value Define the value to give to the uniform
  19914. * @return the material itself allowing "fluent" like uniform updates
  19915. */
  19916. setVector3(name: string, value: Vector3): ShaderMaterial;
  19917. /**
  19918. * Set a vec4 in the shader from a Vector4.
  19919. * @param name Define the name of the uniform as defined in the shader
  19920. * @param value Define the value to give to the uniform
  19921. * @return the material itself allowing "fluent" like uniform updates
  19922. */
  19923. setVector4(name: string, value: Vector4): ShaderMaterial;
  19924. /**
  19925. * Set a mat4 in the shader from a Matrix.
  19926. * @param name Define the name of the uniform as defined in the shader
  19927. * @param value Define the value to give to the uniform
  19928. * @return the material itself allowing "fluent" like uniform updates
  19929. */
  19930. setMatrix(name: string, value: Matrix): ShaderMaterial;
  19931. /**
  19932. * Set a float32Array in the shader from a matrix array.
  19933. * @param name Define the name of the uniform as defined in the shader
  19934. * @param value Define the value to give to the uniform
  19935. * @return the material itself allowing "fluent" like uniform updates
  19936. */
  19937. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  19938. /**
  19939. * Set a mat3 in the shader from a Float32Array.
  19940. * @param name Define the name of the uniform as defined in the shader
  19941. * @param value Define the value to give to the uniform
  19942. * @return the material itself allowing "fluent" like uniform updates
  19943. */
  19944. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  19945. /**
  19946. * Set a mat2 in the shader from a Float32Array.
  19947. * @param name Define the name of the uniform as defined in the shader
  19948. * @param value Define the value to give to the uniform
  19949. * @return the material itself allowing "fluent" like uniform updates
  19950. */
  19951. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  19952. /**
  19953. * Set a vec2 array in the shader from a number array.
  19954. * @param name Define the name of the uniform as defined in the shader
  19955. * @param value Define the value to give to the uniform
  19956. * @return the material itself allowing "fluent" like uniform updates
  19957. */
  19958. setArray2(name: string, value: number[]): ShaderMaterial;
  19959. /**
  19960. * Set a vec3 array in the shader from a number array.
  19961. * @param name Define the name of the uniform as defined in the shader
  19962. * @param value Define the value to give to the uniform
  19963. * @return the material itself allowing "fluent" like uniform updates
  19964. */
  19965. setArray3(name: string, value: number[]): ShaderMaterial;
  19966. /**
  19967. * Set a vec4 array in the shader from a number array.
  19968. * @param name Define the name of the uniform as defined in the shader
  19969. * @param value Define the value to give to the uniform
  19970. * @return the material itself allowing "fluent" like uniform updates
  19971. */
  19972. setArray4(name: string, value: number[]): ShaderMaterial;
  19973. private _checkCache;
  19974. /**
  19975. * Specifies that the submesh is ready to be used
  19976. * @param mesh defines the mesh to check
  19977. * @param subMesh defines which submesh to check
  19978. * @param useInstances specifies that instances should be used
  19979. * @returns a boolean indicating that the submesh is ready or not
  19980. */
  19981. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  19982. /**
  19983. * Checks if the material is ready to render the requested mesh
  19984. * @param mesh Define the mesh to render
  19985. * @param useInstances Define whether or not the material is used with instances
  19986. * @returns true if ready, otherwise false
  19987. */
  19988. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  19989. /**
  19990. * Binds the world matrix to the material
  19991. * @param world defines the world transformation matrix
  19992. */
  19993. bindOnlyWorldMatrix(world: Matrix): void;
  19994. /**
  19995. * Binds the material to the mesh
  19996. * @param world defines the world transformation matrix
  19997. * @param mesh defines the mesh to bind the material to
  19998. */
  19999. bind(world: Matrix, mesh?: Mesh): void;
  20000. /**
  20001. * Gets the active textures from the material
  20002. * @returns an array of textures
  20003. */
  20004. getActiveTextures(): BaseTexture[];
  20005. /**
  20006. * Specifies if the material uses a texture
  20007. * @param texture defines the texture to check against the material
  20008. * @returns a boolean specifying if the material uses the texture
  20009. */
  20010. hasTexture(texture: BaseTexture): boolean;
  20011. /**
  20012. * Makes a duplicate of the material, and gives it a new name
  20013. * @param name defines the new name for the duplicated material
  20014. * @returns the cloned material
  20015. */
  20016. clone(name: string): ShaderMaterial;
  20017. /**
  20018. * Disposes the material
  20019. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  20020. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  20021. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  20022. */
  20023. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  20024. /**
  20025. * Serializes this material in a JSON representation
  20026. * @returns the serialized material object
  20027. */
  20028. serialize(): any;
  20029. /**
  20030. * Creates a shader material from parsed shader material data
  20031. * @param source defines the JSON represnetation of the material
  20032. * @param scene defines the hosting scene
  20033. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  20034. * @returns a new material
  20035. */
  20036. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  20037. }
  20038. }
  20039. declare module "babylonjs/Shaders/color.fragment" {
  20040. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  20041. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  20042. /** @hidden */
  20043. export var colorPixelShader: {
  20044. name: string;
  20045. shader: string;
  20046. };
  20047. }
  20048. declare module "babylonjs/Shaders/color.vertex" {
  20049. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  20050. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  20051. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  20052. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  20053. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  20054. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  20055. /** @hidden */
  20056. export var colorVertexShader: {
  20057. name: string;
  20058. shader: string;
  20059. };
  20060. }
  20061. declare module "babylonjs/Meshes/linesMesh" {
  20062. import { Nullable } from "babylonjs/types";
  20063. import { Scene } from "babylonjs/scene";
  20064. import { Color3 } from "babylonjs/Maths/math.color";
  20065. import { Node } from "babylonjs/node";
  20066. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20067. import { Mesh } from "babylonjs/Meshes/mesh";
  20068. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  20069. import { Effect } from "babylonjs/Materials/effect";
  20070. import { Material } from "babylonjs/Materials/material";
  20071. import "babylonjs/Shaders/color.fragment";
  20072. import "babylonjs/Shaders/color.vertex";
  20073. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20074. /**
  20075. * Line mesh
  20076. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  20077. */
  20078. export class LinesMesh extends Mesh {
  20079. /**
  20080. * If vertex color should be applied to the mesh
  20081. */
  20082. readonly useVertexColor?: boolean | undefined;
  20083. /**
  20084. * If vertex alpha should be applied to the mesh
  20085. */
  20086. readonly useVertexAlpha?: boolean | undefined;
  20087. /**
  20088. * Color of the line (Default: White)
  20089. */
  20090. color: Color3;
  20091. /**
  20092. * Alpha of the line (Default: 1)
  20093. */
  20094. alpha: number;
  20095. /**
  20096. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  20097. * This margin is expressed in world space coordinates, so its value may vary.
  20098. * Default value is 0.1
  20099. */
  20100. intersectionThreshold: number;
  20101. private _colorShader;
  20102. private color4;
  20103. /**
  20104. * Creates a new LinesMesh
  20105. * @param name defines the name
  20106. * @param scene defines the hosting scene
  20107. * @param parent defines the parent mesh if any
  20108. * @param source defines the optional source LinesMesh used to clone data from
  20109. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  20110. * When false, achieved by calling a clone(), also passing False.
  20111. * This will make creation of children, recursive.
  20112. * @param useVertexColor defines if this LinesMesh supports vertex color
  20113. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  20114. */
  20115. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  20116. /**
  20117. * If vertex color should be applied to the mesh
  20118. */
  20119. useVertexColor?: boolean | undefined,
  20120. /**
  20121. * If vertex alpha should be applied to the mesh
  20122. */
  20123. useVertexAlpha?: boolean | undefined);
  20124. private _addClipPlaneDefine;
  20125. private _removeClipPlaneDefine;
  20126. isReady(): boolean;
  20127. /**
  20128. * Returns the string "LineMesh"
  20129. */
  20130. getClassName(): string;
  20131. /**
  20132. * @hidden
  20133. */
  20134. /**
  20135. * @hidden
  20136. */
  20137. material: Material;
  20138. /**
  20139. * @hidden
  20140. */
  20141. readonly checkCollisions: boolean;
  20142. /** @hidden */
  20143. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  20144. /** @hidden */
  20145. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  20146. /**
  20147. * Disposes of the line mesh
  20148. * @param doNotRecurse If children should be disposed
  20149. */
  20150. dispose(doNotRecurse?: boolean): void;
  20151. /**
  20152. * Returns a new LineMesh object cloned from the current one.
  20153. */
  20154. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  20155. /**
  20156. * Creates a new InstancedLinesMesh object from the mesh model.
  20157. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  20158. * @param name defines the name of the new instance
  20159. * @returns a new InstancedLinesMesh
  20160. */
  20161. createInstance(name: string): InstancedLinesMesh;
  20162. }
  20163. /**
  20164. * Creates an instance based on a source LinesMesh
  20165. */
  20166. export class InstancedLinesMesh extends InstancedMesh {
  20167. /**
  20168. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  20169. * This margin is expressed in world space coordinates, so its value may vary.
  20170. * Initilized with the intersectionThreshold value of the source LinesMesh
  20171. */
  20172. intersectionThreshold: number;
  20173. constructor(name: string, source: LinesMesh);
  20174. /**
  20175. * Returns the string "InstancedLinesMesh".
  20176. */
  20177. getClassName(): string;
  20178. }
  20179. }
  20180. declare module "babylonjs/Shaders/line.fragment" {
  20181. /** @hidden */
  20182. export var linePixelShader: {
  20183. name: string;
  20184. shader: string;
  20185. };
  20186. }
  20187. declare module "babylonjs/Shaders/line.vertex" {
  20188. /** @hidden */
  20189. export var lineVertexShader: {
  20190. name: string;
  20191. shader: string;
  20192. };
  20193. }
  20194. declare module "babylonjs/Rendering/edgesRenderer" {
  20195. import { Nullable } from "babylonjs/types";
  20196. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  20197. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20198. import { Vector3 } from "babylonjs/Maths/math.vector";
  20199. import { IDisposable } from "babylonjs/scene";
  20200. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  20201. import "babylonjs/Shaders/line.fragment";
  20202. import "babylonjs/Shaders/line.vertex";
  20203. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  20204. module "babylonjs/Meshes/abstractMesh" {
  20205. interface AbstractMesh {
  20206. /**
  20207. * Gets the edgesRenderer associated with the mesh
  20208. */
  20209. edgesRenderer: Nullable<EdgesRenderer>;
  20210. }
  20211. }
  20212. module "babylonjs/Meshes/linesMesh" {
  20213. interface LinesMesh {
  20214. /**
  20215. * Enables the edge rendering mode on the mesh.
  20216. * This mode makes the mesh edges visible
  20217. * @param epsilon defines the maximal distance between two angles to detect a face
  20218. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  20219. * @returns the currentAbstractMesh
  20220. * @see https://www.babylonjs-playground.com/#19O9TU#0
  20221. */
  20222. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  20223. }
  20224. }
  20225. module "babylonjs/Meshes/linesMesh" {
  20226. interface InstancedLinesMesh {
  20227. /**
  20228. * Enables the edge rendering mode on the mesh.
  20229. * This mode makes the mesh edges visible
  20230. * @param epsilon defines the maximal distance between two angles to detect a face
  20231. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  20232. * @returns the current InstancedLinesMesh
  20233. * @see https://www.babylonjs-playground.com/#19O9TU#0
  20234. */
  20235. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  20236. }
  20237. }
  20238. /**
  20239. * Defines the minimum contract an Edges renderer should follow.
  20240. */
  20241. export interface IEdgesRenderer extends IDisposable {
  20242. /**
  20243. * Gets or sets a boolean indicating if the edgesRenderer is active
  20244. */
  20245. isEnabled: boolean;
  20246. /**
  20247. * Renders the edges of the attached mesh,
  20248. */
  20249. render(): void;
  20250. /**
  20251. * Checks wether or not the edges renderer is ready to render.
  20252. * @return true if ready, otherwise false.
  20253. */
  20254. isReady(): boolean;
  20255. }
  20256. /**
  20257. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  20258. */
  20259. export class EdgesRenderer implements IEdgesRenderer {
  20260. /**
  20261. * Define the size of the edges with an orthographic camera
  20262. */
  20263. edgesWidthScalerForOrthographic: number;
  20264. /**
  20265. * Define the size of the edges with a perspective camera
  20266. */
  20267. edgesWidthScalerForPerspective: number;
  20268. protected _source: AbstractMesh;
  20269. protected _linesPositions: number[];
  20270. protected _linesNormals: number[];
  20271. protected _linesIndices: number[];
  20272. protected _epsilon: number;
  20273. protected _indicesCount: number;
  20274. protected _lineShader: ShaderMaterial;
  20275. protected _ib: DataBuffer;
  20276. protected _buffers: {
  20277. [key: string]: Nullable<VertexBuffer>;
  20278. };
  20279. protected _checkVerticesInsteadOfIndices: boolean;
  20280. private _meshRebuildObserver;
  20281. private _meshDisposeObserver;
  20282. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  20283. isEnabled: boolean;
  20284. /**
  20285. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  20286. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  20287. * @param source Mesh used to create edges
  20288. * @param epsilon sum of angles in adjacency to check for edge
  20289. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  20290. * @param generateEdgesLines - should generate Lines or only prepare resources.
  20291. */
  20292. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  20293. protected _prepareRessources(): void;
  20294. /** @hidden */
  20295. _rebuild(): void;
  20296. /**
  20297. * Releases the required resources for the edges renderer
  20298. */
  20299. dispose(): void;
  20300. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  20301. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  20302. /**
  20303. * Checks if the pair of p0 and p1 is en edge
  20304. * @param faceIndex
  20305. * @param edge
  20306. * @param faceNormals
  20307. * @param p0
  20308. * @param p1
  20309. * @private
  20310. */
  20311. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  20312. /**
  20313. * push line into the position, normal and index buffer
  20314. * @protected
  20315. */
  20316. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  20317. /**
  20318. * Generates lines edges from adjacencjes
  20319. * @private
  20320. */
  20321. _generateEdgesLines(): void;
  20322. /**
  20323. * Checks wether or not the edges renderer is ready to render.
  20324. * @return true if ready, otherwise false.
  20325. */
  20326. isReady(): boolean;
  20327. /**
  20328. * Renders the edges of the attached mesh,
  20329. */
  20330. render(): void;
  20331. }
  20332. /**
  20333. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  20334. */
  20335. export class LineEdgesRenderer extends EdgesRenderer {
  20336. /**
  20337. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  20338. * @param source LineMesh used to generate edges
  20339. * @param epsilon not important (specified angle for edge detection)
  20340. * @param checkVerticesInsteadOfIndices not important for LineMesh
  20341. */
  20342. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  20343. /**
  20344. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  20345. */
  20346. _generateEdgesLines(): void;
  20347. }
  20348. }
  20349. declare module "babylonjs/Rendering/renderingGroup" {
  20350. import { SmartArray } from "babylonjs/Misc/smartArray";
  20351. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20352. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20353. import { Nullable } from "babylonjs/types";
  20354. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  20355. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  20356. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  20357. import { Material } from "babylonjs/Materials/material";
  20358. import { Scene } from "babylonjs/scene";
  20359. /**
  20360. * This represents the object necessary to create a rendering group.
  20361. * This is exclusively used and created by the rendering manager.
  20362. * To modify the behavior, you use the available helpers in your scene or meshes.
  20363. * @hidden
  20364. */
  20365. export class RenderingGroup {
  20366. index: number;
  20367. private static _zeroVector;
  20368. private _scene;
  20369. private _opaqueSubMeshes;
  20370. private _transparentSubMeshes;
  20371. private _alphaTestSubMeshes;
  20372. private _depthOnlySubMeshes;
  20373. private _particleSystems;
  20374. private _spriteManagers;
  20375. private _opaqueSortCompareFn;
  20376. private _alphaTestSortCompareFn;
  20377. private _transparentSortCompareFn;
  20378. private _renderOpaque;
  20379. private _renderAlphaTest;
  20380. private _renderTransparent;
  20381. /** @hidden */
  20382. _edgesRenderers: SmartArray<IEdgesRenderer>;
  20383. onBeforeTransparentRendering: () => void;
  20384. /**
  20385. * Set the opaque sort comparison function.
  20386. * If null the sub meshes will be render in the order they were created
  20387. */
  20388. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  20389. /**
  20390. * Set the alpha test sort comparison function.
  20391. * If null the sub meshes will be render in the order they were created
  20392. */
  20393. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  20394. /**
  20395. * Set the transparent sort comparison function.
  20396. * If null the sub meshes will be render in the order they were created
  20397. */
  20398. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  20399. /**
  20400. * Creates a new rendering group.
  20401. * @param index The rendering group index
  20402. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  20403. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  20404. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  20405. */
  20406. constructor(index: number, scene: Scene, opaqueSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, alphaTestSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, transparentSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>);
  20407. /**
  20408. * Render all the sub meshes contained in the group.
  20409. * @param customRenderFunction Used to override the default render behaviour of the group.
  20410. * @returns true if rendered some submeshes.
  20411. */
  20412. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  20413. /**
  20414. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  20415. * @param subMeshes The submeshes to render
  20416. */
  20417. private renderOpaqueSorted;
  20418. /**
  20419. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  20420. * @param subMeshes The submeshes to render
  20421. */
  20422. private renderAlphaTestSorted;
  20423. /**
  20424. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  20425. * @param subMeshes The submeshes to render
  20426. */
  20427. private renderTransparentSorted;
  20428. /**
  20429. * Renders the submeshes in a specified order.
  20430. * @param subMeshes The submeshes to sort before render
  20431. * @param sortCompareFn The comparison function use to sort
  20432. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  20433. * @param transparent Specifies to activate blending if true
  20434. */
  20435. private static renderSorted;
  20436. /**
  20437. * Renders the submeshes in the order they were dispatched (no sort applied).
  20438. * @param subMeshes The submeshes to render
  20439. */
  20440. private static renderUnsorted;
  20441. /**
  20442. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20443. * are rendered back to front if in the same alpha index.
  20444. *
  20445. * @param a The first submesh
  20446. * @param b The second submesh
  20447. * @returns The result of the comparison
  20448. */
  20449. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  20450. /**
  20451. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20452. * are rendered back to front.
  20453. *
  20454. * @param a The first submesh
  20455. * @param b The second submesh
  20456. * @returns The result of the comparison
  20457. */
  20458. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  20459. /**
  20460. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20461. * are rendered front to back (prevent overdraw).
  20462. *
  20463. * @param a The first submesh
  20464. * @param b The second submesh
  20465. * @returns The result of the comparison
  20466. */
  20467. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  20468. /**
  20469. * Resets the different lists of submeshes to prepare a new frame.
  20470. */
  20471. prepare(): void;
  20472. dispose(): void;
  20473. /**
  20474. * Inserts the submesh in its correct queue depending on its material.
  20475. * @param subMesh The submesh to dispatch
  20476. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  20477. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  20478. */
  20479. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  20480. dispatchSprites(spriteManager: ISpriteManager): void;
  20481. dispatchParticles(particleSystem: IParticleSystem): void;
  20482. private _renderParticles;
  20483. private _renderSprites;
  20484. }
  20485. }
  20486. declare module "babylonjs/Rendering/renderingManager" {
  20487. import { Nullable } from "babylonjs/types";
  20488. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20489. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20490. import { SmartArray } from "babylonjs/Misc/smartArray";
  20491. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  20492. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  20493. import { Material } from "babylonjs/Materials/material";
  20494. import { Scene } from "babylonjs/scene";
  20495. import { Camera } from "babylonjs/Cameras/camera";
  20496. /**
  20497. * Interface describing the different options available in the rendering manager
  20498. * regarding Auto Clear between groups.
  20499. */
  20500. export interface IRenderingManagerAutoClearSetup {
  20501. /**
  20502. * Defines whether or not autoclear is enable.
  20503. */
  20504. autoClear: boolean;
  20505. /**
  20506. * Defines whether or not to autoclear the depth buffer.
  20507. */
  20508. depth: boolean;
  20509. /**
  20510. * Defines whether or not to autoclear the stencil buffer.
  20511. */
  20512. stencil: boolean;
  20513. }
  20514. /**
  20515. * This class is used by the onRenderingGroupObservable
  20516. */
  20517. export class RenderingGroupInfo {
  20518. /**
  20519. * The Scene that being rendered
  20520. */
  20521. scene: Scene;
  20522. /**
  20523. * The camera currently used for the rendering pass
  20524. */
  20525. camera: Nullable<Camera>;
  20526. /**
  20527. * The ID of the renderingGroup being processed
  20528. */
  20529. renderingGroupId: number;
  20530. }
  20531. /**
  20532. * This is the manager responsible of all the rendering for meshes sprites and particles.
  20533. * It is enable to manage the different groups as well as the different necessary sort functions.
  20534. * This should not be used directly aside of the few static configurations
  20535. */
  20536. export class RenderingManager {
  20537. /**
  20538. * The max id used for rendering groups (not included)
  20539. */
  20540. static MAX_RENDERINGGROUPS: number;
  20541. /**
  20542. * The min id used for rendering groups (included)
  20543. */
  20544. static MIN_RENDERINGGROUPS: number;
  20545. /**
  20546. * Used to globally prevent autoclearing scenes.
  20547. */
  20548. static AUTOCLEAR: boolean;
  20549. /**
  20550. * @hidden
  20551. */
  20552. _useSceneAutoClearSetup: boolean;
  20553. private _scene;
  20554. private _renderingGroups;
  20555. private _depthStencilBufferAlreadyCleaned;
  20556. private _autoClearDepthStencil;
  20557. private _customOpaqueSortCompareFn;
  20558. private _customAlphaTestSortCompareFn;
  20559. private _customTransparentSortCompareFn;
  20560. private _renderingGroupInfo;
  20561. /**
  20562. * Instantiates a new rendering group for a particular scene
  20563. * @param scene Defines the scene the groups belongs to
  20564. */
  20565. constructor(scene: Scene);
  20566. private _clearDepthStencilBuffer;
  20567. /**
  20568. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  20569. * @hidden
  20570. */
  20571. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  20572. /**
  20573. * Resets the different information of the group to prepare a new frame
  20574. * @hidden
  20575. */
  20576. reset(): void;
  20577. /**
  20578. * Dispose and release the group and its associated resources.
  20579. * @hidden
  20580. */
  20581. dispose(): void;
  20582. /**
  20583. * Clear the info related to rendering groups preventing retention points during dispose.
  20584. */
  20585. freeRenderingGroups(): void;
  20586. private _prepareRenderingGroup;
  20587. /**
  20588. * Add a sprite manager to the rendering manager in order to render it this frame.
  20589. * @param spriteManager Define the sprite manager to render
  20590. */
  20591. dispatchSprites(spriteManager: ISpriteManager): void;
  20592. /**
  20593. * Add a particle system to the rendering manager in order to render it this frame.
  20594. * @param particleSystem Define the particle system to render
  20595. */
  20596. dispatchParticles(particleSystem: IParticleSystem): void;
  20597. /**
  20598. * Add a submesh to the manager in order to render it this frame
  20599. * @param subMesh The submesh to dispatch
  20600. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  20601. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  20602. */
  20603. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  20604. /**
  20605. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20606. * This allowed control for front to back rendering or reversly depending of the special needs.
  20607. *
  20608. * @param renderingGroupId The rendering group id corresponding to its index
  20609. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20610. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20611. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20612. */
  20613. setRenderingOrder(renderingGroupId: number, opaqueSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, alphaTestSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, transparentSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>): void;
  20614. /**
  20615. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20616. *
  20617. * @param renderingGroupId The rendering group id corresponding to its index
  20618. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20619. * @param depth Automatically clears depth between groups if true and autoClear is true.
  20620. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  20621. */
  20622. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  20623. /**
  20624. * Gets the current auto clear configuration for one rendering group of the rendering
  20625. * manager.
  20626. * @param index the rendering group index to get the information for
  20627. * @returns The auto clear setup for the requested rendering group
  20628. */
  20629. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  20630. }
  20631. }
  20632. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  20633. import { Observable } from "babylonjs/Misc/observable";
  20634. import { SmartArray } from "babylonjs/Misc/smartArray";
  20635. import { Nullable } from "babylonjs/types";
  20636. import { Camera } from "babylonjs/Cameras/camera";
  20637. import { Scene } from "babylonjs/scene";
  20638. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  20639. import { Color4 } from "babylonjs/Maths/math.color";
  20640. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  20641. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20642. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20643. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  20644. import { Texture } from "babylonjs/Materials/Textures/texture";
  20645. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  20646. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  20647. import "babylonjs/Engines/Extensions/engine.renderTarget";
  20648. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  20649. import { Engine } from "babylonjs/Engines/engine";
  20650. /**
  20651. * This Helps creating a texture that will be created from a camera in your scene.
  20652. * It is basically a dynamic texture that could be used to create special effects for instance.
  20653. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  20654. */
  20655. export class RenderTargetTexture extends Texture {
  20656. isCube: boolean;
  20657. /**
  20658. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  20659. */
  20660. static readonly REFRESHRATE_RENDER_ONCE: number;
  20661. /**
  20662. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  20663. */
  20664. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  20665. /**
  20666. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  20667. * the central point of your effect and can save a lot of performances.
  20668. */
  20669. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  20670. /**
  20671. * Use this predicate to dynamically define the list of mesh you want to render.
  20672. * If set, the renderList property will be overwritten.
  20673. */
  20674. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  20675. private _renderList;
  20676. /**
  20677. * Use this list to define the list of mesh you want to render.
  20678. */
  20679. renderList: Nullable<Array<AbstractMesh>>;
  20680. private _hookArray;
  20681. /**
  20682. * Define if particles should be rendered in your texture.
  20683. */
  20684. renderParticles: boolean;
  20685. /**
  20686. * Define if sprites should be rendered in your texture.
  20687. */
  20688. renderSprites: boolean;
  20689. /**
  20690. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  20691. */
  20692. coordinatesMode: number;
  20693. /**
  20694. * Define the camera used to render the texture.
  20695. */
  20696. activeCamera: Nullable<Camera>;
  20697. /**
  20698. * Override the render function of the texture with your own one.
  20699. */
  20700. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  20701. /**
  20702. * Define if camera post processes should be use while rendering the texture.
  20703. */
  20704. useCameraPostProcesses: boolean;
  20705. /**
  20706. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  20707. */
  20708. ignoreCameraViewport: boolean;
  20709. private _postProcessManager;
  20710. private _postProcesses;
  20711. private _resizeObserver;
  20712. /**
  20713. * An event triggered when the texture is unbind.
  20714. */
  20715. onBeforeBindObservable: Observable<RenderTargetTexture>;
  20716. /**
  20717. * An event triggered when the texture is unbind.
  20718. */
  20719. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  20720. private _onAfterUnbindObserver;
  20721. /**
  20722. * Set a after unbind callback in the texture.
  20723. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  20724. */
  20725. onAfterUnbind: () => void;
  20726. /**
  20727. * An event triggered before rendering the texture
  20728. */
  20729. onBeforeRenderObservable: Observable<number>;
  20730. private _onBeforeRenderObserver;
  20731. /**
  20732. * Set a before render callback in the texture.
  20733. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  20734. */
  20735. onBeforeRender: (faceIndex: number) => void;
  20736. /**
  20737. * An event triggered after rendering the texture
  20738. */
  20739. onAfterRenderObservable: Observable<number>;
  20740. private _onAfterRenderObserver;
  20741. /**
  20742. * Set a after render callback in the texture.
  20743. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  20744. */
  20745. onAfterRender: (faceIndex: number) => void;
  20746. /**
  20747. * An event triggered after the texture clear
  20748. */
  20749. onClearObservable: Observable<Engine>;
  20750. private _onClearObserver;
  20751. /**
  20752. * Set a clear callback in the texture.
  20753. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  20754. */
  20755. onClear: (Engine: Engine) => void;
  20756. /**
  20757. * An event triggered when the texture is resized.
  20758. */
  20759. onResizeObservable: Observable<RenderTargetTexture>;
  20760. /**
  20761. * Define the clear color of the Render Target if it should be different from the scene.
  20762. */
  20763. clearColor: Color4;
  20764. protected _size: number | {
  20765. width: number;
  20766. height: number;
  20767. };
  20768. protected _initialSizeParameter: number | {
  20769. width: number;
  20770. height: number;
  20771. } | {
  20772. ratio: number;
  20773. };
  20774. protected _sizeRatio: Nullable<number>;
  20775. /** @hidden */
  20776. _generateMipMaps: boolean;
  20777. protected _renderingManager: RenderingManager;
  20778. /** @hidden */
  20779. _waitingRenderList: string[];
  20780. protected _doNotChangeAspectRatio: boolean;
  20781. protected _currentRefreshId: number;
  20782. protected _refreshRate: number;
  20783. protected _textureMatrix: Matrix;
  20784. protected _samples: number;
  20785. protected _renderTargetOptions: RenderTargetCreationOptions;
  20786. /**
  20787. * Gets render target creation options that were used.
  20788. */
  20789. readonly renderTargetOptions: RenderTargetCreationOptions;
  20790. protected _engine: Engine;
  20791. protected _onRatioRescale(): void;
  20792. /**
  20793. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  20794. * It must define where the camera used to render the texture is set
  20795. */
  20796. boundingBoxPosition: Vector3;
  20797. private _boundingBoxSize;
  20798. /**
  20799. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  20800. * When defined, the cubemap will switch to local mode
  20801. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  20802. * @example https://www.babylonjs-playground.com/#RNASML
  20803. */
  20804. boundingBoxSize: Vector3;
  20805. /**
  20806. * In case the RTT has been created with a depth texture, get the associated
  20807. * depth texture.
  20808. * Otherwise, return null.
  20809. */
  20810. depthStencilTexture: Nullable<InternalTexture>;
  20811. /**
  20812. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  20813. * or used a shadow, depth texture...
  20814. * @param name The friendly name of the texture
  20815. * @param size The size of the RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
  20816. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  20817. * @param generateMipMaps True if mip maps need to be generated after render.
  20818. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  20819. * @param type The type of the buffer in the RTT (int, half float, float...)
  20820. * @param isCube True if a cube texture needs to be created
  20821. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  20822. * @param generateDepthBuffer True to generate a depth buffer
  20823. * @param generateStencilBuffer True to generate a stencil buffer
  20824. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  20825. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  20826. * @param delayAllocation if the texture allocation should be delayed (default: false)
  20827. */
  20828. constructor(name: string, size: number | {
  20829. width: number;
  20830. height: number;
  20831. } | {
  20832. ratio: number;
  20833. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  20834. /**
  20835. * Creates a depth stencil texture.
  20836. * This is only available in WebGL 2 or with the depth texture extension available.
  20837. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  20838. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  20839. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  20840. */
  20841. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  20842. private _processSizeParameter;
  20843. /**
  20844. * Define the number of samples to use in case of MSAA.
  20845. * It defaults to one meaning no MSAA has been enabled.
  20846. */
  20847. samples: number;
  20848. /**
  20849. * Resets the refresh counter of the texture and start bak from scratch.
  20850. * Could be useful to regenerate the texture if it is setup to render only once.
  20851. */
  20852. resetRefreshCounter(): void;
  20853. /**
  20854. * Define the refresh rate of the texture or the rendering frequency.
  20855. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  20856. */
  20857. refreshRate: number;
  20858. /**
  20859. * Adds a post process to the render target rendering passes.
  20860. * @param postProcess define the post process to add
  20861. */
  20862. addPostProcess(postProcess: PostProcess): void;
  20863. /**
  20864. * Clear all the post processes attached to the render target
  20865. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  20866. */
  20867. clearPostProcesses(dispose?: boolean): void;
  20868. /**
  20869. * Remove one of the post process from the list of attached post processes to the texture
  20870. * @param postProcess define the post process to remove from the list
  20871. */
  20872. removePostProcess(postProcess: PostProcess): void;
  20873. /** @hidden */
  20874. _shouldRender(): boolean;
  20875. /**
  20876. * Gets the actual render size of the texture.
  20877. * @returns the width of the render size
  20878. */
  20879. getRenderSize(): number;
  20880. /**
  20881. * Gets the actual render width of the texture.
  20882. * @returns the width of the render size
  20883. */
  20884. getRenderWidth(): number;
  20885. /**
  20886. * Gets the actual render height of the texture.
  20887. * @returns the height of the render size
  20888. */
  20889. getRenderHeight(): number;
  20890. /**
  20891. * Get if the texture can be rescaled or not.
  20892. */
  20893. readonly canRescale: boolean;
  20894. /**
  20895. * Resize the texture using a ratio.
  20896. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  20897. */
  20898. scale(ratio: number): void;
  20899. /**
  20900. * Get the texture reflection matrix used to rotate/transform the reflection.
  20901. * @returns the reflection matrix
  20902. */
  20903. getReflectionTextureMatrix(): Matrix;
  20904. /**
  20905. * Resize the texture to a new desired size.
  20906. * Be carrefull as it will recreate all the data in the new texture.
  20907. * @param size Define the new size. It can be:
  20908. * - a number for squared texture,
  20909. * - an object containing { width: number, height: number }
  20910. * - or an object containing a ratio { ratio: number }
  20911. */
  20912. resize(size: number | {
  20913. width: number;
  20914. height: number;
  20915. } | {
  20916. ratio: number;
  20917. }): void;
  20918. /**
  20919. * Renders all the objects from the render list into the texture.
  20920. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  20921. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  20922. */
  20923. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  20924. private _bestReflectionRenderTargetDimension;
  20925. /**
  20926. * @hidden
  20927. * @param faceIndex face index to bind to if this is a cubetexture
  20928. */
  20929. _bindFrameBuffer(faceIndex?: number): void;
  20930. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  20931. private renderToTarget;
  20932. /**
  20933. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20934. * This allowed control for front to back rendering or reversly depending of the special needs.
  20935. *
  20936. * @param renderingGroupId The rendering group id corresponding to its index
  20937. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20938. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20939. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20940. */
  20941. setRenderingOrder(renderingGroupId: number, opaqueSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, alphaTestSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, transparentSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>): void;
  20942. /**
  20943. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20944. *
  20945. * @param renderingGroupId The rendering group id corresponding to its index
  20946. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20947. */
  20948. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  20949. /**
  20950. * Clones the texture.
  20951. * @returns the cloned texture
  20952. */
  20953. clone(): RenderTargetTexture;
  20954. /**
  20955. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  20956. * @returns The JSON representation of the texture
  20957. */
  20958. serialize(): any;
  20959. /**
  20960. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  20961. */
  20962. disposeFramebufferObjects(): void;
  20963. /**
  20964. * Dispose the texture and release its associated resources.
  20965. */
  20966. dispose(): void;
  20967. /** @hidden */
  20968. _rebuild(): void;
  20969. /**
  20970. * Clear the info related to rendering groups preventing retention point in material dispose.
  20971. */
  20972. freeRenderingGroups(): void;
  20973. /**
  20974. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  20975. * @returns the view count
  20976. */
  20977. getViewCount(): number;
  20978. }
  20979. }
  20980. declare module "babylonjs/Materials/material" {
  20981. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  20982. import { SmartArray } from "babylonjs/Misc/smartArray";
  20983. import { Observable } from "babylonjs/Misc/observable";
  20984. import { Nullable } from "babylonjs/types";
  20985. import { Scene } from "babylonjs/scene";
  20986. import { Matrix } from "babylonjs/Maths/math.vector";
  20987. import { BaseSubMesh, SubMesh } from "babylonjs/Meshes/subMesh";
  20988. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20989. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  20990. import { Effect } from "babylonjs/Materials/effect";
  20991. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  20992. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  20993. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  20994. import { IInspectable } from "babylonjs/Misc/iInspectable";
  20995. import { Mesh } from "babylonjs/Meshes/mesh";
  20996. import { Animation } from "babylonjs/Animations/animation";
  20997. /**
  20998. * Options for compiling materials.
  20999. */
  21000. export interface IMaterialCompilationOptions {
  21001. /**
  21002. * Defines whether clip planes are enabled.
  21003. */
  21004. clipPlane: boolean;
  21005. /**
  21006. * Defines whether instances are enabled.
  21007. */
  21008. useInstances: boolean;
  21009. }
  21010. /**
  21011. * Base class for the main features of a material in Babylon.js
  21012. */
  21013. export class Material implements IAnimatable {
  21014. /**
  21015. * Returns the triangle fill mode
  21016. */
  21017. static readonly TriangleFillMode: number;
  21018. /**
  21019. * Returns the wireframe mode
  21020. */
  21021. static readonly WireFrameFillMode: number;
  21022. /**
  21023. * Returns the point fill mode
  21024. */
  21025. static readonly PointFillMode: number;
  21026. /**
  21027. * Returns the point list draw mode
  21028. */
  21029. static readonly PointListDrawMode: number;
  21030. /**
  21031. * Returns the line list draw mode
  21032. */
  21033. static readonly LineListDrawMode: number;
  21034. /**
  21035. * Returns the line loop draw mode
  21036. */
  21037. static readonly LineLoopDrawMode: number;
  21038. /**
  21039. * Returns the line strip draw mode
  21040. */
  21041. static readonly LineStripDrawMode: number;
  21042. /**
  21043. * Returns the triangle strip draw mode
  21044. */
  21045. static readonly TriangleStripDrawMode: number;
  21046. /**
  21047. * Returns the triangle fan draw mode
  21048. */
  21049. static readonly TriangleFanDrawMode: number;
  21050. /**
  21051. * Stores the clock-wise side orientation
  21052. */
  21053. static readonly ClockWiseSideOrientation: number;
  21054. /**
  21055. * Stores the counter clock-wise side orientation
  21056. */
  21057. static readonly CounterClockWiseSideOrientation: number;
  21058. /**
  21059. * The dirty texture flag value
  21060. */
  21061. static readonly TextureDirtyFlag: number;
  21062. /**
  21063. * The dirty light flag value
  21064. */
  21065. static readonly LightDirtyFlag: number;
  21066. /**
  21067. * The dirty fresnel flag value
  21068. */
  21069. static readonly FresnelDirtyFlag: number;
  21070. /**
  21071. * The dirty attribute flag value
  21072. */
  21073. static readonly AttributesDirtyFlag: number;
  21074. /**
  21075. * The dirty misc flag value
  21076. */
  21077. static readonly MiscDirtyFlag: number;
  21078. /**
  21079. * The all dirty flag value
  21080. */
  21081. static readonly AllDirtyFlag: number;
  21082. /**
  21083. * The ID of the material
  21084. */
  21085. id: string;
  21086. /**
  21087. * Gets or sets the unique id of the material
  21088. */
  21089. uniqueId: number;
  21090. /**
  21091. * The name of the material
  21092. */
  21093. name: string;
  21094. /**
  21095. * Gets or sets user defined metadata
  21096. */
  21097. metadata: any;
  21098. /**
  21099. * For internal use only. Please do not use.
  21100. */
  21101. reservedDataStore: any;
  21102. /**
  21103. * Specifies if the ready state should be checked on each call
  21104. */
  21105. checkReadyOnEveryCall: boolean;
  21106. /**
  21107. * Specifies if the ready state should be checked once
  21108. */
  21109. checkReadyOnlyOnce: boolean;
  21110. /**
  21111. * The state of the material
  21112. */
  21113. state: string;
  21114. /**
  21115. * The alpha value of the material
  21116. */
  21117. protected _alpha: number;
  21118. /**
  21119. * List of inspectable custom properties (used by the Inspector)
  21120. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  21121. */
  21122. inspectableCustomProperties: IInspectable[];
  21123. /**
  21124. * Sets the alpha value of the material
  21125. */
  21126. /**
  21127. * Gets the alpha value of the material
  21128. */
  21129. alpha: number;
  21130. /**
  21131. * Specifies if back face culling is enabled
  21132. */
  21133. protected _backFaceCulling: boolean;
  21134. /**
  21135. * Sets the back-face culling state
  21136. */
  21137. /**
  21138. * Gets the back-face culling state
  21139. */
  21140. backFaceCulling: boolean;
  21141. /**
  21142. * Stores the value for side orientation
  21143. */
  21144. sideOrientation: number;
  21145. /**
  21146. * Callback triggered when the material is compiled
  21147. */
  21148. onCompiled: Nullable<(effect: Effect) => void>;
  21149. /**
  21150. * Callback triggered when an error occurs
  21151. */
  21152. onError: Nullable<(effect: Effect, errors: string) => void>;
  21153. /**
  21154. * Callback triggered to get the render target textures
  21155. */
  21156. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  21157. /**
  21158. * Gets a boolean indicating that current material needs to register RTT
  21159. */
  21160. readonly hasRenderTargetTextures: boolean;
  21161. /**
  21162. * Specifies if the material should be serialized
  21163. */
  21164. doNotSerialize: boolean;
  21165. /**
  21166. * @hidden
  21167. */
  21168. _storeEffectOnSubMeshes: boolean;
  21169. /**
  21170. * Stores the animations for the material
  21171. */
  21172. animations: Nullable<Array<Animation>>;
  21173. /**
  21174. * An event triggered when the material is disposed
  21175. */
  21176. onDisposeObservable: Observable<Material>;
  21177. /**
  21178. * An observer which watches for dispose events
  21179. */
  21180. private _onDisposeObserver;
  21181. private _onUnBindObservable;
  21182. /**
  21183. * Called during a dispose event
  21184. */
  21185. onDispose: () => void;
  21186. private _onBindObservable;
  21187. /**
  21188. * An event triggered when the material is bound
  21189. */
  21190. readonly onBindObservable: Observable<AbstractMesh>;
  21191. /**
  21192. * An observer which watches for bind events
  21193. */
  21194. private _onBindObserver;
  21195. /**
  21196. * Called during a bind event
  21197. */
  21198. onBind: (Mesh: AbstractMesh) => void;
  21199. /**
  21200. * An event triggered when the material is unbound
  21201. */
  21202. readonly onUnBindObservable: Observable<Material>;
  21203. /**
  21204. * Stores the value of the alpha mode
  21205. */
  21206. private _alphaMode;
  21207. /**
  21208. * Sets the value of the alpha mode.
  21209. *
  21210. * | Value | Type | Description |
  21211. * | --- | --- | --- |
  21212. * | 0 | ALPHA_DISABLE | |
  21213. * | 1 | ALPHA_ADD | |
  21214. * | 2 | ALPHA_COMBINE | |
  21215. * | 3 | ALPHA_SUBTRACT | |
  21216. * | 4 | ALPHA_MULTIPLY | |
  21217. * | 5 | ALPHA_MAXIMIZED | |
  21218. * | 6 | ALPHA_ONEONE | |
  21219. * | 7 | ALPHA_PREMULTIPLIED | |
  21220. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  21221. * | 9 | ALPHA_INTERPOLATE | |
  21222. * | 10 | ALPHA_SCREENMODE | |
  21223. *
  21224. */
  21225. /**
  21226. * Gets the value of the alpha mode
  21227. */
  21228. alphaMode: number;
  21229. /**
  21230. * Stores the state of the need depth pre-pass value
  21231. */
  21232. private _needDepthPrePass;
  21233. /**
  21234. * Sets the need depth pre-pass value
  21235. */
  21236. /**
  21237. * Gets the depth pre-pass value
  21238. */
  21239. needDepthPrePass: boolean;
  21240. /**
  21241. * Specifies if depth writing should be disabled
  21242. */
  21243. disableDepthWrite: boolean;
  21244. /**
  21245. * Specifies if depth writing should be forced
  21246. */
  21247. forceDepthWrite: boolean;
  21248. /**
  21249. * Specifies the depth function that should be used. 0 means the default engine function
  21250. */
  21251. depthFunction: number;
  21252. /**
  21253. * Specifies if there should be a separate pass for culling
  21254. */
  21255. separateCullingPass: boolean;
  21256. /**
  21257. * Stores the state specifing if fog should be enabled
  21258. */
  21259. private _fogEnabled;
  21260. /**
  21261. * Sets the state for enabling fog
  21262. */
  21263. /**
  21264. * Gets the value of the fog enabled state
  21265. */
  21266. fogEnabled: boolean;
  21267. /**
  21268. * Stores the size of points
  21269. */
  21270. pointSize: number;
  21271. /**
  21272. * Stores the z offset value
  21273. */
  21274. zOffset: number;
  21275. /**
  21276. * Gets a value specifying if wireframe mode is enabled
  21277. */
  21278. /**
  21279. * Sets the state of wireframe mode
  21280. */
  21281. wireframe: boolean;
  21282. /**
  21283. * Gets the value specifying if point clouds are enabled
  21284. */
  21285. /**
  21286. * Sets the state of point cloud mode
  21287. */
  21288. pointsCloud: boolean;
  21289. /**
  21290. * Gets the material fill mode
  21291. */
  21292. /**
  21293. * Sets the material fill mode
  21294. */
  21295. fillMode: number;
  21296. /**
  21297. * @hidden
  21298. * Stores the effects for the material
  21299. */
  21300. _effect: Nullable<Effect>;
  21301. /**
  21302. * @hidden
  21303. * Specifies if the material was previously ready
  21304. */
  21305. _wasPreviouslyReady: boolean;
  21306. /**
  21307. * Specifies if uniform buffers should be used
  21308. */
  21309. private _useUBO;
  21310. /**
  21311. * Stores a reference to the scene
  21312. */
  21313. private _scene;
  21314. /**
  21315. * Stores the fill mode state
  21316. */
  21317. private _fillMode;
  21318. /**
  21319. * Specifies if the depth write state should be cached
  21320. */
  21321. private _cachedDepthWriteState;
  21322. /**
  21323. * Specifies if the depth function state should be cached
  21324. */
  21325. private _cachedDepthFunctionState;
  21326. /**
  21327. * Stores the uniform buffer
  21328. */
  21329. protected _uniformBuffer: UniformBuffer;
  21330. /** @hidden */
  21331. _indexInSceneMaterialArray: number;
  21332. /** @hidden */
  21333. meshMap: Nullable<{
  21334. [id: string]: AbstractMesh | undefined;
  21335. }>;
  21336. /**
  21337. * Creates a material instance
  21338. * @param name defines the name of the material
  21339. * @param scene defines the scene to reference
  21340. * @param doNotAdd specifies if the material should be added to the scene
  21341. */
  21342. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  21343. /**
  21344. * Returns a string representation of the current material
  21345. * @param fullDetails defines a boolean indicating which levels of logging is desired
  21346. * @returns a string with material information
  21347. */
  21348. toString(fullDetails?: boolean): string;
  21349. /**
  21350. * Gets the class name of the material
  21351. * @returns a string with the class name of the material
  21352. */
  21353. getClassName(): string;
  21354. /**
  21355. * Specifies if updates for the material been locked
  21356. */
  21357. readonly isFrozen: boolean;
  21358. /**
  21359. * Locks updates for the material
  21360. */
  21361. freeze(): void;
  21362. /**
  21363. * Unlocks updates for the material
  21364. */
  21365. unfreeze(): void;
  21366. /**
  21367. * Specifies if the material is ready to be used
  21368. * @param mesh defines the mesh to check
  21369. * @param useInstances specifies if instances should be used
  21370. * @returns a boolean indicating if the material is ready to be used
  21371. */
  21372. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  21373. /**
  21374. * Specifies that the submesh is ready to be used
  21375. * @param mesh defines the mesh to check
  21376. * @param subMesh defines which submesh to check
  21377. * @param useInstances specifies that instances should be used
  21378. * @returns a boolean indicating that the submesh is ready or not
  21379. */
  21380. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21381. /**
  21382. * Returns the material effect
  21383. * @returns the effect associated with the material
  21384. */
  21385. getEffect(): Nullable<Effect>;
  21386. /**
  21387. * Returns the current scene
  21388. * @returns a Scene
  21389. */
  21390. getScene(): Scene;
  21391. /**
  21392. * Specifies if the material will require alpha blending
  21393. * @returns a boolean specifying if alpha blending is needed
  21394. */
  21395. needAlphaBlending(): boolean;
  21396. /**
  21397. * Specifies if the mesh will require alpha blending
  21398. * @param mesh defines the mesh to check
  21399. * @returns a boolean specifying if alpha blending is needed for the mesh
  21400. */
  21401. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  21402. /**
  21403. * Specifies if this material should be rendered in alpha test mode
  21404. * @returns a boolean specifying if an alpha test is needed.
  21405. */
  21406. needAlphaTesting(): boolean;
  21407. /**
  21408. * Gets the texture used for the alpha test
  21409. * @returns the texture to use for alpha testing
  21410. */
  21411. getAlphaTestTexture(): Nullable<BaseTexture>;
  21412. /**
  21413. * Marks the material to indicate that it needs to be re-calculated
  21414. */
  21415. markDirty(): void;
  21416. /** @hidden */
  21417. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  21418. /**
  21419. * Binds the material to the mesh
  21420. * @param world defines the world transformation matrix
  21421. * @param mesh defines the mesh to bind the material to
  21422. */
  21423. bind(world: Matrix, mesh?: Mesh): void;
  21424. /**
  21425. * Binds the submesh to the material
  21426. * @param world defines the world transformation matrix
  21427. * @param mesh defines the mesh containing the submesh
  21428. * @param subMesh defines the submesh to bind the material to
  21429. */
  21430. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  21431. /**
  21432. * Binds the world matrix to the material
  21433. * @param world defines the world transformation matrix
  21434. */
  21435. bindOnlyWorldMatrix(world: Matrix): void;
  21436. /**
  21437. * Binds the scene's uniform buffer to the effect.
  21438. * @param effect defines the effect to bind to the scene uniform buffer
  21439. * @param sceneUbo defines the uniform buffer storing scene data
  21440. */
  21441. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  21442. /**
  21443. * Binds the view matrix to the effect
  21444. * @param effect defines the effect to bind the view matrix to
  21445. */
  21446. bindView(effect: Effect): void;
  21447. /**
  21448. * Binds the view projection matrix to the effect
  21449. * @param effect defines the effect to bind the view projection matrix to
  21450. */
  21451. bindViewProjection(effect: Effect): void;
  21452. /**
  21453. * Specifies if material alpha testing should be turned on for the mesh
  21454. * @param mesh defines the mesh to check
  21455. */
  21456. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  21457. /**
  21458. * Processes to execute after binding the material to a mesh
  21459. * @param mesh defines the rendered mesh
  21460. */
  21461. protected _afterBind(mesh?: Mesh): void;
  21462. /**
  21463. * Unbinds the material from the mesh
  21464. */
  21465. unbind(): void;
  21466. /**
  21467. * Gets the active textures from the material
  21468. * @returns an array of textures
  21469. */
  21470. getActiveTextures(): BaseTexture[];
  21471. /**
  21472. * Specifies if the material uses a texture
  21473. * @param texture defines the texture to check against the material
  21474. * @returns a boolean specifying if the material uses the texture
  21475. */
  21476. hasTexture(texture: BaseTexture): boolean;
  21477. /**
  21478. * Makes a duplicate of the material, and gives it a new name
  21479. * @param name defines the new name for the duplicated material
  21480. * @returns the cloned material
  21481. */
  21482. clone(name: string): Nullable<Material>;
  21483. /**
  21484. * Gets the meshes bound to the material
  21485. * @returns an array of meshes bound to the material
  21486. */
  21487. getBindedMeshes(): AbstractMesh[];
  21488. /**
  21489. * Force shader compilation
  21490. * @param mesh defines the mesh associated with this material
  21491. * @param onCompiled defines a function to execute once the material is compiled
  21492. * @param options defines the options to configure the compilation
  21493. * @param onError defines a function to execute if the material fails compiling
  21494. */
  21495. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  21496. /**
  21497. * Force shader compilation
  21498. * @param mesh defines the mesh that will use this material
  21499. * @param options defines additional options for compiling the shaders
  21500. * @returns a promise that resolves when the compilation completes
  21501. */
  21502. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  21503. private static readonly _AllDirtyCallBack;
  21504. private static readonly _ImageProcessingDirtyCallBack;
  21505. private static readonly _TextureDirtyCallBack;
  21506. private static readonly _FresnelDirtyCallBack;
  21507. private static readonly _MiscDirtyCallBack;
  21508. private static readonly _LightsDirtyCallBack;
  21509. private static readonly _AttributeDirtyCallBack;
  21510. private static _FresnelAndMiscDirtyCallBack;
  21511. private static _TextureAndMiscDirtyCallBack;
  21512. private static readonly _DirtyCallbackArray;
  21513. private static readonly _RunDirtyCallBacks;
  21514. /**
  21515. * Marks a define in the material to indicate that it needs to be re-computed
  21516. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  21517. */
  21518. markAsDirty(flag: number): void;
  21519. /**
  21520. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  21521. * @param func defines a function which checks material defines against the submeshes
  21522. */
  21523. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  21524. /**
  21525. * Indicates that we need to re-calculated for all submeshes
  21526. */
  21527. protected _markAllSubMeshesAsAllDirty(): void;
  21528. /**
  21529. * Indicates that image processing needs to be re-calculated for all submeshes
  21530. */
  21531. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  21532. /**
  21533. * Indicates that textures need to be re-calculated for all submeshes
  21534. */
  21535. protected _markAllSubMeshesAsTexturesDirty(): void;
  21536. /**
  21537. * Indicates that fresnel needs to be re-calculated for all submeshes
  21538. */
  21539. protected _markAllSubMeshesAsFresnelDirty(): void;
  21540. /**
  21541. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  21542. */
  21543. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  21544. /**
  21545. * Indicates that lights need to be re-calculated for all submeshes
  21546. */
  21547. protected _markAllSubMeshesAsLightsDirty(): void;
  21548. /**
  21549. * Indicates that attributes need to be re-calculated for all submeshes
  21550. */
  21551. protected _markAllSubMeshesAsAttributesDirty(): void;
  21552. /**
  21553. * Indicates that misc needs to be re-calculated for all submeshes
  21554. */
  21555. protected _markAllSubMeshesAsMiscDirty(): void;
  21556. /**
  21557. * Indicates that textures and misc need to be re-calculated for all submeshes
  21558. */
  21559. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  21560. /**
  21561. * Disposes the material
  21562. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  21563. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  21564. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  21565. */
  21566. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  21567. /** @hidden */
  21568. private releaseVertexArrayObject;
  21569. /**
  21570. * Serializes this material
  21571. * @returns the serialized material object
  21572. */
  21573. serialize(): any;
  21574. /**
  21575. * Creates a material from parsed material data
  21576. * @param parsedMaterial defines parsed material data
  21577. * @param scene defines the hosting scene
  21578. * @param rootUrl defines the root URL to use to load textures
  21579. * @returns a new material
  21580. */
  21581. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  21582. }
  21583. }
  21584. declare module "babylonjs/Materials/multiMaterial" {
  21585. import { Nullable } from "babylonjs/types";
  21586. import { Scene } from "babylonjs/scene";
  21587. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21588. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  21589. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21590. import { Material } from "babylonjs/Materials/material";
  21591. /**
  21592. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21593. * separate meshes. This can be use to improve performances.
  21594. * @see http://doc.babylonjs.com/how_to/multi_materials
  21595. */
  21596. export class MultiMaterial extends Material {
  21597. private _subMaterials;
  21598. /**
  21599. * Gets or Sets the list of Materials used within the multi material.
  21600. * They need to be ordered according to the submeshes order in the associated mesh
  21601. */
  21602. subMaterials: Nullable<Material>[];
  21603. /**
  21604. * Function used to align with Node.getChildren()
  21605. * @returns the list of Materials used within the multi material
  21606. */
  21607. getChildren(): Nullable<Material>[];
  21608. /**
  21609. * Instantiates a new Multi Material
  21610. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21611. * separate meshes. This can be use to improve performances.
  21612. * @see http://doc.babylonjs.com/how_to/multi_materials
  21613. * @param name Define the name in the scene
  21614. * @param scene Define the scene the material belongs to
  21615. */
  21616. constructor(name: string, scene: Scene);
  21617. private _hookArray;
  21618. /**
  21619. * Get one of the submaterial by its index in the submaterials array
  21620. * @param index The index to look the sub material at
  21621. * @returns The Material if the index has been defined
  21622. */
  21623. getSubMaterial(index: number): Nullable<Material>;
  21624. /**
  21625. * Get the list of active textures for the whole sub materials list.
  21626. * @returns All the textures that will be used during the rendering
  21627. */
  21628. getActiveTextures(): BaseTexture[];
  21629. /**
  21630. * Gets the current class name of the material e.g. "MultiMaterial"
  21631. * Mainly use in serialization.
  21632. * @returns the class name
  21633. */
  21634. getClassName(): string;
  21635. /**
  21636. * Checks if the material is ready to render the requested sub mesh
  21637. * @param mesh Define the mesh the submesh belongs to
  21638. * @param subMesh Define the sub mesh to look readyness for
  21639. * @param useInstances Define whether or not the material is used with instances
  21640. * @returns true if ready, otherwise false
  21641. */
  21642. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21643. /**
  21644. * Clones the current material and its related sub materials
  21645. * @param name Define the name of the newly cloned material
  21646. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  21647. * @returns the cloned material
  21648. */
  21649. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  21650. /**
  21651. * Serializes the materials into a JSON representation.
  21652. * @returns the JSON representation
  21653. */
  21654. serialize(): any;
  21655. /**
  21656. * Dispose the material and release its associated resources
  21657. * @param forceDisposeEffect Define if we want to force disposing the associated effect (if false the shader is not released and could be reuse later on)
  21658. * @param forceDisposeTextures Define if we want to force disposing the associated textures (if false, they will not be disposed and can still be use elsewhere in the app)
  21659. * @param forceDisposeChildren Define if we want to force disposing the associated submaterials (if false, they will not be disposed and can still be use elsewhere in the app)
  21660. */
  21661. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  21662. /**
  21663. * Creates a MultiMaterial from parsed MultiMaterial data.
  21664. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  21665. * @param scene defines the hosting scene
  21666. * @returns a new MultiMaterial
  21667. */
  21668. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  21669. }
  21670. }
  21671. declare module "babylonjs/Meshes/subMesh" {
  21672. import { Nullable, IndicesArray, DeepImmutable, FloatArray } from "babylonjs/types";
  21673. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  21674. import { Engine } from "babylonjs/Engines/engine";
  21675. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  21676. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  21677. import { Effect } from "babylonjs/Materials/effect";
  21678. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  21679. import { Plane } from "babylonjs/Maths/math.plane";
  21680. import { Collider } from "babylonjs/Collisions/collider";
  21681. import { Material } from "babylonjs/Materials/material";
  21682. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  21683. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21684. import { Mesh } from "babylonjs/Meshes/mesh";
  21685. import { Ray } from "babylonjs/Culling/ray";
  21686. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  21687. /**
  21688. * Base class for submeshes
  21689. */
  21690. export class BaseSubMesh {
  21691. /** @hidden */
  21692. _materialDefines: Nullable<MaterialDefines>;
  21693. /** @hidden */
  21694. _materialEffect: Nullable<Effect>;
  21695. /**
  21696. * Gets associated effect
  21697. */
  21698. readonly effect: Nullable<Effect>;
  21699. /**
  21700. * Sets associated effect (effect used to render this submesh)
  21701. * @param effect defines the effect to associate with
  21702. * @param defines defines the set of defines used to compile this effect
  21703. */
  21704. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  21705. }
  21706. /**
  21707. * Defines a subdivision inside a mesh
  21708. */
  21709. export class SubMesh extends BaseSubMesh implements ICullable {
  21710. /** the material index to use */
  21711. materialIndex: number;
  21712. /** vertex index start */
  21713. verticesStart: number;
  21714. /** vertices count */
  21715. verticesCount: number;
  21716. /** index start */
  21717. indexStart: number;
  21718. /** indices count */
  21719. indexCount: number;
  21720. /** @hidden */
  21721. _linesIndexCount: number;
  21722. private _mesh;
  21723. private _renderingMesh;
  21724. private _boundingInfo;
  21725. private _linesIndexBuffer;
  21726. /** @hidden */
  21727. _lastColliderWorldVertices: Nullable<Vector3[]>;
  21728. /** @hidden */
  21729. _trianglePlanes: Plane[];
  21730. /** @hidden */
  21731. _lastColliderTransformMatrix: Nullable<Matrix>;
  21732. /** @hidden */
  21733. _renderId: number;
  21734. /** @hidden */
  21735. _alphaIndex: number;
  21736. /** @hidden */
  21737. _distanceToCamera: number;
  21738. /** @hidden */
  21739. _id: number;
  21740. private _currentMaterial;
  21741. /**
  21742. * Add a new submesh to a mesh
  21743. * @param materialIndex defines the material index to use
  21744. * @param verticesStart defines vertex index start
  21745. * @param verticesCount defines vertices count
  21746. * @param indexStart defines index start
  21747. * @param indexCount defines indices count
  21748. * @param mesh defines the parent mesh
  21749. * @param renderingMesh defines an optional rendering mesh
  21750. * @param createBoundingBox defines if bounding box should be created for this submesh
  21751. * @returns the new submesh
  21752. */
  21753. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  21754. /**
  21755. * Creates a new submesh
  21756. * @param materialIndex defines the material index to use
  21757. * @param verticesStart defines vertex index start
  21758. * @param verticesCount defines vertices count
  21759. * @param indexStart defines index start
  21760. * @param indexCount defines indices count
  21761. * @param mesh defines the parent mesh
  21762. * @param renderingMesh defines an optional rendering mesh
  21763. * @param createBoundingBox defines if bounding box should be created for this submesh
  21764. */
  21765. constructor(
  21766. /** the material index to use */
  21767. materialIndex: number,
  21768. /** vertex index start */
  21769. verticesStart: number,
  21770. /** vertices count */
  21771. verticesCount: number,
  21772. /** index start */
  21773. indexStart: number,
  21774. /** indices count */
  21775. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  21776. /**
  21777. * Returns true if this submesh covers the entire parent mesh
  21778. * @ignorenaming
  21779. */
  21780. readonly IsGlobal: boolean;
  21781. /**
  21782. * Returns the submesh BoudingInfo object
  21783. * @returns current bounding info (or mesh's one if the submesh is global)
  21784. */
  21785. getBoundingInfo(): BoundingInfo;
  21786. /**
  21787. * Sets the submesh BoundingInfo
  21788. * @param boundingInfo defines the new bounding info to use
  21789. * @returns the SubMesh
  21790. */
  21791. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  21792. /**
  21793. * Returns the mesh of the current submesh
  21794. * @return the parent mesh
  21795. */
  21796. getMesh(): AbstractMesh;
  21797. /**
  21798. * Returns the rendering mesh of the submesh
  21799. * @returns the rendering mesh (could be different from parent mesh)
  21800. */
  21801. getRenderingMesh(): Mesh;
  21802. /**
  21803. * Returns the submesh material
  21804. * @returns null or the current material
  21805. */
  21806. getMaterial(): Nullable<Material>;
  21807. /**
  21808. * Sets a new updated BoundingInfo object to the submesh
  21809. * @param data defines an optional position array to use to determine the bounding info
  21810. * @returns the SubMesh
  21811. */
  21812. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  21813. /** @hidden */
  21814. _checkCollision(collider: Collider): boolean;
  21815. /**
  21816. * Updates the submesh BoundingInfo
  21817. * @param world defines the world matrix to use to update the bounding info
  21818. * @returns the submesh
  21819. */
  21820. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  21821. /**
  21822. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  21823. * @param frustumPlanes defines the frustum planes
  21824. * @returns true if the submesh is intersecting with the frustum
  21825. */
  21826. isInFrustum(frustumPlanes: Plane[]): boolean;
  21827. /**
  21828. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  21829. * @param frustumPlanes defines the frustum planes
  21830. * @returns true if the submesh is inside the frustum
  21831. */
  21832. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  21833. /**
  21834. * Renders the submesh
  21835. * @param enableAlphaMode defines if alpha needs to be used
  21836. * @returns the submesh
  21837. */
  21838. render(enableAlphaMode: boolean): SubMesh;
  21839. /**
  21840. * @hidden
  21841. */
  21842. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  21843. /**
  21844. * Checks if the submesh intersects with a ray
  21845. * @param ray defines the ray to test
  21846. * @returns true is the passed ray intersects the submesh bounding box
  21847. */
  21848. canIntersects(ray: Ray): boolean;
  21849. /**
  21850. * Intersects current submesh with a ray
  21851. * @param ray defines the ray to test
  21852. * @param positions defines mesh's positions array
  21853. * @param indices defines mesh's indices array
  21854. * @param fastCheck defines if only bounding info should be used
  21855. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  21856. * @returns intersection info or null if no intersection
  21857. */
  21858. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  21859. /** @hidden */
  21860. private _intersectLines;
  21861. /** @hidden */
  21862. private _intersectUnIndexedLines;
  21863. /** @hidden */
  21864. private _intersectTriangles;
  21865. /** @hidden */
  21866. private _intersectUnIndexedTriangles;
  21867. /** @hidden */
  21868. _rebuild(): void;
  21869. /**
  21870. * Creates a new submesh from the passed mesh
  21871. * @param newMesh defines the new hosting mesh
  21872. * @param newRenderingMesh defines an optional rendering mesh
  21873. * @returns the new submesh
  21874. */
  21875. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  21876. /**
  21877. * Release associated resources
  21878. */
  21879. dispose(): void;
  21880. /**
  21881. * Gets the class name
  21882. * @returns the string "SubMesh".
  21883. */
  21884. getClassName(): string;
  21885. /**
  21886. * Creates a new submesh from indices data
  21887. * @param materialIndex the index of the main mesh material
  21888. * @param startIndex the index where to start the copy in the mesh indices array
  21889. * @param indexCount the number of indices to copy then from the startIndex
  21890. * @param mesh the main mesh to create the submesh from
  21891. * @param renderingMesh the optional rendering mesh
  21892. * @returns a new submesh
  21893. */
  21894. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  21895. }
  21896. }
  21897. declare module "babylonjs/Loading/sceneLoaderFlags" {
  21898. /**
  21899. * Class used to represent data loading progression
  21900. */
  21901. export class SceneLoaderFlags {
  21902. private static _ForceFullSceneLoadingForIncremental;
  21903. private static _ShowLoadingScreen;
  21904. private static _CleanBoneMatrixWeights;
  21905. private static _loggingLevel;
  21906. /**
  21907. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  21908. */
  21909. static ForceFullSceneLoadingForIncremental: boolean;
  21910. /**
  21911. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  21912. */
  21913. static ShowLoadingScreen: boolean;
  21914. /**
  21915. * Defines the current logging level (while loading the scene)
  21916. * @ignorenaming
  21917. */
  21918. static loggingLevel: number;
  21919. /**
  21920. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  21921. */
  21922. static CleanBoneMatrixWeights: boolean;
  21923. }
  21924. }
  21925. declare module "babylonjs/Meshes/geometry" {
  21926. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  21927. import { Scene } from "babylonjs/scene";
  21928. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  21929. import { Engine } from "babylonjs/Engines/engine";
  21930. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  21931. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  21932. import { Effect } from "babylonjs/Materials/effect";
  21933. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  21934. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  21935. import { Mesh } from "babylonjs/Meshes/mesh";
  21936. /**
  21937. * Class used to store geometry data (vertex buffers + index buffer)
  21938. */
  21939. export class Geometry implements IGetSetVerticesData {
  21940. /**
  21941. * Gets or sets the ID of the geometry
  21942. */
  21943. id: string;
  21944. /**
  21945. * Gets or sets the unique ID of the geometry
  21946. */
  21947. uniqueId: number;
  21948. /**
  21949. * Gets the delay loading state of the geometry (none by default which means not delayed)
  21950. */
  21951. delayLoadState: number;
  21952. /**
  21953. * Gets the file containing the data to load when running in delay load state
  21954. */
  21955. delayLoadingFile: Nullable<string>;
  21956. /**
  21957. * Callback called when the geometry is updated
  21958. */
  21959. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  21960. private _scene;
  21961. private _engine;
  21962. private _meshes;
  21963. private _totalVertices;
  21964. /** @hidden */
  21965. _indices: IndicesArray;
  21966. /** @hidden */
  21967. _vertexBuffers: {
  21968. [key: string]: VertexBuffer;
  21969. };
  21970. private _isDisposed;
  21971. private _extend;
  21972. private _boundingBias;
  21973. /** @hidden */
  21974. _delayInfo: Array<string>;
  21975. private _indexBuffer;
  21976. private _indexBufferIsUpdatable;
  21977. /** @hidden */
  21978. _boundingInfo: Nullable<BoundingInfo>;
  21979. /** @hidden */
  21980. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  21981. /** @hidden */
  21982. _softwareSkinningFrameId: number;
  21983. private _vertexArrayObjects;
  21984. private _updatable;
  21985. /** @hidden */
  21986. _positions: Nullable<Vector3[]>;
  21987. /**
  21988. * Gets or sets the Bias Vector to apply on the bounding elements (box/sphere), the max extend is computed as v += v * bias.x + bias.y, the min is computed as v -= v * bias.x + bias.y
  21989. */
  21990. /**
  21991. * Gets or sets the Bias Vector to apply on the bounding elements (box/sphere), the max extend is computed as v += v * bias.x + bias.y, the min is computed as v -= v * bias.x + bias.y
  21992. */
  21993. boundingBias: Vector2;
  21994. /**
  21995. * Static function used to attach a new empty geometry to a mesh
  21996. * @param mesh defines the mesh to attach the geometry to
  21997. * @returns the new Geometry
  21998. */
  21999. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  22000. /**
  22001. * Creates a new geometry
  22002. * @param id defines the unique ID
  22003. * @param scene defines the hosting scene
  22004. * @param vertexData defines the VertexData used to get geometry data
  22005. * @param updatable defines if geometry must be updatable (false by default)
  22006. * @param mesh defines the mesh that will be associated with the geometry
  22007. */
  22008. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  22009. /**
  22010. * Gets the current extend of the geometry
  22011. */
  22012. readonly extend: {
  22013. minimum: Vector3;
  22014. maximum: Vector3;
  22015. };
  22016. /**
  22017. * Gets the hosting scene
  22018. * @returns the hosting Scene
  22019. */
  22020. getScene(): Scene;
  22021. /**
  22022. * Gets the hosting engine
  22023. * @returns the hosting Engine
  22024. */
  22025. getEngine(): Engine;
  22026. /**
  22027. * Defines if the geometry is ready to use
  22028. * @returns true if the geometry is ready to be used
  22029. */
  22030. isReady(): boolean;
  22031. /**
  22032. * Gets a value indicating that the geometry should not be serialized
  22033. */
  22034. readonly doNotSerialize: boolean;
  22035. /** @hidden */
  22036. _rebuild(): void;
  22037. /**
  22038. * Affects all geometry data in one call
  22039. * @param vertexData defines the geometry data
  22040. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  22041. */
  22042. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  22043. /**
  22044. * Set specific vertex data
  22045. * @param kind defines the data kind (Position, normal, etc...)
  22046. * @param data defines the vertex data to use
  22047. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22048. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22049. */
  22050. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  22051. /**
  22052. * Removes a specific vertex data
  22053. * @param kind defines the data kind (Position, normal, etc...)
  22054. */
  22055. removeVerticesData(kind: string): void;
  22056. /**
  22057. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  22058. * @param buffer defines the vertex buffer to use
  22059. * @param totalVertices defines the total number of vertices for position kind (could be null)
  22060. */
  22061. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  22062. /**
  22063. * Update a specific vertex buffer
  22064. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  22065. * It will do nothing if the buffer is not updatable
  22066. * @param kind defines the data kind (Position, normal, etc...)
  22067. * @param data defines the data to use
  22068. * @param offset defines the offset in the target buffer where to store the data
  22069. * @param useBytes set to true if the offset is in bytes
  22070. */
  22071. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  22072. /**
  22073. * Update a specific vertex buffer
  22074. * This function will create a new buffer if the current one is not updatable
  22075. * @param kind defines the data kind (Position, normal, etc...)
  22076. * @param data defines the data to use
  22077. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  22078. */
  22079. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  22080. private _updateBoundingInfo;
  22081. /** @hidden */
  22082. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  22083. /**
  22084. * Gets total number of vertices
  22085. * @returns the total number of vertices
  22086. */
  22087. getTotalVertices(): number;
  22088. /**
  22089. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22090. * @param kind defines the data kind (Position, normal, etc...)
  22091. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22092. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22093. * @returns a float array containing vertex data
  22094. */
  22095. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22096. /**
  22097. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  22098. * @param kind defines the data kind (Position, normal, etc...)
  22099. * @returns true if the vertex buffer with the specified kind is updatable
  22100. */
  22101. isVertexBufferUpdatable(kind: string): boolean;
  22102. /**
  22103. * Gets a specific vertex buffer
  22104. * @param kind defines the data kind (Position, normal, etc...)
  22105. * @returns a VertexBuffer
  22106. */
  22107. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  22108. /**
  22109. * Returns all vertex buffers
  22110. * @return an object holding all vertex buffers indexed by kind
  22111. */
  22112. getVertexBuffers(): Nullable<{
  22113. [key: string]: VertexBuffer;
  22114. }>;
  22115. /**
  22116. * Gets a boolean indicating if specific vertex buffer is present
  22117. * @param kind defines the data kind (Position, normal, etc...)
  22118. * @returns true if data is present
  22119. */
  22120. isVerticesDataPresent(kind: string): boolean;
  22121. /**
  22122. * Gets a list of all attached data kinds (Position, normal, etc...)
  22123. * @returns a list of string containing all kinds
  22124. */
  22125. getVerticesDataKinds(): string[];
  22126. /**
  22127. * Update index buffer
  22128. * @param indices defines the indices to store in the index buffer
  22129. * @param offset defines the offset in the target buffer where to store the data
  22130. * @param gpuMemoryOnly defines a boolean indicating that only the GPU memory must be updated leaving the CPU version of the indices unchanged (false by default)
  22131. */
  22132. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  22133. /**
  22134. * Creates a new index buffer
  22135. * @param indices defines the indices to store in the index buffer
  22136. * @param totalVertices defines the total number of vertices (could be null)
  22137. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22138. */
  22139. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  22140. /**
  22141. * Return the total number of indices
  22142. * @returns the total number of indices
  22143. */
  22144. getTotalIndices(): number;
  22145. /**
  22146. * Gets the index buffer array
  22147. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22148. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22149. * @returns the index buffer array
  22150. */
  22151. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22152. /**
  22153. * Gets the index buffer
  22154. * @return the index buffer
  22155. */
  22156. getIndexBuffer(): Nullable<DataBuffer>;
  22157. /** @hidden */
  22158. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  22159. /**
  22160. * Release the associated resources for a specific mesh
  22161. * @param mesh defines the source mesh
  22162. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  22163. */
  22164. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  22165. /**
  22166. * Apply current geometry to a given mesh
  22167. * @param mesh defines the mesh to apply geometry to
  22168. */
  22169. applyToMesh(mesh: Mesh): void;
  22170. private _updateExtend;
  22171. private _applyToMesh;
  22172. private notifyUpdate;
  22173. /**
  22174. * Load the geometry if it was flagged as delay loaded
  22175. * @param scene defines the hosting scene
  22176. * @param onLoaded defines a callback called when the geometry is loaded
  22177. */
  22178. load(scene: Scene, onLoaded?: () => void): void;
  22179. private _queueLoad;
  22180. /**
  22181. * Invert the geometry to move from a right handed system to a left handed one.
  22182. */
  22183. toLeftHanded(): void;
  22184. /** @hidden */
  22185. _resetPointsArrayCache(): void;
  22186. /** @hidden */
  22187. _generatePointsArray(): boolean;
  22188. /**
  22189. * Gets a value indicating if the geometry is disposed
  22190. * @returns true if the geometry was disposed
  22191. */
  22192. isDisposed(): boolean;
  22193. private _disposeVertexArrayObjects;
  22194. /**
  22195. * Free all associated resources
  22196. */
  22197. dispose(): void;
  22198. /**
  22199. * Clone the current geometry into a new geometry
  22200. * @param id defines the unique ID of the new geometry
  22201. * @returns a new geometry object
  22202. */
  22203. copy(id: string): Geometry;
  22204. /**
  22205. * Serialize the current geometry info (and not the vertices data) into a JSON object
  22206. * @return a JSON representation of the current geometry data (without the vertices data)
  22207. */
  22208. serialize(): any;
  22209. private toNumberArray;
  22210. /**
  22211. * Serialize all vertices data into a JSON oject
  22212. * @returns a JSON representation of the current geometry data
  22213. */
  22214. serializeVerticeData(): any;
  22215. /**
  22216. * Extracts a clone of a mesh geometry
  22217. * @param mesh defines the source mesh
  22218. * @param id defines the unique ID of the new geometry object
  22219. * @returns the new geometry object
  22220. */
  22221. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  22222. /**
  22223. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  22224. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  22225. * Be aware Math.random() could cause collisions, but:
  22226. * "All but 6 of the 128 bits of the ID are randomly generated, which means that for any two ids, there's a 1 in 2^^122 (or 5.3x10^^36) chance they'll collide"
  22227. * @returns a string containing a new GUID
  22228. */
  22229. static RandomId(): string;
  22230. /** @hidden */
  22231. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  22232. private static _CleanMatricesWeights;
  22233. /**
  22234. * Create a new geometry from persisted data (Using .babylon file format)
  22235. * @param parsedVertexData defines the persisted data
  22236. * @param scene defines the hosting scene
  22237. * @param rootUrl defines the root url to use to load assets (like delayed data)
  22238. * @returns the new geometry object
  22239. */
  22240. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  22241. }
  22242. }
  22243. declare module "babylonjs/Meshes/mesh.vertexData" {
  22244. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  22245. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  22246. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  22247. import { Geometry } from "babylonjs/Meshes/geometry";
  22248. import { Mesh } from "babylonjs/Meshes/mesh";
  22249. /**
  22250. * Define an interface for all classes that will get and set the data on vertices
  22251. */
  22252. export interface IGetSetVerticesData {
  22253. /**
  22254. * Gets a boolean indicating if specific vertex data is present
  22255. * @param kind defines the vertex data kind to use
  22256. * @returns true is data kind is present
  22257. */
  22258. isVerticesDataPresent(kind: string): boolean;
  22259. /**
  22260. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22261. * @param kind defines the data kind (Position, normal, etc...)
  22262. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22263. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22264. * @returns a float array containing vertex data
  22265. */
  22266. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22267. /**
  22268. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  22269. * @param copyWhenShared If true (default false) and and if the mesh geometry is shared among some other meshes, the returned array is a copy of the internal one.
  22270. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22271. * @returns the indices array or an empty array if the mesh has no geometry
  22272. */
  22273. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22274. /**
  22275. * Set specific vertex data
  22276. * @param kind defines the data kind (Position, normal, etc...)
  22277. * @param data defines the vertex data to use
  22278. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22279. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22280. */
  22281. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  22282. /**
  22283. * Update a specific associated vertex buffer
  22284. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  22285. * - VertexBuffer.PositionKind
  22286. * - VertexBuffer.UVKind
  22287. * - VertexBuffer.UV2Kind
  22288. * - VertexBuffer.UV3Kind
  22289. * - VertexBuffer.UV4Kind
  22290. * - VertexBuffer.UV5Kind
  22291. * - VertexBuffer.UV6Kind
  22292. * - VertexBuffer.ColorKind
  22293. * - VertexBuffer.MatricesIndicesKind
  22294. * - VertexBuffer.MatricesIndicesExtraKind
  22295. * - VertexBuffer.MatricesWeightsKind
  22296. * - VertexBuffer.MatricesWeightsExtraKind
  22297. * @param data defines the data source
  22298. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  22299. * @param makeItUnique defines if the geometry associated with the mesh must be cloned to make the change only for this mesh (and not all meshes associated with the same geometry)
  22300. */
  22301. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  22302. /**
  22303. * Creates a new index buffer
  22304. * @param indices defines the indices to store in the index buffer
  22305. * @param totalVertices defines the total number of vertices (could be null)
  22306. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22307. */
  22308. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  22309. }
  22310. /**
  22311. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  22312. */
  22313. export class VertexData {
  22314. /**
  22315. * Mesh side orientation : usually the external or front surface
  22316. */
  22317. static readonly FRONTSIDE: number;
  22318. /**
  22319. * Mesh side orientation : usually the internal or back surface
  22320. */
  22321. static readonly BACKSIDE: number;
  22322. /**
  22323. * Mesh side orientation : both internal and external or front and back surfaces
  22324. */
  22325. static readonly DOUBLESIDE: number;
  22326. /**
  22327. * Mesh side orientation : by default, `FRONTSIDE`
  22328. */
  22329. static readonly DEFAULTSIDE: number;
  22330. /**
  22331. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  22332. */
  22333. positions: Nullable<FloatArray>;
  22334. /**
  22335. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  22336. */
  22337. normals: Nullable<FloatArray>;
  22338. /**
  22339. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  22340. */
  22341. tangents: Nullable<FloatArray>;
  22342. /**
  22343. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22344. */
  22345. uvs: Nullable<FloatArray>;
  22346. /**
  22347. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22348. */
  22349. uvs2: Nullable<FloatArray>;
  22350. /**
  22351. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22352. */
  22353. uvs3: Nullable<FloatArray>;
  22354. /**
  22355. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22356. */
  22357. uvs4: Nullable<FloatArray>;
  22358. /**
  22359. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22360. */
  22361. uvs5: Nullable<FloatArray>;
  22362. /**
  22363. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22364. */
  22365. uvs6: Nullable<FloatArray>;
  22366. /**
  22367. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  22368. */
  22369. colors: Nullable<FloatArray>;
  22370. /**
  22371. * An array containing the list of indices to the array of matrices produced by bones, each vertex have up to 4 indices (8 if the matricesIndicesExtra is set).
  22372. */
  22373. matricesIndices: Nullable<FloatArray>;
  22374. /**
  22375. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  22376. */
  22377. matricesWeights: Nullable<FloatArray>;
  22378. /**
  22379. * An array extending the number of possible indices
  22380. */
  22381. matricesIndicesExtra: Nullable<FloatArray>;
  22382. /**
  22383. * An array extending the number of possible weights when the number of indices is extended
  22384. */
  22385. matricesWeightsExtra: Nullable<FloatArray>;
  22386. /**
  22387. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  22388. */
  22389. indices: Nullable<IndicesArray>;
  22390. /**
  22391. * Uses the passed data array to set the set the values for the specified kind of data
  22392. * @param data a linear array of floating numbers
  22393. * @param kind the type of data that is being set, eg positions, colors etc
  22394. */
  22395. set(data: FloatArray, kind: string): void;
  22396. /**
  22397. * Associates the vertexData to the passed Mesh.
  22398. * Sets it as updatable or not (default `false`)
  22399. * @param mesh the mesh the vertexData is applied to
  22400. * @param updatable when used and having the value true allows new data to update the vertexData
  22401. * @returns the VertexData
  22402. */
  22403. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  22404. /**
  22405. * Associates the vertexData to the passed Geometry.
  22406. * Sets it as updatable or not (default `false`)
  22407. * @param geometry the geometry the vertexData is applied to
  22408. * @param updatable when used and having the value true allows new data to update the vertexData
  22409. * @returns VertexData
  22410. */
  22411. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  22412. /**
  22413. * Updates the associated mesh
  22414. * @param mesh the mesh to be updated
  22415. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22416. * @param makeItUnique when true, and when and if position kind is updated, a new global geometry will be created from these positions and set to the mesh, optional with default false
  22417. * @returns VertexData
  22418. */
  22419. updateMesh(mesh: Mesh): VertexData;
  22420. /**
  22421. * Updates the associated geometry
  22422. * @param geometry the geometry to be updated
  22423. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22424. * @param makeItUnique when true, and when and if position kind is updated, a new global geometry will be created from these positions and set to the mesh, optional with default false
  22425. * @returns VertexData.
  22426. */
  22427. updateGeometry(geometry: Geometry): VertexData;
  22428. private _applyTo;
  22429. private _update;
  22430. /**
  22431. * Transforms each position and each normal of the vertexData according to the passed Matrix
  22432. * @param matrix the transforming matrix
  22433. * @returns the VertexData
  22434. */
  22435. transform(matrix: Matrix): VertexData;
  22436. /**
  22437. * Merges the passed VertexData into the current one
  22438. * @param other the VertexData to be merged into the current one
  22439. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  22440. * @returns the modified VertexData
  22441. */
  22442. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  22443. private _mergeElement;
  22444. private _validate;
  22445. /**
  22446. * Serializes the VertexData
  22447. * @returns a serialized object
  22448. */
  22449. serialize(): any;
  22450. /**
  22451. * Extracts the vertexData from a mesh
  22452. * @param mesh the mesh from which to extract the VertexData
  22453. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  22454. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22455. * @returns the object VertexData associated to the passed mesh
  22456. */
  22457. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22458. /**
  22459. * Extracts the vertexData from the geometry
  22460. * @param geometry the geometry from which to extract the VertexData
  22461. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  22462. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22463. * @returns the object VertexData associated to the passed mesh
  22464. */
  22465. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22466. private static _ExtractFrom;
  22467. /**
  22468. * Creates the VertexData for a Ribbon
  22469. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  22470. * * pathArray array of paths, each of which an array of successive Vector3
  22471. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  22472. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  22473. * * offset a positive integer, only used when pathArray contains a single path (offset = 10 means the point 1 is joined to the point 11), default rounded half size of the pathArray length
  22474. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22475. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  22476. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  22477. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  22478. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  22479. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  22480. * @returns the VertexData of the ribbon
  22481. */
  22482. static CreateRibbon(options: {
  22483. pathArray: Vector3[][];
  22484. closeArray?: boolean;
  22485. closePath?: boolean;
  22486. offset?: number;
  22487. sideOrientation?: number;
  22488. frontUVs?: Vector4;
  22489. backUVs?: Vector4;
  22490. invertUV?: boolean;
  22491. uvs?: Vector2[];
  22492. colors?: Color4[];
  22493. }): VertexData;
  22494. /**
  22495. * Creates the VertexData for a box
  22496. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22497. * * size sets the width, height and depth of the box to the value of size, optional default 1
  22498. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  22499. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  22500. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  22501. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22502. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22503. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22504. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  22505. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  22506. * @returns the VertexData of the box
  22507. */
  22508. static CreateBox(options: {
  22509. size?: number;
  22510. width?: number;
  22511. height?: number;
  22512. depth?: number;
  22513. faceUV?: Vector4[];
  22514. faceColors?: Color4[];
  22515. sideOrientation?: number;
  22516. frontUVs?: Vector4;
  22517. backUVs?: Vector4;
  22518. }): VertexData;
  22519. /**
  22520. * Creates the VertexData for a tiled box
  22521. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22522. * * faceTiles sets the pattern, tile size and number of tiles for a face
  22523. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22524. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22525. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22526. * @returns the VertexData of the box
  22527. */
  22528. static CreateTiledBox(options: {
  22529. pattern?: number;
  22530. width?: number;
  22531. height?: number;
  22532. depth?: number;
  22533. tileSize?: number;
  22534. tileWidth?: number;
  22535. tileHeight?: number;
  22536. alignHorizontal?: number;
  22537. alignVertical?: number;
  22538. faceUV?: Vector4[];
  22539. faceColors?: Color4[];
  22540. sideOrientation?: number;
  22541. }): VertexData;
  22542. /**
  22543. * Creates the VertexData for a tiled plane
  22544. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22545. * * pattern a limited pattern arrangement depending on the number
  22546. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  22547. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  22548. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  22549. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22550. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  22551. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  22552. * @returns the VertexData of the tiled plane
  22553. */
  22554. static CreateTiledPlane(options: {
  22555. pattern?: number;
  22556. tileSize?: number;
  22557. tileWidth?: number;
  22558. tileHeight?: number;
  22559. size?: number;
  22560. width?: number;
  22561. height?: number;
  22562. alignHorizontal?: number;
  22563. alignVertical?: number;
  22564. sideOrientation?: number;
  22565. frontUVs?: Vector4;
  22566. backUVs?: Vector4;
  22567. }): VertexData;
  22568. /**
  22569. * Creates the VertexData for an ellipsoid, defaults to a sphere
  22570. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22571. * * segments sets the number of horizontal strips optional, default 32
  22572. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  22573. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  22574. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  22575. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  22576. * * arc a number from 0 to 1, to create an unclosed ellipsoid based on the fraction of the circumference (latitude) given by the arc value, optional, default 1
  22577. * * slice a number from 0 to 1, to create an unclosed ellipsoid based on the fraction of the height (latitude) given by the arc value, optional, default 1
  22578. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22579. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  22580. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  22581. * @returns the VertexData of the ellipsoid
  22582. */
  22583. static CreateSphere(options: {
  22584. segments?: number;
  22585. diameter?: number;
  22586. diameterX?: number;
  22587. diameterY?: number;
  22588. diameterZ?: number;
  22589. arc?: number;
  22590. slice?: number;
  22591. sideOrientation?: number;
  22592. frontUVs?: Vector4;
  22593. backUVs?: Vector4;
  22594. }): VertexData;
  22595. /**
  22596. * Creates the VertexData for a cylinder, cone or prism
  22597. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22598. * * height sets the height (y direction) of the cylinder, optional, default 2
  22599. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  22600. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  22601. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  22602. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22603. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  22604. * * arc a number from 0 to 1, to create an unclosed cylinder based on the fraction of the circumference given by the arc value, optional, default 1
  22605. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22606. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22607. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  22608. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  22609. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22610. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  22611. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  22612. * @returns the VertexData of the cylinder, cone or prism
  22613. */
  22614. static CreateCylinder(options: {
  22615. height?: number;
  22616. diameterTop?: number;
  22617. diameterBottom?: number;
  22618. diameter?: number;
  22619. tessellation?: number;
  22620. subdivisions?: number;
  22621. arc?: number;
  22622. faceColors?: Color4[];
  22623. faceUV?: Vector4[];
  22624. hasRings?: boolean;
  22625. enclose?: boolean;
  22626. sideOrientation?: number;
  22627. frontUVs?: Vector4;
  22628. backUVs?: Vector4;
  22629. }): VertexData;
  22630. /**
  22631. * Creates the VertexData for a torus
  22632. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22633. * * diameter the diameter of the torus, optional default 1
  22634. * * thickness the diameter of the tube forming the torus, optional default 0.5
  22635. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22636. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22637. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  22638. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  22639. * @returns the VertexData of the torus
  22640. */
  22641. static CreateTorus(options: {
  22642. diameter?: number;
  22643. thickness?: number;
  22644. tessellation?: number;
  22645. sideOrientation?: number;
  22646. frontUVs?: Vector4;
  22647. backUVs?: Vector4;
  22648. }): VertexData;
  22649. /**
  22650. * Creates the VertexData of the LineSystem
  22651. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  22652. * - lines an array of lines, each line being an array of successive Vector3
  22653. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  22654. * @returns the VertexData of the LineSystem
  22655. */
  22656. static CreateLineSystem(options: {
  22657. lines: Vector3[][];
  22658. colors?: Nullable<Color4[][]>;
  22659. }): VertexData;
  22660. /**
  22661. * Create the VertexData for a DashedLines
  22662. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  22663. * - points an array successive Vector3
  22664. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  22665. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  22666. * - dashNb the intended total number of dashes, optional, default 200
  22667. * @returns the VertexData for the DashedLines
  22668. */
  22669. static CreateDashedLines(options: {
  22670. points: Vector3[];
  22671. dashSize?: number;
  22672. gapSize?: number;
  22673. dashNb?: number;
  22674. }): VertexData;
  22675. /**
  22676. * Creates the VertexData for a Ground
  22677. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22678. * - width the width (x direction) of the ground, optional, default 1
  22679. * - height the height (z direction) of the ground, optional, default 1
  22680. * - subdivisions the number of subdivisions per side, optional, default 1
  22681. * @returns the VertexData of the Ground
  22682. */
  22683. static CreateGround(options: {
  22684. width?: number;
  22685. height?: number;
  22686. subdivisions?: number;
  22687. subdivisionsX?: number;
  22688. subdivisionsY?: number;
  22689. }): VertexData;
  22690. /**
  22691. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  22692. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22693. * * xmin the ground minimum X coordinate, optional, default -1
  22694. * * zmin the ground minimum Z coordinate, optional, default -1
  22695. * * xmax the ground maximum X coordinate, optional, default 1
  22696. * * zmax the ground maximum Z coordinate, optional, default 1
  22697. * * subdivisions a javascript object {w: positive integer, h: positive integer}, `w` and `h` are the numbers of subdivisions on the ground width and height creating 'tiles', default {w: 6, h: 6}
  22698. * * precision a javascript object {w: positive integer, h: positive integer}, `w` and `h` are the numbers of subdivisions on the tile width and height, default {w: 2, h: 2}
  22699. * @returns the VertexData of the TiledGround
  22700. */
  22701. static CreateTiledGround(options: {
  22702. xmin: number;
  22703. zmin: number;
  22704. xmax: number;
  22705. zmax: number;
  22706. subdivisions?: {
  22707. w: number;
  22708. h: number;
  22709. };
  22710. precision?: {
  22711. w: number;
  22712. h: number;
  22713. };
  22714. }): VertexData;
  22715. /**
  22716. * Creates the VertexData of the Ground designed from a heightmap
  22717. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  22718. * * width the width (x direction) of the ground
  22719. * * height the height (z direction) of the ground
  22720. * * subdivisions the number of subdivisions per side
  22721. * * minHeight the minimum altitude on the ground, optional, default 0
  22722. * * maxHeight the maximum altitude on the ground, optional default 1
  22723. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  22724. * * buffer the array holding the image color data
  22725. * * bufferWidth the width of image
  22726. * * bufferHeight the height of image
  22727. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  22728. * @returns the VertexData of the Ground designed from a heightmap
  22729. */
  22730. static CreateGroundFromHeightMap(options: {
  22731. width: number;
  22732. height: number;
  22733. subdivisions: number;
  22734. minHeight: number;
  22735. maxHeight: number;
  22736. colorFilter: Color3;
  22737. buffer: Uint8Array;
  22738. bufferWidth: number;
  22739. bufferHeight: number;
  22740. alphaFilter: number;
  22741. }): VertexData;
  22742. /**
  22743. * Creates the VertexData for a Plane
  22744. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  22745. * * size sets the width and height of the plane to the value of size, optional default 1
  22746. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  22747. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  22748. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22749. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  22750. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  22751. * @returns the VertexData of the box
  22752. */
  22753. static CreatePlane(options: {
  22754. size?: number;
  22755. width?: number;
  22756. height?: number;
  22757. sideOrientation?: number;
  22758. frontUVs?: Vector4;
  22759. backUVs?: Vector4;
  22760. }): VertexData;
  22761. /**
  22762. * Creates the VertexData of the Disc or regular Polygon
  22763. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  22764. * * radius the radius of the disc, optional default 0.5
  22765. * * tessellation the number of polygon sides, optional, default 64
  22766. * * arc a number from 0 to 1, to create an unclosed polygon based on the fraction of the circumference given by the arc value, optional, default 1
  22767. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22768. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  22769. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  22770. * @returns the VertexData of the box
  22771. */
  22772. static CreateDisc(options: {
  22773. radius?: number;
  22774. tessellation?: number;
  22775. arc?: number;
  22776. sideOrientation?: number;
  22777. frontUVs?: Vector4;
  22778. backUVs?: Vector4;
  22779. }): VertexData;
  22780. /**
  22781. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  22782. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  22783. * @param polygon a mesh built from polygonTriangulation.build()
  22784. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22785. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22786. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22787. * @param frontUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  22788. * @param backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  22789. * @returns the VertexData of the Polygon
  22790. */
  22791. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  22792. /**
  22793. * Creates the VertexData of the IcoSphere
  22794. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  22795. * * radius the radius of the IcoSphere, optional default 1
  22796. * * radiusX allows stretching in the x direction, optional, default radius
  22797. * * radiusY allows stretching in the y direction, optional, default radius
  22798. * * radiusZ allows stretching in the z direction, optional, default radius
  22799. * * flat when true creates a flat shaded mesh, optional, default true
  22800. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22801. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22802. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  22803. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  22804. * @returns the VertexData of the IcoSphere
  22805. */
  22806. static CreateIcoSphere(options: {
  22807. radius?: number;
  22808. radiusX?: number;
  22809. radiusY?: number;
  22810. radiusZ?: number;
  22811. flat?: boolean;
  22812. subdivisions?: number;
  22813. sideOrientation?: number;
  22814. frontUVs?: Vector4;
  22815. backUVs?: Vector4;
  22816. }): VertexData;
  22817. /**
  22818. * Creates the VertexData for a Polyhedron
  22819. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  22820. * * type provided types are:
  22821. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  22822. * * 9 : Pentagonal Pyramid (J2), 10 : Triangular Dipyramid (J12), 11 : Pentagonal Dipyramid (J13), 12 : Elongated Square Dipyramid (J15), 13 : Elongated Pentagonal Dipyramid (J16), 14 : Elongated Pentagonal Cupola (J20)
  22823. * * size the size of the IcoSphere, optional default 1
  22824. * * sizeX allows stretching in the x direction, optional, default size
  22825. * * sizeY allows stretching in the y direction, optional, default size
  22826. * * sizeZ allows stretching in the z direction, optional, default size
  22827. * * custom a number that overwrites the type to create from an extended set of polyhedron from https://www.babylonjs-playground.com/#21QRSK#15 with minimised editor
  22828. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22829. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22830. * * flat when true creates a flat shaded mesh, optional, default true
  22831. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22832. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22833. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  22834. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  22835. * @returns the VertexData of the Polyhedron
  22836. */
  22837. static CreatePolyhedron(options: {
  22838. type?: number;
  22839. size?: number;
  22840. sizeX?: number;
  22841. sizeY?: number;
  22842. sizeZ?: number;
  22843. custom?: any;
  22844. faceUV?: Vector4[];
  22845. faceColors?: Color4[];
  22846. flat?: boolean;
  22847. sideOrientation?: number;
  22848. frontUVs?: Vector4;
  22849. backUVs?: Vector4;
  22850. }): VertexData;
  22851. /**
  22852. * Creates the VertexData for a TorusKnot
  22853. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  22854. * * radius the radius of the torus knot, optional, default 2
  22855. * * tube the thickness of the tube, optional, default 0.5
  22856. * * radialSegments the number of sides on each tube segments, optional, default 32
  22857. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  22858. * * p the number of windings around the z axis, optional, default 2
  22859. * * q the number of windings around the x axis, optional, default 3
  22860. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22861. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  22862. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  22863. * @returns the VertexData of the Torus Knot
  22864. */
  22865. static CreateTorusKnot(options: {
  22866. radius?: number;
  22867. tube?: number;
  22868. radialSegments?: number;
  22869. tubularSegments?: number;
  22870. p?: number;
  22871. q?: number;
  22872. sideOrientation?: number;
  22873. frontUVs?: Vector4;
  22874. backUVs?: Vector4;
  22875. }): VertexData;
  22876. /**
  22877. * Compute normals for given positions and indices
  22878. * @param positions an array of vertex positions, [...., x, y, z, ......]
  22879. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  22880. * @param normals an array of vertex normals, [...., x, y, z, ......]
  22881. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  22882. * * facetNormals : optional array of facet normals (vector3)
  22883. * * facetPositions : optional array of facet positions (vector3)
  22884. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  22885. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  22886. * * bInfo : optional bounding info, required for facetPartitioning computation
  22887. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  22888. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  22889. * * useRightHandedSystem: optional boolean to for right handed system computation
  22890. * * depthSort : optional boolean to enable the facet depth sort computation
  22891. * * distanceTo : optional Vector3 to compute the facet depth from this location
  22892. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  22893. */
  22894. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  22895. facetNormals?: any;
  22896. facetPositions?: any;
  22897. facetPartitioning?: any;
  22898. ratio?: number;
  22899. bInfo?: any;
  22900. bbSize?: Vector3;
  22901. subDiv?: any;
  22902. useRightHandedSystem?: boolean;
  22903. depthSort?: boolean;
  22904. distanceTo?: Vector3;
  22905. depthSortedFacets?: any;
  22906. }): void;
  22907. /** @hidden */
  22908. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  22909. /**
  22910. * Applies VertexData created from the imported parameters to the geometry
  22911. * @param parsedVertexData the parsed data from an imported file
  22912. * @param geometry the geometry to apply the VertexData to
  22913. */
  22914. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  22915. }
  22916. }
  22917. declare module "babylonjs/Morph/morphTarget" {
  22918. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  22919. import { Observable } from "babylonjs/Misc/observable";
  22920. import { Nullable, FloatArray } from "babylonjs/types";
  22921. import { Scene } from "babylonjs/scene";
  22922. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22923. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  22924. /**
  22925. * Defines a target to use with MorphTargetManager
  22926. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22927. */
  22928. export class MorphTarget implements IAnimatable {
  22929. /** defines the name of the target */
  22930. name: string;
  22931. /**
  22932. * Gets or sets the list of animations
  22933. */
  22934. animations: import("babylonjs/Animations/animation").Animation[];
  22935. private _scene;
  22936. private _positions;
  22937. private _normals;
  22938. private _tangents;
  22939. private _uvs;
  22940. private _influence;
  22941. private _uniqueId;
  22942. /**
  22943. * Observable raised when the influence changes
  22944. */
  22945. onInfluenceChanged: Observable<boolean>;
  22946. /** @hidden */
  22947. _onDataLayoutChanged: Observable<void>;
  22948. /**
  22949. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  22950. */
  22951. influence: number;
  22952. /**
  22953. * Gets or sets the id of the morph Target
  22954. */
  22955. id: string;
  22956. private _animationPropertiesOverride;
  22957. /**
  22958. * Gets or sets the animation properties override
  22959. */
  22960. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  22961. /**
  22962. * Creates a new MorphTarget
  22963. * @param name defines the name of the target
  22964. * @param influence defines the influence to use
  22965. * @param scene defines the scene the morphtarget belongs to
  22966. */
  22967. constructor(
  22968. /** defines the name of the target */
  22969. name: string, influence?: number, scene?: Nullable<Scene>);
  22970. /**
  22971. * Gets the unique ID of this manager
  22972. */
  22973. readonly uniqueId: number;
  22974. /**
  22975. * Gets a boolean defining if the target contains position data
  22976. */
  22977. readonly hasPositions: boolean;
  22978. /**
  22979. * Gets a boolean defining if the target contains normal data
  22980. */
  22981. readonly hasNormals: boolean;
  22982. /**
  22983. * Gets a boolean defining if the target contains tangent data
  22984. */
  22985. readonly hasTangents: boolean;
  22986. /**
  22987. * Gets a boolean defining if the target contains texture coordinates data
  22988. */
  22989. readonly hasUVs: boolean;
  22990. /**
  22991. * Affects position data to this target
  22992. * @param data defines the position data to use
  22993. */
  22994. setPositions(data: Nullable<FloatArray>): void;
  22995. /**
  22996. * Gets the position data stored in this target
  22997. * @returns a FloatArray containing the position data (or null if not present)
  22998. */
  22999. getPositions(): Nullable<FloatArray>;
  23000. /**
  23001. * Affects normal data to this target
  23002. * @param data defines the normal data to use
  23003. */
  23004. setNormals(data: Nullable<FloatArray>): void;
  23005. /**
  23006. * Gets the normal data stored in this target
  23007. * @returns a FloatArray containing the normal data (or null if not present)
  23008. */
  23009. getNormals(): Nullable<FloatArray>;
  23010. /**
  23011. * Affects tangent data to this target
  23012. * @param data defines the tangent data to use
  23013. */
  23014. setTangents(data: Nullable<FloatArray>): void;
  23015. /**
  23016. * Gets the tangent data stored in this target
  23017. * @returns a FloatArray containing the tangent data (or null if not present)
  23018. */
  23019. getTangents(): Nullable<FloatArray>;
  23020. /**
  23021. * Affects texture coordinates data to this target
  23022. * @param data defines the texture coordinates data to use
  23023. */
  23024. setUVs(data: Nullable<FloatArray>): void;
  23025. /**
  23026. * Gets the texture coordinates data stored in this target
  23027. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  23028. */
  23029. getUVs(): Nullable<FloatArray>;
  23030. /**
  23031. * Clone the current target
  23032. * @returns a new MorphTarget
  23033. */
  23034. clone(): MorphTarget;
  23035. /**
  23036. * Serializes the current target into a Serialization object
  23037. * @returns the serialized object
  23038. */
  23039. serialize(): any;
  23040. /**
  23041. * Returns the string "MorphTarget"
  23042. * @returns "MorphTarget"
  23043. */
  23044. getClassName(): string;
  23045. /**
  23046. * Creates a new target from serialized data
  23047. * @param serializationObject defines the serialized data to use
  23048. * @returns a new MorphTarget
  23049. */
  23050. static Parse(serializationObject: any): MorphTarget;
  23051. /**
  23052. * Creates a MorphTarget from mesh data
  23053. * @param mesh defines the source mesh
  23054. * @param name defines the name to use for the new target
  23055. * @param influence defines the influence to attach to the target
  23056. * @returns a new MorphTarget
  23057. */
  23058. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  23059. }
  23060. }
  23061. declare module "babylonjs/Morph/morphTargetManager" {
  23062. import { Nullable } from "babylonjs/types";
  23063. import { Scene } from "babylonjs/scene";
  23064. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  23065. /**
  23066. * This class is used to deform meshes using morphing between different targets
  23067. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  23068. */
  23069. export class MorphTargetManager {
  23070. private _targets;
  23071. private _targetInfluenceChangedObservers;
  23072. private _targetDataLayoutChangedObservers;
  23073. private _activeTargets;
  23074. private _scene;
  23075. private _influences;
  23076. private _supportsNormals;
  23077. private _supportsTangents;
  23078. private _supportsUVs;
  23079. private _vertexCount;
  23080. private _uniqueId;
  23081. private _tempInfluences;
  23082. /**
  23083. * Gets or sets a boolean indicating if normals must be morphed
  23084. */
  23085. enableNormalMorphing: boolean;
  23086. /**
  23087. * Gets or sets a boolean indicating if tangents must be morphed
  23088. */
  23089. enableTangentMorphing: boolean;
  23090. /**
  23091. * Gets or sets a boolean indicating if UV must be morphed
  23092. */
  23093. enableUVMorphing: boolean;
  23094. /**
  23095. * Creates a new MorphTargetManager
  23096. * @param scene defines the current scene
  23097. */
  23098. constructor(scene?: Nullable<Scene>);
  23099. /**
  23100. * Gets the unique ID of this manager
  23101. */
  23102. readonly uniqueId: number;
  23103. /**
  23104. * Gets the number of vertices handled by this manager
  23105. */
  23106. readonly vertexCount: number;
  23107. /**
  23108. * Gets a boolean indicating if this manager supports morphing of normals
  23109. */
  23110. readonly supportsNormals: boolean;
  23111. /**
  23112. * Gets a boolean indicating if this manager supports morphing of tangents
  23113. */
  23114. readonly supportsTangents: boolean;
  23115. /**
  23116. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  23117. */
  23118. readonly supportsUVs: boolean;
  23119. /**
  23120. * Gets the number of targets stored in this manager
  23121. */
  23122. readonly numTargets: number;
  23123. /**
  23124. * Gets the number of influencers (ie. the number of targets with influences > 0)
  23125. */
  23126. readonly numInfluencers: number;
  23127. /**
  23128. * Gets the list of influences (one per target)
  23129. */
  23130. readonly influences: Float32Array;
  23131. /**
  23132. * Gets the active target at specified index. An active target is a target with an influence > 0
  23133. * @param index defines the index to check
  23134. * @returns the requested target
  23135. */
  23136. getActiveTarget(index: number): MorphTarget;
  23137. /**
  23138. * Gets the target at specified index
  23139. * @param index defines the index to check
  23140. * @returns the requested target
  23141. */
  23142. getTarget(index: number): MorphTarget;
  23143. /**
  23144. * Add a new target to this manager
  23145. * @param target defines the target to add
  23146. */
  23147. addTarget(target: MorphTarget): void;
  23148. /**
  23149. * Removes a target from the manager
  23150. * @param target defines the target to remove
  23151. */
  23152. removeTarget(target: MorphTarget): void;
  23153. /**
  23154. * Clone the current manager
  23155. * @returns a new MorphTargetManager
  23156. */
  23157. clone(): MorphTargetManager;
  23158. /**
  23159. * Serializes the current manager into a Serialization object
  23160. * @returns the serialized object
  23161. */
  23162. serialize(): any;
  23163. private _syncActiveTargets;
  23164. /**
  23165. * Syncrhonize the targets with all the meshes using this morph target manager
  23166. */
  23167. synchronize(): void;
  23168. /**
  23169. * Creates a new MorphTargetManager from serialized data
  23170. * @param serializationObject defines the serialized data
  23171. * @param scene defines the hosting scene
  23172. * @returns the new MorphTargetManager
  23173. */
  23174. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  23175. }
  23176. }
  23177. declare module "babylonjs/Meshes/meshLODLevel" {
  23178. import { Mesh } from "babylonjs/Meshes/mesh";
  23179. import { Nullable } from "babylonjs/types";
  23180. /**
  23181. * Class used to represent a specific level of detail of a mesh
  23182. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  23183. */
  23184. export class MeshLODLevel {
  23185. /** Defines the distance where this level should start being displayed */
  23186. distance: number;
  23187. /** Defines the mesh to use to render this level */
  23188. mesh: Nullable<Mesh>;
  23189. /**
  23190. * Creates a new LOD level
  23191. * @param distance defines the distance where this level should star being displayed
  23192. * @param mesh defines the mesh to use to render this level
  23193. */
  23194. constructor(
  23195. /** Defines the distance where this level should start being displayed */
  23196. distance: number,
  23197. /** Defines the mesh to use to render this level */
  23198. mesh: Nullable<Mesh>);
  23199. }
  23200. }
  23201. declare module "babylonjs/Meshes/groundMesh" {
  23202. import { Scene } from "babylonjs/scene";
  23203. import { Vector3 } from "babylonjs/Maths/math.vector";
  23204. import { Mesh } from "babylonjs/Meshes/mesh";
  23205. /**
  23206. * Mesh representing the gorund
  23207. */
  23208. export class GroundMesh extends Mesh {
  23209. /** If octree should be generated */
  23210. generateOctree: boolean;
  23211. private _heightQuads;
  23212. /** @hidden */
  23213. _subdivisionsX: number;
  23214. /** @hidden */
  23215. _subdivisionsY: number;
  23216. /** @hidden */
  23217. _width: number;
  23218. /** @hidden */
  23219. _height: number;
  23220. /** @hidden */
  23221. _minX: number;
  23222. /** @hidden */
  23223. _maxX: number;
  23224. /** @hidden */
  23225. _minZ: number;
  23226. /** @hidden */
  23227. _maxZ: number;
  23228. constructor(name: string, scene: Scene);
  23229. /**
  23230. * "GroundMesh"
  23231. * @returns "GroundMesh"
  23232. */
  23233. getClassName(): string;
  23234. /**
  23235. * The minimum of x and y subdivisions
  23236. */
  23237. readonly subdivisions: number;
  23238. /**
  23239. * X subdivisions
  23240. */
  23241. readonly subdivisionsX: number;
  23242. /**
  23243. * Y subdivisions
  23244. */
  23245. readonly subdivisionsY: number;
  23246. /**
  23247. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  23248. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  23249. * @param chunksCount the number of subdivisions for x and y
  23250. * @param octreeBlocksSize (Default: 32)
  23251. */
  23252. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  23253. /**
  23254. * Returns a height (y) value in the Worl system :
  23255. * the ground altitude at the coordinates (x, z) expressed in the World system.
  23256. * @param x x coordinate
  23257. * @param z z coordinate
  23258. * @returns the ground y position if (x, z) are outside the ground surface.
  23259. */
  23260. getHeightAtCoordinates(x: number, z: number): number;
  23261. /**
  23262. * Returns a normalized vector (Vector3) orthogonal to the ground
  23263. * at the ground coordinates (x, z) expressed in the World system.
  23264. * @param x x coordinate
  23265. * @param z z coordinate
  23266. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  23267. */
  23268. getNormalAtCoordinates(x: number, z: number): Vector3;
  23269. /**
  23270. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  23271. * at the ground coordinates (x, z) expressed in the World system.
  23272. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  23273. * @param x x coordinate
  23274. * @param z z coordinate
  23275. * @param ref vector to store the result
  23276. * @returns the GroundMesh.
  23277. */
  23278. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  23279. /**
  23280. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  23281. * if the ground has been updated.
  23282. * This can be used in the render loop.
  23283. * @returns the GroundMesh.
  23284. */
  23285. updateCoordinateHeights(): GroundMesh;
  23286. private _getFacetAt;
  23287. private _initHeightQuads;
  23288. private _computeHeightQuads;
  23289. /**
  23290. * Serializes this ground mesh
  23291. * @param serializationObject object to write serialization to
  23292. */
  23293. serialize(serializationObject: any): void;
  23294. /**
  23295. * Parses a serialized ground mesh
  23296. * @param parsedMesh the serialized mesh
  23297. * @param scene the scene to create the ground mesh in
  23298. * @returns the created ground mesh
  23299. */
  23300. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  23301. }
  23302. }
  23303. declare module "babylonjs/Physics/physicsJoint" {
  23304. import { Vector3 } from "babylonjs/Maths/math.vector";
  23305. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  23306. /**
  23307. * Interface for Physics-Joint data
  23308. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23309. */
  23310. export interface PhysicsJointData {
  23311. /**
  23312. * The main pivot of the joint
  23313. */
  23314. mainPivot?: Vector3;
  23315. /**
  23316. * The connected pivot of the joint
  23317. */
  23318. connectedPivot?: Vector3;
  23319. /**
  23320. * The main axis of the joint
  23321. */
  23322. mainAxis?: Vector3;
  23323. /**
  23324. * The connected axis of the joint
  23325. */
  23326. connectedAxis?: Vector3;
  23327. /**
  23328. * The collision of the joint
  23329. */
  23330. collision?: boolean;
  23331. /**
  23332. * Native Oimo/Cannon/Energy data
  23333. */
  23334. nativeParams?: any;
  23335. }
  23336. /**
  23337. * This is a holder class for the physics joint created by the physics plugin
  23338. * It holds a set of functions to control the underlying joint
  23339. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23340. */
  23341. export class PhysicsJoint {
  23342. /**
  23343. * The type of the physics joint
  23344. */
  23345. type: number;
  23346. /**
  23347. * The data for the physics joint
  23348. */
  23349. jointData: PhysicsJointData;
  23350. private _physicsJoint;
  23351. protected _physicsPlugin: IPhysicsEnginePlugin;
  23352. /**
  23353. * Initializes the physics joint
  23354. * @param type The type of the physics joint
  23355. * @param jointData The data for the physics joint
  23356. */
  23357. constructor(
  23358. /**
  23359. * The type of the physics joint
  23360. */
  23361. type: number,
  23362. /**
  23363. * The data for the physics joint
  23364. */
  23365. jointData: PhysicsJointData);
  23366. /**
  23367. * Gets the physics joint
  23368. */
  23369. /**
  23370. * Sets the physics joint
  23371. */
  23372. physicsJoint: any;
  23373. /**
  23374. * Sets the physics plugin
  23375. */
  23376. physicsPlugin: IPhysicsEnginePlugin;
  23377. /**
  23378. * Execute a function that is physics-plugin specific.
  23379. * @param {Function} func the function that will be executed.
  23380. * It accepts two parameters: the physics world and the physics joint
  23381. */
  23382. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  23383. /**
  23384. * Distance-Joint type
  23385. */
  23386. static DistanceJoint: number;
  23387. /**
  23388. * Hinge-Joint type
  23389. */
  23390. static HingeJoint: number;
  23391. /**
  23392. * Ball-and-Socket joint type
  23393. */
  23394. static BallAndSocketJoint: number;
  23395. /**
  23396. * Wheel-Joint type
  23397. */
  23398. static WheelJoint: number;
  23399. /**
  23400. * Slider-Joint type
  23401. */
  23402. static SliderJoint: number;
  23403. /**
  23404. * Prismatic-Joint type
  23405. */
  23406. static PrismaticJoint: number;
  23407. /**
  23408. * Universal-Joint type
  23409. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  23410. */
  23411. static UniversalJoint: number;
  23412. /**
  23413. * Hinge-Joint 2 type
  23414. */
  23415. static Hinge2Joint: number;
  23416. /**
  23417. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  23418. */
  23419. static PointToPointJoint: number;
  23420. /**
  23421. * Spring-Joint type
  23422. */
  23423. static SpringJoint: number;
  23424. /**
  23425. * Lock-Joint type
  23426. */
  23427. static LockJoint: number;
  23428. }
  23429. /**
  23430. * A class representing a physics distance joint
  23431. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23432. */
  23433. export class DistanceJoint extends PhysicsJoint {
  23434. /**
  23435. *
  23436. * @param jointData The data for the Distance-Joint
  23437. */
  23438. constructor(jointData: DistanceJointData);
  23439. /**
  23440. * Update the predefined distance.
  23441. * @param maxDistance The maximum preferred distance
  23442. * @param minDistance The minimum preferred distance
  23443. */
  23444. updateDistance(maxDistance: number, minDistance?: number): void;
  23445. }
  23446. /**
  23447. * Represents a Motor-Enabled Joint
  23448. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23449. */
  23450. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  23451. /**
  23452. * Initializes the Motor-Enabled Joint
  23453. * @param type The type of the joint
  23454. * @param jointData The physica joint data for the joint
  23455. */
  23456. constructor(type: number, jointData: PhysicsJointData);
  23457. /**
  23458. * Set the motor values.
  23459. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23460. * @param force the force to apply
  23461. * @param maxForce max force for this motor.
  23462. */
  23463. setMotor(force?: number, maxForce?: number): void;
  23464. /**
  23465. * Set the motor's limits.
  23466. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23467. * @param upperLimit The upper limit of the motor
  23468. * @param lowerLimit The lower limit of the motor
  23469. */
  23470. setLimit(upperLimit: number, lowerLimit?: number): void;
  23471. }
  23472. /**
  23473. * This class represents a single physics Hinge-Joint
  23474. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23475. */
  23476. export class HingeJoint extends MotorEnabledJoint {
  23477. /**
  23478. * Initializes the Hinge-Joint
  23479. * @param jointData The joint data for the Hinge-Joint
  23480. */
  23481. constructor(jointData: PhysicsJointData);
  23482. /**
  23483. * Set the motor values.
  23484. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23485. * @param {number} force the force to apply
  23486. * @param {number} maxForce max force for this motor.
  23487. */
  23488. setMotor(force?: number, maxForce?: number): void;
  23489. /**
  23490. * Set the motor's limits.
  23491. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23492. * @param upperLimit The upper limit of the motor
  23493. * @param lowerLimit The lower limit of the motor
  23494. */
  23495. setLimit(upperLimit: number, lowerLimit?: number): void;
  23496. }
  23497. /**
  23498. * This class represents a dual hinge physics joint (same as wheel joint)
  23499. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23500. */
  23501. export class Hinge2Joint extends MotorEnabledJoint {
  23502. /**
  23503. * Initializes the Hinge2-Joint
  23504. * @param jointData The joint data for the Hinge2-Joint
  23505. */
  23506. constructor(jointData: PhysicsJointData);
  23507. /**
  23508. * Set the motor values.
  23509. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23510. * @param {number} targetSpeed the speed the motor is to reach
  23511. * @param {number} maxForce max force for this motor.
  23512. * @param {motorIndex} the motor's index, 0 or 1.
  23513. */
  23514. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  23515. /**
  23516. * Set the motor limits.
  23517. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23518. * @param {number} upperLimit the upper limit
  23519. * @param {number} lowerLimit lower limit
  23520. * @param {motorIndex} the motor's index, 0 or 1.
  23521. */
  23522. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23523. }
  23524. /**
  23525. * Interface for a motor enabled joint
  23526. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23527. */
  23528. export interface IMotorEnabledJoint {
  23529. /**
  23530. * Physics joint
  23531. */
  23532. physicsJoint: any;
  23533. /**
  23534. * Sets the motor of the motor-enabled joint
  23535. * @param force The force of the motor
  23536. * @param maxForce The maximum force of the motor
  23537. * @param motorIndex The index of the motor
  23538. */
  23539. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  23540. /**
  23541. * Sets the limit of the motor
  23542. * @param upperLimit The upper limit of the motor
  23543. * @param lowerLimit The lower limit of the motor
  23544. * @param motorIndex The index of the motor
  23545. */
  23546. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23547. }
  23548. /**
  23549. * Joint data for a Distance-Joint
  23550. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23551. */
  23552. export interface DistanceJointData extends PhysicsJointData {
  23553. /**
  23554. * Max distance the 2 joint objects can be apart
  23555. */
  23556. maxDistance: number;
  23557. }
  23558. /**
  23559. * Joint data from a spring joint
  23560. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23561. */
  23562. export interface SpringJointData extends PhysicsJointData {
  23563. /**
  23564. * Length of the spring
  23565. */
  23566. length: number;
  23567. /**
  23568. * Stiffness of the spring
  23569. */
  23570. stiffness: number;
  23571. /**
  23572. * Damping of the spring
  23573. */
  23574. damping: number;
  23575. /** this callback will be called when applying the force to the impostors. */
  23576. forceApplicationCallback: () => void;
  23577. }
  23578. }
  23579. declare module "babylonjs/Physics/physicsRaycastResult" {
  23580. import { Vector3 } from "babylonjs/Maths/math.vector";
  23581. /**
  23582. * Holds the data for the raycast result
  23583. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23584. */
  23585. export class PhysicsRaycastResult {
  23586. private _hasHit;
  23587. private _hitDistance;
  23588. private _hitNormalWorld;
  23589. private _hitPointWorld;
  23590. private _rayFromWorld;
  23591. private _rayToWorld;
  23592. /**
  23593. * Gets if there was a hit
  23594. */
  23595. readonly hasHit: boolean;
  23596. /**
  23597. * Gets the distance from the hit
  23598. */
  23599. readonly hitDistance: number;
  23600. /**
  23601. * Gets the hit normal/direction in the world
  23602. */
  23603. readonly hitNormalWorld: Vector3;
  23604. /**
  23605. * Gets the hit point in the world
  23606. */
  23607. readonly hitPointWorld: Vector3;
  23608. /**
  23609. * Gets the ray "start point" of the ray in the world
  23610. */
  23611. readonly rayFromWorld: Vector3;
  23612. /**
  23613. * Gets the ray "end point" of the ray in the world
  23614. */
  23615. readonly rayToWorld: Vector3;
  23616. /**
  23617. * Sets the hit data (normal & point in world space)
  23618. * @param hitNormalWorld defines the normal in world space
  23619. * @param hitPointWorld defines the point in world space
  23620. */
  23621. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  23622. /**
  23623. * Sets the distance from the start point to the hit point
  23624. * @param distance
  23625. */
  23626. setHitDistance(distance: number): void;
  23627. /**
  23628. * Calculates the distance manually
  23629. */
  23630. calculateHitDistance(): void;
  23631. /**
  23632. * Resets all the values to default
  23633. * @param from The from point on world space
  23634. * @param to The to point on world space
  23635. */
  23636. reset(from?: Vector3, to?: Vector3): void;
  23637. }
  23638. /**
  23639. * Interface for the size containing width and height
  23640. */
  23641. interface IXYZ {
  23642. /**
  23643. * X
  23644. */
  23645. x: number;
  23646. /**
  23647. * Y
  23648. */
  23649. y: number;
  23650. /**
  23651. * Z
  23652. */
  23653. z: number;
  23654. }
  23655. }
  23656. declare module "babylonjs/Physics/IPhysicsEngine" {
  23657. import { Nullable } from "babylonjs/types";
  23658. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  23659. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23660. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  23661. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  23662. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  23663. /**
  23664. * Interface used to describe a physics joint
  23665. */
  23666. export interface PhysicsImpostorJoint {
  23667. /** Defines the main impostor to which the joint is linked */
  23668. mainImpostor: PhysicsImpostor;
  23669. /** Defines the impostor that is connected to the main impostor using this joint */
  23670. connectedImpostor: PhysicsImpostor;
  23671. /** Defines the joint itself */
  23672. joint: PhysicsJoint;
  23673. }
  23674. /** @hidden */
  23675. export interface IPhysicsEnginePlugin {
  23676. world: any;
  23677. name: string;
  23678. setGravity(gravity: Vector3): void;
  23679. setTimeStep(timeStep: number): void;
  23680. getTimeStep(): number;
  23681. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  23682. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23683. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23684. generatePhysicsBody(impostor: PhysicsImpostor): void;
  23685. removePhysicsBody(impostor: PhysicsImpostor): void;
  23686. generateJoint(joint: PhysicsImpostorJoint): void;
  23687. removeJoint(joint: PhysicsImpostorJoint): void;
  23688. isSupported(): boolean;
  23689. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  23690. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  23691. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23692. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23693. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23694. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23695. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  23696. getBodyMass(impostor: PhysicsImpostor): number;
  23697. getBodyFriction(impostor: PhysicsImpostor): number;
  23698. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  23699. getBodyRestitution(impostor: PhysicsImpostor): number;
  23700. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  23701. getBodyPressure?(impostor: PhysicsImpostor): number;
  23702. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  23703. getBodyStiffness?(impostor: PhysicsImpostor): number;
  23704. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  23705. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  23706. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  23707. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  23708. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  23709. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23710. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23711. sleepBody(impostor: PhysicsImpostor): void;
  23712. wakeUpBody(impostor: PhysicsImpostor): void;
  23713. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23714. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  23715. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  23716. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23717. getRadius(impostor: PhysicsImpostor): number;
  23718. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  23719. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  23720. dispose(): void;
  23721. }
  23722. /**
  23723. * Interface used to define a physics engine
  23724. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  23725. */
  23726. export interface IPhysicsEngine {
  23727. /**
  23728. * Gets the gravity vector used by the simulation
  23729. */
  23730. gravity: Vector3;
  23731. /**
  23732. * Sets the gravity vector used by the simulation
  23733. * @param gravity defines the gravity vector to use
  23734. */
  23735. setGravity(gravity: Vector3): void;
  23736. /**
  23737. * Set the time step of the physics engine.
  23738. * Default is 1/60.
  23739. * To slow it down, enter 1/600 for example.
  23740. * To speed it up, 1/30
  23741. * @param newTimeStep the new timestep to apply to this world.
  23742. */
  23743. setTimeStep(newTimeStep: number): void;
  23744. /**
  23745. * Get the time step of the physics engine.
  23746. * @returns the current time step
  23747. */
  23748. getTimeStep(): number;
  23749. /**
  23750. * Release all resources
  23751. */
  23752. dispose(): void;
  23753. /**
  23754. * Gets the name of the current physics plugin
  23755. * @returns the name of the plugin
  23756. */
  23757. getPhysicsPluginName(): string;
  23758. /**
  23759. * Adding a new impostor for the impostor tracking.
  23760. * This will be done by the impostor itself.
  23761. * @param impostor the impostor to add
  23762. */
  23763. addImpostor(impostor: PhysicsImpostor): void;
  23764. /**
  23765. * Remove an impostor from the engine.
  23766. * This impostor and its mesh will not longer be updated by the physics engine.
  23767. * @param impostor the impostor to remove
  23768. */
  23769. removeImpostor(impostor: PhysicsImpostor): void;
  23770. /**
  23771. * Add a joint to the physics engine
  23772. * @param mainImpostor defines the main impostor to which the joint is added.
  23773. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  23774. * @param joint defines the joint that will connect both impostors.
  23775. */
  23776. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23777. /**
  23778. * Removes a joint from the simulation
  23779. * @param mainImpostor defines the impostor used with the joint
  23780. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  23781. * @param joint defines the joint to remove
  23782. */
  23783. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23784. /**
  23785. * Gets the current plugin used to run the simulation
  23786. * @returns current plugin
  23787. */
  23788. getPhysicsPlugin(): IPhysicsEnginePlugin;
  23789. /**
  23790. * Gets the list of physic impostors
  23791. * @returns an array of PhysicsImpostor
  23792. */
  23793. getImpostors(): Array<PhysicsImpostor>;
  23794. /**
  23795. * Gets the impostor for a physics enabled object
  23796. * @param object defines the object impersonated by the impostor
  23797. * @returns the PhysicsImpostor or null if not found
  23798. */
  23799. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23800. /**
  23801. * Gets the impostor for a physics body object
  23802. * @param body defines physics body used by the impostor
  23803. * @returns the PhysicsImpostor or null if not found
  23804. */
  23805. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  23806. /**
  23807. * Does a raycast in the physics world
  23808. * @param from when should the ray start?
  23809. * @param to when should the ray end?
  23810. * @returns PhysicsRaycastResult
  23811. */
  23812. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23813. /**
  23814. * Called by the scene. No need to call it.
  23815. * @param delta defines the timespam between frames
  23816. */
  23817. _step(delta: number): void;
  23818. }
  23819. }
  23820. declare module "babylonjs/Physics/physicsImpostor" {
  23821. import { Nullable, IndicesArray } from "babylonjs/types";
  23822. import { Vector3, Matrix, Quaternion } from "babylonjs/Maths/math.vector";
  23823. import { TransformNode } from "babylonjs/Meshes/transformNode";
  23824. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23825. import { Scene } from "babylonjs/scene";
  23826. import { Bone } from "babylonjs/Bones/bone";
  23827. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  23828. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  23829. import { Space } from "babylonjs/Maths/math.axis";
  23830. /**
  23831. * The interface for the physics imposter parameters
  23832. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23833. */
  23834. export interface PhysicsImpostorParameters {
  23835. /**
  23836. * The mass of the physics imposter
  23837. */
  23838. mass: number;
  23839. /**
  23840. * The friction of the physics imposter
  23841. */
  23842. friction?: number;
  23843. /**
  23844. * The coefficient of restitution of the physics imposter
  23845. */
  23846. restitution?: number;
  23847. /**
  23848. * The native options of the physics imposter
  23849. */
  23850. nativeOptions?: any;
  23851. /**
  23852. * Specifies if the parent should be ignored
  23853. */
  23854. ignoreParent?: boolean;
  23855. /**
  23856. * Specifies if bi-directional transformations should be disabled
  23857. */
  23858. disableBidirectionalTransformation?: boolean;
  23859. /**
  23860. * The pressure inside the physics imposter, soft object only
  23861. */
  23862. pressure?: number;
  23863. /**
  23864. * The stiffness the physics imposter, soft object only
  23865. */
  23866. stiffness?: number;
  23867. /**
  23868. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  23869. */
  23870. velocityIterations?: number;
  23871. /**
  23872. * The number of iterations used in maintaining consistent vertex positions, soft object only
  23873. */
  23874. positionIterations?: number;
  23875. /**
  23876. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  23877. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  23878. * Add to fix multiple points
  23879. */
  23880. fixedPoints?: number;
  23881. /**
  23882. * The collision margin around a soft object
  23883. */
  23884. margin?: number;
  23885. /**
  23886. * The collision margin around a soft object
  23887. */
  23888. damping?: number;
  23889. /**
  23890. * The path for a rope based on an extrusion
  23891. */
  23892. path?: any;
  23893. /**
  23894. * The shape of an extrusion used for a rope based on an extrusion
  23895. */
  23896. shape?: any;
  23897. }
  23898. /**
  23899. * Interface for a physics-enabled object
  23900. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23901. */
  23902. export interface IPhysicsEnabledObject {
  23903. /**
  23904. * The position of the physics-enabled object
  23905. */
  23906. position: Vector3;
  23907. /**
  23908. * The rotation of the physics-enabled object
  23909. */
  23910. rotationQuaternion: Nullable<Quaternion>;
  23911. /**
  23912. * The scale of the physics-enabled object
  23913. */
  23914. scaling: Vector3;
  23915. /**
  23916. * The rotation of the physics-enabled object
  23917. */
  23918. rotation?: Vector3;
  23919. /**
  23920. * The parent of the physics-enabled object
  23921. */
  23922. parent?: any;
  23923. /**
  23924. * The bounding info of the physics-enabled object
  23925. * @returns The bounding info of the physics-enabled object
  23926. */
  23927. getBoundingInfo(): BoundingInfo;
  23928. /**
  23929. * Computes the world matrix
  23930. * @param force Specifies if the world matrix should be computed by force
  23931. * @returns A world matrix
  23932. */
  23933. computeWorldMatrix(force: boolean): Matrix;
  23934. /**
  23935. * Gets the world matrix
  23936. * @returns A world matrix
  23937. */
  23938. getWorldMatrix?(): Matrix;
  23939. /**
  23940. * Gets the child meshes
  23941. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  23942. * @returns An array of abstract meshes
  23943. */
  23944. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  23945. /**
  23946. * Gets the vertex data
  23947. * @param kind The type of vertex data
  23948. * @returns A nullable array of numbers, or a float32 array
  23949. */
  23950. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  23951. /**
  23952. * Gets the indices from the mesh
  23953. * @returns A nullable array of index arrays
  23954. */
  23955. getIndices?(): Nullable<IndicesArray>;
  23956. /**
  23957. * Gets the scene from the mesh
  23958. * @returns the indices array or null
  23959. */
  23960. getScene?(): Scene;
  23961. /**
  23962. * Gets the absolute position from the mesh
  23963. * @returns the absolute position
  23964. */
  23965. getAbsolutePosition(): Vector3;
  23966. /**
  23967. * Gets the absolute pivot point from the mesh
  23968. * @returns the absolute pivot point
  23969. */
  23970. getAbsolutePivotPoint(): Vector3;
  23971. /**
  23972. * Rotates the mesh
  23973. * @param axis The axis of rotation
  23974. * @param amount The amount of rotation
  23975. * @param space The space of the rotation
  23976. * @returns The rotation transform node
  23977. */
  23978. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  23979. /**
  23980. * Translates the mesh
  23981. * @param axis The axis of translation
  23982. * @param distance The distance of translation
  23983. * @param space The space of the translation
  23984. * @returns The transform node
  23985. */
  23986. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  23987. /**
  23988. * Sets the absolute position of the mesh
  23989. * @param absolutePosition The absolute position of the mesh
  23990. * @returns The transform node
  23991. */
  23992. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  23993. /**
  23994. * Gets the class name of the mesh
  23995. * @returns The class name
  23996. */
  23997. getClassName(): string;
  23998. }
  23999. /**
  24000. * Represents a physics imposter
  24001. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24002. */
  24003. export class PhysicsImpostor {
  24004. /**
  24005. * The physics-enabled object used as the physics imposter
  24006. */
  24007. object: IPhysicsEnabledObject;
  24008. /**
  24009. * The type of the physics imposter
  24010. */
  24011. type: number;
  24012. private _options;
  24013. private _scene?;
  24014. /**
  24015. * The default object size of the imposter
  24016. */
  24017. static DEFAULT_OBJECT_SIZE: Vector3;
  24018. /**
  24019. * The identity quaternion of the imposter
  24020. */
  24021. static IDENTITY_QUATERNION: Quaternion;
  24022. /** @hidden */
  24023. _pluginData: any;
  24024. private _physicsEngine;
  24025. private _physicsBody;
  24026. private _bodyUpdateRequired;
  24027. private _onBeforePhysicsStepCallbacks;
  24028. private _onAfterPhysicsStepCallbacks;
  24029. /** @hidden */
  24030. _onPhysicsCollideCallbacks: Array<{
  24031. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  24032. otherImpostors: Array<PhysicsImpostor>;
  24033. }>;
  24034. private _deltaPosition;
  24035. private _deltaRotation;
  24036. private _deltaRotationConjugated;
  24037. /** @hidden */
  24038. _isFromLine: boolean;
  24039. private _parent;
  24040. private _isDisposed;
  24041. private static _tmpVecs;
  24042. private static _tmpQuat;
  24043. /**
  24044. * Specifies if the physics imposter is disposed
  24045. */
  24046. readonly isDisposed: boolean;
  24047. /**
  24048. * Gets the mass of the physics imposter
  24049. */
  24050. mass: number;
  24051. /**
  24052. * Gets the coefficient of friction
  24053. */
  24054. /**
  24055. * Sets the coefficient of friction
  24056. */
  24057. friction: number;
  24058. /**
  24059. * Gets the coefficient of restitution
  24060. */
  24061. /**
  24062. * Sets the coefficient of restitution
  24063. */
  24064. restitution: number;
  24065. /**
  24066. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  24067. */
  24068. /**
  24069. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  24070. */
  24071. pressure: number;
  24072. /**
  24073. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  24074. */
  24075. /**
  24076. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  24077. */
  24078. stiffness: number;
  24079. /**
  24080. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  24081. */
  24082. /**
  24083. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  24084. */
  24085. velocityIterations: number;
  24086. /**
  24087. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  24088. */
  24089. /**
  24090. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  24091. */
  24092. positionIterations: number;
  24093. /**
  24094. * The unique id of the physics imposter
  24095. * set by the physics engine when adding this impostor to the array
  24096. */
  24097. uniqueId: number;
  24098. /**
  24099. * @hidden
  24100. */
  24101. soft: boolean;
  24102. /**
  24103. * @hidden
  24104. */
  24105. segments: number;
  24106. private _joints;
  24107. /**
  24108. * Initializes the physics imposter
  24109. * @param object The physics-enabled object used as the physics imposter
  24110. * @param type The type of the physics imposter
  24111. * @param _options The options for the physics imposter
  24112. * @param _scene The Babylon scene
  24113. */
  24114. constructor(
  24115. /**
  24116. * The physics-enabled object used as the physics imposter
  24117. */
  24118. object: IPhysicsEnabledObject,
  24119. /**
  24120. * The type of the physics imposter
  24121. */
  24122. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  24123. /**
  24124. * This function will completly initialize this impostor.
  24125. * It will create a new body - but only if this mesh has no parent.
  24126. * If it has, this impostor will not be used other than to define the impostor
  24127. * of the child mesh.
  24128. * @hidden
  24129. */
  24130. _init(): void;
  24131. private _getPhysicsParent;
  24132. /**
  24133. * Should a new body be generated.
  24134. * @returns boolean specifying if body initialization is required
  24135. */
  24136. isBodyInitRequired(): boolean;
  24137. /**
  24138. * Sets the updated scaling
  24139. * @param updated Specifies if the scaling is updated
  24140. */
  24141. setScalingUpdated(): void;
  24142. /**
  24143. * Force a regeneration of this or the parent's impostor's body.
  24144. * Use under cautious - This will remove all joints already implemented.
  24145. */
  24146. forceUpdate(): void;
  24147. /**
  24148. * Gets the body that holds this impostor. Either its own, or its parent.
  24149. */
  24150. /**
  24151. * Set the physics body. Used mainly by the physics engine/plugin
  24152. */
  24153. physicsBody: any;
  24154. /**
  24155. * Get the parent of the physics imposter
  24156. * @returns Physics imposter or null
  24157. */
  24158. /**
  24159. * Sets the parent of the physics imposter
  24160. */
  24161. parent: Nullable<PhysicsImpostor>;
  24162. /**
  24163. * Resets the update flags
  24164. */
  24165. resetUpdateFlags(): void;
  24166. /**
  24167. * Gets the object extend size
  24168. * @returns the object extend size
  24169. */
  24170. getObjectExtendSize(): Vector3;
  24171. /**
  24172. * Gets the object center
  24173. * @returns The object center
  24174. */
  24175. getObjectCenter(): Vector3;
  24176. /**
  24177. * Get a specific parametes from the options parameter
  24178. * @param paramName The object parameter name
  24179. * @returns The object parameter
  24180. */
  24181. getParam(paramName: string): any;
  24182. /**
  24183. * Sets a specific parameter in the options given to the physics plugin
  24184. * @param paramName The parameter name
  24185. * @param value The value of the parameter
  24186. */
  24187. setParam(paramName: string, value: number): void;
  24188. /**
  24189. * Specifically change the body's mass option. Won't recreate the physics body object
  24190. * @param mass The mass of the physics imposter
  24191. */
  24192. setMass(mass: number): void;
  24193. /**
  24194. * Gets the linear velocity
  24195. * @returns linear velocity or null
  24196. */
  24197. getLinearVelocity(): Nullable<Vector3>;
  24198. /**
  24199. * Sets the linear velocity
  24200. * @param velocity linear velocity or null
  24201. */
  24202. setLinearVelocity(velocity: Nullable<Vector3>): void;
  24203. /**
  24204. * Gets the angular velocity
  24205. * @returns angular velocity or null
  24206. */
  24207. getAngularVelocity(): Nullable<Vector3>;
  24208. /**
  24209. * Sets the angular velocity
  24210. * @param velocity The velocity or null
  24211. */
  24212. setAngularVelocity(velocity: Nullable<Vector3>): void;
  24213. /**
  24214. * Execute a function with the physics plugin native code
  24215. * Provide a function the will have two variables - the world object and the physics body object
  24216. * @param func The function to execute with the physics plugin native code
  24217. */
  24218. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  24219. /**
  24220. * Register a function that will be executed before the physics world is stepping forward
  24221. * @param func The function to execute before the physics world is stepped forward
  24222. */
  24223. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24224. /**
  24225. * Unregister a function that will be executed before the physics world is stepping forward
  24226. * @param func The function to execute before the physics world is stepped forward
  24227. */
  24228. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24229. /**
  24230. * Register a function that will be executed after the physics step
  24231. * @param func The function to execute after physics step
  24232. */
  24233. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24234. /**
  24235. * Unregisters a function that will be executed after the physics step
  24236. * @param func The function to execute after physics step
  24237. */
  24238. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24239. /**
  24240. * register a function that will be executed when this impostor collides against a different body
  24241. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  24242. * @param func Callback that is executed on collision
  24243. */
  24244. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  24245. /**
  24246. * Unregisters the physics imposter on contact
  24247. * @param collideAgainst The physics object to collide against
  24248. * @param func Callback to execute on collision
  24249. */
  24250. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  24251. private _tmpQuat;
  24252. private _tmpQuat2;
  24253. /**
  24254. * Get the parent rotation
  24255. * @returns The parent rotation
  24256. */
  24257. getParentsRotation(): Quaternion;
  24258. /**
  24259. * this function is executed by the physics engine.
  24260. */
  24261. beforeStep: () => void;
  24262. /**
  24263. * this function is executed by the physics engine
  24264. */
  24265. afterStep: () => void;
  24266. /**
  24267. * Legacy collision detection event support
  24268. */
  24269. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  24270. /**
  24271. * event and body object due to cannon's event-based architecture.
  24272. */
  24273. onCollide: (e: {
  24274. body: any;
  24275. }) => void;
  24276. /**
  24277. * Apply a force
  24278. * @param force The force to apply
  24279. * @param contactPoint The contact point for the force
  24280. * @returns The physics imposter
  24281. */
  24282. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24283. /**
  24284. * Apply an impulse
  24285. * @param force The impulse force
  24286. * @param contactPoint The contact point for the impulse force
  24287. * @returns The physics imposter
  24288. */
  24289. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24290. /**
  24291. * A help function to create a joint
  24292. * @param otherImpostor A physics imposter used to create a joint
  24293. * @param jointType The type of joint
  24294. * @param jointData The data for the joint
  24295. * @returns The physics imposter
  24296. */
  24297. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  24298. /**
  24299. * Add a joint to this impostor with a different impostor
  24300. * @param otherImpostor A physics imposter used to add a joint
  24301. * @param joint The joint to add
  24302. * @returns The physics imposter
  24303. */
  24304. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  24305. /**
  24306. * Add an anchor to a cloth impostor
  24307. * @param otherImpostor rigid impostor to anchor to
  24308. * @param width ratio across width from 0 to 1
  24309. * @param height ratio up height from 0 to 1
  24310. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  24311. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  24312. * @returns impostor the soft imposter
  24313. */
  24314. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24315. /**
  24316. * Add a hook to a rope impostor
  24317. * @param otherImpostor rigid impostor to anchor to
  24318. * @param length ratio across rope from 0 to 1
  24319. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  24320. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  24321. * @returns impostor the rope imposter
  24322. */
  24323. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24324. /**
  24325. * Will keep this body still, in a sleep mode.
  24326. * @returns the physics imposter
  24327. */
  24328. sleep(): PhysicsImpostor;
  24329. /**
  24330. * Wake the body up.
  24331. * @returns The physics imposter
  24332. */
  24333. wakeUp(): PhysicsImpostor;
  24334. /**
  24335. * Clones the physics imposter
  24336. * @param newObject The physics imposter clones to this physics-enabled object
  24337. * @returns A nullable physics imposter
  24338. */
  24339. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  24340. /**
  24341. * Disposes the physics imposter
  24342. */
  24343. dispose(): void;
  24344. /**
  24345. * Sets the delta position
  24346. * @param position The delta position amount
  24347. */
  24348. setDeltaPosition(position: Vector3): void;
  24349. /**
  24350. * Sets the delta rotation
  24351. * @param rotation The delta rotation amount
  24352. */
  24353. setDeltaRotation(rotation: Quaternion): void;
  24354. /**
  24355. * Gets the box size of the physics imposter and stores the result in the input parameter
  24356. * @param result Stores the box size
  24357. * @returns The physics imposter
  24358. */
  24359. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  24360. /**
  24361. * Gets the radius of the physics imposter
  24362. * @returns Radius of the physics imposter
  24363. */
  24364. getRadius(): number;
  24365. /**
  24366. * Sync a bone with this impostor
  24367. * @param bone The bone to sync to the impostor.
  24368. * @param boneMesh The mesh that the bone is influencing.
  24369. * @param jointPivot The pivot of the joint / bone in local space.
  24370. * @param distToJoint Optional distance from the impostor to the joint.
  24371. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24372. */
  24373. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  24374. /**
  24375. * Sync impostor to a bone
  24376. * @param bone The bone that the impostor will be synced to.
  24377. * @param boneMesh The mesh that the bone is influencing.
  24378. * @param jointPivot The pivot of the joint / bone in local space.
  24379. * @param distToJoint Optional distance from the impostor to the joint.
  24380. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24381. * @param boneAxis Optional vector3 axis the bone is aligned with
  24382. */
  24383. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  24384. /**
  24385. * No-Imposter type
  24386. */
  24387. static NoImpostor: number;
  24388. /**
  24389. * Sphere-Imposter type
  24390. */
  24391. static SphereImpostor: number;
  24392. /**
  24393. * Box-Imposter type
  24394. */
  24395. static BoxImpostor: number;
  24396. /**
  24397. * Plane-Imposter type
  24398. */
  24399. static PlaneImpostor: number;
  24400. /**
  24401. * Mesh-imposter type
  24402. */
  24403. static MeshImpostor: number;
  24404. /**
  24405. * Capsule-Impostor type (Ammo.js plugin only)
  24406. */
  24407. static CapsuleImpostor: number;
  24408. /**
  24409. * Cylinder-Imposter type
  24410. */
  24411. static CylinderImpostor: number;
  24412. /**
  24413. * Particle-Imposter type
  24414. */
  24415. static ParticleImpostor: number;
  24416. /**
  24417. * Heightmap-Imposter type
  24418. */
  24419. static HeightmapImpostor: number;
  24420. /**
  24421. * ConvexHull-Impostor type (Ammo.js plugin only)
  24422. */
  24423. static ConvexHullImpostor: number;
  24424. /**
  24425. * Rope-Imposter type
  24426. */
  24427. static RopeImpostor: number;
  24428. /**
  24429. * Cloth-Imposter type
  24430. */
  24431. static ClothImpostor: number;
  24432. /**
  24433. * Softbody-Imposter type
  24434. */
  24435. static SoftbodyImpostor: number;
  24436. }
  24437. }
  24438. declare module "babylonjs/Meshes/mesh" {
  24439. import { Observable } from "babylonjs/Misc/observable";
  24440. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  24441. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  24442. import { Camera } from "babylonjs/Cameras/camera";
  24443. import { Scene } from "babylonjs/scene";
  24444. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  24445. import { Color4 } from "babylonjs/Maths/math.color";
  24446. import { Engine } from "babylonjs/Engines/engine";
  24447. import { Node } from "babylonjs/node";
  24448. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  24449. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  24450. import { Buffer } from "babylonjs/Meshes/buffer";
  24451. import { Geometry } from "babylonjs/Meshes/geometry";
  24452. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24453. import { SubMesh } from "babylonjs/Meshes/subMesh";
  24454. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  24455. import { Effect } from "babylonjs/Materials/effect";
  24456. import { Material } from "babylonjs/Materials/material";
  24457. import { Skeleton } from "babylonjs/Bones/skeleton";
  24458. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  24459. import { MeshLODLevel } from "babylonjs/Meshes/meshLODLevel";
  24460. import { Path3D } from "babylonjs/Maths/math.path";
  24461. import { Plane } from "babylonjs/Maths/math.plane";
  24462. import { TransformNode } from "babylonjs/Meshes/transformNode";
  24463. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  24464. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  24465. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  24466. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  24467. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  24468. /**
  24469. * @hidden
  24470. **/
  24471. export class _CreationDataStorage {
  24472. closePath?: boolean;
  24473. closeArray?: boolean;
  24474. idx: number[];
  24475. dashSize: number;
  24476. gapSize: number;
  24477. path3D: Path3D;
  24478. pathArray: Vector3[][];
  24479. arc: number;
  24480. radius: number;
  24481. cap: number;
  24482. tessellation: number;
  24483. }
  24484. /**
  24485. * @hidden
  24486. **/
  24487. class _InstanceDataStorage {
  24488. visibleInstances: any;
  24489. batchCache: _InstancesBatch;
  24490. instancesBufferSize: number;
  24491. instancesBuffer: Nullable<Buffer>;
  24492. instancesData: Float32Array;
  24493. overridenInstanceCount: number;
  24494. isFrozen: boolean;
  24495. previousBatch: Nullable<_InstancesBatch>;
  24496. hardwareInstancedRendering: boolean;
  24497. sideOrientation: number;
  24498. manualUpdate: boolean;
  24499. }
  24500. /**
  24501. * @hidden
  24502. **/
  24503. export class _InstancesBatch {
  24504. mustReturn: boolean;
  24505. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  24506. renderSelf: boolean[];
  24507. hardwareInstancedRendering: boolean[];
  24508. }
  24509. /**
  24510. * Class used to represent renderable models
  24511. */
  24512. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  24513. /**
  24514. * Mesh side orientation : usually the external or front surface
  24515. */
  24516. static readonly FRONTSIDE: number;
  24517. /**
  24518. * Mesh side orientation : usually the internal or back surface
  24519. */
  24520. static readonly BACKSIDE: number;
  24521. /**
  24522. * Mesh side orientation : both internal and external or front and back surfaces
  24523. */
  24524. static readonly DOUBLESIDE: number;
  24525. /**
  24526. * Mesh side orientation : by default, `FRONTSIDE`
  24527. */
  24528. static readonly DEFAULTSIDE: number;
  24529. /**
  24530. * Mesh cap setting : no cap
  24531. */
  24532. static readonly NO_CAP: number;
  24533. /**
  24534. * Mesh cap setting : one cap at the beginning of the mesh
  24535. */
  24536. static readonly CAP_START: number;
  24537. /**
  24538. * Mesh cap setting : one cap at the end of the mesh
  24539. */
  24540. static readonly CAP_END: number;
  24541. /**
  24542. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  24543. */
  24544. static readonly CAP_ALL: number;
  24545. /**
  24546. * Mesh pattern setting : no flip or rotate
  24547. */
  24548. static readonly NO_FLIP: number;
  24549. /**
  24550. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  24551. */
  24552. static readonly FLIP_TILE: number;
  24553. /**
  24554. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  24555. */
  24556. static readonly ROTATE_TILE: number;
  24557. /**
  24558. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  24559. */
  24560. static readonly FLIP_ROW: number;
  24561. /**
  24562. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  24563. */
  24564. static readonly ROTATE_ROW: number;
  24565. /**
  24566. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  24567. */
  24568. static readonly FLIP_N_ROTATE_TILE: number;
  24569. /**
  24570. * Mesh pattern setting : rotate pattern and rotate
  24571. */
  24572. static readonly FLIP_N_ROTATE_ROW: number;
  24573. /**
  24574. * Mesh tile positioning : part tiles same on left/right or top/bottom
  24575. */
  24576. static readonly CENTER: number;
  24577. /**
  24578. * Mesh tile positioning : part tiles on left
  24579. */
  24580. static readonly LEFT: number;
  24581. /**
  24582. * Mesh tile positioning : part tiles on right
  24583. */
  24584. static readonly RIGHT: number;
  24585. /**
  24586. * Mesh tile positioning : part tiles on top
  24587. */
  24588. static readonly TOP: number;
  24589. /**
  24590. * Mesh tile positioning : part tiles on bottom
  24591. */
  24592. static readonly BOTTOM: number;
  24593. /**
  24594. * Gets the default side orientation.
  24595. * @param orientation the orientation to value to attempt to get
  24596. * @returns the default orientation
  24597. * @hidden
  24598. */
  24599. static _GetDefaultSideOrientation(orientation?: number): number;
  24600. private _internalMeshDataInfo;
  24601. /**
  24602. * An event triggered before rendering the mesh
  24603. */
  24604. readonly onBeforeRenderObservable: Observable<Mesh>;
  24605. /**
  24606. * An event triggered before binding the mesh
  24607. */
  24608. readonly onBeforeBindObservable: Observable<Mesh>;
  24609. /**
  24610. * An event triggered after rendering the mesh
  24611. */
  24612. readonly onAfterRenderObservable: Observable<Mesh>;
  24613. /**
  24614. * An event triggered before drawing the mesh
  24615. */
  24616. readonly onBeforeDrawObservable: Observable<Mesh>;
  24617. private _onBeforeDrawObserver;
  24618. /**
  24619. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  24620. */
  24621. onBeforeDraw: () => void;
  24622. readonly hasInstances: boolean;
  24623. /**
  24624. * Gets the delay loading state of the mesh (when delay loading is turned on)
  24625. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  24626. */
  24627. delayLoadState: number;
  24628. /**
  24629. * Gets the list of instances created from this mesh
  24630. * it is not supposed to be modified manually.
  24631. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  24632. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24633. */
  24634. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  24635. /**
  24636. * Gets the file containing delay loading data for this mesh
  24637. */
  24638. delayLoadingFile: string;
  24639. /** @hidden */
  24640. _binaryInfo: any;
  24641. /**
  24642. * User defined function used to change how LOD level selection is done
  24643. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  24644. */
  24645. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  24646. /**
  24647. * Gets or sets the morph target manager
  24648. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  24649. */
  24650. morphTargetManager: Nullable<MorphTargetManager>;
  24651. /** @hidden */
  24652. _creationDataStorage: Nullable<_CreationDataStorage>;
  24653. /** @hidden */
  24654. _geometry: Nullable<Geometry>;
  24655. /** @hidden */
  24656. _delayInfo: Array<string>;
  24657. /** @hidden */
  24658. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  24659. /** @hidden */
  24660. _instanceDataStorage: _InstanceDataStorage;
  24661. private _effectiveMaterial;
  24662. /** @hidden */
  24663. _shouldGenerateFlatShading: boolean;
  24664. /** @hidden */
  24665. _originalBuilderSideOrientation: number;
  24666. /**
  24667. * Use this property to change the original side orientation defined at construction time
  24668. */
  24669. overrideMaterialSideOrientation: Nullable<number>;
  24670. /**
  24671. * Gets the source mesh (the one used to clone this one from)
  24672. */
  24673. readonly source: Nullable<Mesh>;
  24674. /**
  24675. * Gets or sets a boolean indicating that this mesh does not use index buffer
  24676. */
  24677. isUnIndexed: boolean;
  24678. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  24679. readonly worldMatrixInstancedBuffer: Float32Array;
  24680. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  24681. manualUpdateOfWorldMatrixInstancedBuffer: boolean;
  24682. /**
  24683. * @constructor
  24684. * @param name The value used by scene.getMeshByName() to do a lookup.
  24685. * @param scene The scene to add this mesh to.
  24686. * @param parent The parent of this mesh, if it has one
  24687. * @param source An optional Mesh from which geometry is shared, cloned.
  24688. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  24689. * When false, achieved by calling a clone(), also passing False.
  24690. * This will make creation of children, recursive.
  24691. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  24692. */
  24693. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  24694. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  24695. doNotInstantiate: boolean;
  24696. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  24697. /**
  24698. * Gets the class name
  24699. * @returns the string "Mesh".
  24700. */
  24701. getClassName(): string;
  24702. /** @hidden */
  24703. readonly _isMesh: boolean;
  24704. /**
  24705. * Returns a description of this mesh
  24706. * @param fullDetails define if full details about this mesh must be used
  24707. * @returns a descriptive string representing this mesh
  24708. */
  24709. toString(fullDetails?: boolean): string;
  24710. /** @hidden */
  24711. _unBindEffect(): void;
  24712. /**
  24713. * Gets a boolean indicating if this mesh has LOD
  24714. */
  24715. readonly hasLODLevels: boolean;
  24716. /**
  24717. * Gets the list of MeshLODLevel associated with the current mesh
  24718. * @returns an array of MeshLODLevel
  24719. */
  24720. getLODLevels(): MeshLODLevel[];
  24721. private _sortLODLevels;
  24722. /**
  24723. * Add a mesh as LOD level triggered at the given distance.
  24724. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24725. * @param distance The distance from the center of the object to show this level
  24726. * @param mesh The mesh to be added as LOD level (can be null)
  24727. * @return This mesh (for chaining)
  24728. */
  24729. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  24730. /**
  24731. * Returns the LOD level mesh at the passed distance or null if not found.
  24732. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24733. * @param distance The distance from the center of the object to show this level
  24734. * @returns a Mesh or `null`
  24735. */
  24736. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  24737. /**
  24738. * Remove a mesh from the LOD array
  24739. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24740. * @param mesh defines the mesh to be removed
  24741. * @return This mesh (for chaining)
  24742. */
  24743. removeLODLevel(mesh: Mesh): Mesh;
  24744. /**
  24745. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  24746. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24747. * @param camera defines the camera to use to compute distance
  24748. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  24749. * @return This mesh (for chaining)
  24750. */
  24751. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  24752. /**
  24753. * Gets the mesh internal Geometry object
  24754. */
  24755. readonly geometry: Nullable<Geometry>;
  24756. /**
  24757. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  24758. * @returns the total number of vertices
  24759. */
  24760. getTotalVertices(): number;
  24761. /**
  24762. * Returns the content of an associated vertex buffer
  24763. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24764. * - VertexBuffer.PositionKind
  24765. * - VertexBuffer.UVKind
  24766. * - VertexBuffer.UV2Kind
  24767. * - VertexBuffer.UV3Kind
  24768. * - VertexBuffer.UV4Kind
  24769. * - VertexBuffer.UV5Kind
  24770. * - VertexBuffer.UV6Kind
  24771. * - VertexBuffer.ColorKind
  24772. * - VertexBuffer.MatricesIndicesKind
  24773. * - VertexBuffer.MatricesIndicesExtraKind
  24774. * - VertexBuffer.MatricesWeightsKind
  24775. * - VertexBuffer.MatricesWeightsExtraKind
  24776. * @param copyWhenShared defines a boolean indicating that if the mesh geometry is shared among some other meshes, the returned array is a copy of the internal one
  24777. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  24778. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  24779. */
  24780. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  24781. /**
  24782. * Returns the mesh VertexBuffer object from the requested `kind`
  24783. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24784. * - VertexBuffer.PositionKind
  24785. * - VertexBuffer.NormalKind
  24786. * - VertexBuffer.UVKind
  24787. * - VertexBuffer.UV2Kind
  24788. * - VertexBuffer.UV3Kind
  24789. * - VertexBuffer.UV4Kind
  24790. * - VertexBuffer.UV5Kind
  24791. * - VertexBuffer.UV6Kind
  24792. * - VertexBuffer.ColorKind
  24793. * - VertexBuffer.MatricesIndicesKind
  24794. * - VertexBuffer.MatricesIndicesExtraKind
  24795. * - VertexBuffer.MatricesWeightsKind
  24796. * - VertexBuffer.MatricesWeightsExtraKind
  24797. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  24798. */
  24799. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  24800. /**
  24801. * Tests if a specific vertex buffer is associated with this mesh
  24802. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24803. * - VertexBuffer.PositionKind
  24804. * - VertexBuffer.NormalKind
  24805. * - VertexBuffer.UVKind
  24806. * - VertexBuffer.UV2Kind
  24807. * - VertexBuffer.UV3Kind
  24808. * - VertexBuffer.UV4Kind
  24809. * - VertexBuffer.UV5Kind
  24810. * - VertexBuffer.UV6Kind
  24811. * - VertexBuffer.ColorKind
  24812. * - VertexBuffer.MatricesIndicesKind
  24813. * - VertexBuffer.MatricesIndicesExtraKind
  24814. * - VertexBuffer.MatricesWeightsKind
  24815. * - VertexBuffer.MatricesWeightsExtraKind
  24816. * @returns a boolean
  24817. */
  24818. isVerticesDataPresent(kind: string): boolean;
  24819. /**
  24820. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  24821. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24822. * - VertexBuffer.PositionKind
  24823. * - VertexBuffer.UVKind
  24824. * - VertexBuffer.UV2Kind
  24825. * - VertexBuffer.UV3Kind
  24826. * - VertexBuffer.UV4Kind
  24827. * - VertexBuffer.UV5Kind
  24828. * - VertexBuffer.UV6Kind
  24829. * - VertexBuffer.ColorKind
  24830. * - VertexBuffer.MatricesIndicesKind
  24831. * - VertexBuffer.MatricesIndicesExtraKind
  24832. * - VertexBuffer.MatricesWeightsKind
  24833. * - VertexBuffer.MatricesWeightsExtraKind
  24834. * @returns a boolean
  24835. */
  24836. isVertexBufferUpdatable(kind: string): boolean;
  24837. /**
  24838. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  24839. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24840. * - VertexBuffer.PositionKind
  24841. * - VertexBuffer.NormalKind
  24842. * - VertexBuffer.UVKind
  24843. * - VertexBuffer.UV2Kind
  24844. * - VertexBuffer.UV3Kind
  24845. * - VertexBuffer.UV4Kind
  24846. * - VertexBuffer.UV5Kind
  24847. * - VertexBuffer.UV6Kind
  24848. * - VertexBuffer.ColorKind
  24849. * - VertexBuffer.MatricesIndicesKind
  24850. * - VertexBuffer.MatricesIndicesExtraKind
  24851. * - VertexBuffer.MatricesWeightsKind
  24852. * - VertexBuffer.MatricesWeightsExtraKind
  24853. * @returns an array of strings
  24854. */
  24855. getVerticesDataKinds(): string[];
  24856. /**
  24857. * Returns a positive integer : the total number of indices in this mesh geometry.
  24858. * @returns the numner of indices or zero if the mesh has no geometry.
  24859. */
  24860. getTotalIndices(): number;
  24861. /**
  24862. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  24863. * @param copyWhenShared If true (default false) and and if the mesh geometry is shared among some other meshes, the returned array is a copy of the internal one.
  24864. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24865. * @returns the indices array or an empty array if the mesh has no geometry
  24866. */
  24867. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  24868. readonly isBlocked: boolean;
  24869. /**
  24870. * Determine if the current mesh is ready to be rendered
  24871. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  24872. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  24873. * @returns true if all associated assets are ready (material, textures, shaders)
  24874. */
  24875. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  24876. /**
  24877. * Gets a boolean indicating if the normals aren't to be recomputed on next mesh `positions` array update. This property is pertinent only for updatable parametric shapes.
  24878. */
  24879. readonly areNormalsFrozen: boolean;
  24880. /**
  24881. * This function affects parametric shapes on vertex position update only : ribbons, tubes, etc. It has no effect at all on other shapes. It prevents the mesh normals from being recomputed on next `positions` array update.
  24882. * @returns the current mesh
  24883. */
  24884. freezeNormals(): Mesh;
  24885. /**
  24886. * This function affects parametric shapes on vertex position update only : ribbons, tubes, etc. It has no effect at all on other shapes. It reactivates the mesh normals computation if it was previously frozen
  24887. * @returns the current mesh
  24888. */
  24889. unfreezeNormals(): Mesh;
  24890. /**
  24891. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  24892. */
  24893. overridenInstanceCount: number;
  24894. /** @hidden */
  24895. _preActivate(): Mesh;
  24896. /** @hidden */
  24897. _preActivateForIntermediateRendering(renderId: number): Mesh;
  24898. /** @hidden */
  24899. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  24900. /**
  24901. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  24902. * This means the mesh underlying bounding box and sphere are recomputed.
  24903. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  24904. * @returns the current mesh
  24905. */
  24906. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  24907. /** @hidden */
  24908. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  24909. /**
  24910. * This function will subdivide the mesh into multiple submeshes
  24911. * @param count defines the expected number of submeshes
  24912. */
  24913. subdivide(count: number): void;
  24914. /**
  24915. * Copy a FloatArray into a specific associated vertex buffer
  24916. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24917. * - VertexBuffer.PositionKind
  24918. * - VertexBuffer.UVKind
  24919. * - VertexBuffer.UV2Kind
  24920. * - VertexBuffer.UV3Kind
  24921. * - VertexBuffer.UV4Kind
  24922. * - VertexBuffer.UV5Kind
  24923. * - VertexBuffer.UV6Kind
  24924. * - VertexBuffer.ColorKind
  24925. * - VertexBuffer.MatricesIndicesKind
  24926. * - VertexBuffer.MatricesIndicesExtraKind
  24927. * - VertexBuffer.MatricesWeightsKind
  24928. * - VertexBuffer.MatricesWeightsExtraKind
  24929. * @param data defines the data source
  24930. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24931. * @param stride defines the data stride size (can be null)
  24932. * @returns the current mesh
  24933. */
  24934. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  24935. /**
  24936. * Delete a vertex buffer associated with this mesh
  24937. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  24938. * - VertexBuffer.PositionKind
  24939. * - VertexBuffer.UVKind
  24940. * - VertexBuffer.UV2Kind
  24941. * - VertexBuffer.UV3Kind
  24942. * - VertexBuffer.UV4Kind
  24943. * - VertexBuffer.UV5Kind
  24944. * - VertexBuffer.UV6Kind
  24945. * - VertexBuffer.ColorKind
  24946. * - VertexBuffer.MatricesIndicesKind
  24947. * - VertexBuffer.MatricesIndicesExtraKind
  24948. * - VertexBuffer.MatricesWeightsKind
  24949. * - VertexBuffer.MatricesWeightsExtraKind
  24950. */
  24951. removeVerticesData(kind: string): void;
  24952. /**
  24953. * Flags an associated vertex buffer as updatable
  24954. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  24955. * - VertexBuffer.PositionKind
  24956. * - VertexBuffer.UVKind
  24957. * - VertexBuffer.UV2Kind
  24958. * - VertexBuffer.UV3Kind
  24959. * - VertexBuffer.UV4Kind
  24960. * - VertexBuffer.UV5Kind
  24961. * - VertexBuffer.UV6Kind
  24962. * - VertexBuffer.ColorKind
  24963. * - VertexBuffer.MatricesIndicesKind
  24964. * - VertexBuffer.MatricesIndicesExtraKind
  24965. * - VertexBuffer.MatricesWeightsKind
  24966. * - VertexBuffer.MatricesWeightsExtraKind
  24967. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24968. */
  24969. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  24970. /**
  24971. * Sets the mesh global Vertex Buffer
  24972. * @param buffer defines the buffer to use
  24973. * @returns the current mesh
  24974. */
  24975. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  24976. /**
  24977. * Update a specific associated vertex buffer
  24978. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24979. * - VertexBuffer.PositionKind
  24980. * - VertexBuffer.UVKind
  24981. * - VertexBuffer.UV2Kind
  24982. * - VertexBuffer.UV3Kind
  24983. * - VertexBuffer.UV4Kind
  24984. * - VertexBuffer.UV5Kind
  24985. * - VertexBuffer.UV6Kind
  24986. * - VertexBuffer.ColorKind
  24987. * - VertexBuffer.MatricesIndicesKind
  24988. * - VertexBuffer.MatricesIndicesExtraKind
  24989. * - VertexBuffer.MatricesWeightsKind
  24990. * - VertexBuffer.MatricesWeightsExtraKind
  24991. * @param data defines the data source
  24992. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  24993. * @param makeItUnique defines if the geometry associated with the mesh must be cloned to make the change only for this mesh (and not all meshes associated with the same geometry)
  24994. * @returns the current mesh
  24995. */
  24996. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  24997. /**
  24998. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  24999. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  25000. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  25001. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  25002. * @returns the current mesh
  25003. */
  25004. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  25005. /**
  25006. * Creates a un-shared specific occurence of the geometry for the mesh.
  25007. * @returns the current mesh
  25008. */
  25009. makeGeometryUnique(): Mesh;
  25010. /**
  25011. * Set the index buffer of this mesh
  25012. * @param indices defines the source data
  25013. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  25014. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  25015. * @returns the current mesh
  25016. */
  25017. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  25018. /**
  25019. * Update the current index buffer
  25020. * @param indices defines the source data
  25021. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  25022. * @param gpuMemoryOnly defines a boolean indicating that only the GPU memory must be updated leaving the CPU version of the indices unchanged (false by default)
  25023. * @returns the current mesh
  25024. */
  25025. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  25026. /**
  25027. * Invert the geometry to move from a right handed system to a left handed one.
  25028. * @returns the current mesh
  25029. */
  25030. toLeftHanded(): Mesh;
  25031. /** @hidden */
  25032. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  25033. /** @hidden */
  25034. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  25035. /**
  25036. * Registers for this mesh a javascript function called just before the rendering process
  25037. * @param func defines the function to call before rendering this mesh
  25038. * @returns the current mesh
  25039. */
  25040. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  25041. /**
  25042. * Disposes a previously registered javascript function called before the rendering
  25043. * @param func defines the function to remove
  25044. * @returns the current mesh
  25045. */
  25046. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  25047. /**
  25048. * Registers for this mesh a javascript function called just after the rendering is complete
  25049. * @param func defines the function to call after rendering this mesh
  25050. * @returns the current mesh
  25051. */
  25052. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  25053. /**
  25054. * Disposes a previously registered javascript function called after the rendering.
  25055. * @param func defines the function to remove
  25056. * @returns the current mesh
  25057. */
  25058. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  25059. /** @hidden */
  25060. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  25061. /** @hidden */
  25062. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  25063. /** @hidden */
  25064. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  25065. /** @hidden */
  25066. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  25067. /** @hidden */
  25068. _rebuild(): void;
  25069. /** @hidden */
  25070. _freeze(): void;
  25071. /** @hidden */
  25072. _unFreeze(): void;
  25073. /**
  25074. * Triggers the draw call for the mesh. Usually, you don't need to call this method by your own because the mesh rendering is handled by the scene rendering manager
  25075. * @param subMesh defines the subMesh to render
  25076. * @param enableAlphaMode defines if alpha mode can be changed
  25077. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  25078. * @returns the current mesh
  25079. */
  25080. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  25081. private _onBeforeDraw;
  25082. /**
  25083. * Renormalize the mesh and patch it up if there are no weights
  25084. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  25085. * However in the case of zero weights then we set just a single influence to 1.
  25086. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  25087. */
  25088. cleanMatrixWeights(): void;
  25089. private normalizeSkinFourWeights;
  25090. private normalizeSkinWeightsAndExtra;
  25091. /**
  25092. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  25093. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  25094. * the user know there was an issue with importing the mesh
  25095. * @returns a validation object with skinned, valid and report string
  25096. */
  25097. validateSkinning(): {
  25098. skinned: boolean;
  25099. valid: boolean;
  25100. report: string;
  25101. };
  25102. /** @hidden */
  25103. _checkDelayState(): Mesh;
  25104. private _queueLoad;
  25105. /**
  25106. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  25107. * A mesh is in the frustum if its bounding box intersects the frustum
  25108. * @param frustumPlanes defines the frustum to test
  25109. * @returns true if the mesh is in the frustum planes
  25110. */
  25111. isInFrustum(frustumPlanes: Plane[]): boolean;
  25112. /**
  25113. * Sets the mesh material by the material or multiMaterial `id` property
  25114. * @param id is a string identifying the material or the multiMaterial
  25115. * @returns the current mesh
  25116. */
  25117. setMaterialByID(id: string): Mesh;
  25118. /**
  25119. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  25120. * @returns an array of IAnimatable
  25121. */
  25122. getAnimatables(): IAnimatable[];
  25123. /**
  25124. * Modifies the mesh geometry according to the passed transformation matrix.
  25125. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  25126. * The mesh normals are modified using the same transformation.
  25127. * Note that, under the hood, this method sets a new VertexBuffer each call.
  25128. * @param transform defines the transform matrix to use
  25129. * @see http://doc.babylonjs.com/resources/baking_transformations
  25130. * @returns the current mesh
  25131. */
  25132. bakeTransformIntoVertices(transform: Matrix): Mesh;
  25133. /**
  25134. * Modifies the mesh geometry according to its own current World Matrix.
  25135. * The mesh World Matrix is then reset.
  25136. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  25137. * Note that, under the hood, this method sets a new VertexBuffer each call.
  25138. * @see http://doc.babylonjs.com/resources/baking_transformations
  25139. * @returns the current mesh
  25140. */
  25141. bakeCurrentTransformIntoVertices(): Mesh;
  25142. /** @hidden */
  25143. readonly _positions: Nullable<Vector3[]>;
  25144. /** @hidden */
  25145. _resetPointsArrayCache(): Mesh;
  25146. /** @hidden */
  25147. _generatePointsArray(): boolean;
  25148. /**
  25149. * Returns a new Mesh object generated from the current mesh properties.
  25150. * This method must not get confused with createInstance()
  25151. * @param name is a string, the name given to the new mesh
  25152. * @param newParent can be any Node object (default `null`)
  25153. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  25154. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  25155. * @returns a new mesh
  25156. */
  25157. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Nullable<AbstractMesh>;
  25158. /**
  25159. * Releases resources associated with this mesh.
  25160. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25161. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25162. */
  25163. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25164. /** @hidden */
  25165. _disposeInstanceSpecificData(): void;
  25166. /**
  25167. * Modifies the mesh geometry according to a displacement map.
  25168. * A displacement map is a colored image. Each pixel color value (actually a gradient computed from red, green, blue values) will give the displacement to apply to each mesh vertex.
  25169. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  25170. * @param url is a string, the URL from the image file is to be downloaded.
  25171. * @param minHeight is the lower limit of the displacement.
  25172. * @param maxHeight is the upper limit of the displacement.
  25173. * @param onSuccess is an optional Javascript function to be called just after the mesh is modified. It is passed the modified mesh and must return nothing.
  25174. * @param uvOffset is an optional vector2 used to offset UV.
  25175. * @param uvScale is an optional vector2 used to scale UV.
  25176. * @param forceUpdate defines whether or not to force an update of the generated buffers. This is useful to apply on a deserialized model for instance.
  25177. * @returns the Mesh.
  25178. */
  25179. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  25180. /**
  25181. * Modifies the mesh geometry according to a displacementMap buffer.
  25182. * A displacement map is a colored image. Each pixel color value (actually a gradient computed from red, green, blue values) will give the displacement to apply to each mesh vertex.
  25183. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  25184. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  25185. * @param heightMapWidth is the width of the buffer image.
  25186. * @param heightMapHeight is the height of the buffer image.
  25187. * @param minHeight is the lower limit of the displacement.
  25188. * @param maxHeight is the upper limit of the displacement.
  25189. * @param onSuccess is an optional Javascript function to be called just after the mesh is modified. It is passed the modified mesh and must return nothing.
  25190. * @param uvOffset is an optional vector2 used to offset UV.
  25191. * @param uvScale is an optional vector2 used to scale UV.
  25192. * @param forceUpdate defines whether or not to force an update of the generated buffers. This is useful to apply on a deserialized model for instance.
  25193. * @returns the Mesh.
  25194. */
  25195. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  25196. /**
  25197. * Modify the mesh to get a flat shading rendering.
  25198. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  25199. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  25200. * @returns current mesh
  25201. */
  25202. convertToFlatShadedMesh(): Mesh;
  25203. /**
  25204. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  25205. * In other words, more vertices, no more indices and a single bigger VBO.
  25206. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  25207. * @returns current mesh
  25208. */
  25209. convertToUnIndexedMesh(): Mesh;
  25210. /**
  25211. * Inverses facet orientations.
  25212. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25213. * @param flipNormals will also inverts the normals
  25214. * @returns current mesh
  25215. */
  25216. flipFaces(flipNormals?: boolean): Mesh;
  25217. /**
  25218. * Increase the number of facets and hence vertices in a mesh
  25219. * Vertex normals are interpolated from existing vertex normals
  25220. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25221. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  25222. */
  25223. increaseVertices(numberPerEdge: number): void;
  25224. /**
  25225. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  25226. * This will undo any application of covertToFlatShadedMesh
  25227. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25228. */
  25229. forceSharedVertices(): void;
  25230. /** @hidden */
  25231. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  25232. /** @hidden */
  25233. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  25234. /**
  25235. * Creates a new InstancedMesh object from the mesh model.
  25236. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  25237. * @param name defines the name of the new instance
  25238. * @returns a new InstancedMesh
  25239. */
  25240. createInstance(name: string): InstancedMesh;
  25241. /**
  25242. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  25243. * After this call, all the mesh instances have the same submeshes than the current mesh.
  25244. * @returns the current mesh
  25245. */
  25246. synchronizeInstances(): Mesh;
  25247. /**
  25248. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  25249. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  25250. * This should be used together with the simplification to avoid disappearing triangles.
  25251. * @param successCallback an optional success callback to be called after the optimization finished.
  25252. * @returns the current mesh
  25253. */
  25254. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  25255. /**
  25256. * Serialize current mesh
  25257. * @param serializationObject defines the object which will receive the serialization data
  25258. */
  25259. serialize(serializationObject: any): void;
  25260. /** @hidden */
  25261. _syncGeometryWithMorphTargetManager(): void;
  25262. /** @hidden */
  25263. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  25264. /**
  25265. * Returns a new Mesh object parsed from the source provided.
  25266. * @param parsedMesh is the source
  25267. * @param scene defines the hosting scene
  25268. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  25269. * @returns a new Mesh
  25270. */
  25271. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  25272. /**
  25273. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  25274. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25275. * @param name defines the name of the mesh to create
  25276. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  25277. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  25278. * @param closePath creates a seam between the first and the last points of each path of the path array
  25279. * @param offset is taken in account only if the `pathArray` is containing a single path
  25280. * @param scene defines the hosting scene
  25281. * @param updatable defines if the mesh must be flagged as updatable
  25282. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25283. * @param instance defines an instance of an existing Ribbon object to be updated with the passed `pathArray` parameter (http://doc.babylonjs.com/how_to/How_to_dynamically_morph_a_mesh#ribbon)
  25284. * @returns a new Mesh
  25285. */
  25286. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25287. /**
  25288. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  25289. * @param name defines the name of the mesh to create
  25290. * @param radius sets the radius size (float) of the polygon (default 0.5)
  25291. * @param tessellation sets the number of polygon sides (positive integer, default 64). So a tessellation valued to 3 will build a triangle, to 4 a square, etc
  25292. * @param scene defines the hosting scene
  25293. * @param updatable defines if the mesh must be flagged as updatable
  25294. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25295. * @returns a new Mesh
  25296. */
  25297. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  25298. /**
  25299. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  25300. * @param name defines the name of the mesh to create
  25301. * @param size sets the size (float) of each box side (default 1)
  25302. * @param scene defines the hosting scene
  25303. * @param updatable defines if the mesh must be flagged as updatable
  25304. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25305. * @returns a new Mesh
  25306. */
  25307. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  25308. /**
  25309. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  25310. * @param name defines the name of the mesh to create
  25311. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  25312. * @param diameter sets the diameter size (float) of the sphere (default 1)
  25313. * @param scene defines the hosting scene
  25314. * @param updatable defines if the mesh must be flagged as updatable
  25315. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25316. * @returns a new Mesh
  25317. */
  25318. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25319. /**
  25320. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  25321. * @param name defines the name of the mesh to create
  25322. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  25323. * @param diameter sets the diameter size (float) of the sphere (default 1)
  25324. * @param scene defines the hosting scene
  25325. * @returns a new Mesh
  25326. */
  25327. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  25328. /**
  25329. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  25330. * @param name defines the name of the mesh to create
  25331. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  25332. * @param diameterTop set the top cap diameter (floats, default 1)
  25333. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  25334. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  25335. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  25336. * @param scene defines the hosting scene
  25337. * @param updatable defines if the mesh must be flagged as updatable
  25338. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25339. * @returns a new Mesh
  25340. */
  25341. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  25342. /**
  25343. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  25344. * @param name defines the name of the mesh to create
  25345. * @param diameter sets the diameter size (float) of the torus (default 1)
  25346. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  25347. * @param tessellation sets the number of torus sides (postive integer, default 16)
  25348. * @param scene defines the hosting scene
  25349. * @param updatable defines if the mesh must be flagged as updatable
  25350. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25351. * @returns a new Mesh
  25352. */
  25353. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25354. /**
  25355. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  25356. * @param name defines the name of the mesh to create
  25357. * @param radius sets the global radius size (float) of the torus knot (default 2)
  25358. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  25359. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  25360. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  25361. * @param p the number of windings on X axis (positive integers, default 2)
  25362. * @param q the number of windings on Y axis (positive integers, default 3)
  25363. * @param scene defines the hosting scene
  25364. * @param updatable defines if the mesh must be flagged as updatable
  25365. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25366. * @returns a new Mesh
  25367. */
  25368. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25369. /**
  25370. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  25371. * @param name defines the name of the mesh to create
  25372. * @param points is an array successive Vector3
  25373. * @param scene defines the hosting scene
  25374. * @param updatable defines if the mesh must be flagged as updatable
  25375. * @param instance is an instance of an existing LineMesh object to be updated with the passed `points` parameter (http://doc.babylonjs.com/how_to/How_to_dynamically_morph_a_mesh#lines-and-dashedlines).
  25376. * @returns a new Mesh
  25377. */
  25378. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  25379. /**
  25380. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  25381. * @param name defines the name of the mesh to create
  25382. * @param points is an array successive Vector3
  25383. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  25384. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  25385. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  25386. * @param scene defines the hosting scene
  25387. * @param updatable defines if the mesh must be flagged as updatable
  25388. * @param instance is an instance of an existing LineMesh object to be updated with the passed `points` parameter (http://doc.babylonjs.com/how_to/How_to_dynamically_morph_a_mesh#lines-and-dashedlines)
  25389. * @returns a new Mesh
  25390. */
  25391. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  25392. /**
  25393. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  25394. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  25395. * The parameter `shape` is a required array of successive Vector3 representing the corners of the polygon in th XoZ plane, that is y = 0 for all vectors.
  25396. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25397. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  25398. * Remember you can only change the shape positions, not their number when updating a polygon.
  25399. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  25400. * @param name defines the name of the mesh to create
  25401. * @param shape is a required array of successive Vector3 representing the corners of the polygon in th XoZ plane, that is y = 0 for all vectors
  25402. * @param scene defines the hosting scene
  25403. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25404. * @param updatable defines if the mesh must be flagged as updatable
  25405. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25406. * @param earcutInjection can be used to inject your own earcut reference
  25407. * @returns a new Mesh
  25408. */
  25409. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25410. /**
  25411. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  25412. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  25413. * @param name defines the name of the mesh to create
  25414. * @param shape is a required array of successive Vector3 representing the corners of the polygon in th XoZ plane, that is y = 0 for all vectors
  25415. * @param depth defines the height of extrusion
  25416. * @param scene defines the hosting scene
  25417. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25418. * @param updatable defines if the mesh must be flagged as updatable
  25419. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25420. * @param earcutInjection can be used to inject your own earcut reference
  25421. * @returns a new Mesh
  25422. */
  25423. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25424. /**
  25425. * Creates an extruded shape mesh.
  25426. * The extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters. Please consider using the same method from the MeshBuilder class instead
  25427. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25428. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25429. * @param name defines the name of the mesh to create
  25430. * @param shape is a required array of successive Vector3. This array depicts the shape to be extruded in its local space : the shape must be designed in the xOy plane and will be extruded along the Z axis
  25431. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25432. * @param scale is the value to scale the shape
  25433. * @param rotation is the angle value to rotate the shape each step (each path point), from the former step (so rotation added each step) along the curve
  25434. * @param cap sets the way the extruded shape is capped. Possible values : Mesh.NO_CAP (default), Mesh.CAP_START, Mesh.CAP_END, Mesh.CAP_ALL
  25435. * @param scene defines the hosting scene
  25436. * @param updatable defines if the mesh must be flagged as updatable
  25437. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25438. * @param instance is an instance of an existing ExtrudedShape object to be updated with the passed `shape`, `path`, `scale` or `rotation` parameters (http://doc.babylonjs.com/how_to/How_to_dynamically_morph_a_mesh#extruded-shape)
  25439. * @returns a new Mesh
  25440. */
  25441. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25442. /**
  25443. * Creates an custom extruded shape mesh.
  25444. * The custom extrusion is a parametric shape.
  25445. * It has no predefined shape. Its final shape will depend on the input parameters.
  25446. * Please consider using the same method from the MeshBuilder class instead
  25447. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25448. * @param name defines the name of the mesh to create
  25449. * @param shape is a required array of successive Vector3. This array depicts the shape to be extruded in its local space : the shape must be designed in the xOy plane and will be extruded along the Z axis
  25450. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25451. * @param scaleFunction is a custom Javascript function called on each path point
  25452. * @param rotationFunction is a custom Javascript function called on each path point
  25453. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  25454. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  25455. * @param cap sets the way the extruded shape is capped. Possible values : Mesh.NO_CAP (default), Mesh.CAP_START, Mesh.CAP_END, Mesh.CAP_ALL
  25456. * @param scene defines the hosting scene
  25457. * @param updatable defines if the mesh must be flagged as updatable
  25458. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25459. * @param instance is an instance of an existing ExtrudedShape object to be updated with the passed `shape`, `path`, `scale` or `rotation` parameters (http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#extruded-shape)
  25460. * @returns a new Mesh
  25461. */
  25462. static ExtrudeShapeCustom(name: string, shape: Vector3[], path: Vector3[], scaleFunction: Function, rotationFunction: Function, ribbonCloseArray: boolean, ribbonClosePath: boolean, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25463. /**
  25464. * Creates lathe mesh.
  25465. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  25466. * Please consider using the same method from the MeshBuilder class instead
  25467. * @param name defines the name of the mesh to create
  25468. * @param shape is a required array of successive Vector3. This array depicts the shape to be rotated in its local space : the shape must be designed in the xOy plane and will be rotated around the Y axis. It's usually a 2D shape, so the Vector3 z coordinates are often set to zero
  25469. * @param radius is the radius value of the lathe
  25470. * @param tessellation is the side number of the lathe.
  25471. * @param scene defines the hosting scene
  25472. * @param updatable defines if the mesh must be flagged as updatable
  25473. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25474. * @returns a new Mesh
  25475. */
  25476. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25477. /**
  25478. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  25479. * @param name defines the name of the mesh to create
  25480. * @param size sets the size (float) of both sides of the plane at once (default 1)
  25481. * @param scene defines the hosting scene
  25482. * @param updatable defines if the mesh must be flagged as updatable
  25483. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25484. * @returns a new Mesh
  25485. */
  25486. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25487. /**
  25488. * Creates a ground mesh.
  25489. * Please consider using the same method from the MeshBuilder class instead
  25490. * @param name defines the name of the mesh to create
  25491. * @param width set the width of the ground
  25492. * @param height set the height of the ground
  25493. * @param subdivisions sets the number of subdivisions per side
  25494. * @param scene defines the hosting scene
  25495. * @param updatable defines if the mesh must be flagged as updatable
  25496. * @returns a new Mesh
  25497. */
  25498. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  25499. /**
  25500. * Creates a tiled ground mesh.
  25501. * Please consider using the same method from the MeshBuilder class instead
  25502. * @param name defines the name of the mesh to create
  25503. * @param xmin set the ground minimum X coordinate
  25504. * @param zmin set the ground minimum Y coordinate
  25505. * @param xmax set the ground maximum X coordinate
  25506. * @param zmax set the ground maximum Z coordinate
  25507. * @param subdivisions is an object `{w: positive integer, h: positive integer}` (default `{w: 6, h: 6}`). `w` and `h` are the numbers of subdivisions on the ground width and height. Each subdivision is called a tile
  25508. * @param precision is an object `{w: positive integer, h: positive integer}` (default `{w: 2, h: 2}`). `w` and `h` are the numbers of subdivisions on the ground width and height of each tile
  25509. * @param scene defines the hosting scene
  25510. * @param updatable defines if the mesh must be flagged as updatable
  25511. * @returns a new Mesh
  25512. */
  25513. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  25514. w: number;
  25515. h: number;
  25516. }, precision: {
  25517. w: number;
  25518. h: number;
  25519. }, scene: Scene, updatable?: boolean): Mesh;
  25520. /**
  25521. * Creates a ground mesh from a height map.
  25522. * Please consider using the same method from the MeshBuilder class instead
  25523. * @see http://doc.babylonjs.com/babylon101/height_map
  25524. * @param name defines the name of the mesh to create
  25525. * @param url sets the URL of the height map image resource
  25526. * @param width set the ground width size
  25527. * @param height set the ground height size
  25528. * @param subdivisions sets the number of subdivision per side
  25529. * @param minHeight is the minimum altitude on the ground
  25530. * @param maxHeight is the maximum altitude on the ground
  25531. * @param scene defines the hosting scene
  25532. * @param updatable defines if the mesh must be flagged as updatable
  25533. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  25534. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  25535. * @returns a new Mesh
  25536. */
  25537. static CreateGroundFromHeightMap(name: string, url: string, width: number, height: number, subdivisions: number, minHeight: number, maxHeight: number, scene: Scene, updatable?: boolean, onReady?: (mesh: GroundMesh) => void, alphaFilter?: number): GroundMesh;
  25538. /**
  25539. * Creates a tube mesh.
  25540. * The tube is a parametric shape.
  25541. * It has no predefined shape. Its final shape will depend on the input parameters.
  25542. * Please consider using the same method from the MeshBuilder class instead
  25543. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25544. * @param name defines the name of the mesh to create
  25545. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  25546. * @param radius sets the tube radius size
  25547. * @param tessellation is the number of sides on the tubular surface
  25548. * @param radiusFunction is a custom function. If it is not null, it overwrittes the parameter `radius`. This function is called on each point of the tube path and is passed the index `i` of the i-th point and the distance of this point from the first point of the path
  25549. * @param cap sets the way the extruded shape is capped. Possible values : Mesh.NO_CAP (default), Mesh.CAP_START, Mesh.CAP_END, Mesh.CAP_ALL
  25550. * @param scene defines the hosting scene
  25551. * @param updatable defines if the mesh must be flagged as updatable
  25552. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25553. * @param instance is an instance of an existing Tube object to be updated with the passed `pathArray` parameter (http://doc.babylonjs.com/how_to/How_to_dynamically_morph_a_mesh#tube)
  25554. * @returns a new Mesh
  25555. */
  25556. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  25557. (i: number, distance: number): number;
  25558. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25559. /**
  25560. * Creates a polyhedron mesh.
  25561. * Please consider using the same method from the MeshBuilder class instead.
  25562. * * The parameter `type` (positive integer, max 14, default 0) sets the polyhedron type to build among the 15 embbeded types. Please refer to the type sheet in the tutorial to choose the wanted type
  25563. * * The parameter `size` (positive float, default 1) sets the polygon size
  25564. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  25565. * * You can build other polyhedron types than the 15 embbeded ones by setting the parameter `custom` (`polyhedronObject`, default null). If you set the parameter `custom`, this overwrittes the parameter `type`
  25566. * * A `polyhedronObject` is a formatted javascript object. You'll find a full file with pre-set polyhedra here : https://github.com/BabylonJS/Extensions/tree/master/Polyhedron
  25567. * * You can set the color and the UV of each side of the polyhedron with the parameters `faceColors` (Color4, default `(1, 1, 1, 1)`) and faceUV (Vector4, default `(0, 0, 1, 1)`)
  25568. * * To understand how to set `faceUV` or `faceColors`, please read this by considering the right number of faces of your polyhedron, instead of only 6 for the box : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  25569. * * The parameter `flat` (boolean, default true). If set to false, it gives the polyhedron a single global face, so less vertices and shared normals. In this case, `faceColors` and `faceUV` are ignored
  25570. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25571. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  25572. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25573. * @param name defines the name of the mesh to create
  25574. * @param options defines the options used to create the mesh
  25575. * @param scene defines the hosting scene
  25576. * @returns a new Mesh
  25577. */
  25578. static CreatePolyhedron(name: string, options: {
  25579. type?: number;
  25580. size?: number;
  25581. sizeX?: number;
  25582. sizeY?: number;
  25583. sizeZ?: number;
  25584. custom?: any;
  25585. faceUV?: Vector4[];
  25586. faceColors?: Color4[];
  25587. updatable?: boolean;
  25588. sideOrientation?: number;
  25589. }, scene: Scene): Mesh;
  25590. /**
  25591. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  25592. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  25593. * * You can set some different icosphere dimensions, for instance to build an ellipsoid, by using the parameters `radiusX`, `radiusY` and `radiusZ` (all by default have the same value than `radius`)
  25594. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  25595. * * The parameter `flat` (boolean, default true) gives each side its own normals. Set it to false to get a smooth continuous light reflection on the surface
  25596. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25597. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  25598. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25599. * @param name defines the name of the mesh
  25600. * @param options defines the options used to create the mesh
  25601. * @param scene defines the hosting scene
  25602. * @returns a new Mesh
  25603. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  25604. */
  25605. static CreateIcoSphere(name: string, options: {
  25606. radius?: number;
  25607. flat?: boolean;
  25608. subdivisions?: number;
  25609. sideOrientation?: number;
  25610. updatable?: boolean;
  25611. }, scene: Scene): Mesh;
  25612. /**
  25613. * Creates a decal mesh.
  25614. * Please consider using the same method from the MeshBuilder class instead.
  25615. * A decal is a mesh usually applied as a model onto the surface of another mesh
  25616. * @param name defines the name of the mesh
  25617. * @param sourceMesh defines the mesh receiving the decal
  25618. * @param position sets the position of the decal in world coordinates
  25619. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  25620. * @param size sets the decal scaling
  25621. * @param angle sets the angle to rotate the decal
  25622. * @returns a new Mesh
  25623. */
  25624. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  25625. /**
  25626. * Prepare internal position array for software CPU skinning
  25627. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  25628. */
  25629. setPositionsForCPUSkinning(): Float32Array;
  25630. /**
  25631. * Prepare internal normal array for software CPU skinning
  25632. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  25633. */
  25634. setNormalsForCPUSkinning(): Float32Array;
  25635. /**
  25636. * Updates the vertex buffer by applying transformation from the bones
  25637. * @param skeleton defines the skeleton to apply to current mesh
  25638. * @returns the current mesh
  25639. */
  25640. applySkeleton(skeleton: Skeleton): Mesh;
  25641. /**
  25642. * Returns an object containing a min and max Vector3 which are the minimum and maximum vectors of each mesh bounding box from the passed array, in the world coordinates
  25643. * @param meshes defines the list of meshes to scan
  25644. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  25645. */
  25646. static MinMax(meshes: AbstractMesh[]): {
  25647. min: Vector3;
  25648. max: Vector3;
  25649. };
  25650. /**
  25651. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  25652. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  25653. * @returns a vector3
  25654. */
  25655. static Center(meshesOrMinMaxVector: {
  25656. min: Vector3;
  25657. max: Vector3;
  25658. } | AbstractMesh[]): Vector3;
  25659. /**
  25660. * Merge the array of meshes into a single mesh for performance reasons.
  25661. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  25662. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  25663. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  25664. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  25665. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  25666. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  25667. * @returns a new mesh
  25668. */
  25669. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  25670. /** @hidden */
  25671. addInstance(instance: InstancedMesh): void;
  25672. /** @hidden */
  25673. removeInstance(instance: InstancedMesh): void;
  25674. }
  25675. }
  25676. declare module "babylonjs/Cameras/camera" {
  25677. import { SmartArray } from "babylonjs/Misc/smartArray";
  25678. import { Observable } from "babylonjs/Misc/observable";
  25679. import { Nullable } from "babylonjs/types";
  25680. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  25681. import { Scene } from "babylonjs/scene";
  25682. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  25683. import { Node } from "babylonjs/node";
  25684. import { Mesh } from "babylonjs/Meshes/mesh";
  25685. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25686. import { ICullable } from "babylonjs/Culling/boundingInfo";
  25687. import { Viewport } from "babylonjs/Maths/math.viewport";
  25688. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  25689. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  25690. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  25691. import { Ray } from "babylonjs/Culling/ray";
  25692. /**
  25693. * This is the base class of all the camera used in the application.
  25694. * @see http://doc.babylonjs.com/features/cameras
  25695. */
  25696. export class Camera extends Node {
  25697. /** @hidden */
  25698. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  25699. /**
  25700. * This is the default projection mode used by the cameras.
  25701. * It helps recreating a feeling of perspective and better appreciate depth.
  25702. * This is the best way to simulate real life cameras.
  25703. */
  25704. static readonly PERSPECTIVE_CAMERA: number;
  25705. /**
  25706. * This helps creating camera with an orthographic mode.
  25707. * Orthographic is commonly used in engineering as a means to produce object specifications that communicate dimensions unambiguously, each line of 1 unit length (cm, meter..whatever) will appear to have the same length everywhere on the drawing. This allows the drafter to dimension only a subset of lines and let the reader know that other lines of that length on the drawing are also that length in reality. Every parallel line in the drawing is also parallel in the object.
  25708. */
  25709. static readonly ORTHOGRAPHIC_CAMERA: number;
  25710. /**
  25711. * This is the default FOV mode for perspective cameras.
  25712. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  25713. */
  25714. static readonly FOVMODE_VERTICAL_FIXED: number;
  25715. /**
  25716. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  25717. */
  25718. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  25719. /**
  25720. * This specifies ther is no need for a camera rig.
  25721. * Basically only one eye is rendered corresponding to the camera.
  25722. */
  25723. static readonly RIG_MODE_NONE: number;
  25724. /**
  25725. * Simulates a camera Rig with one blue eye and one red eye.
  25726. * This can be use with 3d blue and red glasses.
  25727. */
  25728. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  25729. /**
  25730. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  25731. */
  25732. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  25733. /**
  25734. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  25735. */
  25736. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  25737. /**
  25738. * Defines that both eyes of the camera will be rendered over under each other.
  25739. */
  25740. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  25741. /**
  25742. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  25743. */
  25744. static readonly RIG_MODE_VR: number;
  25745. /**
  25746. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  25747. */
  25748. static readonly RIG_MODE_WEBVR: number;
  25749. /**
  25750. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  25751. */
  25752. static readonly RIG_MODE_CUSTOM: number;
  25753. /**
  25754. * Defines if by default attaching controls should prevent the default javascript event to continue.
  25755. */
  25756. static ForceAttachControlToAlwaysPreventDefault: boolean;
  25757. /**
  25758. * Define the input manager associated with the camera.
  25759. */
  25760. inputs: CameraInputsManager<Camera>;
  25761. /** @hidden */
  25762. _position: Vector3;
  25763. /**
  25764. * Define the current local position of the camera in the scene
  25765. */
  25766. position: Vector3;
  25767. /**
  25768. * The vector the camera should consider as up.
  25769. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  25770. */
  25771. upVector: Vector3;
  25772. /**
  25773. * Define the current limit on the left side for an orthographic camera
  25774. * In scene unit
  25775. */
  25776. orthoLeft: Nullable<number>;
  25777. /**
  25778. * Define the current limit on the right side for an orthographic camera
  25779. * In scene unit
  25780. */
  25781. orthoRight: Nullable<number>;
  25782. /**
  25783. * Define the current limit on the bottom side for an orthographic camera
  25784. * In scene unit
  25785. */
  25786. orthoBottom: Nullable<number>;
  25787. /**
  25788. * Define the current limit on the top side for an orthographic camera
  25789. * In scene unit
  25790. */
  25791. orthoTop: Nullable<number>;
  25792. /**
  25793. * Field Of View is set in Radians. (default is 0.8)
  25794. */
  25795. fov: number;
  25796. /**
  25797. * Define the minimum distance the camera can see from.
  25798. * This is important to note that the depth buffer are not infinite and the closer it starts
  25799. * the more your scene might encounter depth fighting issue.
  25800. */
  25801. minZ: number;
  25802. /**
  25803. * Define the maximum distance the camera can see to.
  25804. * This is important to note that the depth buffer are not infinite and the further it end
  25805. * the more your scene might encounter depth fighting issue.
  25806. */
  25807. maxZ: number;
  25808. /**
  25809. * Define the default inertia of the camera.
  25810. * This helps giving a smooth feeling to the camera movement.
  25811. */
  25812. inertia: number;
  25813. /**
  25814. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  25815. */
  25816. mode: number;
  25817. /**
  25818. * Define wether the camera is intermediate.
  25819. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  25820. */
  25821. isIntermediate: boolean;
  25822. /**
  25823. * Define the viewport of the camera.
  25824. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  25825. */
  25826. viewport: Viewport;
  25827. /**
  25828. * Restricts the camera to viewing objects with the same layerMask.
  25829. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  25830. */
  25831. layerMask: number;
  25832. /**
  25833. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  25834. */
  25835. fovMode: number;
  25836. /**
  25837. * Rig mode of the camera.
  25838. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  25839. * This is normally controlled byt the camera themselves as internal use.
  25840. */
  25841. cameraRigMode: number;
  25842. /**
  25843. * Defines the distance between both "eyes" in case of a RIG
  25844. */
  25845. interaxialDistance: number;
  25846. /**
  25847. * Defines if stereoscopic rendering is done side by side or over under.
  25848. */
  25849. isStereoscopicSideBySide: boolean;
  25850. /**
  25851. * Defines the list of custom render target which are rendered to and then used as the input to this camera's render. Eg. display another camera view on a TV in the main scene
  25852. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  25853. * else in the scene. (Eg. security camera)
  25854. *
  25855. * To change the final output target of the camera, camera.outputRenderTarget should be used instead (eg. webXR renders to a render target corrisponding to an HMD)
  25856. */
  25857. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  25858. /**
  25859. * When set, the camera will render to this render target instead of the default canvas
  25860. *
  25861. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  25862. */
  25863. outputRenderTarget: Nullable<RenderTargetTexture>;
  25864. /**
  25865. * Observable triggered when the camera view matrix has changed.
  25866. */
  25867. onViewMatrixChangedObservable: Observable<Camera>;
  25868. /**
  25869. * Observable triggered when the camera Projection matrix has changed.
  25870. */
  25871. onProjectionMatrixChangedObservable: Observable<Camera>;
  25872. /**
  25873. * Observable triggered when the inputs have been processed.
  25874. */
  25875. onAfterCheckInputsObservable: Observable<Camera>;
  25876. /**
  25877. * Observable triggered when reset has been called and applied to the camera.
  25878. */
  25879. onRestoreStateObservable: Observable<Camera>;
  25880. /** @hidden */
  25881. _cameraRigParams: any;
  25882. /** @hidden */
  25883. _rigCameras: Camera[];
  25884. /** @hidden */
  25885. _rigPostProcess: Nullable<PostProcess>;
  25886. protected _webvrViewMatrix: Matrix;
  25887. /** @hidden */
  25888. _skipRendering: boolean;
  25889. /** @hidden */
  25890. _projectionMatrix: Matrix;
  25891. /** @hidden */
  25892. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  25893. /** @hidden */
  25894. _activeMeshes: SmartArray<AbstractMesh>;
  25895. protected _globalPosition: Vector3;
  25896. /** @hidden */
  25897. _computedViewMatrix: Matrix;
  25898. private _doNotComputeProjectionMatrix;
  25899. private _transformMatrix;
  25900. private _frustumPlanes;
  25901. private _refreshFrustumPlanes;
  25902. private _storedFov;
  25903. private _stateStored;
  25904. /**
  25905. * Instantiates a new camera object.
  25906. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  25907. * @see http://doc.babylonjs.com/features/cameras
  25908. * @param name Defines the name of the camera in the scene
  25909. * @param position Defines the position of the camera
  25910. * @param scene Defines the scene the camera belongs too
  25911. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  25912. */
  25913. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  25914. /**
  25915. * Store current camera state (fov, position, etc..)
  25916. * @returns the camera
  25917. */
  25918. storeState(): Camera;
  25919. /**
  25920. * Restores the camera state values if it has been stored. You must call storeState() first
  25921. */
  25922. protected _restoreStateValues(): boolean;
  25923. /**
  25924. * Restored camera state. You must call storeState() first.
  25925. * @returns true if restored and false otherwise
  25926. */
  25927. restoreState(): boolean;
  25928. /**
  25929. * Gets the class name of the camera.
  25930. * @returns the class name
  25931. */
  25932. getClassName(): string;
  25933. /** @hidden */
  25934. readonly _isCamera: boolean;
  25935. /**
  25936. * Gets a string representation of the camera useful for debug purpose.
  25937. * @param fullDetails Defines that a more verboe level of logging is required
  25938. * @returns the string representation
  25939. */
  25940. toString(fullDetails?: boolean): string;
  25941. /**
  25942. * Gets the current world space position of the camera.
  25943. */
  25944. readonly globalPosition: Vector3;
  25945. /**
  25946. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  25947. * @returns the active meshe list
  25948. */
  25949. getActiveMeshes(): SmartArray<AbstractMesh>;
  25950. /**
  25951. * Check wether a mesh is part of the current active mesh list of the camera
  25952. * @param mesh Defines the mesh to check
  25953. * @returns true if active, false otherwise
  25954. */
  25955. isActiveMesh(mesh: Mesh): boolean;
  25956. /**
  25957. * Is this camera ready to be used/rendered
  25958. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  25959. * @return true if the camera is ready
  25960. */
  25961. isReady(completeCheck?: boolean): boolean;
  25962. /** @hidden */
  25963. _initCache(): void;
  25964. /** @hidden */
  25965. _updateCache(ignoreParentClass?: boolean): void;
  25966. /** @hidden */
  25967. _isSynchronized(): boolean;
  25968. /** @hidden */
  25969. _isSynchronizedViewMatrix(): boolean;
  25970. /** @hidden */
  25971. _isSynchronizedProjectionMatrix(): boolean;
  25972. /**
  25973. * Attach the input controls to a specific dom element to get the input from.
  25974. * @param element Defines the element the controls should be listened from
  25975. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  25976. */
  25977. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  25978. /**
  25979. * Detach the current controls from the specified dom element.
  25980. * @param element Defines the element to stop listening the inputs from
  25981. */
  25982. detachControl(element: HTMLElement): void;
  25983. /**
  25984. * Update the camera state according to the different inputs gathered during the frame.
  25985. */
  25986. update(): void;
  25987. /** @hidden */
  25988. _checkInputs(): void;
  25989. /** @hidden */
  25990. readonly rigCameras: Camera[];
  25991. /**
  25992. * Gets the post process used by the rig cameras
  25993. */
  25994. readonly rigPostProcess: Nullable<PostProcess>;
  25995. /**
  25996. * Internal, gets the first post proces.
  25997. * @returns the first post process to be run on this camera.
  25998. */
  25999. _getFirstPostProcess(): Nullable<PostProcess>;
  26000. private _cascadePostProcessesToRigCams;
  26001. /**
  26002. * Attach a post process to the camera.
  26003. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  26004. * @param postProcess The post process to attach to the camera
  26005. * @param insertAt The position of the post process in case several of them are in use in the scene
  26006. * @returns the position the post process has been inserted at
  26007. */
  26008. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  26009. /**
  26010. * Detach a post process to the camera.
  26011. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  26012. * @param postProcess The post process to detach from the camera
  26013. */
  26014. detachPostProcess(postProcess: PostProcess): void;
  26015. /**
  26016. * Gets the current world matrix of the camera
  26017. */
  26018. getWorldMatrix(): Matrix;
  26019. /** @hidden */
  26020. _getViewMatrix(): Matrix;
  26021. /**
  26022. * Gets the current view matrix of the camera.
  26023. * @param force forces the camera to recompute the matrix without looking at the cached state
  26024. * @returns the view matrix
  26025. */
  26026. getViewMatrix(force?: boolean): Matrix;
  26027. /**
  26028. * Freeze the projection matrix.
  26029. * It will prevent the cache check of the camera projection compute and can speed up perf
  26030. * if no parameter of the camera are meant to change
  26031. * @param projection Defines manually a projection if necessary
  26032. */
  26033. freezeProjectionMatrix(projection?: Matrix): void;
  26034. /**
  26035. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  26036. */
  26037. unfreezeProjectionMatrix(): void;
  26038. /**
  26039. * Gets the current projection matrix of the camera.
  26040. * @param force forces the camera to recompute the matrix without looking at the cached state
  26041. * @returns the projection matrix
  26042. */
  26043. getProjectionMatrix(force?: boolean): Matrix;
  26044. /**
  26045. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  26046. * @returns a Matrix
  26047. */
  26048. getTransformationMatrix(): Matrix;
  26049. private _updateFrustumPlanes;
  26050. /**
  26051. * Checks if a cullable object (mesh...) is in the camera frustum
  26052. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  26053. * @param target The object to check
  26054. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  26055. * @returns true if the object is in frustum otherwise false
  26056. */
  26057. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  26058. /**
  26059. * Checks if a cullable object (mesh...) is in the camera frustum
  26060. * Unlike isInFrustum this cheks the full bounding box
  26061. * @param target The object to check
  26062. * @returns true if the object is in frustum otherwise false
  26063. */
  26064. isCompletelyInFrustum(target: ICullable): boolean;
  26065. /**
  26066. * Gets a ray in the forward direction from the camera.
  26067. * @param length Defines the length of the ray to create
  26068. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  26069. * @param origin Defines the start point of the ray which defaults to the camera position
  26070. * @returns the forward ray
  26071. */
  26072. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  26073. /**
  26074. * Releases resources associated with this node.
  26075. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26076. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26077. */
  26078. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26079. /** @hidden */
  26080. _isLeftCamera: boolean;
  26081. /**
  26082. * Gets the left camera of a rig setup in case of Rigged Camera
  26083. */
  26084. readonly isLeftCamera: boolean;
  26085. /** @hidden */
  26086. _isRightCamera: boolean;
  26087. /**
  26088. * Gets the right camera of a rig setup in case of Rigged Camera
  26089. */
  26090. readonly isRightCamera: boolean;
  26091. /**
  26092. * Gets the left camera of a rig setup in case of Rigged Camera
  26093. */
  26094. readonly leftCamera: Nullable<FreeCamera>;
  26095. /**
  26096. * Gets the right camera of a rig setup in case of Rigged Camera
  26097. */
  26098. readonly rightCamera: Nullable<FreeCamera>;
  26099. /**
  26100. * Gets the left camera target of a rig setup in case of Rigged Camera
  26101. * @returns the target position
  26102. */
  26103. getLeftTarget(): Nullable<Vector3>;
  26104. /**
  26105. * Gets the right camera target of a rig setup in case of Rigged Camera
  26106. * @returns the target position
  26107. */
  26108. getRightTarget(): Nullable<Vector3>;
  26109. /**
  26110. * @hidden
  26111. */
  26112. setCameraRigMode(mode: number, rigParams: any): void;
  26113. /** @hidden */
  26114. static _setStereoscopicRigMode(camera: Camera): void;
  26115. /** @hidden */
  26116. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  26117. /** @hidden */
  26118. static _setVRRigMode(camera: Camera, rigParams: any): void;
  26119. /** @hidden */
  26120. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  26121. /** @hidden */
  26122. _getVRProjectionMatrix(): Matrix;
  26123. protected _updateCameraRotationMatrix(): void;
  26124. protected _updateWebVRCameraRotationMatrix(): void;
  26125. /**
  26126. * This function MUST be overwritten by the different WebVR cameras available.
  26127. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  26128. * @hidden
  26129. */
  26130. _getWebVRProjectionMatrix(): Matrix;
  26131. /**
  26132. * This function MUST be overwritten by the different WebVR cameras available.
  26133. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  26134. * @hidden
  26135. */
  26136. _getWebVRViewMatrix(): Matrix;
  26137. /** @hidden */
  26138. setCameraRigParameter(name: string, value: any): void;
  26139. /**
  26140. * needs to be overridden by children so sub has required properties to be copied
  26141. * @hidden
  26142. */
  26143. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  26144. /**
  26145. * May need to be overridden by children
  26146. * @hidden
  26147. */
  26148. _updateRigCameras(): void;
  26149. /** @hidden */
  26150. _setupInputs(): void;
  26151. /**
  26152. * Serialiaze the camera setup to a json represention
  26153. * @returns the JSON representation
  26154. */
  26155. serialize(): any;
  26156. /**
  26157. * Clones the current camera.
  26158. * @param name The cloned camera name
  26159. * @returns the cloned camera
  26160. */
  26161. clone(name: string): Camera;
  26162. /**
  26163. * Gets the direction of the camera relative to a given local axis.
  26164. * @param localAxis Defines the reference axis to provide a relative direction.
  26165. * @return the direction
  26166. */
  26167. getDirection(localAxis: Vector3): Vector3;
  26168. /**
  26169. * Returns the current camera absolute rotation
  26170. */
  26171. readonly absoluteRotation: Quaternion;
  26172. /**
  26173. * Gets the direction of the camera relative to a given local axis into a passed vector.
  26174. * @param localAxis Defines the reference axis to provide a relative direction.
  26175. * @param result Defines the vector to store the result in
  26176. */
  26177. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  26178. /**
  26179. * Gets a camera constructor for a given camera type
  26180. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  26181. * @param name The name of the camera the result will be able to instantiate
  26182. * @param scene The scene the result will construct the camera in
  26183. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  26184. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  26185. * @returns a factory method to construc the camera
  26186. */
  26187. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  26188. /**
  26189. * Compute the world matrix of the camera.
  26190. * @returns the camera world matrix
  26191. */
  26192. computeWorldMatrix(): Matrix;
  26193. /**
  26194. * Parse a JSON and creates the camera from the parsed information
  26195. * @param parsedCamera The JSON to parse
  26196. * @param scene The scene to instantiate the camera in
  26197. * @returns the newly constructed camera
  26198. */
  26199. static Parse(parsedCamera: any, scene: Scene): Camera;
  26200. }
  26201. }
  26202. declare module "babylonjs/Meshes/Builders/discBuilder" {
  26203. import { Nullable } from "babylonjs/types";
  26204. import { Scene } from "babylonjs/scene";
  26205. import { Vector4 } from "babylonjs/Maths/math.vector";
  26206. import { Mesh } from "babylonjs/Meshes/mesh";
  26207. /**
  26208. * Class containing static functions to help procedurally build meshes
  26209. */
  26210. export class DiscBuilder {
  26211. /**
  26212. * Creates a plane polygonal mesh. By default, this is a disc
  26213. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  26214. * * The parameter `tessellation` sets the number of polygon sides (positive integer, default 64). So a tessellation valued to 3 will build a triangle, to 4 a square, etc
  26215. * * You can create an unclosed polygon with the parameter `arc` (positive float, default 1), valued between 0 and 1, what is the ratio of the circumference : 2 x PI x ratio
  26216. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  26217. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  26218. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  26219. * @param name defines the name of the mesh
  26220. * @param options defines the options used to create the mesh
  26221. * @param scene defines the hosting scene
  26222. * @returns the plane polygonal mesh
  26223. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  26224. */
  26225. static CreateDisc(name: string, options: {
  26226. radius?: number;
  26227. tessellation?: number;
  26228. arc?: number;
  26229. updatable?: boolean;
  26230. sideOrientation?: number;
  26231. frontUVs?: Vector4;
  26232. backUVs?: Vector4;
  26233. }, scene?: Nullable<Scene>): Mesh;
  26234. }
  26235. }
  26236. declare module "babylonjs/Particles/solidParticleSystem" {
  26237. import { Nullable } from "babylonjs/types";
  26238. import { Vector3 } from "babylonjs/Maths/math.vector";
  26239. import { Mesh } from "babylonjs/Meshes/mesh";
  26240. import { Scene, IDisposable } from "babylonjs/scene";
  26241. import { DepthSortedParticle, SolidParticle } from "babylonjs/Particles/solidParticle";
  26242. /**
  26243. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  26244. *As it is just a mesh, the SPS has all the same properties than any other BJS mesh : not more, not less. It can be scaled, rotated, translated, enlighted, textured, moved, etc.
  26245. * The SPS is also a particle system. It provides some methods to manage the particles.
  26246. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  26247. *
  26248. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  26249. */
  26250. export class SolidParticleSystem implements IDisposable {
  26251. /**
  26252. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  26253. * Example : var p = SPS.particles[i];
  26254. */
  26255. particles: SolidParticle[];
  26256. /**
  26257. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  26258. */
  26259. nbParticles: number;
  26260. /**
  26261. * If the particles must ever face the camera (default false). Useful for planar particles.
  26262. */
  26263. billboard: boolean;
  26264. /**
  26265. * Recompute normals when adding a shape
  26266. */
  26267. recomputeNormals: boolean;
  26268. /**
  26269. * This a counter ofr your own usage. It's not set by any SPS functions.
  26270. */
  26271. counter: number;
  26272. /**
  26273. * The SPS name. This name is also given to the underlying mesh.
  26274. */
  26275. name: string;
  26276. /**
  26277. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  26278. */
  26279. mesh: Mesh;
  26280. /**
  26281. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  26282. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  26283. */
  26284. vars: any;
  26285. /**
  26286. * This array is populated when the SPS is set as 'pickable'.
  26287. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  26288. * Each element of this array is an object `{idx: int, faceId: int}`.
  26289. * `idx` is the picked particle index in the `SPS.particles` array
  26290. * `faceId` is the picked face index counted within this particle.
  26291. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  26292. */
  26293. pickedParticles: {
  26294. idx: number;
  26295. faceId: number;
  26296. }[];
  26297. /**
  26298. * This array is populated when `enableDepthSort` is set to true.
  26299. * Each element of this array is an instance of the class DepthSortedParticle.
  26300. */
  26301. depthSortedParticles: DepthSortedParticle[];
  26302. /**
  26303. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  26304. * @hidden
  26305. */
  26306. _bSphereOnly: boolean;
  26307. /**
  26308. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  26309. * @hidden
  26310. */
  26311. _bSphereRadiusFactor: number;
  26312. private _scene;
  26313. private _positions;
  26314. private _indices;
  26315. private _normals;
  26316. private _colors;
  26317. private _uvs;
  26318. private _indices32;
  26319. private _positions32;
  26320. private _normals32;
  26321. private _fixedNormal32;
  26322. private _colors32;
  26323. private _uvs32;
  26324. private _index;
  26325. private _updatable;
  26326. private _pickable;
  26327. private _isVisibilityBoxLocked;
  26328. private _alwaysVisible;
  26329. private _depthSort;
  26330. private _expandable;
  26331. private _shapeCounter;
  26332. private _copy;
  26333. private _color;
  26334. private _computeParticleColor;
  26335. private _computeParticleTexture;
  26336. private _computeParticleRotation;
  26337. private _computeParticleVertex;
  26338. private _computeBoundingBox;
  26339. private _depthSortParticles;
  26340. private _camera;
  26341. private _mustUnrotateFixedNormals;
  26342. private _particlesIntersect;
  26343. private _needs32Bits;
  26344. private _isNotBuilt;
  26345. private _lastParticleId;
  26346. private _idxOfId;
  26347. private _multimaterialEnabled;
  26348. private _indicesByMaterial;
  26349. private _materialIndexes;
  26350. private _depthSortFunction;
  26351. private _materialSortFunction;
  26352. /**
  26353. * Creates a SPS (Solid Particle System) object.
  26354. * @param name (String) is the SPS name, this will be the underlying mesh name.
  26355. * @param scene (Scene) is the scene in which the SPS is added.
  26356. * @param options defines the options of the sps e.g.
  26357. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  26358. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  26359. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  26360. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  26361. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  26362. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  26363. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  26364. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  26365. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  26366. */
  26367. constructor(name: string, scene: Scene, options?: {
  26368. updatable?: boolean;
  26369. isPickable?: boolean;
  26370. enableDepthSort?: boolean;
  26371. particleIntersection?: boolean;
  26372. boundingSphereOnly?: boolean;
  26373. bSphereRadiusFactor?: number;
  26374. expandable?: boolean;
  26375. enableMultiMaterial?: boolean;
  26376. });
  26377. /**
  26378. * Builds the SPS underlying mesh. Returns a standard Mesh.
  26379. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  26380. * @returns the created mesh
  26381. */
  26382. buildMesh(): Mesh;
  26383. /**
  26384. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  26385. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  26386. * Thus the particles generated from `digest()` have their property `position` set yet.
  26387. * @param mesh ( Mesh ) is the mesh to be digested
  26388. * @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
  26389. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  26390. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  26391. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  26392. * @returns the current SPS
  26393. */
  26394. digest(mesh: Mesh, options?: {
  26395. facetNb?: number;
  26396. number?: number;
  26397. delta?: number;
  26398. storage?: [];
  26399. }): SolidParticleSystem;
  26400. /**
  26401. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  26402. * @hidden
  26403. */
  26404. private _unrotateFixedNormals;
  26405. /**
  26406. * Resets the temporary working copy particle
  26407. * @hidden
  26408. */
  26409. private _resetCopy;
  26410. /**
  26411. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  26412. * @param p the current index in the positions array to be updated
  26413. * @param shape a Vector3 array, the shape geometry
  26414. * @param positions the positions array to be updated
  26415. * @param meshInd the shape indices array
  26416. * @param indices the indices array to be updated
  26417. * @param meshUV the shape uv array
  26418. * @param uvs the uv array to be updated
  26419. * @param meshCol the shape color array
  26420. * @param colors the color array to be updated
  26421. * @param meshNor the shape normals array
  26422. * @param normals the normals array to be updated
  26423. * @param idx the particle index
  26424. * @param idxInShape the particle index in its shape
  26425. * @param options the addShape() method passed options
  26426. * @hidden
  26427. */
  26428. private _meshBuilder;
  26429. /**
  26430. * Returns a shape Vector3 array from positions float array
  26431. * @param positions float array
  26432. * @returns a vector3 array
  26433. * @hidden
  26434. */
  26435. private _posToShape;
  26436. /**
  26437. * Returns a shapeUV array from a float uvs (array deep copy)
  26438. * @param uvs as a float array
  26439. * @returns a shapeUV array
  26440. * @hidden
  26441. */
  26442. private _uvsToShapeUV;
  26443. /**
  26444. * Adds a new particle object in the particles array
  26445. * @param idx particle index in particles array
  26446. * @param id particle id
  26447. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  26448. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  26449. * @param model particle ModelShape object
  26450. * @param shapeId model shape identifier
  26451. * @param idxInShape index of the particle in the current model
  26452. * @param bInfo model bounding info object
  26453. * @param storage target storage array, if any
  26454. * @hidden
  26455. */
  26456. private _addParticle;
  26457. /**
  26458. * Adds some particles to the SPS from the model shape. Returns the shape id.
  26459. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  26460. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  26461. * @param nb (positive integer) the number of particles to be created from this model
  26462. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  26463. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  26464. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  26465. * @returns the number of shapes in the system
  26466. */
  26467. addShape(mesh: Mesh, nb: number, options?: {
  26468. positionFunction?: any;
  26469. vertexFunction?: any;
  26470. storage?: [];
  26471. }): number;
  26472. /**
  26473. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  26474. * @hidden
  26475. */
  26476. private _rebuildParticle;
  26477. /**
  26478. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  26479. * @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.
  26480. * @returns the SPS.
  26481. */
  26482. rebuildMesh(reset?: boolean): SolidParticleSystem;
  26483. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  26484. * Returns an array with the removed particles.
  26485. * 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.
  26486. * The SPS can't be empty so at least one particle needs to remain in place.
  26487. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  26488. * @param start index of the first particle to remove
  26489. * @param end index of the last particle to remove (included)
  26490. * @returns an array populated with the removed particles
  26491. */
  26492. removeParticles(start: number, end: number): SolidParticle[];
  26493. /**
  26494. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  26495. * @param solidParticleArray an array populated with Solid Particles objects
  26496. * @returns the SPS
  26497. */
  26498. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  26499. /**
  26500. * Creates a new particle and modifies the SPS mesh geometry :
  26501. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  26502. * - calls _addParticle() to populate the particle array
  26503. * factorized code from addShape() and insertParticlesFromArray()
  26504. * @param idx particle index in the particles array
  26505. * @param i particle index in its shape
  26506. * @param modelShape particle ModelShape object
  26507. * @param shape shape vertex array
  26508. * @param meshInd shape indices array
  26509. * @param meshUV shape uv array
  26510. * @param meshCol shape color array
  26511. * @param meshNor shape normals array
  26512. * @param bbInfo shape bounding info
  26513. * @param storage target particle storage
  26514. * @options addShape() passed options
  26515. * @hidden
  26516. */
  26517. private _insertNewParticle;
  26518. /**
  26519. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  26520. * This method calls `updateParticle()` for each particle of the SPS.
  26521. * For an animated SPS, it is usually called within the render loop.
  26522. * 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.
  26523. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  26524. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  26525. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  26526. * @returns the SPS.
  26527. */
  26528. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  26529. /**
  26530. * Disposes the SPS.
  26531. */
  26532. dispose(): void;
  26533. /**
  26534. * Returns a SolidParticle object from its identifier : particle.id
  26535. * @param id (integer) the particle Id
  26536. * @returns the searched particle or null if not found in the SPS.
  26537. */
  26538. getParticleById(id: number): Nullable<SolidParticle>;
  26539. /**
  26540. * Returns a new array populated with the particles having the passed shapeId.
  26541. * @param shapeId (integer) the shape identifier
  26542. * @returns a new solid particle array
  26543. */
  26544. getParticlesByShapeId(shapeId: number): SolidParticle[];
  26545. /**
  26546. * Populates the passed array "ref" with the particles having the passed shapeId.
  26547. * @param shapeId the shape identifier
  26548. * @returns the SPS
  26549. * @param ref
  26550. */
  26551. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  26552. /**
  26553. * Computes the required SubMeshes according the materials assigned to the particles.
  26554. * @returns the solid particle system.
  26555. * Does nothing if called before the SPS mesh is built.
  26556. */
  26557. computeSubMeshes(): SolidParticleSystem;
  26558. /**
  26559. * Sorts the solid particles by material when MultiMaterial is enabled.
  26560. * Updates the indices32 array.
  26561. * Updates the indicesByMaterial array.
  26562. * Updates the mesh indices array.
  26563. * @returns the SPS
  26564. * @hidden
  26565. */
  26566. private _sortParticlesByMaterial;
  26567. /**
  26568. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  26569. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26570. * @returns the SPS.
  26571. */
  26572. refreshVisibleSize(): SolidParticleSystem;
  26573. /**
  26574. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  26575. * @param size the size (float) of the visibility box
  26576. * note : this doesn't lock the SPS mesh bounding box.
  26577. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26578. */
  26579. setVisibilityBox(size: number): void;
  26580. /**
  26581. * Gets whether the SPS as always visible or not
  26582. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26583. */
  26584. /**
  26585. * Sets the SPS as always visible or not
  26586. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26587. */
  26588. isAlwaysVisible: boolean;
  26589. /**
  26590. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  26591. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26592. */
  26593. /**
  26594. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  26595. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26596. */
  26597. isVisibilityBoxLocked: boolean;
  26598. /**
  26599. * Tells to `setParticles()` to compute the particle rotations or not.
  26600. * Default value : true. The SPS is faster when it's set to false.
  26601. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  26602. */
  26603. /**
  26604. * Gets if `setParticles()` computes the particle rotations or not.
  26605. * Default value : true. The SPS is faster when it's set to false.
  26606. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  26607. */
  26608. computeParticleRotation: boolean;
  26609. /**
  26610. * Tells to `setParticles()` to compute the particle colors or not.
  26611. * Default value : true. The SPS is faster when it's set to false.
  26612. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  26613. */
  26614. /**
  26615. * Gets if `setParticles()` computes the particle colors or not.
  26616. * Default value : true. The SPS is faster when it's set to false.
  26617. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  26618. */
  26619. computeParticleColor: boolean;
  26620. /**
  26621. * Gets if `setParticles()` computes the particle textures or not.
  26622. * Default value : true. The SPS is faster when it's set to false.
  26623. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  26624. */
  26625. computeParticleTexture: boolean;
  26626. /**
  26627. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  26628. * Default value : false. The SPS is faster when it's set to false.
  26629. * Note : the particle custom vertex positions aren't stored values.
  26630. */
  26631. /**
  26632. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  26633. * Default value : false. The SPS is faster when it's set to false.
  26634. * Note : the particle custom vertex positions aren't stored values.
  26635. */
  26636. computeParticleVertex: boolean;
  26637. /**
  26638. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  26639. */
  26640. /**
  26641. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  26642. */
  26643. computeBoundingBox: boolean;
  26644. /**
  26645. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  26646. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  26647. * Default : `true`
  26648. */
  26649. /**
  26650. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  26651. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  26652. * Default : `true`
  26653. */
  26654. depthSortParticles: boolean;
  26655. /**
  26656. * Gets if the SPS is created as expandable at construction time.
  26657. * Default : `false`
  26658. */
  26659. readonly expandable: boolean;
  26660. /**
  26661. * Gets if the SPS supports the Multi Materials
  26662. */
  26663. readonly multimaterialEnabled: boolean;
  26664. /**
  26665. * This function does nothing. It may be overwritten to set all the particle first values.
  26666. * The SPS doesn't call this function, you may have to call it by your own.
  26667. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  26668. */
  26669. initParticles(): void;
  26670. /**
  26671. * This function does nothing. It may be overwritten to recycle a particle.
  26672. * The SPS doesn't call this function, you may have to call it by your own.
  26673. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  26674. * @param particle The particle to recycle
  26675. * @returns the recycled particle
  26676. */
  26677. recycleParticle(particle: SolidParticle): SolidParticle;
  26678. /**
  26679. * Updates a particle : this function should be overwritten by the user.
  26680. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  26681. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  26682. * @example : just set a particle position or velocity and recycle conditions
  26683. * @param particle The particle to update
  26684. * @returns the updated particle
  26685. */
  26686. updateParticle(particle: SolidParticle): SolidParticle;
  26687. /**
  26688. * Updates a vertex of a particle : it can be overwritten by the user.
  26689. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  26690. * @param particle the current particle
  26691. * @param vertex the current index of the current particle
  26692. * @param pt the index of the current vertex in the particle shape
  26693. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  26694. * @example : just set a vertex particle position
  26695. * @returns the updated vertex
  26696. */
  26697. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  26698. /**
  26699. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  26700. * This does nothing and may be overwritten by the user.
  26701. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26702. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26703. * @param update the boolean update value actually passed to setParticles()
  26704. */
  26705. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  26706. /**
  26707. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  26708. * This will be passed three parameters.
  26709. * This does nothing and may be overwritten by the user.
  26710. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26711. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26712. * @param update the boolean update value actually passed to setParticles()
  26713. */
  26714. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  26715. }
  26716. }
  26717. declare module "babylonjs/Particles/solidParticle" {
  26718. import { Nullable } from "babylonjs/types";
  26719. import { Vector3, Matrix, Quaternion, Vector4 } from "babylonjs/Maths/math.vector";
  26720. import { Color4 } from "babylonjs/Maths/math.color";
  26721. import { Mesh } from "babylonjs/Meshes/mesh";
  26722. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  26723. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  26724. import { Plane } from "babylonjs/Maths/math.plane";
  26725. /**
  26726. * Represents one particle of a solid particle system.
  26727. */
  26728. export class SolidParticle {
  26729. /**
  26730. * particle global index
  26731. */
  26732. idx: number;
  26733. /**
  26734. * particle identifier
  26735. */
  26736. id: number;
  26737. /**
  26738. * The color of the particle
  26739. */
  26740. color: Nullable<Color4>;
  26741. /**
  26742. * The world space position of the particle.
  26743. */
  26744. position: Vector3;
  26745. /**
  26746. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  26747. */
  26748. rotation: Vector3;
  26749. /**
  26750. * The world space rotation quaternion of the particle.
  26751. */
  26752. rotationQuaternion: Nullable<Quaternion>;
  26753. /**
  26754. * The scaling of the particle.
  26755. */
  26756. scaling: Vector3;
  26757. /**
  26758. * The uvs of the particle.
  26759. */
  26760. uvs: Vector4;
  26761. /**
  26762. * The current speed of the particle.
  26763. */
  26764. velocity: Vector3;
  26765. /**
  26766. * The pivot point in the particle local space.
  26767. */
  26768. pivot: Vector3;
  26769. /**
  26770. * Must the particle be translated from its pivot point in its local space ?
  26771. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  26772. * Default : false
  26773. */
  26774. translateFromPivot: boolean;
  26775. /**
  26776. * Is the particle active or not ?
  26777. */
  26778. alive: boolean;
  26779. /**
  26780. * Is the particle visible or not ?
  26781. */
  26782. isVisible: boolean;
  26783. /**
  26784. * Index of this particle in the global "positions" array (Internal use)
  26785. * @hidden
  26786. */
  26787. _pos: number;
  26788. /**
  26789. * @hidden Index of this particle in the global "indices" array (Internal use)
  26790. */
  26791. _ind: number;
  26792. /**
  26793. * @hidden ModelShape of this particle (Internal use)
  26794. */
  26795. _model: ModelShape;
  26796. /**
  26797. * ModelShape id of this particle
  26798. */
  26799. shapeId: number;
  26800. /**
  26801. * Index of the particle in its shape id
  26802. */
  26803. idxInShape: number;
  26804. /**
  26805. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  26806. */
  26807. _modelBoundingInfo: BoundingInfo;
  26808. /**
  26809. * @hidden Particle BoundingInfo object (Internal use)
  26810. */
  26811. _boundingInfo: BoundingInfo;
  26812. /**
  26813. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  26814. */
  26815. _sps: SolidParticleSystem;
  26816. /**
  26817. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  26818. */
  26819. _stillInvisible: boolean;
  26820. /**
  26821. * @hidden Last computed particle rotation matrix
  26822. */
  26823. _rotationMatrix: number[];
  26824. /**
  26825. * Parent particle Id, if any.
  26826. * Default null.
  26827. */
  26828. parentId: Nullable<number>;
  26829. /**
  26830. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  26831. */
  26832. materialIndex: Nullable<number>;
  26833. /**
  26834. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  26835. * The possible values are :
  26836. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  26837. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  26838. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  26839. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  26840. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  26841. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  26842. * */
  26843. cullingStrategy: number;
  26844. /**
  26845. * @hidden Internal global position in the SPS.
  26846. */
  26847. _globalPosition: Vector3;
  26848. /**
  26849. * Creates a Solid Particle object.
  26850. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  26851. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  26852. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  26853. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  26854. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  26855. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  26856. * @param shapeId (integer) is the model shape identifier in the SPS.
  26857. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  26858. * @param sps defines the sps it is associated to
  26859. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  26860. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  26861. */
  26862. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  26863. /**
  26864. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  26865. * @param target the particle target
  26866. * @returns the current particle
  26867. */
  26868. copyToRef(target: SolidParticle): SolidParticle;
  26869. /**
  26870. * Legacy support, changed scale to scaling
  26871. */
  26872. /**
  26873. * Legacy support, changed scale to scaling
  26874. */
  26875. scale: Vector3;
  26876. /**
  26877. * Legacy support, changed quaternion to rotationQuaternion
  26878. */
  26879. /**
  26880. * Legacy support, changed quaternion to rotationQuaternion
  26881. */
  26882. quaternion: Nullable<Quaternion>;
  26883. /**
  26884. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  26885. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  26886. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  26887. * @returns true if it intersects
  26888. */
  26889. intersectsMesh(target: Mesh | SolidParticle): boolean;
  26890. /**
  26891. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  26892. * A particle is in the frustum if its bounding box intersects the frustum
  26893. * @param frustumPlanes defines the frustum to test
  26894. * @returns true if the particle is in the frustum planes
  26895. */
  26896. isInFrustum(frustumPlanes: Plane[]): boolean;
  26897. /**
  26898. * get the rotation matrix of the particle
  26899. * @hidden
  26900. */
  26901. getRotationMatrix(m: Matrix): void;
  26902. }
  26903. /**
  26904. * Represents the shape of the model used by one particle of a solid particle system.
  26905. * SPS internal tool, don't use it manually.
  26906. */
  26907. export class ModelShape {
  26908. /**
  26909. * The shape id
  26910. * @hidden
  26911. */
  26912. shapeID: number;
  26913. /**
  26914. * flat array of model positions (internal use)
  26915. * @hidden
  26916. */
  26917. _shape: Vector3[];
  26918. /**
  26919. * flat array of model UVs (internal use)
  26920. * @hidden
  26921. */
  26922. _shapeUV: number[];
  26923. /**
  26924. * color array of the model
  26925. * @hidden
  26926. */
  26927. _shapeColors: number[];
  26928. /**
  26929. * indices array of the model
  26930. * @hidden
  26931. */
  26932. _indices: number[];
  26933. /**
  26934. * normals array of the model
  26935. * @hidden
  26936. */
  26937. _normals: number[];
  26938. /**
  26939. * length of the shape in the model indices array (internal use)
  26940. * @hidden
  26941. */
  26942. _indicesLength: number;
  26943. /**
  26944. * Custom position function (internal use)
  26945. * @hidden
  26946. */
  26947. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  26948. /**
  26949. * Custom vertex function (internal use)
  26950. * @hidden
  26951. */
  26952. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  26953. /**
  26954. * 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.
  26955. * SPS internal tool, don't use it manually.
  26956. * @hidden
  26957. */
  26958. 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>);
  26959. }
  26960. /**
  26961. * Represents a Depth Sorted Particle in the solid particle system.
  26962. * @hidden
  26963. */
  26964. export class DepthSortedParticle {
  26965. /**
  26966. * Index of the particle in the "indices" array
  26967. */
  26968. ind: number;
  26969. /**
  26970. * Length of the particle shape in the "indices" array
  26971. */
  26972. indicesLength: number;
  26973. /**
  26974. * Squared distance from the particle to the camera
  26975. */
  26976. sqDistance: number;
  26977. /**
  26978. * Material index when used with MultiMaterials
  26979. */
  26980. materialIndex: number;
  26981. /**
  26982. * Creates a new sorted particle
  26983. * @param materialIndex
  26984. */
  26985. constructor(materialIndex: number);
  26986. }
  26987. }
  26988. declare module "babylonjs/Collisions/meshCollisionData" {
  26989. import { Collider } from "babylonjs/Collisions/collider";
  26990. import { Vector3 } from "babylonjs/Maths/math.vector";
  26991. import { Nullable } from "babylonjs/types";
  26992. import { Observer } from "babylonjs/Misc/observable";
  26993. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26994. /**
  26995. * @hidden
  26996. */
  26997. export class _MeshCollisionData {
  26998. _checkCollisions: boolean;
  26999. _collisionMask: number;
  27000. _collisionGroup: number;
  27001. _collider: Nullable<Collider>;
  27002. _oldPositionForCollisions: Vector3;
  27003. _diffPositionForCollisions: Vector3;
  27004. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  27005. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  27006. }
  27007. }
  27008. declare module "babylonjs/Meshes/abstractMesh" {
  27009. import { Observable } from "babylonjs/Misc/observable";
  27010. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  27011. import { Camera } from "babylonjs/Cameras/camera";
  27012. import { Scene, IDisposable } from "babylonjs/scene";
  27013. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  27014. import { Node } from "babylonjs/node";
  27015. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  27016. import { TransformNode } from "babylonjs/Meshes/transformNode";
  27017. import { SubMesh } from "babylonjs/Meshes/subMesh";
  27018. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  27019. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  27020. import { Material } from "babylonjs/Materials/material";
  27021. import { Light } from "babylonjs/Lights/light";
  27022. import { Skeleton } from "babylonjs/Bones/skeleton";
  27023. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  27024. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  27025. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  27026. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  27027. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  27028. import { Plane } from "babylonjs/Maths/math.plane";
  27029. import { Ray } from "babylonjs/Culling/ray";
  27030. import { Collider } from "babylonjs/Collisions/collider";
  27031. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  27032. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  27033. /** @hidden */
  27034. class _FacetDataStorage {
  27035. facetPositions: Vector3[];
  27036. facetNormals: Vector3[];
  27037. facetPartitioning: number[][];
  27038. facetNb: number;
  27039. partitioningSubdivisions: number;
  27040. partitioningBBoxRatio: number;
  27041. facetDataEnabled: boolean;
  27042. facetParameters: any;
  27043. bbSize: Vector3;
  27044. subDiv: {
  27045. max: number;
  27046. X: number;
  27047. Y: number;
  27048. Z: number;
  27049. };
  27050. facetDepthSort: boolean;
  27051. facetDepthSortEnabled: boolean;
  27052. depthSortedIndices: IndicesArray;
  27053. depthSortedFacets: {
  27054. ind: number;
  27055. sqDistance: number;
  27056. }[];
  27057. facetDepthSortFunction: (f1: {
  27058. ind: number;
  27059. sqDistance: number;
  27060. }, f2: {
  27061. ind: number;
  27062. sqDistance: number;
  27063. }) => number;
  27064. facetDepthSortFrom: Vector3;
  27065. facetDepthSortOrigin: Vector3;
  27066. invertedMatrix: Matrix;
  27067. }
  27068. /**
  27069. * @hidden
  27070. **/
  27071. class _InternalAbstractMeshDataInfo {
  27072. _hasVertexAlpha: boolean;
  27073. _useVertexColors: boolean;
  27074. _numBoneInfluencers: number;
  27075. _applyFog: boolean;
  27076. _receiveShadows: boolean;
  27077. _facetData: _FacetDataStorage;
  27078. _visibility: number;
  27079. _skeleton: Nullable<Skeleton>;
  27080. _layerMask: number;
  27081. _computeBonesUsingShaders: boolean;
  27082. _isActive: boolean;
  27083. _onlyForInstances: boolean;
  27084. _isActiveIntermediate: boolean;
  27085. _onlyForInstancesIntermediate: boolean;
  27086. _actAsRegularMesh: boolean;
  27087. }
  27088. /**
  27089. * Class used to store all common mesh properties
  27090. */
  27091. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  27092. /** No occlusion */
  27093. static OCCLUSION_TYPE_NONE: number;
  27094. /** Occlusion set to optimisitic */
  27095. static OCCLUSION_TYPE_OPTIMISTIC: number;
  27096. /** Occlusion set to strict */
  27097. static OCCLUSION_TYPE_STRICT: number;
  27098. /** Use an accurante occlusion algorithm */
  27099. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  27100. /** Use a conservative occlusion algorithm */
  27101. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  27102. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  27103. * Test order :
  27104. * Is the bounding sphere outside the frustum ?
  27105. * If not, are the bounding box vertices outside the frustum ?
  27106. * It not, then the cullable object is in the frustum.
  27107. */
  27108. static readonly CULLINGSTRATEGY_STANDARD: number;
  27109. /** Culling strategy : Bounding Sphere Only.
  27110. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  27111. * It's also less accurate than the standard because some not visible objects can still be selected.
  27112. * Test : is the bounding sphere outside the frustum ?
  27113. * If not, then the cullable object is in the frustum.
  27114. */
  27115. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  27116. /** Culling strategy : Optimistic Inclusion.
  27117. * This in an inclusion test first, then the standard exclusion test.
  27118. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  27119. * 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.
  27120. * Anyway, it's as accurate as the standard strategy.
  27121. * Test :
  27122. * Is the cullable object bounding sphere center in the frustum ?
  27123. * If not, apply the default culling strategy.
  27124. */
  27125. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  27126. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  27127. * This in an inclusion test first, then the bounding sphere only exclusion test.
  27128. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  27129. * 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.
  27130. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  27131. * Test :
  27132. * Is the cullable object bounding sphere center in the frustum ?
  27133. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  27134. */
  27135. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  27136. /**
  27137. * No billboard
  27138. */
  27139. static readonly BILLBOARDMODE_NONE: number;
  27140. /** Billboard on X axis */
  27141. static readonly BILLBOARDMODE_X: number;
  27142. /** Billboard on Y axis */
  27143. static readonly BILLBOARDMODE_Y: number;
  27144. /** Billboard on Z axis */
  27145. static readonly BILLBOARDMODE_Z: number;
  27146. /** Billboard on all axes */
  27147. static readonly BILLBOARDMODE_ALL: number;
  27148. /** Billboard on using position instead of orientation */
  27149. static readonly BILLBOARDMODE_USE_POSITION: number;
  27150. /** @hidden */
  27151. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  27152. /**
  27153. * The culling strategy to use to check whether the mesh must be rendered or not.
  27154. * This value can be changed at any time and will be used on the next render mesh selection.
  27155. * The possible values are :
  27156. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  27157. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  27158. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  27159. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  27160. * Please read each static variable documentation to get details about the culling process.
  27161. * */
  27162. cullingStrategy: number;
  27163. /**
  27164. * Gets the number of facets in the mesh
  27165. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  27166. */
  27167. readonly facetNb: number;
  27168. /**
  27169. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  27170. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  27171. */
  27172. partitioningSubdivisions: number;
  27173. /**
  27174. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  27175. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  27176. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  27177. */
  27178. partitioningBBoxRatio: number;
  27179. /**
  27180. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  27181. * Works only for updatable meshes.
  27182. * Doesn't work with multi-materials
  27183. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  27184. */
  27185. mustDepthSortFacets: boolean;
  27186. /**
  27187. * The location (Vector3) where the facet depth sort must be computed from.
  27188. * By default, the active camera position.
  27189. * Used only when facet depth sort is enabled
  27190. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  27191. */
  27192. facetDepthSortFrom: Vector3;
  27193. /**
  27194. * gets a boolean indicating if facetData is enabled
  27195. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  27196. */
  27197. readonly isFacetDataEnabled: boolean;
  27198. /** @hidden */
  27199. _updateNonUniformScalingState(value: boolean): boolean;
  27200. /**
  27201. * An event triggered when this mesh collides with another one
  27202. */
  27203. onCollideObservable: Observable<AbstractMesh>;
  27204. /** Set a function to call when this mesh collides with another one */
  27205. onCollide: () => void;
  27206. /**
  27207. * An event triggered when the collision's position changes
  27208. */
  27209. onCollisionPositionChangeObservable: Observable<Vector3>;
  27210. /** Set a function to call when the collision's position changes */
  27211. onCollisionPositionChange: () => void;
  27212. /**
  27213. * An event triggered when material is changed
  27214. */
  27215. onMaterialChangedObservable: Observable<AbstractMesh>;
  27216. /**
  27217. * Gets or sets the orientation for POV movement & rotation
  27218. */
  27219. definedFacingForward: boolean;
  27220. /** @hidden */
  27221. _occlusionQuery: Nullable<WebGLQuery>;
  27222. /** @hidden */
  27223. _renderingGroup: Nullable<RenderingGroup>;
  27224. /**
  27225. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  27226. */
  27227. /**
  27228. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  27229. */
  27230. visibility: number;
  27231. /** Gets or sets the alpha index used to sort transparent meshes
  27232. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  27233. */
  27234. alphaIndex: number;
  27235. /**
  27236. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  27237. */
  27238. isVisible: boolean;
  27239. /**
  27240. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  27241. */
  27242. isPickable: boolean;
  27243. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  27244. showSubMeshesBoundingBox: boolean;
  27245. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  27246. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  27247. */
  27248. isBlocker: boolean;
  27249. /**
  27250. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  27251. */
  27252. enablePointerMoveEvents: boolean;
  27253. /**
  27254. * Specifies the rendering group id for this mesh (0 by default)
  27255. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  27256. */
  27257. renderingGroupId: number;
  27258. private _material;
  27259. /** Gets or sets current material */
  27260. material: Nullable<Material>;
  27261. /**
  27262. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  27263. * @see http://doc.babylonjs.com/babylon101/shadows
  27264. */
  27265. receiveShadows: boolean;
  27266. /** Defines color to use when rendering outline */
  27267. outlineColor: Color3;
  27268. /** Define width to use when rendering outline */
  27269. outlineWidth: number;
  27270. /** Defines color to use when rendering overlay */
  27271. overlayColor: Color3;
  27272. /** Defines alpha to use when rendering overlay */
  27273. overlayAlpha: number;
  27274. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  27275. hasVertexAlpha: boolean;
  27276. /** 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) */
  27277. useVertexColors: boolean;
  27278. /**
  27279. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  27280. */
  27281. computeBonesUsingShaders: boolean;
  27282. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  27283. numBoneInfluencers: number;
  27284. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  27285. applyFog: boolean;
  27286. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  27287. useOctreeForRenderingSelection: boolean;
  27288. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  27289. useOctreeForPicking: boolean;
  27290. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  27291. useOctreeForCollisions: boolean;
  27292. /**
  27293. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  27294. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  27295. */
  27296. layerMask: number;
  27297. /**
  27298. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  27299. */
  27300. alwaysSelectAsActiveMesh: boolean;
  27301. /**
  27302. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  27303. */
  27304. doNotSyncBoundingInfo: boolean;
  27305. /**
  27306. * Gets or sets the current action manager
  27307. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  27308. */
  27309. actionManager: Nullable<AbstractActionManager>;
  27310. private _meshCollisionData;
  27311. /**
  27312. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  27313. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27314. */
  27315. ellipsoid: Vector3;
  27316. /**
  27317. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  27318. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27319. */
  27320. ellipsoidOffset: Vector3;
  27321. /**
  27322. * Gets or sets a collision mask used to mask collisions (default is -1).
  27323. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  27324. */
  27325. collisionMask: number;
  27326. /**
  27327. * Gets or sets the current collision group mask (-1 by default).
  27328. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  27329. */
  27330. collisionGroup: number;
  27331. /**
  27332. * Defines edge width used when edgesRenderer is enabled
  27333. * @see https://www.babylonjs-playground.com/#10OJSG#13
  27334. */
  27335. edgesWidth: number;
  27336. /**
  27337. * Defines edge color used when edgesRenderer is enabled
  27338. * @see https://www.babylonjs-playground.com/#10OJSG#13
  27339. */
  27340. edgesColor: Color4;
  27341. /** @hidden */
  27342. _edgesRenderer: Nullable<IEdgesRenderer>;
  27343. /** @hidden */
  27344. _masterMesh: Nullable<AbstractMesh>;
  27345. /** @hidden */
  27346. _boundingInfo: Nullable<BoundingInfo>;
  27347. /** @hidden */
  27348. _renderId: number;
  27349. /**
  27350. * Gets or sets the list of subMeshes
  27351. * @see http://doc.babylonjs.com/how_to/multi_materials
  27352. */
  27353. subMeshes: SubMesh[];
  27354. /** @hidden */
  27355. _intersectionsInProgress: AbstractMesh[];
  27356. /** @hidden */
  27357. _unIndexed: boolean;
  27358. /** @hidden */
  27359. _lightSources: Light[];
  27360. /** Gets the list of lights affecting that mesh */
  27361. readonly lightSources: Light[];
  27362. /** @hidden */
  27363. readonly _positions: Nullable<Vector3[]>;
  27364. /** @hidden */
  27365. _waitingData: {
  27366. lods: Nullable<any>;
  27367. actions: Nullable<any>;
  27368. freezeWorldMatrix: Nullable<boolean>;
  27369. };
  27370. /** @hidden */
  27371. _bonesTransformMatrices: Nullable<Float32Array>;
  27372. /** @hidden */
  27373. _transformMatrixTexture: Nullable<RawTexture>;
  27374. /**
  27375. * Gets or sets a skeleton to apply skining transformations
  27376. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  27377. */
  27378. skeleton: Nullable<Skeleton>;
  27379. /**
  27380. * An event triggered when the mesh is rebuilt.
  27381. */
  27382. onRebuildObservable: Observable<AbstractMesh>;
  27383. /**
  27384. * Creates a new AbstractMesh
  27385. * @param name defines the name of the mesh
  27386. * @param scene defines the hosting scene
  27387. */
  27388. constructor(name: string, scene?: Nullable<Scene>);
  27389. /**
  27390. * Returns the string "AbstractMesh"
  27391. * @returns "AbstractMesh"
  27392. */
  27393. getClassName(): string;
  27394. /**
  27395. * Gets a string representation of the current mesh
  27396. * @param fullDetails defines a boolean indicating if full details must be included
  27397. * @returns a string representation of the current mesh
  27398. */
  27399. toString(fullDetails?: boolean): string;
  27400. /**
  27401. * @hidden
  27402. */
  27403. protected _getEffectiveParent(): Nullable<Node>;
  27404. /** @hidden */
  27405. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  27406. /** @hidden */
  27407. _rebuild(): void;
  27408. /** @hidden */
  27409. _resyncLightSources(): void;
  27410. /** @hidden */
  27411. _resyncLighSource(light: Light): void;
  27412. /** @hidden */
  27413. _unBindEffect(): void;
  27414. /** @hidden */
  27415. _removeLightSource(light: Light, dispose: boolean): void;
  27416. private _markSubMeshesAsDirty;
  27417. /** @hidden */
  27418. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  27419. /** @hidden */
  27420. _markSubMeshesAsAttributesDirty(): void;
  27421. /** @hidden */
  27422. _markSubMeshesAsMiscDirty(): void;
  27423. /**
  27424. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  27425. */
  27426. scaling: Vector3;
  27427. /**
  27428. * Returns true if the mesh is blocked. Implemented by child classes
  27429. */
  27430. readonly isBlocked: boolean;
  27431. /**
  27432. * Returns the mesh itself by default. Implemented by child classes
  27433. * @param camera defines the camera to use to pick the right LOD level
  27434. * @returns the currentAbstractMesh
  27435. */
  27436. getLOD(camera: Camera): Nullable<AbstractMesh>;
  27437. /**
  27438. * Returns 0 by default. Implemented by child classes
  27439. * @returns an integer
  27440. */
  27441. getTotalVertices(): number;
  27442. /**
  27443. * Returns a positive integer : the total number of indices in this mesh geometry.
  27444. * @returns the numner of indices or zero if the mesh has no geometry.
  27445. */
  27446. getTotalIndices(): number;
  27447. /**
  27448. * Returns null by default. Implemented by child classes
  27449. * @returns null
  27450. */
  27451. getIndices(): Nullable<IndicesArray>;
  27452. /**
  27453. * Returns the array of the requested vertex data kind. Implemented by child classes
  27454. * @param kind defines the vertex data kind to use
  27455. * @returns null
  27456. */
  27457. getVerticesData(kind: string): Nullable<FloatArray>;
  27458. /**
  27459. * Sets the vertex data of the mesh geometry for the requested `kind`.
  27460. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  27461. * Note that a new underlying VertexBuffer object is created each call.
  27462. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  27463. * @param kind defines vertex data kind:
  27464. * * VertexBuffer.PositionKind
  27465. * * VertexBuffer.UVKind
  27466. * * VertexBuffer.UV2Kind
  27467. * * VertexBuffer.UV3Kind
  27468. * * VertexBuffer.UV4Kind
  27469. * * VertexBuffer.UV5Kind
  27470. * * VertexBuffer.UV6Kind
  27471. * * VertexBuffer.ColorKind
  27472. * * VertexBuffer.MatricesIndicesKind
  27473. * * VertexBuffer.MatricesIndicesExtraKind
  27474. * * VertexBuffer.MatricesWeightsKind
  27475. * * VertexBuffer.MatricesWeightsExtraKind
  27476. * @param data defines the data source
  27477. * @param updatable defines if the data must be flagged as updatable (or static)
  27478. * @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
  27479. * @returns the current mesh
  27480. */
  27481. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  27482. /**
  27483. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  27484. * If the mesh has no geometry, it is simply returned as it is.
  27485. * @param kind defines vertex data kind:
  27486. * * VertexBuffer.PositionKind
  27487. * * VertexBuffer.UVKind
  27488. * * VertexBuffer.UV2Kind
  27489. * * VertexBuffer.UV3Kind
  27490. * * VertexBuffer.UV4Kind
  27491. * * VertexBuffer.UV5Kind
  27492. * * VertexBuffer.UV6Kind
  27493. * * VertexBuffer.ColorKind
  27494. * * VertexBuffer.MatricesIndicesKind
  27495. * * VertexBuffer.MatricesIndicesExtraKind
  27496. * * VertexBuffer.MatricesWeightsKind
  27497. * * VertexBuffer.MatricesWeightsExtraKind
  27498. * @param data defines the data source
  27499. * @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
  27500. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  27501. * @returns the current mesh
  27502. */
  27503. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  27504. /**
  27505. * Sets the mesh indices,
  27506. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  27507. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  27508. * @param totalVertices Defines the total number of vertices
  27509. * @returns the current mesh
  27510. */
  27511. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  27512. /**
  27513. * Gets a boolean indicating if specific vertex data is present
  27514. * @param kind defines the vertex data kind to use
  27515. * @returns true is data kind is present
  27516. */
  27517. isVerticesDataPresent(kind: string): boolean;
  27518. /**
  27519. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  27520. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  27521. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  27522. * @returns a BoundingInfo
  27523. */
  27524. getBoundingInfo(): BoundingInfo;
  27525. /**
  27526. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  27527. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  27528. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  27529. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  27530. * @returns the current mesh
  27531. */
  27532. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  27533. /**
  27534. * Overwrite the current bounding info
  27535. * @param boundingInfo defines the new bounding info
  27536. * @returns the current mesh
  27537. */
  27538. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  27539. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  27540. readonly useBones: boolean;
  27541. /** @hidden */
  27542. _preActivate(): void;
  27543. /** @hidden */
  27544. _preActivateForIntermediateRendering(renderId: number): void;
  27545. /** @hidden */
  27546. _activate(renderId: number, intermediateRendering: boolean): boolean;
  27547. /** @hidden */
  27548. _postActivate(): void;
  27549. /** @hidden */
  27550. _freeze(): void;
  27551. /** @hidden */
  27552. _unFreeze(): void;
  27553. /**
  27554. * Gets the current world matrix
  27555. * @returns a Matrix
  27556. */
  27557. getWorldMatrix(): Matrix;
  27558. /** @hidden */
  27559. _getWorldMatrixDeterminant(): number;
  27560. /**
  27561. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  27562. */
  27563. readonly isAnInstance: boolean;
  27564. /**
  27565. * Gets a boolean indicating if this mesh has instances
  27566. */
  27567. readonly hasInstances: boolean;
  27568. /**
  27569. * Perform relative position change from the point of view of behind the front of the mesh.
  27570. * This is performed taking into account the meshes current rotation, so you do not have to care.
  27571. * Supports definition of mesh facing forward or backward
  27572. * @param amountRight defines the distance on the right axis
  27573. * @param amountUp defines the distance on the up axis
  27574. * @param amountForward defines the distance on the forward axis
  27575. * @returns the current mesh
  27576. */
  27577. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  27578. /**
  27579. * Calculate relative position change from the point of view of behind the front of the mesh.
  27580. * This is performed taking into account the meshes current rotation, so you do not have to care.
  27581. * Supports definition of mesh facing forward or backward
  27582. * @param amountRight defines the distance on the right axis
  27583. * @param amountUp defines the distance on the up axis
  27584. * @param amountForward defines the distance on the forward axis
  27585. * @returns the new displacement vector
  27586. */
  27587. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  27588. /**
  27589. * Perform relative rotation change from the point of view of behind the front of the mesh.
  27590. * Supports definition of mesh facing forward or backward
  27591. * @param flipBack defines the flip
  27592. * @param twirlClockwise defines the twirl
  27593. * @param tiltRight defines the tilt
  27594. * @returns the current mesh
  27595. */
  27596. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  27597. /**
  27598. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  27599. * Supports definition of mesh facing forward or backward.
  27600. * @param flipBack defines the flip
  27601. * @param twirlClockwise defines the twirl
  27602. * @param tiltRight defines the tilt
  27603. * @returns the new rotation vector
  27604. */
  27605. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  27606. /**
  27607. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  27608. * This means the mesh underlying bounding box and sphere are recomputed.
  27609. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  27610. * @returns the current mesh
  27611. */
  27612. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  27613. /** @hidden */
  27614. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  27615. /** @hidden */
  27616. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  27617. /** @hidden */
  27618. _updateBoundingInfo(): AbstractMesh;
  27619. /** @hidden */
  27620. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  27621. /** @hidden */
  27622. protected _afterComputeWorldMatrix(): void;
  27623. /** @hidden */
  27624. readonly _effectiveMesh: AbstractMesh;
  27625. /**
  27626. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  27627. * A mesh is in the frustum if its bounding box intersects the frustum
  27628. * @param frustumPlanes defines the frustum to test
  27629. * @returns true if the mesh is in the frustum planes
  27630. */
  27631. isInFrustum(frustumPlanes: Plane[]): boolean;
  27632. /**
  27633. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  27634. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  27635. * @param frustumPlanes defines the frustum to test
  27636. * @returns true if the mesh is completely in the frustum planes
  27637. */
  27638. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  27639. /**
  27640. * True if the mesh intersects another mesh or a SolidParticle object
  27641. * @param mesh defines a target mesh or SolidParticle to test
  27642. * @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)
  27643. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  27644. * @returns true if there is an intersection
  27645. */
  27646. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  27647. /**
  27648. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  27649. * @param point defines the point to test
  27650. * @returns true if there is an intersection
  27651. */
  27652. intersectsPoint(point: Vector3): boolean;
  27653. /**
  27654. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  27655. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27656. */
  27657. checkCollisions: boolean;
  27658. /**
  27659. * Gets Collider object used to compute collisions (not physics)
  27660. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27661. */
  27662. readonly collider: Nullable<Collider>;
  27663. /**
  27664. * Move the mesh using collision engine
  27665. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27666. * @param displacement defines the requested displacement vector
  27667. * @returns the current mesh
  27668. */
  27669. moveWithCollisions(displacement: Vector3): AbstractMesh;
  27670. private _onCollisionPositionChange;
  27671. /** @hidden */
  27672. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  27673. /** @hidden */
  27674. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  27675. /** @hidden */
  27676. _checkCollision(collider: Collider): AbstractMesh;
  27677. /** @hidden */
  27678. _generatePointsArray(): boolean;
  27679. /**
  27680. * Checks if the passed Ray intersects with the mesh
  27681. * @param ray defines the ray to use
  27682. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  27683. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  27684. * @returns the picking info
  27685. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  27686. */
  27687. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  27688. /**
  27689. * Clones the current mesh
  27690. * @param name defines the mesh name
  27691. * @param newParent defines the new mesh parent
  27692. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  27693. * @returns the new mesh
  27694. */
  27695. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  27696. /**
  27697. * Disposes all the submeshes of the current meshnp
  27698. * @returns the current mesh
  27699. */
  27700. releaseSubMeshes(): AbstractMesh;
  27701. /**
  27702. * Releases resources associated with this abstract mesh.
  27703. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  27704. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  27705. */
  27706. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  27707. /**
  27708. * Adds the passed mesh as a child to the current mesh
  27709. * @param mesh defines the child mesh
  27710. * @returns the current mesh
  27711. */
  27712. addChild(mesh: AbstractMesh): AbstractMesh;
  27713. /**
  27714. * Removes the passed mesh from the current mesh children list
  27715. * @param mesh defines the child mesh
  27716. * @returns the current mesh
  27717. */
  27718. removeChild(mesh: AbstractMesh): AbstractMesh;
  27719. /** @hidden */
  27720. private _initFacetData;
  27721. /**
  27722. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  27723. * This method can be called within the render loop.
  27724. * 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
  27725. * @returns the current mesh
  27726. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27727. */
  27728. updateFacetData(): AbstractMesh;
  27729. /**
  27730. * Returns the facetLocalNormals array.
  27731. * The normals are expressed in the mesh local spac
  27732. * @returns an array of Vector3
  27733. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27734. */
  27735. getFacetLocalNormals(): Vector3[];
  27736. /**
  27737. * Returns the facetLocalPositions array.
  27738. * The facet positions are expressed in the mesh local space
  27739. * @returns an array of Vector3
  27740. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27741. */
  27742. getFacetLocalPositions(): Vector3[];
  27743. /**
  27744. * Returns the facetLocalPartioning array
  27745. * @returns an array of array of numbers
  27746. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27747. */
  27748. getFacetLocalPartitioning(): number[][];
  27749. /**
  27750. * Returns the i-th facet position in the world system.
  27751. * This method allocates a new Vector3 per call
  27752. * @param i defines the facet index
  27753. * @returns a new Vector3
  27754. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27755. */
  27756. getFacetPosition(i: number): Vector3;
  27757. /**
  27758. * Sets the reference Vector3 with the i-th facet position in the world system
  27759. * @param i defines the facet index
  27760. * @param ref defines the target vector
  27761. * @returns the current mesh
  27762. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27763. */
  27764. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  27765. /**
  27766. * Returns the i-th facet normal in the world system.
  27767. * This method allocates a new Vector3 per call
  27768. * @param i defines the facet index
  27769. * @returns a new Vector3
  27770. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27771. */
  27772. getFacetNormal(i: number): Vector3;
  27773. /**
  27774. * Sets the reference Vector3 with the i-th facet normal in the world system
  27775. * @param i defines the facet index
  27776. * @param ref defines the target vector
  27777. * @returns the current mesh
  27778. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27779. */
  27780. getFacetNormalToRef(i: number, ref: Vector3): this;
  27781. /**
  27782. * 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)
  27783. * @param x defines x coordinate
  27784. * @param y defines y coordinate
  27785. * @param z defines z coordinate
  27786. * @returns the array of facet indexes
  27787. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27788. */
  27789. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  27790. /**
  27791. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  27792. * @param projected sets as the (x,y,z) world projection on the facet
  27793. * @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
  27794. * @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
  27795. * @param x defines x coordinate
  27796. * @param y defines y coordinate
  27797. * @param z defines z coordinate
  27798. * @returns the face index if found (or null instead)
  27799. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27800. */
  27801. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  27802. /**
  27803. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  27804. * @param projected sets as the (x,y,z) local projection on the facet
  27805. * @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
  27806. * @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
  27807. * @param x defines x coordinate
  27808. * @param y defines y coordinate
  27809. * @param z defines z coordinate
  27810. * @returns the face index if found (or null instead)
  27811. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27812. */
  27813. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  27814. /**
  27815. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  27816. * @returns the parameters
  27817. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27818. */
  27819. getFacetDataParameters(): any;
  27820. /**
  27821. * Disables the feature FacetData and frees the related memory
  27822. * @returns the current mesh
  27823. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27824. */
  27825. disableFacetData(): AbstractMesh;
  27826. /**
  27827. * Updates the AbstractMesh indices array
  27828. * @param indices defines the data source
  27829. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  27830. * @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)
  27831. * @returns the current mesh
  27832. */
  27833. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  27834. /**
  27835. * Creates new normals data for the mesh
  27836. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  27837. * @returns the current mesh
  27838. */
  27839. createNormals(updatable: boolean): AbstractMesh;
  27840. /**
  27841. * Align the mesh with a normal
  27842. * @param normal defines the normal to use
  27843. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  27844. * @returns the current mesh
  27845. */
  27846. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  27847. /** @hidden */
  27848. _checkOcclusionQuery(): boolean;
  27849. /**
  27850. * Disables the mesh edge rendering mode
  27851. * @returns the currentAbstractMesh
  27852. */
  27853. disableEdgesRendering(): AbstractMesh;
  27854. /**
  27855. * Enables the edge rendering mode on the mesh.
  27856. * This mode makes the mesh edges visible
  27857. * @param epsilon defines the maximal distance between two angles to detect a face
  27858. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  27859. * @returns the currentAbstractMesh
  27860. * @see https://www.babylonjs-playground.com/#19O9TU#0
  27861. */
  27862. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  27863. }
  27864. }
  27865. declare module "babylonjs/Actions/actionEvent" {
  27866. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27867. import { Nullable } from "babylonjs/types";
  27868. import { Sprite } from "babylonjs/Sprites/sprite";
  27869. import { Scene } from "babylonjs/scene";
  27870. import { Vector2 } from "babylonjs/Maths/math.vector";
  27871. /**
  27872. * Interface used to define ActionEvent
  27873. */
  27874. export interface IActionEvent {
  27875. /** The mesh or sprite that triggered the action */
  27876. source: any;
  27877. /** The X mouse cursor position at the time of the event */
  27878. pointerX: number;
  27879. /** The Y mouse cursor position at the time of the event */
  27880. pointerY: number;
  27881. /** The mesh that is currently pointed at (can be null) */
  27882. meshUnderPointer: Nullable<AbstractMesh>;
  27883. /** the original (browser) event that triggered the ActionEvent */
  27884. sourceEvent?: any;
  27885. /** additional data for the event */
  27886. additionalData?: any;
  27887. }
  27888. /**
  27889. * ActionEvent is the event being sent when an action is triggered.
  27890. */
  27891. export class ActionEvent implements IActionEvent {
  27892. /** The mesh or sprite that triggered the action */
  27893. source: any;
  27894. /** The X mouse cursor position at the time of the event */
  27895. pointerX: number;
  27896. /** The Y mouse cursor position at the time of the event */
  27897. pointerY: number;
  27898. /** The mesh that is currently pointed at (can be null) */
  27899. meshUnderPointer: Nullable<AbstractMesh>;
  27900. /** the original (browser) event that triggered the ActionEvent */
  27901. sourceEvent?: any;
  27902. /** additional data for the event */
  27903. additionalData?: any;
  27904. /**
  27905. * Creates a new ActionEvent
  27906. * @param source The mesh or sprite that triggered the action
  27907. * @param pointerX The X mouse cursor position at the time of the event
  27908. * @param pointerY The Y mouse cursor position at the time of the event
  27909. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  27910. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  27911. * @param additionalData additional data for the event
  27912. */
  27913. constructor(
  27914. /** The mesh or sprite that triggered the action */
  27915. source: any,
  27916. /** The X mouse cursor position at the time of the event */
  27917. pointerX: number,
  27918. /** The Y mouse cursor position at the time of the event */
  27919. pointerY: number,
  27920. /** The mesh that is currently pointed at (can be null) */
  27921. meshUnderPointer: Nullable<AbstractMesh>,
  27922. /** the original (browser) event that triggered the ActionEvent */
  27923. sourceEvent?: any,
  27924. /** additional data for the event */
  27925. additionalData?: any);
  27926. /**
  27927. * Helper function to auto-create an ActionEvent from a source mesh.
  27928. * @param source The source mesh that triggered the event
  27929. * @param evt The original (browser) event
  27930. * @param additionalData additional data for the event
  27931. * @returns the new ActionEvent
  27932. */
  27933. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  27934. /**
  27935. * Helper function to auto-create an ActionEvent from a source sprite
  27936. * @param source The source sprite that triggered the event
  27937. * @param scene Scene associated with the sprite
  27938. * @param evt The original (browser) event
  27939. * @param additionalData additional data for the event
  27940. * @returns the new ActionEvent
  27941. */
  27942. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  27943. /**
  27944. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  27945. * @param scene the scene where the event occurred
  27946. * @param evt The original (browser) event
  27947. * @returns the new ActionEvent
  27948. */
  27949. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  27950. /**
  27951. * Helper function to auto-create an ActionEvent from a primitive
  27952. * @param prim defines the target primitive
  27953. * @param pointerPos defines the pointer position
  27954. * @param evt The original (browser) event
  27955. * @param additionalData additional data for the event
  27956. * @returns the new ActionEvent
  27957. */
  27958. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  27959. }
  27960. }
  27961. declare module "babylonjs/Actions/abstractActionManager" {
  27962. import { IDisposable } from "babylonjs/scene";
  27963. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  27964. import { IAction } from "babylonjs/Actions/action";
  27965. import { Nullable } from "babylonjs/types";
  27966. /**
  27967. * Abstract class used to decouple action Manager from scene and meshes.
  27968. * Do not instantiate.
  27969. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  27970. */
  27971. export abstract class AbstractActionManager implements IDisposable {
  27972. /** Gets the list of active triggers */
  27973. static Triggers: {
  27974. [key: string]: number;
  27975. };
  27976. /** Gets the cursor to use when hovering items */
  27977. hoverCursor: string;
  27978. /** Gets the list of actions */
  27979. actions: IAction[];
  27980. /**
  27981. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  27982. */
  27983. isRecursive: boolean;
  27984. /**
  27985. * Releases all associated resources
  27986. */
  27987. abstract dispose(): void;
  27988. /**
  27989. * Does this action manager has pointer triggers
  27990. */
  27991. abstract readonly hasPointerTriggers: boolean;
  27992. /**
  27993. * Does this action manager has pick triggers
  27994. */
  27995. abstract readonly hasPickTriggers: boolean;
  27996. /**
  27997. * Process a specific trigger
  27998. * @param trigger defines the trigger to process
  27999. * @param evt defines the event details to be processed
  28000. */
  28001. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  28002. /**
  28003. * Does this action manager handles actions of any of the given triggers
  28004. * @param triggers defines the triggers to be tested
  28005. * @return a boolean indicating whether one (or more) of the triggers is handled
  28006. */
  28007. abstract hasSpecificTriggers(triggers: number[]): boolean;
  28008. /**
  28009. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  28010. * speed.
  28011. * @param triggerA defines the trigger to be tested
  28012. * @param triggerB defines the trigger to be tested
  28013. * @return a boolean indicating whether one (or more) of the triggers is handled
  28014. */
  28015. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  28016. /**
  28017. * Does this action manager handles actions of a given trigger
  28018. * @param trigger defines the trigger to be tested
  28019. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  28020. * @return whether the trigger is handled
  28021. */
  28022. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  28023. /**
  28024. * Serialize this manager to a JSON object
  28025. * @param name defines the property name to store this manager
  28026. * @returns a JSON representation of this manager
  28027. */
  28028. abstract serialize(name: string): any;
  28029. /**
  28030. * Registers an action to this action manager
  28031. * @param action defines the action to be registered
  28032. * @return the action amended (prepared) after registration
  28033. */
  28034. abstract registerAction(action: IAction): Nullable<IAction>;
  28035. /**
  28036. * Unregisters an action to this action manager
  28037. * @param action defines the action to be unregistered
  28038. * @return a boolean indicating whether the action has been unregistered
  28039. */
  28040. abstract unregisterAction(action: IAction): Boolean;
  28041. /**
  28042. * Does exist one action manager with at least one trigger
  28043. **/
  28044. static readonly HasTriggers: boolean;
  28045. /**
  28046. * Does exist one action manager with at least one pick trigger
  28047. **/
  28048. static readonly HasPickTriggers: boolean;
  28049. /**
  28050. * Does exist one action manager that handles actions of a given trigger
  28051. * @param trigger defines the trigger to be tested
  28052. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  28053. **/
  28054. static HasSpecificTrigger(trigger: number): boolean;
  28055. }
  28056. }
  28057. declare module "babylonjs/node" {
  28058. import { Scene } from "babylonjs/scene";
  28059. import { Nullable } from "babylonjs/types";
  28060. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  28061. import { Engine } from "babylonjs/Engines/engine";
  28062. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  28063. import { Observable } from "babylonjs/Misc/observable";
  28064. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  28065. import { IInspectable } from "babylonjs/Misc/iInspectable";
  28066. import { Animatable } from "babylonjs/Animations/animatable";
  28067. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  28068. import { Animation } from "babylonjs/Animations/animation";
  28069. import { AnimationRange } from "babylonjs/Animations/animationRange";
  28070. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28071. /**
  28072. * Defines how a node can be built from a string name.
  28073. */
  28074. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  28075. /**
  28076. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  28077. */
  28078. export class Node implements IBehaviorAware<Node> {
  28079. /** @hidden */
  28080. static _AnimationRangeFactory: (name: string, from: number, to: number) => import("babylonjs/Animations/animationRange").AnimationRange;
  28081. private static _NodeConstructors;
  28082. /**
  28083. * Add a new node constructor
  28084. * @param type defines the type name of the node to construct
  28085. * @param constructorFunc defines the constructor function
  28086. */
  28087. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  28088. /**
  28089. * Returns a node constructor based on type name
  28090. * @param type defines the type name
  28091. * @param name defines the new node name
  28092. * @param scene defines the hosting scene
  28093. * @param options defines optional options to transmit to constructors
  28094. * @returns the new constructor or null
  28095. */
  28096. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  28097. /**
  28098. * Gets or sets the name of the node
  28099. */
  28100. name: string;
  28101. /**
  28102. * Gets or sets the id of the node
  28103. */
  28104. id: string;
  28105. /**
  28106. * Gets or sets the unique id of the node
  28107. */
  28108. uniqueId: number;
  28109. /**
  28110. * Gets or sets a string used to store user defined state for the node
  28111. */
  28112. state: string;
  28113. /**
  28114. * Gets or sets an object used to store user defined information for the node
  28115. */
  28116. metadata: any;
  28117. /**
  28118. * For internal use only. Please do not use.
  28119. */
  28120. reservedDataStore: any;
  28121. /**
  28122. * List of inspectable custom properties (used by the Inspector)
  28123. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  28124. */
  28125. inspectableCustomProperties: IInspectable[];
  28126. private _doNotSerialize;
  28127. /**
  28128. * Gets or sets a boolean used to define if the node must be serialized
  28129. */
  28130. doNotSerialize: boolean;
  28131. /** @hidden */
  28132. _isDisposed: boolean;
  28133. /**
  28134. * Gets a list of Animations associated with the node
  28135. */
  28136. animations: import("babylonjs/Animations/animation").Animation[];
  28137. protected _ranges: {
  28138. [name: string]: Nullable<AnimationRange>;
  28139. };
  28140. /**
  28141. * Callback raised when the node is ready to be used
  28142. */
  28143. onReady: Nullable<(node: Node) => void>;
  28144. private _isEnabled;
  28145. private _isParentEnabled;
  28146. private _isReady;
  28147. /** @hidden */
  28148. _currentRenderId: number;
  28149. private _parentUpdateId;
  28150. /** @hidden */
  28151. _childUpdateId: number;
  28152. /** @hidden */
  28153. _waitingParentId: Nullable<string>;
  28154. /** @hidden */
  28155. _scene: Scene;
  28156. /** @hidden */
  28157. _cache: any;
  28158. private _parentNode;
  28159. private _children;
  28160. /** @hidden */
  28161. _worldMatrix: Matrix;
  28162. /** @hidden */
  28163. _worldMatrixDeterminant: number;
  28164. /** @hidden */
  28165. _worldMatrixDeterminantIsDirty: boolean;
  28166. /** @hidden */
  28167. private _sceneRootNodesIndex;
  28168. /**
  28169. * Gets a boolean indicating if the node has been disposed
  28170. * @returns true if the node was disposed
  28171. */
  28172. isDisposed(): boolean;
  28173. /**
  28174. * Gets or sets the parent of the node (without keeping the current position in the scene)
  28175. * @see https://doc.babylonjs.com/how_to/parenting
  28176. */
  28177. parent: Nullable<Node>;
  28178. /** @hidden */
  28179. _addToSceneRootNodes(): void;
  28180. /** @hidden */
  28181. _removeFromSceneRootNodes(): void;
  28182. private _animationPropertiesOverride;
  28183. /**
  28184. * Gets or sets the animation properties override
  28185. */
  28186. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  28187. /**
  28188. * Gets a string idenfifying the name of the class
  28189. * @returns "Node" string
  28190. */
  28191. getClassName(): string;
  28192. /** @hidden */
  28193. readonly _isNode: boolean;
  28194. /**
  28195. * An event triggered when the mesh is disposed
  28196. */
  28197. onDisposeObservable: Observable<Node>;
  28198. private _onDisposeObserver;
  28199. /**
  28200. * Sets a callback that will be raised when the node will be disposed
  28201. */
  28202. onDispose: () => void;
  28203. /**
  28204. * Creates a new Node
  28205. * @param name the name and id to be given to this node
  28206. * @param scene the scene this node will be added to
  28207. */
  28208. constructor(name: string, scene?: Nullable<Scene>);
  28209. /**
  28210. * Gets the scene of the node
  28211. * @returns a scene
  28212. */
  28213. getScene(): Scene;
  28214. /**
  28215. * Gets the engine of the node
  28216. * @returns a Engine
  28217. */
  28218. getEngine(): Engine;
  28219. private _behaviors;
  28220. /**
  28221. * Attach a behavior to the node
  28222. * @see http://doc.babylonjs.com/features/behaviour
  28223. * @param behavior defines the behavior to attach
  28224. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  28225. * @returns the current Node
  28226. */
  28227. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  28228. /**
  28229. * Remove an attached behavior
  28230. * @see http://doc.babylonjs.com/features/behaviour
  28231. * @param behavior defines the behavior to attach
  28232. * @returns the current Node
  28233. */
  28234. removeBehavior(behavior: Behavior<Node>): Node;
  28235. /**
  28236. * Gets the list of attached behaviors
  28237. * @see http://doc.babylonjs.com/features/behaviour
  28238. */
  28239. readonly behaviors: Behavior<Node>[];
  28240. /**
  28241. * Gets an attached behavior by name
  28242. * @param name defines the name of the behavior to look for
  28243. * @see http://doc.babylonjs.com/features/behaviour
  28244. * @returns null if behavior was not found else the requested behavior
  28245. */
  28246. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  28247. /**
  28248. * Returns the latest update of the World matrix
  28249. * @returns a Matrix
  28250. */
  28251. getWorldMatrix(): Matrix;
  28252. /** @hidden */
  28253. _getWorldMatrixDeterminant(): number;
  28254. /**
  28255. * Returns directly the latest state of the mesh World matrix.
  28256. * A Matrix is returned.
  28257. */
  28258. readonly worldMatrixFromCache: Matrix;
  28259. /** @hidden */
  28260. _initCache(): void;
  28261. /** @hidden */
  28262. updateCache(force?: boolean): void;
  28263. /** @hidden */
  28264. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  28265. /** @hidden */
  28266. _updateCache(ignoreParentClass?: boolean): void;
  28267. /** @hidden */
  28268. _isSynchronized(): boolean;
  28269. /** @hidden */
  28270. _markSyncedWithParent(): void;
  28271. /** @hidden */
  28272. isSynchronizedWithParent(): boolean;
  28273. /** @hidden */
  28274. isSynchronized(): boolean;
  28275. /**
  28276. * Is this node ready to be used/rendered
  28277. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  28278. * @return true if the node is ready
  28279. */
  28280. isReady(completeCheck?: boolean): boolean;
  28281. /**
  28282. * Is this node enabled?
  28283. * 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
  28284. * @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
  28285. * @return whether this node (and its parent) is enabled
  28286. */
  28287. isEnabled(checkAncestors?: boolean): boolean;
  28288. /** @hidden */
  28289. protected _syncParentEnabledState(): void;
  28290. /**
  28291. * Set the enabled state of this node
  28292. * @param value defines the new enabled state
  28293. */
  28294. setEnabled(value: boolean): void;
  28295. /**
  28296. * Is this node a descendant of the given node?
  28297. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  28298. * @param ancestor defines the parent node to inspect
  28299. * @returns a boolean indicating if this node is a descendant of the given node
  28300. */
  28301. isDescendantOf(ancestor: Node): boolean;
  28302. /** @hidden */
  28303. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  28304. /**
  28305. * Will return all nodes that have this node as ascendant
  28306. * @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
  28307. * @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
  28308. * @return all children nodes of all types
  28309. */
  28310. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  28311. /**
  28312. * Get all child-meshes of this node
  28313. * @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)
  28314. * @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
  28315. * @returns an array of AbstractMesh
  28316. */
  28317. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  28318. /**
  28319. * Get all direct children of this node
  28320. * @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
  28321. * @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)
  28322. * @returns an array of Node
  28323. */
  28324. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  28325. /** @hidden */
  28326. _setReady(state: boolean): void;
  28327. /**
  28328. * Get an animation by name
  28329. * @param name defines the name of the animation to look for
  28330. * @returns null if not found else the requested animation
  28331. */
  28332. getAnimationByName(name: string): Nullable<Animation>;
  28333. /**
  28334. * Creates an animation range for this node
  28335. * @param name defines the name of the range
  28336. * @param from defines the starting key
  28337. * @param to defines the end key
  28338. */
  28339. createAnimationRange(name: string, from: number, to: number): void;
  28340. /**
  28341. * Delete a specific animation range
  28342. * @param name defines the name of the range to delete
  28343. * @param deleteFrames defines if animation frames from the range must be deleted as well
  28344. */
  28345. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  28346. /**
  28347. * Get an animation range by name
  28348. * @param name defines the name of the animation range to look for
  28349. * @returns null if not found else the requested animation range
  28350. */
  28351. getAnimationRange(name: string): Nullable<AnimationRange>;
  28352. /**
  28353. * Gets the list of all animation ranges defined on this node
  28354. * @returns an array
  28355. */
  28356. getAnimationRanges(): Nullable<AnimationRange>[];
  28357. /**
  28358. * Will start the animation sequence
  28359. * @param name defines the range frames for animation sequence
  28360. * @param loop defines if the animation should loop (false by default)
  28361. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  28362. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  28363. * @returns the object created for this animation. If range does not exist, it will return null
  28364. */
  28365. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  28366. /**
  28367. * Serialize animation ranges into a JSON compatible object
  28368. * @returns serialization object
  28369. */
  28370. serializeAnimationRanges(): any;
  28371. /**
  28372. * Computes the world matrix of the node
  28373. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  28374. * @returns the world matrix
  28375. */
  28376. computeWorldMatrix(force?: boolean): Matrix;
  28377. /**
  28378. * Releases resources associated with this node.
  28379. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  28380. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  28381. */
  28382. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  28383. /**
  28384. * Parse animation range data from a serialization object and store them into a given node
  28385. * @param node defines where to store the animation ranges
  28386. * @param parsedNode defines the serialization object to read data from
  28387. * @param scene defines the hosting scene
  28388. */
  28389. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  28390. /**
  28391. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  28392. * @param includeDescendants Include bounding info from descendants as well (true by default)
  28393. * @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
  28394. * @returns the new bounding vectors
  28395. */
  28396. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  28397. min: Vector3;
  28398. max: Vector3;
  28399. };
  28400. }
  28401. }
  28402. declare module "babylonjs/Animations/animation" {
  28403. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  28404. import { Vector3, Quaternion, Vector2, Matrix } from "babylonjs/Maths/math.vector";
  28405. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  28406. import { Nullable } from "babylonjs/types";
  28407. import { Scene } from "babylonjs/scene";
  28408. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  28409. import { AnimationRange } from "babylonjs/Animations/animationRange";
  28410. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  28411. import { Node } from "babylonjs/node";
  28412. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  28413. import { Size } from "babylonjs/Maths/math.size";
  28414. import { Animatable } from "babylonjs/Animations/animatable";
  28415. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  28416. /**
  28417. * @hidden
  28418. */
  28419. export class _IAnimationState {
  28420. key: number;
  28421. repeatCount: number;
  28422. workValue?: any;
  28423. loopMode?: number;
  28424. offsetValue?: any;
  28425. highLimitValue?: any;
  28426. }
  28427. /**
  28428. * Class used to store any kind of animation
  28429. */
  28430. export class Animation {
  28431. /**Name of the animation */
  28432. name: string;
  28433. /**Property to animate */
  28434. targetProperty: string;
  28435. /**The frames per second of the animation */
  28436. framePerSecond: number;
  28437. /**The data type of the animation */
  28438. dataType: number;
  28439. /**The loop mode of the animation */
  28440. loopMode?: number | undefined;
  28441. /**Specifies if blending should be enabled */
  28442. enableBlending?: boolean | undefined;
  28443. /**
  28444. * Use matrix interpolation instead of using direct key value when animating matrices
  28445. */
  28446. static AllowMatricesInterpolation: boolean;
  28447. /**
  28448. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  28449. */
  28450. static AllowMatrixDecomposeForInterpolation: boolean;
  28451. /**
  28452. * Stores the key frames of the animation
  28453. */
  28454. private _keys;
  28455. /**
  28456. * Stores the easing function of the animation
  28457. */
  28458. private _easingFunction;
  28459. /**
  28460. * @hidden Internal use only
  28461. */
  28462. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  28463. /**
  28464. * The set of event that will be linked to this animation
  28465. */
  28466. private _events;
  28467. /**
  28468. * Stores an array of target property paths
  28469. */
  28470. targetPropertyPath: string[];
  28471. /**
  28472. * Stores the blending speed of the animation
  28473. */
  28474. blendingSpeed: number;
  28475. /**
  28476. * Stores the animation ranges for the animation
  28477. */
  28478. private _ranges;
  28479. /**
  28480. * @hidden Internal use
  28481. */
  28482. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  28483. /**
  28484. * Sets up an animation
  28485. * @param property The property to animate
  28486. * @param animationType The animation type to apply
  28487. * @param framePerSecond The frames per second of the animation
  28488. * @param easingFunction The easing function used in the animation
  28489. * @returns The created animation
  28490. */
  28491. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  28492. /**
  28493. * Create and start an animation on a node
  28494. * @param name defines the name of the global animation that will be run on all nodes
  28495. * @param node defines the root node where the animation will take place
  28496. * @param targetProperty defines property to animate
  28497. * @param framePerSecond defines the number of frame per second yo use
  28498. * @param totalFrame defines the number of frames in total
  28499. * @param from defines the initial value
  28500. * @param to defines the final value
  28501. * @param loopMode defines which loop mode you want to use (off by default)
  28502. * @param easingFunction defines the easing function to use (linear by default)
  28503. * @param onAnimationEnd defines the callback to call when animation end
  28504. * @returns the animatable created for this animation
  28505. */
  28506. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  28507. /**
  28508. * Create and start an animation on a node and its descendants
  28509. * @param name defines the name of the global animation that will be run on all nodes
  28510. * @param node defines the root node where the animation will take place
  28511. * @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
  28512. * @param targetProperty defines property to animate
  28513. * @param framePerSecond defines the number of frame per second to use
  28514. * @param totalFrame defines the number of frames in total
  28515. * @param from defines the initial value
  28516. * @param to defines the final value
  28517. * @param loopMode defines which loop mode you want to use (off by default)
  28518. * @param easingFunction defines the easing function to use (linear by default)
  28519. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  28520. * @returns the list of animatables created for all nodes
  28521. * @example https://www.babylonjs-playground.com/#MH0VLI
  28522. */
  28523. 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[]>;
  28524. /**
  28525. * Creates a new animation, merges it with the existing animations and starts it
  28526. * @param name Name of the animation
  28527. * @param node Node which contains the scene that begins the animations
  28528. * @param targetProperty Specifies which property to animate
  28529. * @param framePerSecond The frames per second of the animation
  28530. * @param totalFrame The total number of frames
  28531. * @param from The frame at the beginning of the animation
  28532. * @param to The frame at the end of the animation
  28533. * @param loopMode Specifies the loop mode of the animation
  28534. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  28535. * @param onAnimationEnd Callback to run once the animation is complete
  28536. * @returns Nullable animation
  28537. */
  28538. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  28539. /**
  28540. * Transition property of an host to the target Value
  28541. * @param property The property to transition
  28542. * @param targetValue The target Value of the property
  28543. * @param host The object where the property to animate belongs
  28544. * @param scene Scene used to run the animation
  28545. * @param frameRate Framerate (in frame/s) to use
  28546. * @param transition The transition type we want to use
  28547. * @param duration The duration of the animation, in milliseconds
  28548. * @param onAnimationEnd Callback trigger at the end of the animation
  28549. * @returns Nullable animation
  28550. */
  28551. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  28552. /**
  28553. * Return the array of runtime animations currently using this animation
  28554. */
  28555. readonly runtimeAnimations: RuntimeAnimation[];
  28556. /**
  28557. * Specifies if any of the runtime animations are currently running
  28558. */
  28559. readonly hasRunningRuntimeAnimations: boolean;
  28560. /**
  28561. * Initializes the animation
  28562. * @param name Name of the animation
  28563. * @param targetProperty Property to animate
  28564. * @param framePerSecond The frames per second of the animation
  28565. * @param dataType The data type of the animation
  28566. * @param loopMode The loop mode of the animation
  28567. * @param enableBlending Specifies if blending should be enabled
  28568. */
  28569. constructor(
  28570. /**Name of the animation */
  28571. name: string,
  28572. /**Property to animate */
  28573. targetProperty: string,
  28574. /**The frames per second of the animation */
  28575. framePerSecond: number,
  28576. /**The data type of the animation */
  28577. dataType: number,
  28578. /**The loop mode of the animation */
  28579. loopMode?: number | undefined,
  28580. /**Specifies if blending should be enabled */
  28581. enableBlending?: boolean | undefined);
  28582. /**
  28583. * Converts the animation to a string
  28584. * @param fullDetails support for multiple levels of logging within scene loading
  28585. * @returns String form of the animation
  28586. */
  28587. toString(fullDetails?: boolean): string;
  28588. /**
  28589. * Add an event to this animation
  28590. * @param event Event to add
  28591. */
  28592. addEvent(event: AnimationEvent): void;
  28593. /**
  28594. * Remove all events found at the given frame
  28595. * @param frame The frame to remove events from
  28596. */
  28597. removeEvents(frame: number): void;
  28598. /**
  28599. * Retrieves all the events from the animation
  28600. * @returns Events from the animation
  28601. */
  28602. getEvents(): AnimationEvent[];
  28603. /**
  28604. * Creates an animation range
  28605. * @param name Name of the animation range
  28606. * @param from Starting frame of the animation range
  28607. * @param to Ending frame of the animation
  28608. */
  28609. createRange(name: string, from: number, to: number): void;
  28610. /**
  28611. * Deletes an animation range by name
  28612. * @param name Name of the animation range to delete
  28613. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  28614. */
  28615. deleteRange(name: string, deleteFrames?: boolean): void;
  28616. /**
  28617. * Gets the animation range by name, or null if not defined
  28618. * @param name Name of the animation range
  28619. * @returns Nullable animation range
  28620. */
  28621. getRange(name: string): Nullable<AnimationRange>;
  28622. /**
  28623. * Gets the key frames from the animation
  28624. * @returns The key frames of the animation
  28625. */
  28626. getKeys(): Array<IAnimationKey>;
  28627. /**
  28628. * Gets the highest frame rate of the animation
  28629. * @returns Highest frame rate of the animation
  28630. */
  28631. getHighestFrame(): number;
  28632. /**
  28633. * Gets the easing function of the animation
  28634. * @returns Easing function of the animation
  28635. */
  28636. getEasingFunction(): IEasingFunction;
  28637. /**
  28638. * Sets the easing function of the animation
  28639. * @param easingFunction A custom mathematical formula for animation
  28640. */
  28641. setEasingFunction(easingFunction: EasingFunction): void;
  28642. /**
  28643. * Interpolates a scalar linearly
  28644. * @param startValue Start value of the animation curve
  28645. * @param endValue End value of the animation curve
  28646. * @param gradient Scalar amount to interpolate
  28647. * @returns Interpolated scalar value
  28648. */
  28649. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  28650. /**
  28651. * Interpolates a scalar cubically
  28652. * @param startValue Start value of the animation curve
  28653. * @param outTangent End tangent of the animation
  28654. * @param endValue End value of the animation curve
  28655. * @param inTangent Start tangent of the animation curve
  28656. * @param gradient Scalar amount to interpolate
  28657. * @returns Interpolated scalar value
  28658. */
  28659. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  28660. /**
  28661. * Interpolates a quaternion using a spherical linear interpolation
  28662. * @param startValue Start value of the animation curve
  28663. * @param endValue End value of the animation curve
  28664. * @param gradient Scalar amount to interpolate
  28665. * @returns Interpolated quaternion value
  28666. */
  28667. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  28668. /**
  28669. * Interpolates a quaternion cubically
  28670. * @param startValue Start value of the animation curve
  28671. * @param outTangent End tangent of the animation curve
  28672. * @param endValue End value of the animation curve
  28673. * @param inTangent Start tangent of the animation curve
  28674. * @param gradient Scalar amount to interpolate
  28675. * @returns Interpolated quaternion value
  28676. */
  28677. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  28678. /**
  28679. * Interpolates a Vector3 linearl
  28680. * @param startValue Start value of the animation curve
  28681. * @param endValue End value of the animation curve
  28682. * @param gradient Scalar amount to interpolate
  28683. * @returns Interpolated scalar value
  28684. */
  28685. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  28686. /**
  28687. * Interpolates a Vector3 cubically
  28688. * @param startValue Start value of the animation curve
  28689. * @param outTangent End tangent of the animation
  28690. * @param endValue End value of the animation curve
  28691. * @param inTangent Start tangent of the animation curve
  28692. * @param gradient Scalar amount to interpolate
  28693. * @returns InterpolatedVector3 value
  28694. */
  28695. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  28696. /**
  28697. * Interpolates a Vector2 linearly
  28698. * @param startValue Start value of the animation curve
  28699. * @param endValue End value of the animation curve
  28700. * @param gradient Scalar amount to interpolate
  28701. * @returns Interpolated Vector2 value
  28702. */
  28703. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  28704. /**
  28705. * Interpolates a Vector2 cubically
  28706. * @param startValue Start value of the animation curve
  28707. * @param outTangent End tangent of the animation
  28708. * @param endValue End value of the animation curve
  28709. * @param inTangent Start tangent of the animation curve
  28710. * @param gradient Scalar amount to interpolate
  28711. * @returns Interpolated Vector2 value
  28712. */
  28713. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  28714. /**
  28715. * Interpolates a size linearly
  28716. * @param startValue Start value of the animation curve
  28717. * @param endValue End value of the animation curve
  28718. * @param gradient Scalar amount to interpolate
  28719. * @returns Interpolated Size value
  28720. */
  28721. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  28722. /**
  28723. * Interpolates a Color3 linearly
  28724. * @param startValue Start value of the animation curve
  28725. * @param endValue End value of the animation curve
  28726. * @param gradient Scalar amount to interpolate
  28727. * @returns Interpolated Color3 value
  28728. */
  28729. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  28730. /**
  28731. * Interpolates a Color4 linearly
  28732. * @param startValue Start value of the animation curve
  28733. * @param endValue End value of the animation curve
  28734. * @param gradient Scalar amount to interpolate
  28735. * @returns Interpolated Color3 value
  28736. */
  28737. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  28738. /**
  28739. * @hidden Internal use only
  28740. */
  28741. _getKeyValue(value: any): any;
  28742. /**
  28743. * @hidden Internal use only
  28744. */
  28745. _interpolate(currentFrame: number, state: _IAnimationState): any;
  28746. /**
  28747. * Defines the function to use to interpolate matrices
  28748. * @param startValue defines the start matrix
  28749. * @param endValue defines the end matrix
  28750. * @param gradient defines the gradient between both matrices
  28751. * @param result defines an optional target matrix where to store the interpolation
  28752. * @returns the interpolated matrix
  28753. */
  28754. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  28755. /**
  28756. * Makes a copy of the animation
  28757. * @returns Cloned animation
  28758. */
  28759. clone(): Animation;
  28760. /**
  28761. * Sets the key frames of the animation
  28762. * @param values The animation key frames to set
  28763. */
  28764. setKeys(values: Array<IAnimationKey>): void;
  28765. /**
  28766. * Serializes the animation to an object
  28767. * @returns Serialized object
  28768. */
  28769. serialize(): any;
  28770. /**
  28771. * Float animation type
  28772. */
  28773. static readonly ANIMATIONTYPE_FLOAT: number;
  28774. /**
  28775. * Vector3 animation type
  28776. */
  28777. static readonly ANIMATIONTYPE_VECTOR3: number;
  28778. /**
  28779. * Quaternion animation type
  28780. */
  28781. static readonly ANIMATIONTYPE_QUATERNION: number;
  28782. /**
  28783. * Matrix animation type
  28784. */
  28785. static readonly ANIMATIONTYPE_MATRIX: number;
  28786. /**
  28787. * Color3 animation type
  28788. */
  28789. static readonly ANIMATIONTYPE_COLOR3: number;
  28790. /**
  28791. * Color3 animation type
  28792. */
  28793. static readonly ANIMATIONTYPE_COLOR4: number;
  28794. /**
  28795. * Vector2 animation type
  28796. */
  28797. static readonly ANIMATIONTYPE_VECTOR2: number;
  28798. /**
  28799. * Size animation type
  28800. */
  28801. static readonly ANIMATIONTYPE_SIZE: number;
  28802. /**
  28803. * Relative Loop Mode
  28804. */
  28805. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  28806. /**
  28807. * Cycle Loop Mode
  28808. */
  28809. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  28810. /**
  28811. * Constant Loop Mode
  28812. */
  28813. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  28814. /** @hidden */
  28815. static _UniversalLerp(left: any, right: any, amount: number): any;
  28816. /**
  28817. * Parses an animation object and creates an animation
  28818. * @param parsedAnimation Parsed animation object
  28819. * @returns Animation object
  28820. */
  28821. static Parse(parsedAnimation: any): Animation;
  28822. /**
  28823. * Appends the serialized animations from the source animations
  28824. * @param source Source containing the animations
  28825. * @param destination Target to store the animations
  28826. */
  28827. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  28828. }
  28829. }
  28830. declare module "babylonjs/Animations/animatable.interface" {
  28831. import { Nullable } from "babylonjs/types";
  28832. import { Animation } from "babylonjs/Animations/animation";
  28833. /**
  28834. * Interface containing an array of animations
  28835. */
  28836. export interface IAnimatable {
  28837. /**
  28838. * Array of animations
  28839. */
  28840. animations: Nullable<Array<Animation>>;
  28841. }
  28842. }
  28843. declare module "babylonjs/Materials/fresnelParameters" {
  28844. import { Color3 } from "babylonjs/Maths/math.color";
  28845. /**
  28846. * This represents all the required information to add a fresnel effect on a material:
  28847. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  28848. */
  28849. export class FresnelParameters {
  28850. private _isEnabled;
  28851. /**
  28852. * Define if the fresnel effect is enable or not.
  28853. */
  28854. isEnabled: boolean;
  28855. /**
  28856. * Define the color used on edges (grazing angle)
  28857. */
  28858. leftColor: Color3;
  28859. /**
  28860. * Define the color used on center
  28861. */
  28862. rightColor: Color3;
  28863. /**
  28864. * Define bias applied to computed fresnel term
  28865. */
  28866. bias: number;
  28867. /**
  28868. * Defined the power exponent applied to fresnel term
  28869. */
  28870. power: number;
  28871. /**
  28872. * Clones the current fresnel and its valuues
  28873. * @returns a clone fresnel configuration
  28874. */
  28875. clone(): FresnelParameters;
  28876. /**
  28877. * Serializes the current fresnel parameters to a JSON representation.
  28878. * @return the JSON serialization
  28879. */
  28880. serialize(): any;
  28881. /**
  28882. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  28883. * @param parsedFresnelParameters Define the JSON representation
  28884. * @returns the parsed parameters
  28885. */
  28886. static Parse(parsedFresnelParameters: any): FresnelParameters;
  28887. }
  28888. }
  28889. declare module "babylonjs/Misc/decorators" {
  28890. import { Nullable } from "babylonjs/types";
  28891. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  28892. import { Scene } from "babylonjs/scene";
  28893. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  28894. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28895. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28896. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28897. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28898. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28899. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28900. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28901. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28902. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28903. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28904. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28905. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28906. /**
  28907. * Decorator used to define property that can be serialized as reference to a camera
  28908. * @param sourceName defines the name of the property to decorate
  28909. */
  28910. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28911. /**
  28912. * Class used to help serialization objects
  28913. */
  28914. export class SerializationHelper {
  28915. /** @hidden */
  28916. static _ImageProcessingConfigurationParser: (sourceProperty: any) => import("babylonjs/Materials/imageProcessingConfiguration").ImageProcessingConfiguration;
  28917. /** @hidden */
  28918. static _FresnelParametersParser: (sourceProperty: any) => import("babylonjs/Materials/fresnelParameters").FresnelParameters;
  28919. /** @hidden */
  28920. static _ColorCurvesParser: (sourceProperty: any) => import("babylonjs/Materials/colorCurves").ColorCurves;
  28921. /** @hidden */
  28922. static _TextureParser: (sourceProperty: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => Nullable<import("babylonjs/Materials/Textures/baseTexture").BaseTexture>;
  28923. /**
  28924. * Appends the serialized animations from the source animations
  28925. * @param source Source containing the animations
  28926. * @param destination Target to store the animations
  28927. */
  28928. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  28929. /**
  28930. * Static function used to serialized a specific entity
  28931. * @param entity defines the entity to serialize
  28932. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  28933. * @returns a JSON compatible object representing the serialization of the entity
  28934. */
  28935. static Serialize<T>(entity: T, serializationObject?: any): any;
  28936. /**
  28937. * Creates a new entity from a serialization data object
  28938. * @param creationFunction defines a function used to instanciated the new entity
  28939. * @param source defines the source serialization data
  28940. * @param scene defines the hosting scene
  28941. * @param rootUrl defines the root url for resources
  28942. * @returns a new entity
  28943. */
  28944. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  28945. /**
  28946. * Clones an object
  28947. * @param creationFunction defines the function used to instanciate the new object
  28948. * @param source defines the source object
  28949. * @returns the cloned object
  28950. */
  28951. static Clone<T>(creationFunction: () => T, source: T): T;
  28952. /**
  28953. * Instanciates a new object based on a source one (some data will be shared between both object)
  28954. * @param creationFunction defines the function used to instanciate the new object
  28955. * @param source defines the source object
  28956. * @returns the new object
  28957. */
  28958. static Instanciate<T>(creationFunction: () => T, source: T): T;
  28959. }
  28960. }
  28961. declare module "babylonjs/Misc/guid" {
  28962. /**
  28963. * Class used to manipulate GUIDs
  28964. */
  28965. export class GUID {
  28966. /**
  28967. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  28968. * Be aware Math.random() could cause collisions, but:
  28969. * "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"
  28970. * @returns a pseudo random id
  28971. */
  28972. static RandomId(): string;
  28973. }
  28974. }
  28975. declare module "babylonjs/Materials/Textures/baseTexture" {
  28976. import { Observable } from "babylonjs/Misc/observable";
  28977. import { Nullable } from "babylonjs/types";
  28978. import { Scene } from "babylonjs/scene";
  28979. import { Matrix } from "babylonjs/Maths/math.vector";
  28980. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  28981. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  28982. import { ISize } from "babylonjs/Maths/math.size";
  28983. /**
  28984. * Base class of all the textures in babylon.
  28985. * It groups all the common properties the materials, post process, lights... might need
  28986. * in order to make a correct use of the texture.
  28987. */
  28988. export class BaseTexture implements IAnimatable {
  28989. /**
  28990. * Default anisotropic filtering level for the application.
  28991. * It is set to 4 as a good tradeoff between perf and quality.
  28992. */
  28993. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  28994. /**
  28995. * Gets or sets the unique id of the texture
  28996. */
  28997. uniqueId: number;
  28998. /**
  28999. * Define the name of the texture.
  29000. */
  29001. name: string;
  29002. /**
  29003. * Gets or sets an object used to store user defined information.
  29004. */
  29005. metadata: any;
  29006. /**
  29007. * For internal use only. Please do not use.
  29008. */
  29009. reservedDataStore: any;
  29010. private _hasAlpha;
  29011. /**
  29012. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  29013. */
  29014. hasAlpha: boolean;
  29015. /**
  29016. * Defines if the alpha value should be determined via the rgb values.
  29017. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  29018. */
  29019. getAlphaFromRGB: boolean;
  29020. /**
  29021. * Intensity or strength of the texture.
  29022. * It is commonly used by materials to fine tune the intensity of the texture
  29023. */
  29024. level: number;
  29025. /**
  29026. * Define the UV chanel to use starting from 0 and defaulting to 0.
  29027. * This is part of the texture as textures usually maps to one uv set.
  29028. */
  29029. coordinatesIndex: number;
  29030. private _coordinatesMode;
  29031. /**
  29032. * How a texture is mapped.
  29033. *
  29034. * | Value | Type | Description |
  29035. * | ----- | ----------------------------------- | ----------- |
  29036. * | 0 | EXPLICIT_MODE | |
  29037. * | 1 | SPHERICAL_MODE | |
  29038. * | 2 | PLANAR_MODE | |
  29039. * | 3 | CUBIC_MODE | |
  29040. * | 4 | PROJECTION_MODE | |
  29041. * | 5 | SKYBOX_MODE | |
  29042. * | 6 | INVCUBIC_MODE | |
  29043. * | 7 | EQUIRECTANGULAR_MODE | |
  29044. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  29045. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  29046. */
  29047. coordinatesMode: number;
  29048. /**
  29049. * | Value | Type | Description |
  29050. * | ----- | ------------------ | ----------- |
  29051. * | 0 | CLAMP_ADDRESSMODE | |
  29052. * | 1 | WRAP_ADDRESSMODE | |
  29053. * | 2 | MIRROR_ADDRESSMODE | |
  29054. */
  29055. wrapU: number;
  29056. /**
  29057. * | Value | Type | Description |
  29058. * | ----- | ------------------ | ----------- |
  29059. * | 0 | CLAMP_ADDRESSMODE | |
  29060. * | 1 | WRAP_ADDRESSMODE | |
  29061. * | 2 | MIRROR_ADDRESSMODE | |
  29062. */
  29063. wrapV: number;
  29064. /**
  29065. * | Value | Type | Description |
  29066. * | ----- | ------------------ | ----------- |
  29067. * | 0 | CLAMP_ADDRESSMODE | |
  29068. * | 1 | WRAP_ADDRESSMODE | |
  29069. * | 2 | MIRROR_ADDRESSMODE | |
  29070. */
  29071. wrapR: number;
  29072. /**
  29073. * With compliant hardware and browser (supporting anisotropic filtering)
  29074. * this defines the level of anisotropic filtering in the texture.
  29075. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  29076. */
  29077. anisotropicFilteringLevel: number;
  29078. /**
  29079. * Define if the texture is a cube texture or if false a 2d texture.
  29080. */
  29081. isCube: boolean;
  29082. /**
  29083. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  29084. */
  29085. is3D: boolean;
  29086. /**
  29087. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  29088. */
  29089. is2DArray: boolean;
  29090. /**
  29091. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  29092. * HDR texture are usually stored in linear space.
  29093. * This only impacts the PBR and Background materials
  29094. */
  29095. gammaSpace: boolean;
  29096. /**
  29097. * Gets or sets whether or not the texture contains RGBD data.
  29098. */
  29099. isRGBD: boolean;
  29100. /**
  29101. * Is Z inverted in the texture (useful in a cube texture).
  29102. */
  29103. invertZ: boolean;
  29104. /**
  29105. * Are mip maps generated for this texture or not.
  29106. */
  29107. readonly noMipmap: boolean;
  29108. /**
  29109. * @hidden
  29110. */
  29111. lodLevelInAlpha: boolean;
  29112. /**
  29113. * With prefiltered texture, defined the offset used during the prefiltering steps.
  29114. */
  29115. lodGenerationOffset: number;
  29116. /**
  29117. * With prefiltered texture, defined the scale used during the prefiltering steps.
  29118. */
  29119. lodGenerationScale: number;
  29120. /**
  29121. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  29122. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  29123. * average roughness values.
  29124. */
  29125. linearSpecularLOD: boolean;
  29126. /**
  29127. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  29128. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  29129. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  29130. */
  29131. irradianceTexture: Nullable<BaseTexture>;
  29132. /**
  29133. * Define if the texture is a render target.
  29134. */
  29135. isRenderTarget: boolean;
  29136. /**
  29137. * Define the unique id of the texture in the scene.
  29138. */
  29139. readonly uid: string;
  29140. /**
  29141. * Return a string representation of the texture.
  29142. * @returns the texture as a string
  29143. */
  29144. toString(): string;
  29145. /**
  29146. * Get the class name of the texture.
  29147. * @returns "BaseTexture"
  29148. */
  29149. getClassName(): string;
  29150. /**
  29151. * Define the list of animation attached to the texture.
  29152. */
  29153. animations: import("babylonjs/Animations/animation").Animation[];
  29154. /**
  29155. * An event triggered when the texture is disposed.
  29156. */
  29157. onDisposeObservable: Observable<BaseTexture>;
  29158. private _onDisposeObserver;
  29159. /**
  29160. * Callback triggered when the texture has been disposed.
  29161. * Kept for back compatibility, you can use the onDisposeObservable instead.
  29162. */
  29163. onDispose: () => void;
  29164. /**
  29165. * Define the current state of the loading sequence when in delayed load mode.
  29166. */
  29167. delayLoadState: number;
  29168. private _scene;
  29169. /** @hidden */
  29170. _texture: Nullable<InternalTexture>;
  29171. private _uid;
  29172. /**
  29173. * Define if the texture is preventinga material to render or not.
  29174. * If not and the texture is not ready, the engine will use a default black texture instead.
  29175. */
  29176. readonly isBlocking: boolean;
  29177. /**
  29178. * Instantiates a new BaseTexture.
  29179. * Base class of all the textures in babylon.
  29180. * It groups all the common properties the materials, post process, lights... might need
  29181. * in order to make a correct use of the texture.
  29182. * @param scene Define the scene the texture blongs to
  29183. */
  29184. constructor(scene: Nullable<Scene>);
  29185. /**
  29186. * Get the scene the texture belongs to.
  29187. * @returns the scene or null if undefined
  29188. */
  29189. getScene(): Nullable<Scene>;
  29190. /**
  29191. * Get the texture transform matrix used to offset tile the texture for istance.
  29192. * @returns the transformation matrix
  29193. */
  29194. getTextureMatrix(): Matrix;
  29195. /**
  29196. * Get the texture reflection matrix used to rotate/transform the reflection.
  29197. * @returns the reflection matrix
  29198. */
  29199. getReflectionTextureMatrix(): Matrix;
  29200. /**
  29201. * Get the underlying lower level texture from Babylon.
  29202. * @returns the insternal texture
  29203. */
  29204. getInternalTexture(): Nullable<InternalTexture>;
  29205. /**
  29206. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  29207. * @returns true if ready or not blocking
  29208. */
  29209. isReadyOrNotBlocking(): boolean;
  29210. /**
  29211. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  29212. * @returns true if fully ready
  29213. */
  29214. isReady(): boolean;
  29215. private _cachedSize;
  29216. /**
  29217. * Get the size of the texture.
  29218. * @returns the texture size.
  29219. */
  29220. getSize(): ISize;
  29221. /**
  29222. * Get the base size of the texture.
  29223. * It can be different from the size if the texture has been resized for POT for instance
  29224. * @returns the base size
  29225. */
  29226. getBaseSize(): ISize;
  29227. /**
  29228. * Update the sampling mode of the texture.
  29229. * Default is Trilinear mode.
  29230. *
  29231. * | Value | Type | Description |
  29232. * | ----- | ------------------ | ----------- |
  29233. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  29234. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  29235. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  29236. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  29237. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  29238. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  29239. * | 7 | NEAREST_LINEAR | |
  29240. * | 8 | NEAREST_NEAREST | |
  29241. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  29242. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  29243. * | 11 | LINEAR_LINEAR | |
  29244. * | 12 | LINEAR_NEAREST | |
  29245. *
  29246. * > _mag_: magnification filter (close to the viewer)
  29247. * > _min_: minification filter (far from the viewer)
  29248. * > _mip_: filter used between mip map levels
  29249. *@param samplingMode Define the new sampling mode of the texture
  29250. */
  29251. updateSamplingMode(samplingMode: number): void;
  29252. /**
  29253. * Scales the texture if is `canRescale()`
  29254. * @param ratio the resize factor we want to use to rescale
  29255. */
  29256. scale(ratio: number): void;
  29257. /**
  29258. * Get if the texture can rescale.
  29259. */
  29260. readonly canRescale: boolean;
  29261. /** @hidden */
  29262. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  29263. /** @hidden */
  29264. _rebuild(): void;
  29265. /**
  29266. * Triggers the load sequence in delayed load mode.
  29267. */
  29268. delayLoad(): void;
  29269. /**
  29270. * Clones the texture.
  29271. * @returns the cloned texture
  29272. */
  29273. clone(): Nullable<BaseTexture>;
  29274. /**
  29275. * Get the texture underlying type (INT, FLOAT...)
  29276. */
  29277. readonly textureType: number;
  29278. /**
  29279. * Get the texture underlying format (RGB, RGBA...)
  29280. */
  29281. readonly textureFormat: number;
  29282. /**
  29283. * Indicates that textures need to be re-calculated for all materials
  29284. */
  29285. protected _markAllSubMeshesAsTexturesDirty(): void;
  29286. /**
  29287. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  29288. * This will returns an RGBA array buffer containing either in values (0-255) or
  29289. * float values (0-1) depending of the underlying buffer type.
  29290. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  29291. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  29292. * @param buffer defines a user defined buffer to fill with data (can be null)
  29293. * @returns The Array buffer containing the pixels data.
  29294. */
  29295. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  29296. /**
  29297. * Release and destroy the underlying lower level texture aka internalTexture.
  29298. */
  29299. releaseInternalTexture(): void;
  29300. /** @hidden */
  29301. readonly _lodTextureHigh: Nullable<BaseTexture>;
  29302. /** @hidden */
  29303. readonly _lodTextureMid: Nullable<BaseTexture>;
  29304. /** @hidden */
  29305. readonly _lodTextureLow: Nullable<BaseTexture>;
  29306. /**
  29307. * Dispose the texture and release its associated resources.
  29308. */
  29309. dispose(): void;
  29310. /**
  29311. * Serialize the texture into a JSON representation that can be parsed later on.
  29312. * @returns the JSON representation of the texture
  29313. */
  29314. serialize(): any;
  29315. /**
  29316. * Helper function to be called back once a list of texture contains only ready textures.
  29317. * @param textures Define the list of textures to wait for
  29318. * @param callback Define the callback triggered once the entire list will be ready
  29319. */
  29320. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  29321. }
  29322. }
  29323. declare module "babylonjs/Materials/effect" {
  29324. import { Observable } from "babylonjs/Misc/observable";
  29325. import { Nullable } from "babylonjs/types";
  29326. import { IDisposable } from "babylonjs/scene";
  29327. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  29328. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  29329. import { IMatrixLike, IVector2Like, IVector3Like, IVector4Like, IColor3Like, IColor4Like } from "babylonjs/Maths/math.like";
  29330. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  29331. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  29332. import { Engine } from "babylonjs/Engines/engine";
  29333. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  29334. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  29335. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  29336. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  29337. /**
  29338. * Options to be used when creating an effect.
  29339. */
  29340. export interface IEffectCreationOptions {
  29341. /**
  29342. * Atrributes that will be used in the shader.
  29343. */
  29344. attributes: string[];
  29345. /**
  29346. * Uniform varible names that will be set in the shader.
  29347. */
  29348. uniformsNames: string[];
  29349. /**
  29350. * Uniform buffer variable names that will be set in the shader.
  29351. */
  29352. uniformBuffersNames: string[];
  29353. /**
  29354. * Sampler texture variable names that will be set in the shader.
  29355. */
  29356. samplers: string[];
  29357. /**
  29358. * Define statements that will be set in the shader.
  29359. */
  29360. defines: any;
  29361. /**
  29362. * Possible fallbacks for this effect to improve performance when needed.
  29363. */
  29364. fallbacks: Nullable<IEffectFallbacks>;
  29365. /**
  29366. * Callback that will be called when the shader is compiled.
  29367. */
  29368. onCompiled: Nullable<(effect: Effect) => void>;
  29369. /**
  29370. * Callback that will be called if an error occurs during shader compilation.
  29371. */
  29372. onError: Nullable<(effect: Effect, errors: string) => void>;
  29373. /**
  29374. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29375. */
  29376. indexParameters?: any;
  29377. /**
  29378. * Max number of lights that can be used in the shader.
  29379. */
  29380. maxSimultaneousLights?: number;
  29381. /**
  29382. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  29383. */
  29384. transformFeedbackVaryings?: Nullable<string[]>;
  29385. }
  29386. /**
  29387. * Effect containing vertex and fragment shader that can be executed on an object.
  29388. */
  29389. export class Effect implements IDisposable {
  29390. /**
  29391. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  29392. */
  29393. static ShadersRepository: string;
  29394. /**
  29395. * Name of the effect.
  29396. */
  29397. name: any;
  29398. /**
  29399. * String container all the define statements that should be set on the shader.
  29400. */
  29401. defines: string;
  29402. /**
  29403. * Callback that will be called when the shader is compiled.
  29404. */
  29405. onCompiled: Nullable<(effect: Effect) => void>;
  29406. /**
  29407. * Callback that will be called if an error occurs during shader compilation.
  29408. */
  29409. onError: Nullable<(effect: Effect, errors: string) => void>;
  29410. /**
  29411. * Callback that will be called when effect is bound.
  29412. */
  29413. onBind: Nullable<(effect: Effect) => void>;
  29414. /**
  29415. * Unique ID of the effect.
  29416. */
  29417. uniqueId: number;
  29418. /**
  29419. * Observable that will be called when the shader is compiled.
  29420. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  29421. */
  29422. onCompileObservable: Observable<Effect>;
  29423. /**
  29424. * Observable that will be called if an error occurs during shader compilation.
  29425. */
  29426. onErrorObservable: Observable<Effect>;
  29427. /** @hidden */
  29428. _onBindObservable: Nullable<Observable<Effect>>;
  29429. /**
  29430. * Observable that will be called when effect is bound.
  29431. */
  29432. readonly onBindObservable: Observable<Effect>;
  29433. /** @hidden */
  29434. _bonesComputationForcedToCPU: boolean;
  29435. private static _uniqueIdSeed;
  29436. private _engine;
  29437. private _uniformBuffersNames;
  29438. private _uniformsNames;
  29439. private _samplerList;
  29440. private _samplers;
  29441. private _isReady;
  29442. private _compilationError;
  29443. private _allFallbacksProcessed;
  29444. private _attributesNames;
  29445. private _attributes;
  29446. private _uniforms;
  29447. /**
  29448. * Key for the effect.
  29449. * @hidden
  29450. */
  29451. _key: string;
  29452. private _indexParameters;
  29453. private _fallbacks;
  29454. private _vertexSourceCode;
  29455. private _fragmentSourceCode;
  29456. private _vertexSourceCodeOverride;
  29457. private _fragmentSourceCodeOverride;
  29458. private _transformFeedbackVaryings;
  29459. /**
  29460. * Compiled shader to webGL program.
  29461. * @hidden
  29462. */
  29463. _pipelineContext: Nullable<IPipelineContext>;
  29464. private _valueCache;
  29465. private static _baseCache;
  29466. /**
  29467. * Instantiates an effect.
  29468. * An effect can be used to create/manage/execute vertex and fragment shaders.
  29469. * @param baseName Name of the effect.
  29470. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  29471. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  29472. * @param samplers List of sampler variables that will be passed to the shader.
  29473. * @param engine Engine to be used to render the effect
  29474. * @param defines Define statements to be added to the shader.
  29475. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  29476. * @param onCompiled Callback that will be called when the shader is compiled.
  29477. * @param onError Callback that will be called if an error occurs during shader compilation.
  29478. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29479. */
  29480. 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);
  29481. private _useFinalCode;
  29482. /**
  29483. * Unique key for this effect
  29484. */
  29485. readonly key: string;
  29486. /**
  29487. * If the effect has been compiled and prepared.
  29488. * @returns if the effect is compiled and prepared.
  29489. */
  29490. isReady(): boolean;
  29491. private _isReadyInternal;
  29492. /**
  29493. * The engine the effect was initialized with.
  29494. * @returns the engine.
  29495. */
  29496. getEngine(): Engine;
  29497. /**
  29498. * The pipeline context for this effect
  29499. * @returns the associated pipeline context
  29500. */
  29501. getPipelineContext(): Nullable<IPipelineContext>;
  29502. /**
  29503. * The set of names of attribute variables for the shader.
  29504. * @returns An array of attribute names.
  29505. */
  29506. getAttributesNames(): string[];
  29507. /**
  29508. * Returns the attribute at the given index.
  29509. * @param index The index of the attribute.
  29510. * @returns The location of the attribute.
  29511. */
  29512. getAttributeLocation(index: number): number;
  29513. /**
  29514. * Returns the attribute based on the name of the variable.
  29515. * @param name of the attribute to look up.
  29516. * @returns the attribute location.
  29517. */
  29518. getAttributeLocationByName(name: string): number;
  29519. /**
  29520. * The number of attributes.
  29521. * @returns the numnber of attributes.
  29522. */
  29523. getAttributesCount(): number;
  29524. /**
  29525. * Gets the index of a uniform variable.
  29526. * @param uniformName of the uniform to look up.
  29527. * @returns the index.
  29528. */
  29529. getUniformIndex(uniformName: string): number;
  29530. /**
  29531. * Returns the attribute based on the name of the variable.
  29532. * @param uniformName of the uniform to look up.
  29533. * @returns the location of the uniform.
  29534. */
  29535. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  29536. /**
  29537. * Returns an array of sampler variable names
  29538. * @returns The array of sampler variable neames.
  29539. */
  29540. getSamplers(): string[];
  29541. /**
  29542. * The error from the last compilation.
  29543. * @returns the error string.
  29544. */
  29545. getCompilationError(): string;
  29546. /**
  29547. * Gets a boolean indicating that all fallbacks were used during compilation
  29548. * @returns true if all fallbacks were used
  29549. */
  29550. allFallbacksProcessed(): boolean;
  29551. /**
  29552. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  29553. * @param func The callback to be used.
  29554. */
  29555. executeWhenCompiled(func: (effect: Effect) => void): void;
  29556. private _checkIsReady;
  29557. private _loadShader;
  29558. /**
  29559. * Recompiles the webGL program
  29560. * @param vertexSourceCode The source code for the vertex shader.
  29561. * @param fragmentSourceCode The source code for the fragment shader.
  29562. * @param onCompiled Callback called when completed.
  29563. * @param onError Callback called on error.
  29564. * @hidden
  29565. */
  29566. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  29567. /**
  29568. * Prepares the effect
  29569. * @hidden
  29570. */
  29571. _prepareEffect(): void;
  29572. private _processCompilationErrors;
  29573. /**
  29574. * Checks if the effect is supported. (Must be called after compilation)
  29575. */
  29576. readonly isSupported: boolean;
  29577. /**
  29578. * Binds a texture to the engine to be used as output of the shader.
  29579. * @param channel Name of the output variable.
  29580. * @param texture Texture to bind.
  29581. * @hidden
  29582. */
  29583. _bindTexture(channel: string, texture: InternalTexture): void;
  29584. /**
  29585. * Sets a texture on the engine to be used in the shader.
  29586. * @param channel Name of the sampler variable.
  29587. * @param texture Texture to set.
  29588. */
  29589. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  29590. /**
  29591. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  29592. * @param channel Name of the sampler variable.
  29593. * @param texture Texture to set.
  29594. */
  29595. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  29596. /**
  29597. * Sets an array of textures on the engine to be used in the shader.
  29598. * @param channel Name of the variable.
  29599. * @param textures Textures to set.
  29600. */
  29601. setTextureArray(channel: string, textures: BaseTexture[]): void;
  29602. /**
  29603. * 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)
  29604. * @param channel Name of the sampler variable.
  29605. * @param postProcess Post process to get the input texture from.
  29606. */
  29607. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  29608. /**
  29609. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  29610. * 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)
  29611. * @param channel Name of the sampler variable.
  29612. * @param postProcess Post process to get the output texture from.
  29613. */
  29614. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  29615. /** @hidden */
  29616. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  29617. /** @hidden */
  29618. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  29619. /** @hidden */
  29620. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  29621. /** @hidden */
  29622. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  29623. /**
  29624. * Binds a buffer to a uniform.
  29625. * @param buffer Buffer to bind.
  29626. * @param name Name of the uniform variable to bind to.
  29627. */
  29628. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  29629. /**
  29630. * Binds block to a uniform.
  29631. * @param blockName Name of the block to bind.
  29632. * @param index Index to bind.
  29633. */
  29634. bindUniformBlock(blockName: string, index: number): void;
  29635. /**
  29636. * Sets an interger value on a uniform variable.
  29637. * @param uniformName Name of the variable.
  29638. * @param value Value to be set.
  29639. * @returns this effect.
  29640. */
  29641. setInt(uniformName: string, value: number): Effect;
  29642. /**
  29643. * Sets an int array on a uniform variable.
  29644. * @param uniformName Name of the variable.
  29645. * @param array array to be set.
  29646. * @returns this effect.
  29647. */
  29648. setIntArray(uniformName: string, array: Int32Array): Effect;
  29649. /**
  29650. * 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)
  29651. * @param uniformName Name of the variable.
  29652. * @param array array to be set.
  29653. * @returns this effect.
  29654. */
  29655. setIntArray2(uniformName: string, array: Int32Array): Effect;
  29656. /**
  29657. * 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)
  29658. * @param uniformName Name of the variable.
  29659. * @param array array to be set.
  29660. * @returns this effect.
  29661. */
  29662. setIntArray3(uniformName: string, array: Int32Array): Effect;
  29663. /**
  29664. * 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)
  29665. * @param uniformName Name of the variable.
  29666. * @param array array to be set.
  29667. * @returns this effect.
  29668. */
  29669. setIntArray4(uniformName: string, array: Int32Array): Effect;
  29670. /**
  29671. * Sets an float array on a uniform variable.
  29672. * @param uniformName Name of the variable.
  29673. * @param array array to be set.
  29674. * @returns this effect.
  29675. */
  29676. setFloatArray(uniformName: string, array: Float32Array): Effect;
  29677. /**
  29678. * 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)
  29679. * @param uniformName Name of the variable.
  29680. * @param array array to be set.
  29681. * @returns this effect.
  29682. */
  29683. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  29684. /**
  29685. * 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)
  29686. * @param uniformName Name of the variable.
  29687. * @param array array to be set.
  29688. * @returns this effect.
  29689. */
  29690. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  29691. /**
  29692. * 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)
  29693. * @param uniformName Name of the variable.
  29694. * @param array array to be set.
  29695. * @returns this effect.
  29696. */
  29697. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  29698. /**
  29699. * Sets an array on a uniform variable.
  29700. * @param uniformName Name of the variable.
  29701. * @param array array to be set.
  29702. * @returns this effect.
  29703. */
  29704. setArray(uniformName: string, array: number[]): Effect;
  29705. /**
  29706. * 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)
  29707. * @param uniformName Name of the variable.
  29708. * @param array array to be set.
  29709. * @returns this effect.
  29710. */
  29711. setArray2(uniformName: string, array: number[]): Effect;
  29712. /**
  29713. * 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)
  29714. * @param uniformName Name of the variable.
  29715. * @param array array to be set.
  29716. * @returns this effect.
  29717. */
  29718. setArray3(uniformName: string, array: number[]): Effect;
  29719. /**
  29720. * 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)
  29721. * @param uniformName Name of the variable.
  29722. * @param array array to be set.
  29723. * @returns this effect.
  29724. */
  29725. setArray4(uniformName: string, array: number[]): Effect;
  29726. /**
  29727. * Sets matrices on a uniform variable.
  29728. * @param uniformName Name of the variable.
  29729. * @param matrices matrices to be set.
  29730. * @returns this effect.
  29731. */
  29732. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  29733. /**
  29734. * Sets matrix on a uniform variable.
  29735. * @param uniformName Name of the variable.
  29736. * @param matrix matrix to be set.
  29737. * @returns this effect.
  29738. */
  29739. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  29740. /**
  29741. * 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)
  29742. * @param uniformName Name of the variable.
  29743. * @param matrix matrix to be set.
  29744. * @returns this effect.
  29745. */
  29746. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  29747. /**
  29748. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  29749. * @param uniformName Name of the variable.
  29750. * @param matrix matrix to be set.
  29751. * @returns this effect.
  29752. */
  29753. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  29754. /**
  29755. * Sets a float on a uniform variable.
  29756. * @param uniformName Name of the variable.
  29757. * @param value value to be set.
  29758. * @returns this effect.
  29759. */
  29760. setFloat(uniformName: string, value: number): Effect;
  29761. /**
  29762. * Sets a boolean on a uniform variable.
  29763. * @param uniformName Name of the variable.
  29764. * @param bool value to be set.
  29765. * @returns this effect.
  29766. */
  29767. setBool(uniformName: string, bool: boolean): Effect;
  29768. /**
  29769. * Sets a Vector2 on a uniform variable.
  29770. * @param uniformName Name of the variable.
  29771. * @param vector2 vector2 to be set.
  29772. * @returns this effect.
  29773. */
  29774. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  29775. /**
  29776. * Sets a float2 on a uniform variable.
  29777. * @param uniformName Name of the variable.
  29778. * @param x First float in float2.
  29779. * @param y Second float in float2.
  29780. * @returns this effect.
  29781. */
  29782. setFloat2(uniformName: string, x: number, y: number): Effect;
  29783. /**
  29784. * Sets a Vector3 on a uniform variable.
  29785. * @param uniformName Name of the variable.
  29786. * @param vector3 Value to be set.
  29787. * @returns this effect.
  29788. */
  29789. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  29790. /**
  29791. * Sets a float3 on a uniform variable.
  29792. * @param uniformName Name of the variable.
  29793. * @param x First float in float3.
  29794. * @param y Second float in float3.
  29795. * @param z Third float in float3.
  29796. * @returns this effect.
  29797. */
  29798. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  29799. /**
  29800. * Sets a Vector4 on a uniform variable.
  29801. * @param uniformName Name of the variable.
  29802. * @param vector4 Value to be set.
  29803. * @returns this effect.
  29804. */
  29805. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  29806. /**
  29807. * Sets a float4 on a uniform variable.
  29808. * @param uniformName Name of the variable.
  29809. * @param x First float in float4.
  29810. * @param y Second float in float4.
  29811. * @param z Third float in float4.
  29812. * @param w Fourth float in float4.
  29813. * @returns this effect.
  29814. */
  29815. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  29816. /**
  29817. * Sets a Color3 on a uniform variable.
  29818. * @param uniformName Name of the variable.
  29819. * @param color3 Value to be set.
  29820. * @returns this effect.
  29821. */
  29822. setColor3(uniformName: string, color3: IColor3Like): Effect;
  29823. /**
  29824. * Sets a Color4 on a uniform variable.
  29825. * @param uniformName Name of the variable.
  29826. * @param color3 Value to be set.
  29827. * @param alpha Alpha value to be set.
  29828. * @returns this effect.
  29829. */
  29830. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  29831. /**
  29832. * Sets a Color4 on a uniform variable
  29833. * @param uniformName defines the name of the variable
  29834. * @param color4 defines the value to be set
  29835. * @returns this effect.
  29836. */
  29837. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  29838. /** Release all associated resources */
  29839. dispose(): void;
  29840. /**
  29841. * This function will add a new shader to the shader store
  29842. * @param name the name of the shader
  29843. * @param pixelShader optional pixel shader content
  29844. * @param vertexShader optional vertex shader content
  29845. */
  29846. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  29847. /**
  29848. * Store of each shader (The can be looked up using effect.key)
  29849. */
  29850. static ShadersStore: {
  29851. [key: string]: string;
  29852. };
  29853. /**
  29854. * Store of each included file for a shader (The can be looked up using effect.key)
  29855. */
  29856. static IncludesShadersStore: {
  29857. [key: string]: string;
  29858. };
  29859. /**
  29860. * Resets the cache of effects.
  29861. */
  29862. static ResetCache(): void;
  29863. }
  29864. }
  29865. declare module "babylonjs/Engines/engineCapabilities" {
  29866. /**
  29867. * Interface used to describe the capabilities of the engine relatively to the current browser
  29868. */
  29869. export interface EngineCapabilities {
  29870. /** Maximum textures units per fragment shader */
  29871. maxTexturesImageUnits: number;
  29872. /** Maximum texture units per vertex shader */
  29873. maxVertexTextureImageUnits: number;
  29874. /** Maximum textures units in the entire pipeline */
  29875. maxCombinedTexturesImageUnits: number;
  29876. /** Maximum texture size */
  29877. maxTextureSize: number;
  29878. /** Maximum texture samples */
  29879. maxSamples?: number;
  29880. /** Maximum cube texture size */
  29881. maxCubemapTextureSize: number;
  29882. /** Maximum render texture size */
  29883. maxRenderTextureSize: number;
  29884. /** Maximum number of vertex attributes */
  29885. maxVertexAttribs: number;
  29886. /** Maximum number of varyings */
  29887. maxVaryingVectors: number;
  29888. /** Maximum number of uniforms per vertex shader */
  29889. maxVertexUniformVectors: number;
  29890. /** Maximum number of uniforms per fragment shader */
  29891. maxFragmentUniformVectors: number;
  29892. /** Defines if standard derivates (dx/dy) are supported */
  29893. standardDerivatives: boolean;
  29894. /** Defines if s3tc texture compression is supported */
  29895. s3tc?: WEBGL_compressed_texture_s3tc;
  29896. /** Defines if pvrtc texture compression is supported */
  29897. pvrtc: any;
  29898. /** Defines if etc1 texture compression is supported */
  29899. etc1: any;
  29900. /** Defines if etc2 texture compression is supported */
  29901. etc2: any;
  29902. /** Defines if astc texture compression is supported */
  29903. astc: any;
  29904. /** Defines if float textures are supported */
  29905. textureFloat: boolean;
  29906. /** Defines if vertex array objects are supported */
  29907. vertexArrayObject: boolean;
  29908. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  29909. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  29910. /** Gets the maximum level of anisotropy supported */
  29911. maxAnisotropy: number;
  29912. /** Defines if instancing is supported */
  29913. instancedArrays: boolean;
  29914. /** Defines if 32 bits indices are supported */
  29915. uintIndices: boolean;
  29916. /** Defines if high precision shaders are supported */
  29917. highPrecisionShaderSupported: boolean;
  29918. /** Defines if depth reading in the fragment shader is supported */
  29919. fragmentDepthSupported: boolean;
  29920. /** Defines if float texture linear filtering is supported*/
  29921. textureFloatLinearFiltering: boolean;
  29922. /** Defines if rendering to float textures is supported */
  29923. textureFloatRender: boolean;
  29924. /** Defines if half float textures are supported*/
  29925. textureHalfFloat: boolean;
  29926. /** Defines if half float texture linear filtering is supported*/
  29927. textureHalfFloatLinearFiltering: boolean;
  29928. /** Defines if rendering to half float textures is supported */
  29929. textureHalfFloatRender: boolean;
  29930. /** Defines if textureLOD shader command is supported */
  29931. textureLOD: boolean;
  29932. /** Defines if draw buffers extension is supported */
  29933. drawBuffersExtension: boolean;
  29934. /** Defines if depth textures are supported */
  29935. depthTextureExtension: boolean;
  29936. /** Defines if float color buffer are supported */
  29937. colorBufferFloat: boolean;
  29938. /** Gets disjoint timer query extension (null if not supported) */
  29939. timerQuery?: EXT_disjoint_timer_query;
  29940. /** Defines if timestamp can be used with timer query */
  29941. canUseTimestampForTimerQuery: boolean;
  29942. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  29943. multiview?: any;
  29944. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  29945. oculusMultiview?: any;
  29946. /** Function used to let the system compiles shaders in background */
  29947. parallelShaderCompile?: {
  29948. COMPLETION_STATUS_KHR: number;
  29949. };
  29950. /** Max number of texture samples for MSAA */
  29951. maxMSAASamples: number;
  29952. /** Defines if the blend min max extension is supported */
  29953. blendMinMax: boolean;
  29954. }
  29955. }
  29956. declare module "babylonjs/States/depthCullingState" {
  29957. import { Nullable } from "babylonjs/types";
  29958. /**
  29959. * @hidden
  29960. **/
  29961. export class DepthCullingState {
  29962. private _isDepthTestDirty;
  29963. private _isDepthMaskDirty;
  29964. private _isDepthFuncDirty;
  29965. private _isCullFaceDirty;
  29966. private _isCullDirty;
  29967. private _isZOffsetDirty;
  29968. private _isFrontFaceDirty;
  29969. private _depthTest;
  29970. private _depthMask;
  29971. private _depthFunc;
  29972. private _cull;
  29973. private _cullFace;
  29974. private _zOffset;
  29975. private _frontFace;
  29976. /**
  29977. * Initializes the state.
  29978. */
  29979. constructor();
  29980. readonly isDirty: boolean;
  29981. zOffset: number;
  29982. cullFace: Nullable<number>;
  29983. cull: Nullable<boolean>;
  29984. depthFunc: Nullable<number>;
  29985. depthMask: boolean;
  29986. depthTest: boolean;
  29987. frontFace: Nullable<number>;
  29988. reset(): void;
  29989. apply(gl: WebGLRenderingContext): void;
  29990. }
  29991. }
  29992. declare module "babylonjs/States/stencilState" {
  29993. /**
  29994. * @hidden
  29995. **/
  29996. export class StencilState {
  29997. /** 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 */
  29998. static readonly ALWAYS: number;
  29999. /** Passed to stencilOperation to specify that stencil value must be kept */
  30000. static readonly KEEP: number;
  30001. /** Passed to stencilOperation to specify that stencil value must be replaced */
  30002. static readonly REPLACE: number;
  30003. private _isStencilTestDirty;
  30004. private _isStencilMaskDirty;
  30005. private _isStencilFuncDirty;
  30006. private _isStencilOpDirty;
  30007. private _stencilTest;
  30008. private _stencilMask;
  30009. private _stencilFunc;
  30010. private _stencilFuncRef;
  30011. private _stencilFuncMask;
  30012. private _stencilOpStencilFail;
  30013. private _stencilOpDepthFail;
  30014. private _stencilOpStencilDepthPass;
  30015. readonly isDirty: boolean;
  30016. stencilFunc: number;
  30017. stencilFuncRef: number;
  30018. stencilFuncMask: number;
  30019. stencilOpStencilFail: number;
  30020. stencilOpDepthFail: number;
  30021. stencilOpStencilDepthPass: number;
  30022. stencilMask: number;
  30023. stencilTest: boolean;
  30024. constructor();
  30025. reset(): void;
  30026. apply(gl: WebGLRenderingContext): void;
  30027. }
  30028. }
  30029. declare module "babylonjs/States/alphaCullingState" {
  30030. /**
  30031. * @hidden
  30032. **/
  30033. export class AlphaState {
  30034. private _isAlphaBlendDirty;
  30035. private _isBlendFunctionParametersDirty;
  30036. private _isBlendEquationParametersDirty;
  30037. private _isBlendConstantsDirty;
  30038. private _alphaBlend;
  30039. private _blendFunctionParameters;
  30040. private _blendEquationParameters;
  30041. private _blendConstants;
  30042. /**
  30043. * Initializes the state.
  30044. */
  30045. constructor();
  30046. readonly isDirty: boolean;
  30047. alphaBlend: boolean;
  30048. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  30049. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  30050. setAlphaEquationParameters(rgb: number, alpha: number): void;
  30051. reset(): void;
  30052. apply(gl: WebGLRenderingContext): void;
  30053. }
  30054. }
  30055. declare module "babylonjs/Engines/WebGL/webGL2ShaderProcessors" {
  30056. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  30057. /** @hidden */
  30058. export class WebGL2ShaderProcessor implements IShaderProcessor {
  30059. attributeProcessor(attribute: string): string;
  30060. varyingProcessor(varying: string, isFragment: boolean): string;
  30061. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  30062. }
  30063. }
  30064. declare module "babylonjs/Engines/instancingAttributeInfo" {
  30065. /**
  30066. * Interface for attribute information associated with buffer instanciation
  30067. */
  30068. export interface InstancingAttributeInfo {
  30069. /**
  30070. * Index/offset of the attribute in the vertex shader
  30071. */
  30072. index: number;
  30073. /**
  30074. * size of the attribute, 1, 2, 3 or 4
  30075. */
  30076. attributeSize: number;
  30077. /**
  30078. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  30079. * default is FLOAT
  30080. */
  30081. attributeType: number;
  30082. /**
  30083. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  30084. */
  30085. normalized: boolean;
  30086. /**
  30087. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  30088. */
  30089. offset: number;
  30090. /**
  30091. * Name of the GLSL attribute, for debugging purpose only
  30092. */
  30093. attributeName: string;
  30094. }
  30095. }
  30096. declare module "babylonjs/Engines/Extensions/engine.videoTexture" {
  30097. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  30098. import { Nullable } from "babylonjs/types";
  30099. module "babylonjs/Engines/thinEngine" {
  30100. interface ThinEngine {
  30101. /**
  30102. * Update a video texture
  30103. * @param texture defines the texture to update
  30104. * @param video defines the video element to use
  30105. * @param invertY defines if data must be stored with Y axis inverted
  30106. */
  30107. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  30108. }
  30109. }
  30110. }
  30111. declare module "babylonjs/Materials/Textures/videoTexture" {
  30112. import { Observable } from "babylonjs/Misc/observable";
  30113. import { Nullable } from "babylonjs/types";
  30114. import { Scene } from "babylonjs/scene";
  30115. import { Texture } from "babylonjs/Materials/Textures/texture";
  30116. import "babylonjs/Engines/Extensions/engine.videoTexture";
  30117. /**
  30118. * Settings for finer control over video usage
  30119. */
  30120. export interface VideoTextureSettings {
  30121. /**
  30122. * Applies `autoplay` to video, if specified
  30123. */
  30124. autoPlay?: boolean;
  30125. /**
  30126. * Applies `loop` to video, if specified
  30127. */
  30128. loop?: boolean;
  30129. /**
  30130. * Automatically updates internal texture from video at every frame in the render loop
  30131. */
  30132. autoUpdateTexture: boolean;
  30133. /**
  30134. * Image src displayed during the video loading or until the user interacts with the video.
  30135. */
  30136. poster?: string;
  30137. }
  30138. /**
  30139. * If you want to display a video in your scene, this is the special texture for that.
  30140. * This special texture works similar to other textures, with the exception of a few parameters.
  30141. * @see https://doc.babylonjs.com/how_to/video_texture
  30142. */
  30143. export class VideoTexture extends Texture {
  30144. /**
  30145. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  30146. */
  30147. readonly autoUpdateTexture: boolean;
  30148. /**
  30149. * The video instance used by the texture internally
  30150. */
  30151. readonly video: HTMLVideoElement;
  30152. private _onUserActionRequestedObservable;
  30153. /**
  30154. * Event triggerd when a dom action is required by the user to play the video.
  30155. * This happens due to recent changes in browser policies preventing video to auto start.
  30156. */
  30157. readonly onUserActionRequestedObservable: Observable<Texture>;
  30158. private _generateMipMaps;
  30159. private _engine;
  30160. private _stillImageCaptured;
  30161. private _displayingPosterTexture;
  30162. private _settings;
  30163. private _createInternalTextureOnEvent;
  30164. private _frameId;
  30165. /**
  30166. * Creates a video texture.
  30167. * If you want to display a video in your scene, this is the special texture for that.
  30168. * This special texture works similar to other textures, with the exception of a few parameters.
  30169. * @see https://doc.babylonjs.com/how_to/video_texture
  30170. * @param name optional name, will detect from video source, if not defined
  30171. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  30172. * @param scene is obviously the current scene.
  30173. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  30174. * @param invertY is false by default but can be used to invert video on Y axis
  30175. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  30176. * @param settings allows finer control over video usage
  30177. */
  30178. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  30179. private _getName;
  30180. private _getVideo;
  30181. private _createInternalTexture;
  30182. private reset;
  30183. /**
  30184. * @hidden Internal method to initiate `update`.
  30185. */
  30186. _rebuild(): void;
  30187. /**
  30188. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  30189. */
  30190. update(): void;
  30191. /**
  30192. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  30193. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  30194. */
  30195. updateTexture(isVisible: boolean): void;
  30196. protected _updateInternalTexture: () => void;
  30197. /**
  30198. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  30199. * @param url New url.
  30200. */
  30201. updateURL(url: string): void;
  30202. /**
  30203. * Dispose the texture and release its associated resources.
  30204. */
  30205. dispose(): void;
  30206. /**
  30207. * Creates a video texture straight from a stream.
  30208. * @param scene Define the scene the texture should be created in
  30209. * @param stream Define the stream the texture should be created from
  30210. * @returns The created video texture as a promise
  30211. */
  30212. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  30213. /**
  30214. * Creates a video texture straight from your WebCam video feed.
  30215. * @param scene Define the scene the texture should be created in
  30216. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  30217. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  30218. * @returns The created video texture as a promise
  30219. */
  30220. static CreateFromWebCamAsync(scene: Scene, constraints: {
  30221. minWidth: number;
  30222. maxWidth: number;
  30223. minHeight: number;
  30224. maxHeight: number;
  30225. deviceId: string;
  30226. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  30227. /**
  30228. * Creates a video texture straight from your WebCam video feed.
  30229. * @param scene Define the scene the texture should be created in
  30230. * @param onReady Define a callback to triggered once the texture will be ready
  30231. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  30232. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  30233. */
  30234. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  30235. minWidth: number;
  30236. maxWidth: number;
  30237. minHeight: number;
  30238. maxHeight: number;
  30239. deviceId: string;
  30240. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  30241. }
  30242. }
  30243. declare module "babylonjs/Engines/thinEngine" {
  30244. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  30245. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  30246. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  30247. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  30248. import { Nullable, DataArray, IndicesArray } from "babylonjs/types";
  30249. import { EngineCapabilities } from "babylonjs/Engines/engineCapabilities";
  30250. import { Observable } from "babylonjs/Misc/observable";
  30251. import { DepthCullingState } from "babylonjs/States/depthCullingState";
  30252. import { StencilState } from "babylonjs/States/stencilState";
  30253. import { AlphaState } from "babylonjs/States/alphaCullingState";
  30254. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  30255. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  30256. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  30257. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  30258. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  30259. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  30260. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  30261. import { InstancingAttributeInfo } from "babylonjs/Engines/instancingAttributeInfo";
  30262. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  30263. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  30264. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  30265. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  30266. /**
  30267. * Defines the interface used by objects working like Scene
  30268. * @hidden
  30269. */
  30270. interface ISceneLike {
  30271. _addPendingData(data: any): void;
  30272. _removePendingData(data: any): void;
  30273. offlineProvider: IOfflineProvider;
  30274. }
  30275. /** Interface defining initialization parameters for Engine class */
  30276. export interface EngineOptions extends WebGLContextAttributes {
  30277. /**
  30278. * Defines if the engine should no exceed a specified device ratio
  30279. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  30280. */
  30281. limitDeviceRatio?: number;
  30282. /**
  30283. * Defines if webvr should be enabled automatically
  30284. * @see http://doc.babylonjs.com/how_to/webvr_camera
  30285. */
  30286. autoEnableWebVR?: boolean;
  30287. /**
  30288. * Defines if webgl2 should be turned off even if supported
  30289. * @see http://doc.babylonjs.com/features/webgl2
  30290. */
  30291. disableWebGL2Support?: boolean;
  30292. /**
  30293. * Defines if webaudio should be initialized as well
  30294. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  30295. */
  30296. audioEngine?: boolean;
  30297. /**
  30298. * Defines if animations should run using a deterministic lock step
  30299. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  30300. */
  30301. deterministicLockstep?: boolean;
  30302. /** Defines the maximum steps to use with deterministic lock step mode */
  30303. lockstepMaxSteps?: number;
  30304. /** Defines the seconds between each deterministic lock step */
  30305. timeStep?: number;
  30306. /**
  30307. * Defines that engine should ignore context lost events
  30308. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  30309. */
  30310. doNotHandleContextLost?: boolean;
  30311. /**
  30312. * Defines that engine should ignore modifying touch action attribute and style
  30313. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  30314. */
  30315. doNotHandleTouchAction?: boolean;
  30316. /**
  30317. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  30318. */
  30319. useHighPrecisionFloats?: boolean;
  30320. }
  30321. /**
  30322. * The base engine class (root of all engines)
  30323. */
  30324. export class ThinEngine {
  30325. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  30326. static ExceptionList: ({
  30327. key: string;
  30328. capture: string;
  30329. captureConstraint: number;
  30330. targets: string[];
  30331. } | {
  30332. key: string;
  30333. capture: null;
  30334. captureConstraint: null;
  30335. targets: string[];
  30336. })[];
  30337. /** @hidden */
  30338. static _TextureLoaders: IInternalTextureLoader[];
  30339. /**
  30340. * Returns the current npm package of the sdk
  30341. */
  30342. static readonly NpmPackage: string;
  30343. /**
  30344. * Returns the current version of the framework
  30345. */
  30346. static readonly Version: string;
  30347. /**
  30348. * Returns a string describing the current engine
  30349. */
  30350. readonly description: string;
  30351. /**
  30352. * Gets or sets the epsilon value used by collision engine
  30353. */
  30354. static CollisionsEpsilon: number;
  30355. /**
  30356. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  30357. */
  30358. static ShadersRepository: string;
  30359. /** @hidden */
  30360. _shaderProcessor: IShaderProcessor;
  30361. /**
  30362. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  30363. */
  30364. forcePOTTextures: boolean;
  30365. /**
  30366. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  30367. */
  30368. isFullscreen: boolean;
  30369. /**
  30370. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  30371. */
  30372. cullBackFaces: boolean;
  30373. /**
  30374. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  30375. */
  30376. renderEvenInBackground: boolean;
  30377. /**
  30378. * Gets or sets a boolean indicating that cache can be kept between frames
  30379. */
  30380. preventCacheWipeBetweenFrames: boolean;
  30381. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  30382. validateShaderPrograms: boolean;
  30383. /**
  30384. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  30385. * This can provide greater z depth for distant objects.
  30386. */
  30387. useReverseDepthBuffer: boolean;
  30388. /**
  30389. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  30390. */
  30391. disableUniformBuffers: boolean;
  30392. /** @hidden */
  30393. _uniformBuffers: UniformBuffer[];
  30394. /**
  30395. * Gets a boolean indicating that the engine supports uniform buffers
  30396. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  30397. */
  30398. readonly supportsUniformBuffers: boolean;
  30399. /** @hidden */
  30400. _gl: WebGLRenderingContext;
  30401. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  30402. protected _windowIsBackground: boolean;
  30403. protected _webGLVersion: number;
  30404. protected _creationOptions: EngineOptions;
  30405. protected _highPrecisionShadersAllowed: boolean;
  30406. /** @hidden */
  30407. readonly _shouldUseHighPrecisionShader: boolean;
  30408. /**
  30409. * Gets a boolean indicating that only power of 2 textures are supported
  30410. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  30411. */
  30412. readonly needPOTTextures: boolean;
  30413. /** @hidden */
  30414. _badOS: boolean;
  30415. /** @hidden */
  30416. _badDesktopOS: boolean;
  30417. private _hardwareScalingLevel;
  30418. /** @hidden */
  30419. _caps: EngineCapabilities;
  30420. private _isStencilEnable;
  30421. protected _colorWrite: boolean;
  30422. private _glVersion;
  30423. private _glRenderer;
  30424. private _glVendor;
  30425. /** @hidden */
  30426. _videoTextureSupported: boolean;
  30427. protected _renderingQueueLaunched: boolean;
  30428. protected _activeRenderLoops: (() => void)[];
  30429. /**
  30430. * Observable signaled when a context lost event is raised
  30431. */
  30432. onContextLostObservable: Observable<ThinEngine>;
  30433. /**
  30434. * Observable signaled when a context restored event is raised
  30435. */
  30436. onContextRestoredObservable: Observable<ThinEngine>;
  30437. private _onContextLost;
  30438. private _onContextRestored;
  30439. protected _contextWasLost: boolean;
  30440. /** @hidden */
  30441. _doNotHandleContextLost: boolean;
  30442. /**
  30443. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  30444. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  30445. */
  30446. doNotHandleContextLost: boolean;
  30447. /**
  30448. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  30449. */
  30450. disableVertexArrayObjects: boolean;
  30451. /** @hidden */
  30452. protected _depthCullingState: DepthCullingState;
  30453. /** @hidden */
  30454. protected _stencilState: StencilState;
  30455. /** @hidden */
  30456. protected _alphaState: AlphaState;
  30457. /** @hidden */
  30458. _internalTexturesCache: InternalTexture[];
  30459. /** @hidden */
  30460. protected _activeChannel: number;
  30461. private _currentTextureChannel;
  30462. /** @hidden */
  30463. protected _boundTexturesCache: {
  30464. [key: string]: Nullable<InternalTexture>;
  30465. };
  30466. /** @hidden */
  30467. protected _currentEffect: Nullable<Effect>;
  30468. /** @hidden */
  30469. protected _currentProgram: Nullable<WebGLProgram>;
  30470. private _compiledEffects;
  30471. private _vertexAttribArraysEnabled;
  30472. /** @hidden */
  30473. protected _cachedViewport: Nullable<IViewportLike>;
  30474. private _cachedVertexArrayObject;
  30475. /** @hidden */
  30476. protected _cachedVertexBuffers: any;
  30477. /** @hidden */
  30478. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  30479. /** @hidden */
  30480. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  30481. /** @hidden */
  30482. _currentRenderTarget: Nullable<InternalTexture>;
  30483. private _uintIndicesCurrentlySet;
  30484. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  30485. /** @hidden */
  30486. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  30487. private _currentBufferPointers;
  30488. private _currentInstanceLocations;
  30489. private _currentInstanceBuffers;
  30490. private _textureUnits;
  30491. /** @hidden */
  30492. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  30493. /** @hidden */
  30494. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  30495. /** @hidden */
  30496. _boundRenderFunction: any;
  30497. private _vaoRecordInProgress;
  30498. private _mustWipeVertexAttributes;
  30499. private _emptyTexture;
  30500. private _emptyCubeTexture;
  30501. private _emptyTexture3D;
  30502. private _emptyTexture2DArray;
  30503. /** @hidden */
  30504. _frameHandler: number;
  30505. private _nextFreeTextureSlots;
  30506. private _maxSimultaneousTextures;
  30507. private _activeRequests;
  30508. protected _texturesSupported: string[];
  30509. /** @hidden */
  30510. _textureFormatInUse: Nullable<string>;
  30511. protected readonly _supportsHardwareTextureRescaling: boolean;
  30512. /**
  30513. * Gets the list of texture formats supported
  30514. */
  30515. readonly texturesSupported: Array<string>;
  30516. /**
  30517. * Gets the list of texture formats in use
  30518. */
  30519. readonly textureFormatInUse: Nullable<string>;
  30520. /**
  30521. * Gets the current viewport
  30522. */
  30523. readonly currentViewport: Nullable<IViewportLike>;
  30524. /**
  30525. * Gets the default empty texture
  30526. */
  30527. readonly emptyTexture: InternalTexture;
  30528. /**
  30529. * Gets the default empty 3D texture
  30530. */
  30531. readonly emptyTexture3D: InternalTexture;
  30532. /**
  30533. * Gets the default empty 2D array texture
  30534. */
  30535. readonly emptyTexture2DArray: InternalTexture;
  30536. /**
  30537. * Gets the default empty cube texture
  30538. */
  30539. readonly emptyCubeTexture: InternalTexture;
  30540. /**
  30541. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  30542. */
  30543. readonly premultipliedAlpha: boolean;
  30544. /**
  30545. * Observable event triggered before each texture is initialized
  30546. */
  30547. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  30548. /**
  30549. * Creates a new engine
  30550. * @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
  30551. * @param antialias defines enable antialiasing (default: false)
  30552. * @param options defines further options to be sent to the getContext() function
  30553. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  30554. */
  30555. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  30556. private _rebuildInternalTextures;
  30557. private _rebuildEffects;
  30558. /**
  30559. * Gets a boolean indicating if all created effects are ready
  30560. * @returns true if all effects are ready
  30561. */
  30562. areAllEffectsReady(): boolean;
  30563. protected _rebuildBuffers(): void;
  30564. private _initGLContext;
  30565. /**
  30566. * Gets version of the current webGL context
  30567. */
  30568. readonly webGLVersion: number;
  30569. /**
  30570. * Gets a string idenfifying the name of the class
  30571. * @returns "Engine" string
  30572. */
  30573. getClassName(): string;
  30574. /**
  30575. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  30576. */
  30577. readonly isStencilEnable: boolean;
  30578. /** @hidden */
  30579. _prepareWorkingCanvas(): void;
  30580. /**
  30581. * Reset the texture cache to empty state
  30582. */
  30583. resetTextureCache(): void;
  30584. /**
  30585. * Gets an object containing information about the current webGL context
  30586. * @returns an object containing the vender, the renderer and the version of the current webGL context
  30587. */
  30588. getGlInfo(): {
  30589. vendor: string;
  30590. renderer: string;
  30591. version: string;
  30592. };
  30593. /**
  30594. * Defines the hardware scaling level.
  30595. * By default the hardware scaling level is computed from the window device ratio.
  30596. * 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.
  30597. * @param level defines the level to use
  30598. */
  30599. setHardwareScalingLevel(level: number): void;
  30600. /**
  30601. * Gets the current hardware scaling level.
  30602. * By default the hardware scaling level is computed from the window device ratio.
  30603. * 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.
  30604. * @returns a number indicating the current hardware scaling level
  30605. */
  30606. getHardwareScalingLevel(): number;
  30607. /**
  30608. * Gets the list of loaded textures
  30609. * @returns an array containing all loaded textures
  30610. */
  30611. getLoadedTexturesCache(): InternalTexture[];
  30612. /**
  30613. * Gets the object containing all engine capabilities
  30614. * @returns the EngineCapabilities object
  30615. */
  30616. getCaps(): EngineCapabilities;
  30617. /**
  30618. * stop executing a render loop function and remove it from the execution array
  30619. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  30620. */
  30621. stopRenderLoop(renderFunction?: () => void): void;
  30622. /** @hidden */
  30623. _renderLoop(): void;
  30624. /**
  30625. * Gets the HTML canvas attached with the current webGL context
  30626. * @returns a HTML canvas
  30627. */
  30628. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  30629. /**
  30630. * Gets host window
  30631. * @returns the host window object
  30632. */
  30633. getHostWindow(): Nullable<Window>;
  30634. /**
  30635. * Gets the current render width
  30636. * @param useScreen defines if screen size must be used (or the current render target if any)
  30637. * @returns a number defining the current render width
  30638. */
  30639. getRenderWidth(useScreen?: boolean): number;
  30640. /**
  30641. * Gets the current render height
  30642. * @param useScreen defines if screen size must be used (or the current render target if any)
  30643. * @returns a number defining the current render height
  30644. */
  30645. getRenderHeight(useScreen?: boolean): number;
  30646. /**
  30647. * Can be used to override the current requestAnimationFrame requester.
  30648. * @hidden
  30649. */
  30650. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  30651. /**
  30652. * Register and execute a render loop. The engine can have more than one render function
  30653. * @param renderFunction defines the function to continuously execute
  30654. */
  30655. runRenderLoop(renderFunction: () => void): void;
  30656. /**
  30657. * Clear the current render buffer or the current render target (if any is set up)
  30658. * @param color defines the color to use
  30659. * @param backBuffer defines if the back buffer must be cleared
  30660. * @param depth defines if the depth buffer must be cleared
  30661. * @param stencil defines if the stencil buffer must be cleared
  30662. */
  30663. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  30664. private _viewportCached;
  30665. /** @hidden */
  30666. _viewport(x: number, y: number, width: number, height: number): void;
  30667. /**
  30668. * Set the WebGL's viewport
  30669. * @param viewport defines the viewport element to be used
  30670. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  30671. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  30672. */
  30673. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  30674. /**
  30675. * Begin a new frame
  30676. */
  30677. beginFrame(): void;
  30678. /**
  30679. * Enf the current frame
  30680. */
  30681. endFrame(): void;
  30682. /**
  30683. * Resize the view according to the canvas' size
  30684. */
  30685. resize(): void;
  30686. /**
  30687. * Force a specific size of the canvas
  30688. * @param width defines the new canvas' width
  30689. * @param height defines the new canvas' height
  30690. */
  30691. setSize(width: number, height: number): void;
  30692. /**
  30693. * Binds the frame buffer to the specified texture.
  30694. * @param texture The texture to render to or null for the default canvas
  30695. * @param faceIndex The face of the texture to render to in case of cube texture
  30696. * @param requiredWidth The width of the target to render to
  30697. * @param requiredHeight The height of the target to render to
  30698. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  30699. * @param depthStencilTexture The depth stencil texture to use to render
  30700. * @param lodLevel defines le lod level to bind to the frame buffer
  30701. */
  30702. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  30703. /** @hidden */
  30704. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  30705. /**
  30706. * Unbind the current render target texture from the webGL context
  30707. * @param texture defines the render target texture to unbind
  30708. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  30709. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  30710. */
  30711. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  30712. /**
  30713. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  30714. */
  30715. flushFramebuffer(): void;
  30716. /**
  30717. * Unbind the current render target and bind the default framebuffer
  30718. */
  30719. restoreDefaultFramebuffer(): void;
  30720. /** @hidden */
  30721. protected _resetVertexBufferBinding(): void;
  30722. /**
  30723. * Creates a vertex buffer
  30724. * @param data the data for the vertex buffer
  30725. * @returns the new WebGL static buffer
  30726. */
  30727. createVertexBuffer(data: DataArray): DataBuffer;
  30728. private _createVertexBuffer;
  30729. /**
  30730. * Creates a dynamic vertex buffer
  30731. * @param data the data for the dynamic vertex buffer
  30732. * @returns the new WebGL dynamic buffer
  30733. */
  30734. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  30735. protected _resetIndexBufferBinding(): void;
  30736. /**
  30737. * Creates a new index buffer
  30738. * @param indices defines the content of the index buffer
  30739. * @param updatable defines if the index buffer must be updatable
  30740. * @returns a new webGL buffer
  30741. */
  30742. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  30743. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  30744. /**
  30745. * Bind a webGL buffer to the webGL context
  30746. * @param buffer defines the buffer to bind
  30747. */
  30748. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  30749. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  30750. private bindBuffer;
  30751. /**
  30752. * update the bound buffer with the given data
  30753. * @param data defines the data to update
  30754. */
  30755. updateArrayBuffer(data: Float32Array): void;
  30756. private _vertexAttribPointer;
  30757. private _bindIndexBufferWithCache;
  30758. private _bindVertexBuffersAttributes;
  30759. /**
  30760. * Records a vertex array object
  30761. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  30762. * @param vertexBuffers defines the list of vertex buffers to store
  30763. * @param indexBuffer defines the index buffer to store
  30764. * @param effect defines the effect to store
  30765. * @returns the new vertex array object
  30766. */
  30767. recordVertexArrayObject(vertexBuffers: {
  30768. [key: string]: VertexBuffer;
  30769. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  30770. /**
  30771. * Bind a specific vertex array object
  30772. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  30773. * @param vertexArrayObject defines the vertex array object to bind
  30774. * @param indexBuffer defines the index buffer to bind
  30775. */
  30776. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  30777. /**
  30778. * Bind webGl buffers directly to the webGL context
  30779. * @param vertexBuffer defines the vertex buffer to bind
  30780. * @param indexBuffer defines the index buffer to bind
  30781. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  30782. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  30783. * @param effect defines the effect associated with the vertex buffer
  30784. */
  30785. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  30786. private _unbindVertexArrayObject;
  30787. /**
  30788. * Bind a list of vertex buffers to the webGL context
  30789. * @param vertexBuffers defines the list of vertex buffers to bind
  30790. * @param indexBuffer defines the index buffer to bind
  30791. * @param effect defines the effect associated with the vertex buffers
  30792. */
  30793. bindBuffers(vertexBuffers: {
  30794. [key: string]: Nullable<VertexBuffer>;
  30795. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  30796. /**
  30797. * Unbind all instance attributes
  30798. */
  30799. unbindInstanceAttributes(): void;
  30800. /**
  30801. * Release and free the memory of a vertex array object
  30802. * @param vao defines the vertex array object to delete
  30803. */
  30804. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  30805. /** @hidden */
  30806. _releaseBuffer(buffer: DataBuffer): boolean;
  30807. protected _deleteBuffer(buffer: DataBuffer): void;
  30808. /**
  30809. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  30810. * @param instancesBuffer defines the webGL buffer to update and bind
  30811. * @param data defines the data to store in the buffer
  30812. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  30813. */
  30814. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  30815. /**
  30816. * Apply all cached states (depth, culling, stencil and alpha)
  30817. */
  30818. applyStates(): void;
  30819. /**
  30820. * Send a draw order
  30821. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  30822. * @param indexStart defines the starting index
  30823. * @param indexCount defines the number of index to draw
  30824. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30825. */
  30826. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  30827. /**
  30828. * Draw a list of points
  30829. * @param verticesStart defines the index of first vertex to draw
  30830. * @param verticesCount defines the count of vertices to draw
  30831. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30832. */
  30833. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  30834. /**
  30835. * Draw a list of unindexed primitives
  30836. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  30837. * @param verticesStart defines the index of first vertex to draw
  30838. * @param verticesCount defines the count of vertices to draw
  30839. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30840. */
  30841. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  30842. /**
  30843. * Draw a list of indexed primitives
  30844. * @param fillMode defines the primitive to use
  30845. * @param indexStart defines the starting index
  30846. * @param indexCount defines the number of index to draw
  30847. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30848. */
  30849. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  30850. /**
  30851. * Draw a list of unindexed primitives
  30852. * @param fillMode defines the primitive to use
  30853. * @param verticesStart defines the index of first vertex to draw
  30854. * @param verticesCount defines the count of vertices to draw
  30855. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30856. */
  30857. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  30858. private _drawMode;
  30859. /** @hidden */
  30860. protected _reportDrawCall(): void;
  30861. /** @hidden */
  30862. _releaseEffect(effect: Effect): void;
  30863. /** @hidden */
  30864. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  30865. /**
  30866. * Create a new effect (used to store vertex/fragment shaders)
  30867. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  30868. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  30869. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  30870. * @param samplers defines an array of string used to represent textures
  30871. * @param defines defines the string containing the defines to use to compile the shaders
  30872. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  30873. * @param onCompiled defines a function to call when the effect creation is successful
  30874. * @param onError defines a function to call when the effect creation has failed
  30875. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  30876. * @returns the new Effect
  30877. */
  30878. 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;
  30879. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  30880. private _compileShader;
  30881. private _compileRawShader;
  30882. /**
  30883. * Directly creates a webGL program
  30884. * @param pipelineContext defines the pipeline context to attach to
  30885. * @param vertexCode defines the vertex shader code to use
  30886. * @param fragmentCode defines the fragment shader code to use
  30887. * @param context defines the webGL context to use (if not set, the current one will be used)
  30888. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  30889. * @returns the new webGL program
  30890. */
  30891. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  30892. /**
  30893. * Creates a webGL program
  30894. * @param pipelineContext defines the pipeline context to attach to
  30895. * @param vertexCode defines the vertex shader code to use
  30896. * @param fragmentCode defines the fragment shader code to use
  30897. * @param defines defines the string containing the defines to use to compile the shaders
  30898. * @param context defines the webGL context to use (if not set, the current one will be used)
  30899. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  30900. * @returns the new webGL program
  30901. */
  30902. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  30903. /**
  30904. * Creates a new pipeline context
  30905. * @returns the new pipeline
  30906. */
  30907. createPipelineContext(): IPipelineContext;
  30908. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  30909. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  30910. /** @hidden */
  30911. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  30912. /** @hidden */
  30913. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  30914. /** @hidden */
  30915. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  30916. /**
  30917. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  30918. * @param pipelineContext defines the pipeline context to use
  30919. * @param uniformsNames defines the list of uniform names
  30920. * @returns an array of webGL uniform locations
  30921. */
  30922. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  30923. /**
  30924. * Gets the lsit of active attributes for a given webGL program
  30925. * @param pipelineContext defines the pipeline context to use
  30926. * @param attributesNames defines the list of attribute names to get
  30927. * @returns an array of indices indicating the offset of each attribute
  30928. */
  30929. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  30930. /**
  30931. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  30932. * @param effect defines the effect to activate
  30933. */
  30934. enableEffect(effect: Nullable<Effect>): void;
  30935. /**
  30936. * Set the value of an uniform to a number (int)
  30937. * @param uniform defines the webGL uniform location where to store the value
  30938. * @param value defines the int number to store
  30939. */
  30940. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  30941. /**
  30942. * Set the value of an uniform to an array of int32
  30943. * @param uniform defines the webGL uniform location where to store the value
  30944. * @param array defines the array of int32 to store
  30945. */
  30946. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30947. /**
  30948. * Set the value of an uniform to an array of int32 (stored as vec2)
  30949. * @param uniform defines the webGL uniform location where to store the value
  30950. * @param array defines the array of int32 to store
  30951. */
  30952. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30953. /**
  30954. * Set the value of an uniform to an array of int32 (stored as vec3)
  30955. * @param uniform defines the webGL uniform location where to store the value
  30956. * @param array defines the array of int32 to store
  30957. */
  30958. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30959. /**
  30960. * Set the value of an uniform to an array of int32 (stored as vec4)
  30961. * @param uniform defines the webGL uniform location where to store the value
  30962. * @param array defines the array of int32 to store
  30963. */
  30964. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30965. /**
  30966. * Set the value of an uniform to an array of number
  30967. * @param uniform defines the webGL uniform location where to store the value
  30968. * @param array defines the array of number to store
  30969. */
  30970. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  30971. /**
  30972. * Set the value of an uniform to an array of number (stored as vec2)
  30973. * @param uniform defines the webGL uniform location where to store the value
  30974. * @param array defines the array of number to store
  30975. */
  30976. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  30977. /**
  30978. * Set the value of an uniform to an array of number (stored as vec3)
  30979. * @param uniform defines the webGL uniform location where to store the value
  30980. * @param array defines the array of number to store
  30981. */
  30982. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  30983. /**
  30984. * Set the value of an uniform to an array of number (stored as vec4)
  30985. * @param uniform defines the webGL uniform location where to store the value
  30986. * @param array defines the array of number to store
  30987. */
  30988. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  30989. /**
  30990. * Set the value of an uniform to an array of float32 (stored as matrices)
  30991. * @param uniform defines the webGL uniform location where to store the value
  30992. * @param matrices defines the array of float32 to store
  30993. */
  30994. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  30995. /**
  30996. * Set the value of an uniform to a matrix (3x3)
  30997. * @param uniform defines the webGL uniform location where to store the value
  30998. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  30999. */
  31000. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  31001. /**
  31002. * Set the value of an uniform to a matrix (2x2)
  31003. * @param uniform defines the webGL uniform location where to store the value
  31004. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  31005. */
  31006. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  31007. /**
  31008. * Set the value of an uniform to a number (float)
  31009. * @param uniform defines the webGL uniform location where to store the value
  31010. * @param value defines the float number to store
  31011. */
  31012. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  31013. /**
  31014. * Set the value of an uniform to a vec2
  31015. * @param uniform defines the webGL uniform location where to store the value
  31016. * @param x defines the 1st component of the value
  31017. * @param y defines the 2nd component of the value
  31018. */
  31019. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  31020. /**
  31021. * Set the value of an uniform to a vec3
  31022. * @param uniform defines the webGL uniform location where to store the value
  31023. * @param x defines the 1st component of the value
  31024. * @param y defines the 2nd component of the value
  31025. * @param z defines the 3rd component of the value
  31026. */
  31027. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  31028. /**
  31029. * Set the value of an uniform to a vec4
  31030. * @param uniform defines the webGL uniform location where to store the value
  31031. * @param x defines the 1st component of the value
  31032. * @param y defines the 2nd component of the value
  31033. * @param z defines the 3rd component of the value
  31034. * @param w defines the 4th component of the value
  31035. */
  31036. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  31037. /**
  31038. * Gets the depth culling state manager
  31039. */
  31040. readonly depthCullingState: DepthCullingState;
  31041. /**
  31042. * Gets the alpha state manager
  31043. */
  31044. readonly alphaState: AlphaState;
  31045. /**
  31046. * Gets the stencil state manager
  31047. */
  31048. readonly stencilState: StencilState;
  31049. /**
  31050. * Clears the list of texture accessible through engine.
  31051. * This can help preventing texture load conflict due to name collision.
  31052. */
  31053. clearInternalTexturesCache(): void;
  31054. /**
  31055. * Force the entire cache to be cleared
  31056. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  31057. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  31058. */
  31059. wipeCaches(bruteForce?: boolean): void;
  31060. /** @hidden */
  31061. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  31062. min: number;
  31063. mag: number;
  31064. };
  31065. /** @hidden */
  31066. _createTexture(): WebGLTexture;
  31067. /**
  31068. * Usually called from Texture.ts.
  31069. * Passed information to create a WebGLTexture
  31070. * @param urlArg defines a value which contains one of the following:
  31071. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  31072. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  31073. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  31074. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  31075. * @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)
  31076. * @param scene needed for loading to the correct scene
  31077. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  31078. * @param onLoad optional callback to be called upon successful completion
  31079. * @param onError optional callback to be called upon failure
  31080. * @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
  31081. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  31082. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  31083. * @param forcedExtension defines the extension to use to pick the right loader
  31084. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  31085. * @param mimeType defines an optional mime type
  31086. * @returns a InternalTexture for assignment back into BABYLON.Texture
  31087. */
  31088. 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;
  31089. /**
  31090. * @hidden
  31091. */
  31092. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  31093. /**
  31094. * Creates a raw texture
  31095. * @param data defines the data to store in the texture
  31096. * @param width defines the width of the texture
  31097. * @param height defines the height of the texture
  31098. * @param format defines the format of the data
  31099. * @param generateMipMaps defines if the engine should generate the mip levels
  31100. * @param invertY defines if data must be stored with Y axis inverted
  31101. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  31102. * @param compression defines the compression used (null by default)
  31103. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  31104. * @returns the raw texture inside an InternalTexture
  31105. */
  31106. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  31107. /**
  31108. * Creates a new raw cube texture
  31109. * @param data defines the array of data to use to create each face
  31110. * @param size defines the size of the textures
  31111. * @param format defines the format of the data
  31112. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  31113. * @param generateMipMaps defines if the engine should generate the mip levels
  31114. * @param invertY defines if data must be stored with Y axis inverted
  31115. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  31116. * @param compression defines the compression used (null by default)
  31117. * @returns the cube texture as an InternalTexture
  31118. */
  31119. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  31120. /**
  31121. * Creates a new raw 3D texture
  31122. * @param data defines the data used to create the texture
  31123. * @param width defines the width of the texture
  31124. * @param height defines the height of the texture
  31125. * @param depth defines the depth of the texture
  31126. * @param format defines the format of the texture
  31127. * @param generateMipMaps defines if the engine must generate mip levels
  31128. * @param invertY defines if data must be stored with Y axis inverted
  31129. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  31130. * @param compression defines the compressed used (can be null)
  31131. * @param textureType defines the compressed used (can be null)
  31132. * @returns a new raw 3D texture (stored in an InternalTexture)
  31133. */
  31134. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  31135. /**
  31136. * Creates a new raw 2D array texture
  31137. * @param data defines the data used to create the texture
  31138. * @param width defines the width of the texture
  31139. * @param height defines the height of the texture
  31140. * @param depth defines the number of layers of the texture
  31141. * @param format defines the format of the texture
  31142. * @param generateMipMaps defines if the engine must generate mip levels
  31143. * @param invertY defines if data must be stored with Y axis inverted
  31144. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  31145. * @param compression defines the compressed used (can be null)
  31146. * @param textureType defines the compressed used (can be null)
  31147. * @returns a new raw 2D array texture (stored in an InternalTexture)
  31148. */
  31149. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  31150. private _unpackFlipYCached;
  31151. /**
  31152. * In case you are sharing the context with other applications, it might
  31153. * be interested to not cache the unpack flip y state to ensure a consistent
  31154. * value would be set.
  31155. */
  31156. enableUnpackFlipYCached: boolean;
  31157. /** @hidden */
  31158. _unpackFlipY(value: boolean): void;
  31159. /** @hidden */
  31160. _getUnpackAlignement(): number;
  31161. /**
  31162. * Update the sampling mode of a given texture
  31163. * @param samplingMode defines the required sampling mode
  31164. * @param texture defines the texture to update
  31165. */
  31166. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  31167. /** @hidden */
  31168. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  31169. width: number;
  31170. height: number;
  31171. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  31172. /** @hidden */
  31173. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  31174. /** @hidden */
  31175. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  31176. /** @hidden */
  31177. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  31178. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  31179. private _prepareWebGLTexture;
  31180. /** @hidden */
  31181. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  31182. /** @hidden */
  31183. _releaseFramebufferObjects(texture: InternalTexture): void;
  31184. /** @hidden */
  31185. _releaseTexture(texture: InternalTexture): void;
  31186. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  31187. protected _setProgram(program: WebGLProgram): void;
  31188. protected _boundUniforms: {
  31189. [key: number]: WebGLUniformLocation;
  31190. };
  31191. /**
  31192. * Binds an effect to the webGL context
  31193. * @param effect defines the effect to bind
  31194. */
  31195. bindSamplers(effect: Effect): void;
  31196. private _activateCurrentTexture;
  31197. /** @hidden */
  31198. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  31199. /** @hidden */
  31200. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  31201. /**
  31202. * Unbind all textures from the webGL context
  31203. */
  31204. unbindAllTextures(): void;
  31205. /**
  31206. * Sets a texture to the according uniform.
  31207. * @param channel The texture channel
  31208. * @param uniform The uniform to set
  31209. * @param texture The texture to apply
  31210. */
  31211. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  31212. private _bindSamplerUniformToChannel;
  31213. private _getTextureWrapMode;
  31214. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  31215. /**
  31216. * Sets an array of texture to the webGL context
  31217. * @param channel defines the channel where the texture array must be set
  31218. * @param uniform defines the associated uniform location
  31219. * @param textures defines the array of textures to bind
  31220. */
  31221. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  31222. /** @hidden */
  31223. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  31224. private _setTextureParameterFloat;
  31225. private _setTextureParameterInteger;
  31226. /**
  31227. * Unbind all vertex attributes from the webGL context
  31228. */
  31229. unbindAllAttributes(): void;
  31230. /**
  31231. * 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
  31232. */
  31233. releaseEffects(): void;
  31234. /**
  31235. * Dispose and release all associated resources
  31236. */
  31237. dispose(): void;
  31238. /**
  31239. * Attach a new callback raised when context lost event is fired
  31240. * @param callback defines the callback to call
  31241. */
  31242. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  31243. /**
  31244. * Attach a new callback raised when context restored event is fired
  31245. * @param callback defines the callback to call
  31246. */
  31247. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  31248. /**
  31249. * Get the current error code of the webGL context
  31250. * @returns the error code
  31251. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  31252. */
  31253. getError(): number;
  31254. private _canRenderToFloatFramebuffer;
  31255. private _canRenderToHalfFloatFramebuffer;
  31256. private _canRenderToFramebuffer;
  31257. /** @hidden */
  31258. _getWebGLTextureType(type: number): number;
  31259. /** @hidden */
  31260. _getInternalFormat(format: number): number;
  31261. /** @hidden */
  31262. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  31263. /** @hidden */
  31264. _getRGBAMultiSampleBufferFormat(type: number): number;
  31265. /** @hidden */
  31266. _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;
  31267. /**
  31268. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  31269. * @returns true if the engine can be created
  31270. * @ignorenaming
  31271. */
  31272. static isSupported(): boolean;
  31273. /**
  31274. * Find the next highest power of two.
  31275. * @param x Number to start search from.
  31276. * @return Next highest power of two.
  31277. */
  31278. static CeilingPOT(x: number): number;
  31279. /**
  31280. * Find the next lowest power of two.
  31281. * @param x Number to start search from.
  31282. * @return Next lowest power of two.
  31283. */
  31284. static FloorPOT(x: number): number;
  31285. /**
  31286. * Find the nearest power of two.
  31287. * @param x Number to start search from.
  31288. * @return Next nearest power of two.
  31289. */
  31290. static NearestPOT(x: number): number;
  31291. /**
  31292. * Get the closest exponent of two
  31293. * @param value defines the value to approximate
  31294. * @param max defines the maximum value to return
  31295. * @param mode defines how to define the closest value
  31296. * @returns closest exponent of two of the given value
  31297. */
  31298. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  31299. /**
  31300. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  31301. * @param func - the function to be called
  31302. * @param requester - the object that will request the next frame. Falls back to window.
  31303. * @returns frame number
  31304. */
  31305. static QueueNewFrame(func: () => void, requester?: any): number;
  31306. /**
  31307. * Gets host document
  31308. * @returns the host document object
  31309. */
  31310. getHostDocument(): Document;
  31311. }
  31312. }
  31313. declare module "babylonjs/Maths/sphericalPolynomial" {
  31314. import { Vector3 } from "babylonjs/Maths/math.vector";
  31315. import { Color3 } from "babylonjs/Maths/math.color";
  31316. /**
  31317. * Class representing spherical harmonics coefficients to the 3rd degree
  31318. */
  31319. export class SphericalHarmonics {
  31320. /**
  31321. * Defines whether or not the harmonics have been prescaled for rendering.
  31322. */
  31323. preScaled: boolean;
  31324. /**
  31325. * The l0,0 coefficients of the spherical harmonics
  31326. */
  31327. l00: Vector3;
  31328. /**
  31329. * The l1,-1 coefficients of the spherical harmonics
  31330. */
  31331. l1_1: Vector3;
  31332. /**
  31333. * The l1,0 coefficients of the spherical harmonics
  31334. */
  31335. l10: Vector3;
  31336. /**
  31337. * The l1,1 coefficients of the spherical harmonics
  31338. */
  31339. l11: Vector3;
  31340. /**
  31341. * The l2,-2 coefficients of the spherical harmonics
  31342. */
  31343. l2_2: Vector3;
  31344. /**
  31345. * The l2,-1 coefficients of the spherical harmonics
  31346. */
  31347. l2_1: Vector3;
  31348. /**
  31349. * The l2,0 coefficients of the spherical harmonics
  31350. */
  31351. l20: Vector3;
  31352. /**
  31353. * The l2,1 coefficients of the spherical harmonics
  31354. */
  31355. l21: Vector3;
  31356. /**
  31357. * The l2,2 coefficients of the spherical harmonics
  31358. */
  31359. l22: Vector3;
  31360. /**
  31361. * Adds a light to the spherical harmonics
  31362. * @param direction the direction of the light
  31363. * @param color the color of the light
  31364. * @param deltaSolidAngle the delta solid angle of the light
  31365. */
  31366. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  31367. /**
  31368. * Scales the spherical harmonics by the given amount
  31369. * @param scale the amount to scale
  31370. */
  31371. scaleInPlace(scale: number): void;
  31372. /**
  31373. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  31374. *
  31375. * ```
  31376. * E_lm = A_l * L_lm
  31377. * ```
  31378. *
  31379. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  31380. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  31381. * the scaling factors are given in equation 9.
  31382. */
  31383. convertIncidentRadianceToIrradiance(): void;
  31384. /**
  31385. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  31386. *
  31387. * ```
  31388. * L = (1/pi) * E * rho
  31389. * ```
  31390. *
  31391. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  31392. */
  31393. convertIrradianceToLambertianRadiance(): void;
  31394. /**
  31395. * Integrates the reconstruction coefficients directly in to the SH preventing further
  31396. * required operations at run time.
  31397. *
  31398. * This is simply done by scaling back the SH with Ylm constants parameter.
  31399. * The trigonometric part being applied by the shader at run time.
  31400. */
  31401. preScaleForRendering(): void;
  31402. /**
  31403. * Constructs a spherical harmonics from an array.
  31404. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  31405. * @returns the spherical harmonics
  31406. */
  31407. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  31408. /**
  31409. * Gets the spherical harmonics from polynomial
  31410. * @param polynomial the spherical polynomial
  31411. * @returns the spherical harmonics
  31412. */
  31413. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  31414. }
  31415. /**
  31416. * Class representing spherical polynomial coefficients to the 3rd degree
  31417. */
  31418. export class SphericalPolynomial {
  31419. private _harmonics;
  31420. /**
  31421. * The spherical harmonics used to create the polynomials.
  31422. */
  31423. readonly preScaledHarmonics: SphericalHarmonics;
  31424. /**
  31425. * The x coefficients of the spherical polynomial
  31426. */
  31427. x: Vector3;
  31428. /**
  31429. * The y coefficients of the spherical polynomial
  31430. */
  31431. y: Vector3;
  31432. /**
  31433. * The z coefficients of the spherical polynomial
  31434. */
  31435. z: Vector3;
  31436. /**
  31437. * The xx coefficients of the spherical polynomial
  31438. */
  31439. xx: Vector3;
  31440. /**
  31441. * The yy coefficients of the spherical polynomial
  31442. */
  31443. yy: Vector3;
  31444. /**
  31445. * The zz coefficients of the spherical polynomial
  31446. */
  31447. zz: Vector3;
  31448. /**
  31449. * The xy coefficients of the spherical polynomial
  31450. */
  31451. xy: Vector3;
  31452. /**
  31453. * The yz coefficients of the spherical polynomial
  31454. */
  31455. yz: Vector3;
  31456. /**
  31457. * The zx coefficients of the spherical polynomial
  31458. */
  31459. zx: Vector3;
  31460. /**
  31461. * Adds an ambient color to the spherical polynomial
  31462. * @param color the color to add
  31463. */
  31464. addAmbient(color: Color3): void;
  31465. /**
  31466. * Scales the spherical polynomial by the given amount
  31467. * @param scale the amount to scale
  31468. */
  31469. scaleInPlace(scale: number): void;
  31470. /**
  31471. * Gets the spherical polynomial from harmonics
  31472. * @param harmonics the spherical harmonics
  31473. * @returns the spherical polynomial
  31474. */
  31475. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  31476. /**
  31477. * Constructs a spherical polynomial from an array.
  31478. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  31479. * @returns the spherical polynomial
  31480. */
  31481. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  31482. }
  31483. }
  31484. declare module "babylonjs/Materials/Textures/internalTexture" {
  31485. import { Observable } from "babylonjs/Misc/observable";
  31486. import { Nullable, int } from "babylonjs/types";
  31487. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  31488. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  31489. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  31490. /**
  31491. * Defines the source of the internal texture
  31492. */
  31493. export enum InternalTextureSource {
  31494. /**
  31495. * The source of the texture data is unknown
  31496. */
  31497. Unknown = 0,
  31498. /**
  31499. * Texture data comes from an URL
  31500. */
  31501. Url = 1,
  31502. /**
  31503. * Texture data is only used for temporary storage
  31504. */
  31505. Temp = 2,
  31506. /**
  31507. * Texture data comes from raw data (ArrayBuffer)
  31508. */
  31509. Raw = 3,
  31510. /**
  31511. * Texture content is dynamic (video or dynamic texture)
  31512. */
  31513. Dynamic = 4,
  31514. /**
  31515. * Texture content is generated by rendering to it
  31516. */
  31517. RenderTarget = 5,
  31518. /**
  31519. * Texture content is part of a multi render target process
  31520. */
  31521. MultiRenderTarget = 6,
  31522. /**
  31523. * Texture data comes from a cube data file
  31524. */
  31525. Cube = 7,
  31526. /**
  31527. * Texture data comes from a raw cube data
  31528. */
  31529. CubeRaw = 8,
  31530. /**
  31531. * Texture data come from a prefiltered cube data file
  31532. */
  31533. CubePrefiltered = 9,
  31534. /**
  31535. * Texture content is raw 3D data
  31536. */
  31537. Raw3D = 10,
  31538. /**
  31539. * Texture content is raw 2D array data
  31540. */
  31541. Raw2DArray = 11,
  31542. /**
  31543. * Texture content is a depth texture
  31544. */
  31545. Depth = 12,
  31546. /**
  31547. * Texture data comes from a raw cube data encoded with RGBD
  31548. */
  31549. CubeRawRGBD = 13
  31550. }
  31551. /**
  31552. * Class used to store data associated with WebGL texture data for the engine
  31553. * This class should not be used directly
  31554. */
  31555. export class InternalTexture {
  31556. /** @hidden */
  31557. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<import("babylonjs/Maths/sphericalPolynomial").SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  31558. /**
  31559. * Defines if the texture is ready
  31560. */
  31561. isReady: boolean;
  31562. /**
  31563. * Defines if the texture is a cube texture
  31564. */
  31565. isCube: boolean;
  31566. /**
  31567. * Defines if the texture contains 3D data
  31568. */
  31569. is3D: boolean;
  31570. /**
  31571. * Defines if the texture contains 2D array data
  31572. */
  31573. is2DArray: boolean;
  31574. /**
  31575. * Defines if the texture contains multiview data
  31576. */
  31577. isMultiview: boolean;
  31578. /**
  31579. * Gets the URL used to load this texture
  31580. */
  31581. url: string;
  31582. /**
  31583. * Gets the sampling mode of the texture
  31584. */
  31585. samplingMode: number;
  31586. /**
  31587. * Gets a boolean indicating if the texture needs mipmaps generation
  31588. */
  31589. generateMipMaps: boolean;
  31590. /**
  31591. * Gets the number of samples used by the texture (WebGL2+ only)
  31592. */
  31593. samples: number;
  31594. /**
  31595. * Gets the type of the texture (int, float...)
  31596. */
  31597. type: number;
  31598. /**
  31599. * Gets the format of the texture (RGB, RGBA...)
  31600. */
  31601. format: number;
  31602. /**
  31603. * Observable called when the texture is loaded
  31604. */
  31605. onLoadedObservable: Observable<InternalTexture>;
  31606. /**
  31607. * Gets the width of the texture
  31608. */
  31609. width: number;
  31610. /**
  31611. * Gets the height of the texture
  31612. */
  31613. height: number;
  31614. /**
  31615. * Gets the depth of the texture
  31616. */
  31617. depth: number;
  31618. /**
  31619. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  31620. */
  31621. baseWidth: number;
  31622. /**
  31623. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  31624. */
  31625. baseHeight: number;
  31626. /**
  31627. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  31628. */
  31629. baseDepth: number;
  31630. /**
  31631. * Gets a boolean indicating if the texture is inverted on Y axis
  31632. */
  31633. invertY: boolean;
  31634. /** @hidden */
  31635. _invertVScale: boolean;
  31636. /** @hidden */
  31637. _associatedChannel: number;
  31638. /** @hidden */
  31639. _source: InternalTextureSource;
  31640. /** @hidden */
  31641. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  31642. /** @hidden */
  31643. _bufferView: Nullable<ArrayBufferView>;
  31644. /** @hidden */
  31645. _bufferViewArray: Nullable<ArrayBufferView[]>;
  31646. /** @hidden */
  31647. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  31648. /** @hidden */
  31649. _size: number;
  31650. /** @hidden */
  31651. _extension: string;
  31652. /** @hidden */
  31653. _files: Nullable<string[]>;
  31654. /** @hidden */
  31655. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  31656. /** @hidden */
  31657. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  31658. /** @hidden */
  31659. _framebuffer: Nullable<WebGLFramebuffer>;
  31660. /** @hidden */
  31661. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  31662. /** @hidden */
  31663. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  31664. /** @hidden */
  31665. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  31666. /** @hidden */
  31667. _attachments: Nullable<number[]>;
  31668. /** @hidden */
  31669. _cachedCoordinatesMode: Nullable<number>;
  31670. /** @hidden */
  31671. _cachedWrapU: Nullable<number>;
  31672. /** @hidden */
  31673. _cachedWrapV: Nullable<number>;
  31674. /** @hidden */
  31675. _cachedWrapR: Nullable<number>;
  31676. /** @hidden */
  31677. _cachedAnisotropicFilteringLevel: Nullable<number>;
  31678. /** @hidden */
  31679. _isDisabled: boolean;
  31680. /** @hidden */
  31681. _compression: Nullable<string>;
  31682. /** @hidden */
  31683. _generateStencilBuffer: boolean;
  31684. /** @hidden */
  31685. _generateDepthBuffer: boolean;
  31686. /** @hidden */
  31687. _comparisonFunction: number;
  31688. /** @hidden */
  31689. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  31690. /** @hidden */
  31691. _lodGenerationScale: number;
  31692. /** @hidden */
  31693. _lodGenerationOffset: number;
  31694. /** @hidden */
  31695. _colorTextureArray: Nullable<WebGLTexture>;
  31696. /** @hidden */
  31697. _depthStencilTextureArray: Nullable<WebGLTexture>;
  31698. /** @hidden */
  31699. _lodTextureHigh: Nullable<BaseTexture>;
  31700. /** @hidden */
  31701. _lodTextureMid: Nullable<BaseTexture>;
  31702. /** @hidden */
  31703. _lodTextureLow: Nullable<BaseTexture>;
  31704. /** @hidden */
  31705. _isRGBD: boolean;
  31706. /** @hidden */
  31707. _linearSpecularLOD: boolean;
  31708. /** @hidden */
  31709. _irradianceTexture: Nullable<BaseTexture>;
  31710. /** @hidden */
  31711. _webGLTexture: Nullable<WebGLTexture>;
  31712. /** @hidden */
  31713. _references: number;
  31714. private _engine;
  31715. /**
  31716. * Gets the Engine the texture belongs to.
  31717. * @returns The babylon engine
  31718. */
  31719. getEngine(): ThinEngine;
  31720. /**
  31721. * Gets the data source type of the texture
  31722. */
  31723. readonly source: InternalTextureSource;
  31724. /**
  31725. * Creates a new InternalTexture
  31726. * @param engine defines the engine to use
  31727. * @param source defines the type of data that will be used
  31728. * @param delayAllocation if the texture allocation should be delayed (default: false)
  31729. */
  31730. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  31731. /**
  31732. * Increments the number of references (ie. the number of Texture that point to it)
  31733. */
  31734. incrementReferences(): void;
  31735. /**
  31736. * Change the size of the texture (not the size of the content)
  31737. * @param width defines the new width
  31738. * @param height defines the new height
  31739. * @param depth defines the new depth (1 by default)
  31740. */
  31741. updateSize(width: int, height: int, depth?: int): void;
  31742. /** @hidden */
  31743. _rebuild(): void;
  31744. /** @hidden */
  31745. _swapAndDie(target: InternalTexture): void;
  31746. /**
  31747. * Dispose the current allocated resources
  31748. */
  31749. dispose(): void;
  31750. }
  31751. }
  31752. declare module "babylonjs/Audio/analyser" {
  31753. import { Scene } from "babylonjs/scene";
  31754. /**
  31755. * Class used to work with sound analyzer using fast fourier transform (FFT)
  31756. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  31757. */
  31758. export class Analyser {
  31759. /**
  31760. * Gets or sets the smoothing
  31761. * @ignorenaming
  31762. */
  31763. SMOOTHING: number;
  31764. /**
  31765. * Gets or sets the FFT table size
  31766. * @ignorenaming
  31767. */
  31768. FFT_SIZE: number;
  31769. /**
  31770. * Gets or sets the bar graph amplitude
  31771. * @ignorenaming
  31772. */
  31773. BARGRAPHAMPLITUDE: number;
  31774. /**
  31775. * Gets or sets the position of the debug canvas
  31776. * @ignorenaming
  31777. */
  31778. DEBUGCANVASPOS: {
  31779. x: number;
  31780. y: number;
  31781. };
  31782. /**
  31783. * Gets or sets the debug canvas size
  31784. * @ignorenaming
  31785. */
  31786. DEBUGCANVASSIZE: {
  31787. width: number;
  31788. height: number;
  31789. };
  31790. private _byteFreqs;
  31791. private _byteTime;
  31792. private _floatFreqs;
  31793. private _webAudioAnalyser;
  31794. private _debugCanvas;
  31795. private _debugCanvasContext;
  31796. private _scene;
  31797. private _registerFunc;
  31798. private _audioEngine;
  31799. /**
  31800. * Creates a new analyser
  31801. * @param scene defines hosting scene
  31802. */
  31803. constructor(scene: Scene);
  31804. /**
  31805. * Get the number of data values you will have to play with for the visualization
  31806. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  31807. * @returns a number
  31808. */
  31809. getFrequencyBinCount(): number;
  31810. /**
  31811. * Gets the current frequency data as a byte array
  31812. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  31813. * @returns a Uint8Array
  31814. */
  31815. getByteFrequencyData(): Uint8Array;
  31816. /**
  31817. * Gets the current waveform as a byte array
  31818. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  31819. * @returns a Uint8Array
  31820. */
  31821. getByteTimeDomainData(): Uint8Array;
  31822. /**
  31823. * Gets the current frequency data as a float array
  31824. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  31825. * @returns a Float32Array
  31826. */
  31827. getFloatFrequencyData(): Float32Array;
  31828. /**
  31829. * Renders the debug canvas
  31830. */
  31831. drawDebugCanvas(): void;
  31832. /**
  31833. * Stops rendering the debug canvas and removes it
  31834. */
  31835. stopDebugCanvas(): void;
  31836. /**
  31837. * Connects two audio nodes
  31838. * @param inputAudioNode defines first node to connect
  31839. * @param outputAudioNode defines second node to connect
  31840. */
  31841. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  31842. /**
  31843. * Releases all associated resources
  31844. */
  31845. dispose(): void;
  31846. }
  31847. }
  31848. declare module "babylonjs/Audio/audioEngine" {
  31849. import { IDisposable } from "babylonjs/scene";
  31850. import { Analyser } from "babylonjs/Audio/analyser";
  31851. import { Nullable } from "babylonjs/types";
  31852. import { Observable } from "babylonjs/Misc/observable";
  31853. /**
  31854. * This represents an audio engine and it is responsible
  31855. * to play, synchronize and analyse sounds throughout the application.
  31856. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  31857. */
  31858. export interface IAudioEngine extends IDisposable {
  31859. /**
  31860. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  31861. */
  31862. readonly canUseWebAudio: boolean;
  31863. /**
  31864. * Gets the current AudioContext if available.
  31865. */
  31866. readonly audioContext: Nullable<AudioContext>;
  31867. /**
  31868. * The master gain node defines the global audio volume of your audio engine.
  31869. */
  31870. readonly masterGain: GainNode;
  31871. /**
  31872. * Gets whether or not mp3 are supported by your browser.
  31873. */
  31874. readonly isMP3supported: boolean;
  31875. /**
  31876. * Gets whether or not ogg are supported by your browser.
  31877. */
  31878. readonly isOGGsupported: boolean;
  31879. /**
  31880. * Defines if Babylon should emit a warning if WebAudio is not supported.
  31881. * @ignoreNaming
  31882. */
  31883. WarnedWebAudioUnsupported: boolean;
  31884. /**
  31885. * Defines if the audio engine relies on a custom unlocked button.
  31886. * In this case, the embedded button will not be displayed.
  31887. */
  31888. useCustomUnlockedButton: boolean;
  31889. /**
  31890. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  31891. */
  31892. readonly unlocked: boolean;
  31893. /**
  31894. * Event raised when audio has been unlocked on the browser.
  31895. */
  31896. onAudioUnlockedObservable: Observable<AudioEngine>;
  31897. /**
  31898. * Event raised when audio has been locked on the browser.
  31899. */
  31900. onAudioLockedObservable: Observable<AudioEngine>;
  31901. /**
  31902. * Flags the audio engine in Locked state.
  31903. * This happens due to new browser policies preventing audio to autoplay.
  31904. */
  31905. lock(): void;
  31906. /**
  31907. * Unlocks the audio engine once a user action has been done on the dom.
  31908. * This is helpful to resume play once browser policies have been satisfied.
  31909. */
  31910. unlock(): void;
  31911. }
  31912. /**
  31913. * This represents the default audio engine used in babylon.
  31914. * It is responsible to play, synchronize and analyse sounds throughout the application.
  31915. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  31916. */
  31917. export class AudioEngine implements IAudioEngine {
  31918. private _audioContext;
  31919. private _audioContextInitialized;
  31920. private _muteButton;
  31921. private _hostElement;
  31922. /**
  31923. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  31924. */
  31925. canUseWebAudio: boolean;
  31926. /**
  31927. * The master gain node defines the global audio volume of your audio engine.
  31928. */
  31929. masterGain: GainNode;
  31930. /**
  31931. * Defines if Babylon should emit a warning if WebAudio is not supported.
  31932. * @ignoreNaming
  31933. */
  31934. WarnedWebAudioUnsupported: boolean;
  31935. /**
  31936. * Gets whether or not mp3 are supported by your browser.
  31937. */
  31938. isMP3supported: boolean;
  31939. /**
  31940. * Gets whether or not ogg are supported by your browser.
  31941. */
  31942. isOGGsupported: boolean;
  31943. /**
  31944. * Gets whether audio has been unlocked on the device.
  31945. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  31946. * a user interaction has happened.
  31947. */
  31948. unlocked: boolean;
  31949. /**
  31950. * Defines if the audio engine relies on a custom unlocked button.
  31951. * In this case, the embedded button will not be displayed.
  31952. */
  31953. useCustomUnlockedButton: boolean;
  31954. /**
  31955. * Event raised when audio has been unlocked on the browser.
  31956. */
  31957. onAudioUnlockedObservable: Observable<AudioEngine>;
  31958. /**
  31959. * Event raised when audio has been locked on the browser.
  31960. */
  31961. onAudioLockedObservable: Observable<AudioEngine>;
  31962. /**
  31963. * Gets the current AudioContext if available.
  31964. */
  31965. readonly audioContext: Nullable<AudioContext>;
  31966. private _connectedAnalyser;
  31967. /**
  31968. * Instantiates a new audio engine.
  31969. *
  31970. * There should be only one per page as some browsers restrict the number
  31971. * of audio contexts you can create.
  31972. * @param hostElement defines the host element where to display the mute icon if necessary
  31973. */
  31974. constructor(hostElement?: Nullable<HTMLElement>);
  31975. /**
  31976. * Flags the audio engine in Locked state.
  31977. * This happens due to new browser policies preventing audio to autoplay.
  31978. */
  31979. lock(): void;
  31980. /**
  31981. * Unlocks the audio engine once a user action has been done on the dom.
  31982. * This is helpful to resume play once browser policies have been satisfied.
  31983. */
  31984. unlock(): void;
  31985. private _resumeAudioContext;
  31986. private _initializeAudioContext;
  31987. private _tryToRun;
  31988. private _triggerRunningState;
  31989. private _triggerSuspendedState;
  31990. private _displayMuteButton;
  31991. private _moveButtonToTopLeft;
  31992. private _onResize;
  31993. private _hideMuteButton;
  31994. /**
  31995. * Destroy and release the resources associated with the audio ccontext.
  31996. */
  31997. dispose(): void;
  31998. /**
  31999. * Gets the global volume sets on the master gain.
  32000. * @returns the global volume if set or -1 otherwise
  32001. */
  32002. getGlobalVolume(): number;
  32003. /**
  32004. * Sets the global volume of your experience (sets on the master gain).
  32005. * @param newVolume Defines the new global volume of the application
  32006. */
  32007. setGlobalVolume(newVolume: number): void;
  32008. /**
  32009. * Connect the audio engine to an audio analyser allowing some amazing
  32010. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  32011. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  32012. * @param analyser The analyser to connect to the engine
  32013. */
  32014. connectToAnalyser(analyser: Analyser): void;
  32015. }
  32016. }
  32017. declare module "babylonjs/Loading/loadingScreen" {
  32018. /**
  32019. * Interface used to present a loading screen while loading a scene
  32020. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32021. */
  32022. export interface ILoadingScreen {
  32023. /**
  32024. * Function called to display the loading screen
  32025. */
  32026. displayLoadingUI: () => void;
  32027. /**
  32028. * Function called to hide the loading screen
  32029. */
  32030. hideLoadingUI: () => void;
  32031. /**
  32032. * Gets or sets the color to use for the background
  32033. */
  32034. loadingUIBackgroundColor: string;
  32035. /**
  32036. * Gets or sets the text to display while loading
  32037. */
  32038. loadingUIText: string;
  32039. }
  32040. /**
  32041. * Class used for the default loading screen
  32042. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32043. */
  32044. export class DefaultLoadingScreen implements ILoadingScreen {
  32045. private _renderingCanvas;
  32046. private _loadingText;
  32047. private _loadingDivBackgroundColor;
  32048. private _loadingDiv;
  32049. private _loadingTextDiv;
  32050. /** Gets or sets the logo url to use for the default loading screen */
  32051. static DefaultLogoUrl: string;
  32052. /** Gets or sets the spinner url to use for the default loading screen */
  32053. static DefaultSpinnerUrl: string;
  32054. /**
  32055. * Creates a new default loading screen
  32056. * @param _renderingCanvas defines the canvas used to render the scene
  32057. * @param _loadingText defines the default text to display
  32058. * @param _loadingDivBackgroundColor defines the default background color
  32059. */
  32060. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  32061. /**
  32062. * Function called to display the loading screen
  32063. */
  32064. displayLoadingUI(): void;
  32065. /**
  32066. * Function called to hide the loading screen
  32067. */
  32068. hideLoadingUI(): void;
  32069. /**
  32070. * Gets or sets the text to display while loading
  32071. */
  32072. loadingUIText: string;
  32073. /**
  32074. * Gets or sets the color to use for the background
  32075. */
  32076. loadingUIBackgroundColor: string;
  32077. private _resizeLoadingUI;
  32078. }
  32079. }
  32080. declare module "babylonjs/Misc/customAnimationFrameRequester" {
  32081. /**
  32082. * Interface for any object that can request an animation frame
  32083. */
  32084. export interface ICustomAnimationFrameRequester {
  32085. /**
  32086. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  32087. */
  32088. renderFunction?: Function;
  32089. /**
  32090. * Called to request the next frame to render to
  32091. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  32092. */
  32093. requestAnimationFrame: Function;
  32094. /**
  32095. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  32096. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  32097. */
  32098. requestID?: number;
  32099. }
  32100. }
  32101. declare module "babylonjs/Misc/performanceMonitor" {
  32102. /**
  32103. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  32104. */
  32105. export class PerformanceMonitor {
  32106. private _enabled;
  32107. private _rollingFrameTime;
  32108. private _lastFrameTimeMs;
  32109. /**
  32110. * constructor
  32111. * @param frameSampleSize The number of samples required to saturate the sliding window
  32112. */
  32113. constructor(frameSampleSize?: number);
  32114. /**
  32115. * Samples current frame
  32116. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  32117. */
  32118. sampleFrame(timeMs?: number): void;
  32119. /**
  32120. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  32121. */
  32122. readonly averageFrameTime: number;
  32123. /**
  32124. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  32125. */
  32126. readonly averageFrameTimeVariance: number;
  32127. /**
  32128. * Returns the frame time of the most recent frame
  32129. */
  32130. readonly instantaneousFrameTime: number;
  32131. /**
  32132. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  32133. */
  32134. readonly averageFPS: number;
  32135. /**
  32136. * Returns the average framerate in frames per second using the most recent frame time
  32137. */
  32138. readonly instantaneousFPS: number;
  32139. /**
  32140. * Returns true if enough samples have been taken to completely fill the sliding window
  32141. */
  32142. readonly isSaturated: boolean;
  32143. /**
  32144. * Enables contributions to the sliding window sample set
  32145. */
  32146. enable(): void;
  32147. /**
  32148. * Disables contributions to the sliding window sample set
  32149. * Samples will not be interpolated over the disabled period
  32150. */
  32151. disable(): void;
  32152. /**
  32153. * Returns true if sampling is enabled
  32154. */
  32155. readonly isEnabled: boolean;
  32156. /**
  32157. * Resets performance monitor
  32158. */
  32159. reset(): void;
  32160. }
  32161. /**
  32162. * RollingAverage
  32163. *
  32164. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  32165. */
  32166. export class RollingAverage {
  32167. /**
  32168. * Current average
  32169. */
  32170. average: number;
  32171. /**
  32172. * Current variance
  32173. */
  32174. variance: number;
  32175. protected _samples: Array<number>;
  32176. protected _sampleCount: number;
  32177. protected _pos: number;
  32178. protected _m2: number;
  32179. /**
  32180. * constructor
  32181. * @param length The number of samples required to saturate the sliding window
  32182. */
  32183. constructor(length: number);
  32184. /**
  32185. * Adds a sample to the sample set
  32186. * @param v The sample value
  32187. */
  32188. add(v: number): void;
  32189. /**
  32190. * Returns previously added values or null if outside of history or outside the sliding window domain
  32191. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  32192. * @return Value previously recorded with add() or null if outside of range
  32193. */
  32194. history(i: number): number;
  32195. /**
  32196. * Returns true if enough samples have been taken to completely fill the sliding window
  32197. * @return true if sample-set saturated
  32198. */
  32199. isSaturated(): boolean;
  32200. /**
  32201. * Resets the rolling average (equivalent to 0 samples taken so far)
  32202. */
  32203. reset(): void;
  32204. /**
  32205. * Wraps a value around the sample range boundaries
  32206. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  32207. * @return Wrapped position in sample range
  32208. */
  32209. protected _wrapPosition(i: number): number;
  32210. }
  32211. }
  32212. declare module "babylonjs/Misc/perfCounter" {
  32213. /**
  32214. * This class is used to track a performance counter which is number based.
  32215. * The user has access to many properties which give statistics of different nature.
  32216. *
  32217. * The implementer can track two kinds of Performance Counter: time and count.
  32218. * 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.
  32219. * 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.
  32220. */
  32221. export class PerfCounter {
  32222. /**
  32223. * Gets or sets a global boolean to turn on and off all the counters
  32224. */
  32225. static Enabled: boolean;
  32226. /**
  32227. * Returns the smallest value ever
  32228. */
  32229. readonly min: number;
  32230. /**
  32231. * Returns the biggest value ever
  32232. */
  32233. readonly max: number;
  32234. /**
  32235. * Returns the average value since the performance counter is running
  32236. */
  32237. readonly average: number;
  32238. /**
  32239. * Returns the average value of the last second the counter was monitored
  32240. */
  32241. readonly lastSecAverage: number;
  32242. /**
  32243. * Returns the current value
  32244. */
  32245. readonly current: number;
  32246. /**
  32247. * Gets the accumulated total
  32248. */
  32249. readonly total: number;
  32250. /**
  32251. * Gets the total value count
  32252. */
  32253. readonly count: number;
  32254. /**
  32255. * Creates a new counter
  32256. */
  32257. constructor();
  32258. /**
  32259. * Call this method to start monitoring a new frame.
  32260. * 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.
  32261. */
  32262. fetchNewFrame(): void;
  32263. /**
  32264. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  32265. * @param newCount the count value to add to the monitored count
  32266. * @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.
  32267. */
  32268. addCount(newCount: number, fetchResult: boolean): void;
  32269. /**
  32270. * Start monitoring this performance counter
  32271. */
  32272. beginMonitoring(): void;
  32273. /**
  32274. * Compute the time lapsed since the previous beginMonitoring() call.
  32275. * @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
  32276. */
  32277. endMonitoring(newFrame?: boolean): void;
  32278. private _fetchResult;
  32279. private _startMonitoringTime;
  32280. private _min;
  32281. private _max;
  32282. private _average;
  32283. private _current;
  32284. private _totalValueCount;
  32285. private _totalAccumulated;
  32286. private _lastSecAverage;
  32287. private _lastSecAccumulated;
  32288. private _lastSecTime;
  32289. private _lastSecValueCount;
  32290. }
  32291. }
  32292. declare module "babylonjs/Engines/engine" {
  32293. import { Observable } from "babylonjs/Misc/observable";
  32294. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  32295. import { Scene } from "babylonjs/scene";
  32296. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  32297. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  32298. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  32299. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  32300. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  32301. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  32302. import { ICustomAnimationFrameRequester } from "babylonjs/Misc/customAnimationFrameRequester";
  32303. import { ThinEngine, EngineOptions } from "babylonjs/Engines/thinEngine";
  32304. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  32305. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  32306. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  32307. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  32308. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  32309. import { Material } from "babylonjs/Materials/material";
  32310. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  32311. /**
  32312. * Defines the interface used by display changed events
  32313. */
  32314. export interface IDisplayChangedEventArgs {
  32315. /** Gets the vrDisplay object (if any) */
  32316. vrDisplay: Nullable<any>;
  32317. /** Gets a boolean indicating if webVR is supported */
  32318. vrSupported: boolean;
  32319. }
  32320. /**
  32321. * Defines the interface used by objects containing a viewport (like a camera)
  32322. */
  32323. interface IViewportOwnerLike {
  32324. /**
  32325. * Gets or sets the viewport
  32326. */
  32327. viewport: IViewportLike;
  32328. }
  32329. /**
  32330. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  32331. */
  32332. export class Engine extends ThinEngine {
  32333. /** Defines that alpha blending is disabled */
  32334. static readonly ALPHA_DISABLE: number;
  32335. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  32336. static readonly ALPHA_ADD: number;
  32337. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  32338. static readonly ALPHA_COMBINE: number;
  32339. /** Defines that alpha blending to DEST - SRC * DEST */
  32340. static readonly ALPHA_SUBTRACT: number;
  32341. /** Defines that alpha blending to SRC * DEST */
  32342. static readonly ALPHA_MULTIPLY: number;
  32343. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  32344. static readonly ALPHA_MAXIMIZED: number;
  32345. /** Defines that alpha blending to SRC + DEST */
  32346. static readonly ALPHA_ONEONE: number;
  32347. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  32348. static readonly ALPHA_PREMULTIPLIED: number;
  32349. /**
  32350. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  32351. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  32352. */
  32353. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  32354. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  32355. static readonly ALPHA_INTERPOLATE: number;
  32356. /**
  32357. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  32358. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  32359. */
  32360. static readonly ALPHA_SCREENMODE: number;
  32361. /** Defines that the ressource is not delayed*/
  32362. static readonly DELAYLOADSTATE_NONE: number;
  32363. /** Defines that the ressource was successfully delay loaded */
  32364. static readonly DELAYLOADSTATE_LOADED: number;
  32365. /** Defines that the ressource is currently delay loading */
  32366. static readonly DELAYLOADSTATE_LOADING: number;
  32367. /** Defines that the ressource is delayed and has not started loading */
  32368. static readonly DELAYLOADSTATE_NOTLOADED: number;
  32369. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  32370. static readonly NEVER: number;
  32371. /** 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 */
  32372. static readonly ALWAYS: number;
  32373. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  32374. static readonly LESS: number;
  32375. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  32376. static readonly EQUAL: number;
  32377. /** 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 */
  32378. static readonly LEQUAL: number;
  32379. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  32380. static readonly GREATER: number;
  32381. /** 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 */
  32382. static readonly GEQUAL: number;
  32383. /** 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 */
  32384. static readonly NOTEQUAL: number;
  32385. /** Passed to stencilOperation to specify that stencil value must be kept */
  32386. static readonly KEEP: number;
  32387. /** Passed to stencilOperation to specify that stencil value must be replaced */
  32388. static readonly REPLACE: number;
  32389. /** Passed to stencilOperation to specify that stencil value must be incremented */
  32390. static readonly INCR: number;
  32391. /** Passed to stencilOperation to specify that stencil value must be decremented */
  32392. static readonly DECR: number;
  32393. /** Passed to stencilOperation to specify that stencil value must be inverted */
  32394. static readonly INVERT: number;
  32395. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  32396. static readonly INCR_WRAP: number;
  32397. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  32398. static readonly DECR_WRAP: number;
  32399. /** Texture is not repeating outside of 0..1 UVs */
  32400. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  32401. /** Texture is repeating outside of 0..1 UVs */
  32402. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  32403. /** Texture is repeating and mirrored */
  32404. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  32405. /** ALPHA */
  32406. static readonly TEXTUREFORMAT_ALPHA: number;
  32407. /** LUMINANCE */
  32408. static readonly TEXTUREFORMAT_LUMINANCE: number;
  32409. /** LUMINANCE_ALPHA */
  32410. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  32411. /** RGB */
  32412. static readonly TEXTUREFORMAT_RGB: number;
  32413. /** RGBA */
  32414. static readonly TEXTUREFORMAT_RGBA: number;
  32415. /** RED */
  32416. static readonly TEXTUREFORMAT_RED: number;
  32417. /** RED (2nd reference) */
  32418. static readonly TEXTUREFORMAT_R: number;
  32419. /** RG */
  32420. static readonly TEXTUREFORMAT_RG: number;
  32421. /** RED_INTEGER */
  32422. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  32423. /** RED_INTEGER (2nd reference) */
  32424. static readonly TEXTUREFORMAT_R_INTEGER: number;
  32425. /** RG_INTEGER */
  32426. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  32427. /** RGB_INTEGER */
  32428. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  32429. /** RGBA_INTEGER */
  32430. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  32431. /** UNSIGNED_BYTE */
  32432. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  32433. /** UNSIGNED_BYTE (2nd reference) */
  32434. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  32435. /** FLOAT */
  32436. static readonly TEXTURETYPE_FLOAT: number;
  32437. /** HALF_FLOAT */
  32438. static readonly TEXTURETYPE_HALF_FLOAT: number;
  32439. /** BYTE */
  32440. static readonly TEXTURETYPE_BYTE: number;
  32441. /** SHORT */
  32442. static readonly TEXTURETYPE_SHORT: number;
  32443. /** UNSIGNED_SHORT */
  32444. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  32445. /** INT */
  32446. static readonly TEXTURETYPE_INT: number;
  32447. /** UNSIGNED_INT */
  32448. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  32449. /** UNSIGNED_SHORT_4_4_4_4 */
  32450. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  32451. /** UNSIGNED_SHORT_5_5_5_1 */
  32452. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  32453. /** UNSIGNED_SHORT_5_6_5 */
  32454. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  32455. /** UNSIGNED_INT_2_10_10_10_REV */
  32456. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  32457. /** UNSIGNED_INT_24_8 */
  32458. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  32459. /** UNSIGNED_INT_10F_11F_11F_REV */
  32460. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  32461. /** UNSIGNED_INT_5_9_9_9_REV */
  32462. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  32463. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  32464. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  32465. /** nearest is mag = nearest and min = nearest and mip = linear */
  32466. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  32467. /** Bilinear is mag = linear and min = linear and mip = nearest */
  32468. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  32469. /** Trilinear is mag = linear and min = linear and mip = linear */
  32470. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  32471. /** nearest is mag = nearest and min = nearest and mip = linear */
  32472. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  32473. /** Bilinear is mag = linear and min = linear and mip = nearest */
  32474. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  32475. /** Trilinear is mag = linear and min = linear and mip = linear */
  32476. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  32477. /** mag = nearest and min = nearest and mip = nearest */
  32478. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  32479. /** mag = nearest and min = linear and mip = nearest */
  32480. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  32481. /** mag = nearest and min = linear and mip = linear */
  32482. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  32483. /** mag = nearest and min = linear and mip = none */
  32484. static readonly TEXTURE_NEAREST_LINEAR: number;
  32485. /** mag = nearest and min = nearest and mip = none */
  32486. static readonly TEXTURE_NEAREST_NEAREST: number;
  32487. /** mag = linear and min = nearest and mip = nearest */
  32488. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  32489. /** mag = linear and min = nearest and mip = linear */
  32490. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  32491. /** mag = linear and min = linear and mip = none */
  32492. static readonly TEXTURE_LINEAR_LINEAR: number;
  32493. /** mag = linear and min = nearest and mip = none */
  32494. static readonly TEXTURE_LINEAR_NEAREST: number;
  32495. /** Explicit coordinates mode */
  32496. static readonly TEXTURE_EXPLICIT_MODE: number;
  32497. /** Spherical coordinates mode */
  32498. static readonly TEXTURE_SPHERICAL_MODE: number;
  32499. /** Planar coordinates mode */
  32500. static readonly TEXTURE_PLANAR_MODE: number;
  32501. /** Cubic coordinates mode */
  32502. static readonly TEXTURE_CUBIC_MODE: number;
  32503. /** Projection coordinates mode */
  32504. static readonly TEXTURE_PROJECTION_MODE: number;
  32505. /** Skybox coordinates mode */
  32506. static readonly TEXTURE_SKYBOX_MODE: number;
  32507. /** Inverse Cubic coordinates mode */
  32508. static readonly TEXTURE_INVCUBIC_MODE: number;
  32509. /** Equirectangular coordinates mode */
  32510. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  32511. /** Equirectangular Fixed coordinates mode */
  32512. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  32513. /** Equirectangular Fixed Mirrored coordinates mode */
  32514. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  32515. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  32516. static readonly SCALEMODE_FLOOR: number;
  32517. /** Defines that texture rescaling will look for the nearest power of 2 size */
  32518. static readonly SCALEMODE_NEAREST: number;
  32519. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  32520. static readonly SCALEMODE_CEILING: number;
  32521. /**
  32522. * Returns the current npm package of the sdk
  32523. */
  32524. static readonly NpmPackage: string;
  32525. /**
  32526. * Returns the current version of the framework
  32527. */
  32528. static readonly Version: string;
  32529. /** Gets the list of created engines */
  32530. static readonly Instances: Engine[];
  32531. /**
  32532. * Gets the latest created engine
  32533. */
  32534. static readonly LastCreatedEngine: Nullable<Engine>;
  32535. /**
  32536. * Gets the latest created scene
  32537. */
  32538. static readonly LastCreatedScene: Nullable<Scene>;
  32539. /**
  32540. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  32541. * @param flag defines which part of the materials must be marked as dirty
  32542. * @param predicate defines a predicate used to filter which materials should be affected
  32543. */
  32544. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  32545. /**
  32546. * Method called to create the default loading screen.
  32547. * This can be overriden in your own app.
  32548. * @param canvas The rendering canvas element
  32549. * @returns The loading screen
  32550. */
  32551. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  32552. /**
  32553. * Method called to create the default rescale post process on each engine.
  32554. */
  32555. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  32556. /**
  32557. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  32558. **/
  32559. enableOfflineSupport: boolean;
  32560. /**
  32561. * 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)
  32562. **/
  32563. disableManifestCheck: boolean;
  32564. /**
  32565. * Gets the list of created scenes
  32566. */
  32567. scenes: Scene[];
  32568. /**
  32569. * Event raised when a new scene is created
  32570. */
  32571. onNewSceneAddedObservable: Observable<Scene>;
  32572. /**
  32573. * Gets the list of created postprocesses
  32574. */
  32575. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  32576. /**
  32577. * Gets a boolean indicating if the pointer is currently locked
  32578. */
  32579. isPointerLock: boolean;
  32580. /**
  32581. * Observable event triggered each time the rendering canvas is resized
  32582. */
  32583. onResizeObservable: Observable<Engine>;
  32584. /**
  32585. * Observable event triggered each time the canvas loses focus
  32586. */
  32587. onCanvasBlurObservable: Observable<Engine>;
  32588. /**
  32589. * Observable event triggered each time the canvas gains focus
  32590. */
  32591. onCanvasFocusObservable: Observable<Engine>;
  32592. /**
  32593. * Observable event triggered each time the canvas receives pointerout event
  32594. */
  32595. onCanvasPointerOutObservable: Observable<PointerEvent>;
  32596. /**
  32597. * Observable raised when the engine begins a new frame
  32598. */
  32599. onBeginFrameObservable: Observable<Engine>;
  32600. /**
  32601. * If set, will be used to request the next animation frame for the render loop
  32602. */
  32603. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  32604. /**
  32605. * Observable raised when the engine ends the current frame
  32606. */
  32607. onEndFrameObservable: Observable<Engine>;
  32608. /**
  32609. * Observable raised when the engine is about to compile a shader
  32610. */
  32611. onBeforeShaderCompilationObservable: Observable<Engine>;
  32612. /**
  32613. * Observable raised when the engine has jsut compiled a shader
  32614. */
  32615. onAfterShaderCompilationObservable: Observable<Engine>;
  32616. /**
  32617. * Gets the audio engine
  32618. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32619. * @ignorenaming
  32620. */
  32621. static audioEngine: IAudioEngine;
  32622. /**
  32623. * Default AudioEngine factory responsible of creating the Audio Engine.
  32624. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  32625. */
  32626. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  32627. /**
  32628. * Default offline support factory responsible of creating a tool used to store data locally.
  32629. * By default, this will create a Database object if the workload has been embedded.
  32630. */
  32631. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  32632. private _loadingScreen;
  32633. private _pointerLockRequested;
  32634. private _dummyFramebuffer;
  32635. private _rescalePostProcess;
  32636. /** @hidden */
  32637. protected _alphaMode: number;
  32638. /** @hidden */
  32639. protected _alphaEquation: number;
  32640. private _deterministicLockstep;
  32641. private _lockstepMaxSteps;
  32642. private _timeStep;
  32643. protected readonly _supportsHardwareTextureRescaling: boolean;
  32644. private _fps;
  32645. private _deltaTime;
  32646. /** @hidden */
  32647. _drawCalls: PerfCounter;
  32648. /**
  32649. * Turn this value on if you want to pause FPS computation when in background
  32650. */
  32651. disablePerformanceMonitorInBackground: boolean;
  32652. private _performanceMonitor;
  32653. /**
  32654. * Gets the performance monitor attached to this engine
  32655. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  32656. */
  32657. readonly performanceMonitor: PerformanceMonitor;
  32658. private _onFocus;
  32659. private _onBlur;
  32660. private _onCanvasPointerOut;
  32661. private _onCanvasBlur;
  32662. private _onCanvasFocus;
  32663. private _onFullscreenChange;
  32664. private _onPointerLockChange;
  32665. /**
  32666. * Gets the HTML element used to attach event listeners
  32667. * @returns a HTML element
  32668. */
  32669. getInputElement(): Nullable<HTMLElement>;
  32670. /**
  32671. * Creates a new engine
  32672. * @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
  32673. * @param antialias defines enable antialiasing (default: false)
  32674. * @param options defines further options to be sent to the getContext() function
  32675. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  32676. */
  32677. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  32678. /**
  32679. * Gets current aspect ratio
  32680. * @param viewportOwner defines the camera to use to get the aspect ratio
  32681. * @param useScreen defines if screen size must be used (or the current render target if any)
  32682. * @returns a number defining the aspect ratio
  32683. */
  32684. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  32685. /**
  32686. * Gets current screen aspect ratio
  32687. * @returns a number defining the aspect ratio
  32688. */
  32689. getScreenAspectRatio(): number;
  32690. /**
  32691. * Gets the client rect of the HTML canvas attached with the current webGL context
  32692. * @returns a client rectanglee
  32693. */
  32694. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  32695. /**
  32696. * Gets the client rect of the HTML element used for events
  32697. * @returns a client rectanglee
  32698. */
  32699. getInputElementClientRect(): Nullable<ClientRect>;
  32700. /**
  32701. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  32702. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32703. * @returns true if engine is in deterministic lock step mode
  32704. */
  32705. isDeterministicLockStep(): boolean;
  32706. /**
  32707. * Gets the max steps when engine is running in deterministic lock step
  32708. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32709. * @returns the max steps
  32710. */
  32711. getLockstepMaxSteps(): number;
  32712. /**
  32713. * Returns the time in ms between steps when using deterministic lock step.
  32714. * @returns time step in (ms)
  32715. */
  32716. getTimeStep(): number;
  32717. /**
  32718. * Force the mipmap generation for the given render target texture
  32719. * @param texture defines the render target texture to use
  32720. */
  32721. generateMipMapsForCubemap(texture: InternalTexture): void;
  32722. /** States */
  32723. /**
  32724. * Set various states to the webGL context
  32725. * @param culling defines backface culling state
  32726. * @param zOffset defines the value to apply to zOffset (0 by default)
  32727. * @param force defines if states must be applied even if cache is up to date
  32728. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  32729. */
  32730. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  32731. /**
  32732. * Set the z offset to apply to current rendering
  32733. * @param value defines the offset to apply
  32734. */
  32735. setZOffset(value: number): void;
  32736. /**
  32737. * Gets the current value of the zOffset
  32738. * @returns the current zOffset state
  32739. */
  32740. getZOffset(): number;
  32741. /**
  32742. * Enable or disable depth buffering
  32743. * @param enable defines the state to set
  32744. */
  32745. setDepthBuffer(enable: boolean): void;
  32746. /**
  32747. * Gets a boolean indicating if depth writing is enabled
  32748. * @returns the current depth writing state
  32749. */
  32750. getDepthWrite(): boolean;
  32751. /**
  32752. * Enable or disable depth writing
  32753. * @param enable defines the state to set
  32754. */
  32755. setDepthWrite(enable: boolean): void;
  32756. /**
  32757. * Enable or disable color writing
  32758. * @param enable defines the state to set
  32759. */
  32760. setColorWrite(enable: boolean): void;
  32761. /**
  32762. * Gets a boolean indicating if color writing is enabled
  32763. * @returns the current color writing state
  32764. */
  32765. getColorWrite(): boolean;
  32766. /**
  32767. * Sets alpha constants used by some alpha blending modes
  32768. * @param r defines the red component
  32769. * @param g defines the green component
  32770. * @param b defines the blue component
  32771. * @param a defines the alpha component
  32772. */
  32773. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  32774. /**
  32775. * Sets the current alpha mode
  32776. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  32777. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  32778. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  32779. */
  32780. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  32781. /**
  32782. * Gets the current alpha mode
  32783. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  32784. * @returns the current alpha mode
  32785. */
  32786. getAlphaMode(): number;
  32787. /**
  32788. * Sets the current alpha equation
  32789. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  32790. */
  32791. setAlphaEquation(equation: number): void;
  32792. /**
  32793. * Gets the current alpha equation.
  32794. * @returns the current alpha equation
  32795. */
  32796. getAlphaEquation(): number;
  32797. /**
  32798. * Gets a boolean indicating if stencil buffer is enabled
  32799. * @returns the current stencil buffer state
  32800. */
  32801. getStencilBuffer(): boolean;
  32802. /**
  32803. * Enable or disable the stencil buffer
  32804. * @param enable defines if the stencil buffer must be enabled or disabled
  32805. */
  32806. setStencilBuffer(enable: boolean): void;
  32807. /**
  32808. * Gets the current stencil mask
  32809. * @returns a number defining the new stencil mask to use
  32810. */
  32811. getStencilMask(): number;
  32812. /**
  32813. * Sets the current stencil mask
  32814. * @param mask defines the new stencil mask to use
  32815. */
  32816. setStencilMask(mask: number): void;
  32817. /**
  32818. * Gets the current stencil function
  32819. * @returns a number defining the stencil function to use
  32820. */
  32821. getStencilFunction(): number;
  32822. /**
  32823. * Gets the current stencil reference value
  32824. * @returns a number defining the stencil reference value to use
  32825. */
  32826. getStencilFunctionReference(): number;
  32827. /**
  32828. * Gets the current stencil mask
  32829. * @returns a number defining the stencil mask to use
  32830. */
  32831. getStencilFunctionMask(): number;
  32832. /**
  32833. * Sets the current stencil function
  32834. * @param stencilFunc defines the new stencil function to use
  32835. */
  32836. setStencilFunction(stencilFunc: number): void;
  32837. /**
  32838. * Sets the current stencil reference
  32839. * @param reference defines the new stencil reference to use
  32840. */
  32841. setStencilFunctionReference(reference: number): void;
  32842. /**
  32843. * Sets the current stencil mask
  32844. * @param mask defines the new stencil mask to use
  32845. */
  32846. setStencilFunctionMask(mask: number): void;
  32847. /**
  32848. * Gets the current stencil operation when stencil fails
  32849. * @returns a number defining stencil operation to use when stencil fails
  32850. */
  32851. getStencilOperationFail(): number;
  32852. /**
  32853. * Gets the current stencil operation when depth fails
  32854. * @returns a number defining stencil operation to use when depth fails
  32855. */
  32856. getStencilOperationDepthFail(): number;
  32857. /**
  32858. * Gets the current stencil operation when stencil passes
  32859. * @returns a number defining stencil operation to use when stencil passes
  32860. */
  32861. getStencilOperationPass(): number;
  32862. /**
  32863. * Sets the stencil operation to use when stencil fails
  32864. * @param operation defines the stencil operation to use when stencil fails
  32865. */
  32866. setStencilOperationFail(operation: number): void;
  32867. /**
  32868. * Sets the stencil operation to use when depth fails
  32869. * @param operation defines the stencil operation to use when depth fails
  32870. */
  32871. setStencilOperationDepthFail(operation: number): void;
  32872. /**
  32873. * Sets the stencil operation to use when stencil passes
  32874. * @param operation defines the stencil operation to use when stencil passes
  32875. */
  32876. setStencilOperationPass(operation: number): void;
  32877. /**
  32878. * Sets a boolean indicating if the dithering state is enabled or disabled
  32879. * @param value defines the dithering state
  32880. */
  32881. setDitheringState(value: boolean): void;
  32882. /**
  32883. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  32884. * @param value defines the rasterizer state
  32885. */
  32886. setRasterizerState(value: boolean): void;
  32887. /**
  32888. * Gets the current depth function
  32889. * @returns a number defining the depth function
  32890. */
  32891. getDepthFunction(): Nullable<number>;
  32892. /**
  32893. * Sets the current depth function
  32894. * @param depthFunc defines the function to use
  32895. */
  32896. setDepthFunction(depthFunc: number): void;
  32897. /**
  32898. * Sets the current depth function to GREATER
  32899. */
  32900. setDepthFunctionToGreater(): void;
  32901. /**
  32902. * Sets the current depth function to GEQUAL
  32903. */
  32904. setDepthFunctionToGreaterOrEqual(): void;
  32905. /**
  32906. * Sets the current depth function to LESS
  32907. */
  32908. setDepthFunctionToLess(): void;
  32909. /**
  32910. * Sets the current depth function to LEQUAL
  32911. */
  32912. setDepthFunctionToLessOrEqual(): void;
  32913. private _cachedStencilBuffer;
  32914. private _cachedStencilFunction;
  32915. private _cachedStencilMask;
  32916. private _cachedStencilOperationPass;
  32917. private _cachedStencilOperationFail;
  32918. private _cachedStencilOperationDepthFail;
  32919. private _cachedStencilReference;
  32920. /**
  32921. * Caches the the state of the stencil buffer
  32922. */
  32923. cacheStencilState(): void;
  32924. /**
  32925. * Restores the state of the stencil buffer
  32926. */
  32927. restoreStencilState(): void;
  32928. /**
  32929. * Directly set the WebGL Viewport
  32930. * @param x defines the x coordinate of the viewport (in screen space)
  32931. * @param y defines the y coordinate of the viewport (in screen space)
  32932. * @param width defines the width of the viewport (in screen space)
  32933. * @param height defines the height of the viewport (in screen space)
  32934. * @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
  32935. */
  32936. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  32937. /**
  32938. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  32939. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  32940. * @param y defines the y-coordinate of the corner of the clear rectangle
  32941. * @param width defines the width of the clear rectangle
  32942. * @param height defines the height of the clear rectangle
  32943. * @param clearColor defines the clear color
  32944. */
  32945. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  32946. /**
  32947. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  32948. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  32949. * @param y defines the y-coordinate of the corner of the clear rectangle
  32950. * @param width defines the width of the clear rectangle
  32951. * @param height defines the height of the clear rectangle
  32952. */
  32953. enableScissor(x: number, y: number, width: number, height: number): void;
  32954. /**
  32955. * Disable previously set scissor test rectangle
  32956. */
  32957. disableScissor(): void;
  32958. protected _reportDrawCall(): void;
  32959. /**
  32960. * Initializes a webVR display and starts listening to display change events
  32961. * The onVRDisplayChangedObservable will be notified upon these changes
  32962. * @returns The onVRDisplayChangedObservable
  32963. */
  32964. initWebVR(): Observable<IDisplayChangedEventArgs>;
  32965. /** @hidden */
  32966. _prepareVRComponent(): void;
  32967. /** @hidden */
  32968. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  32969. /** @hidden */
  32970. _submitVRFrame(): void;
  32971. /**
  32972. * Call this function to leave webVR mode
  32973. * Will do nothing if webVR is not supported or if there is no webVR device
  32974. * @see http://doc.babylonjs.com/how_to/webvr_camera
  32975. */
  32976. disableVR(): void;
  32977. /**
  32978. * Gets a boolean indicating that the system is in VR mode and is presenting
  32979. * @returns true if VR mode is engaged
  32980. */
  32981. isVRPresenting(): boolean;
  32982. /** @hidden */
  32983. _requestVRFrame(): void;
  32984. /** @hidden */
  32985. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  32986. /**
  32987. * Gets the source code of the vertex shader associated with a specific webGL program
  32988. * @param program defines the program to use
  32989. * @returns a string containing the source code of the vertex shader associated with the program
  32990. */
  32991. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  32992. /**
  32993. * Gets the source code of the fragment shader associated with a specific webGL program
  32994. * @param program defines the program to use
  32995. * @returns a string containing the source code of the fragment shader associated with the program
  32996. */
  32997. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  32998. /**
  32999. * Reads pixels from the current frame buffer. Please note that this function can be slow
  33000. * @param x defines the x coordinate of the rectangle where pixels must be read
  33001. * @param y defines the y coordinate of the rectangle where pixels must be read
  33002. * @param width defines the width of the rectangle where pixels must be read
  33003. * @param height defines the height of the rectangle where pixels must be read
  33004. * @returns a Uint8Array containing RGBA colors
  33005. */
  33006. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  33007. /**
  33008. * Sets a depth stencil texture from a render target to the according uniform.
  33009. * @param channel The texture channel
  33010. * @param uniform The uniform to set
  33011. * @param texture The render target texture containing the depth stencil texture to apply
  33012. */
  33013. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  33014. /**
  33015. * Sets a texture to the webGL context from a postprocess
  33016. * @param channel defines the channel to use
  33017. * @param postProcess defines the source postprocess
  33018. */
  33019. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  33020. /**
  33021. * Binds the output of the passed in post process to the texture channel specified
  33022. * @param channel The channel the texture should be bound to
  33023. * @param postProcess The post process which's output should be bound
  33024. */
  33025. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  33026. /** @hidden */
  33027. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  33028. protected _rebuildBuffers(): void;
  33029. /** @hidden */
  33030. _renderFrame(): void;
  33031. _renderLoop(): void;
  33032. /** @hidden */
  33033. _renderViews(): boolean;
  33034. /**
  33035. * Toggle full screen mode
  33036. * @param requestPointerLock defines if a pointer lock should be requested from the user
  33037. */
  33038. switchFullscreen(requestPointerLock: boolean): void;
  33039. /**
  33040. * Enters full screen mode
  33041. * @param requestPointerLock defines if a pointer lock should be requested from the user
  33042. */
  33043. enterFullscreen(requestPointerLock: boolean): void;
  33044. /**
  33045. * Exits full screen mode
  33046. */
  33047. exitFullscreen(): void;
  33048. /**
  33049. * Enters Pointerlock mode
  33050. */
  33051. enterPointerlock(): void;
  33052. /**
  33053. * Exits Pointerlock mode
  33054. */
  33055. exitPointerlock(): void;
  33056. /**
  33057. * Begin a new frame
  33058. */
  33059. beginFrame(): void;
  33060. /**
  33061. * Enf the current frame
  33062. */
  33063. endFrame(): void;
  33064. resize(): void;
  33065. /**
  33066. * Set the compressed texture format to use, based on the formats you have, and the formats
  33067. * supported by the hardware / browser.
  33068. *
  33069. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  33070. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  33071. * to API arguments needed to compressed textures. This puts the burden on the container
  33072. * generator to house the arcane code for determining these for current & future formats.
  33073. *
  33074. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  33075. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  33076. *
  33077. * Note: The result of this call is not taken into account when a texture is base64.
  33078. *
  33079. * @param formatsAvailable defines the list of those format families you have created
  33080. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  33081. *
  33082. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  33083. * @returns The extension selected.
  33084. */
  33085. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  33086. /**
  33087. * Force a specific size of the canvas
  33088. * @param width defines the new canvas' width
  33089. * @param height defines the new canvas' height
  33090. */
  33091. setSize(width: number, height: number): void;
  33092. /**
  33093. * Updates a dynamic vertex buffer.
  33094. * @param vertexBuffer the vertex buffer to update
  33095. * @param data the data used to update the vertex buffer
  33096. * @param byteOffset the byte offset of the data
  33097. * @param byteLength the byte length of the data
  33098. */
  33099. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  33100. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  33101. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  33102. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  33103. _releaseTexture(texture: InternalTexture): void;
  33104. /**
  33105. * @hidden
  33106. * Rescales a texture
  33107. * @param source input texutre
  33108. * @param destination destination texture
  33109. * @param scene scene to use to render the resize
  33110. * @param internalFormat format to use when resizing
  33111. * @param onComplete callback to be called when resize has completed
  33112. */
  33113. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  33114. /**
  33115. * Gets the current framerate
  33116. * @returns a number representing the framerate
  33117. */
  33118. getFps(): number;
  33119. /**
  33120. * Gets the time spent between current and previous frame
  33121. * @returns a number representing the delta time in ms
  33122. */
  33123. getDeltaTime(): number;
  33124. private _measureFps;
  33125. /** @hidden */
  33126. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  33127. /**
  33128. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  33129. * @param renderTarget The render target to set the frame buffer for
  33130. */
  33131. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  33132. /**
  33133. * Update a dynamic index buffer
  33134. * @param indexBuffer defines the target index buffer
  33135. * @param indices defines the data to update
  33136. * @param offset defines the offset in the target index buffer where update should start
  33137. */
  33138. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  33139. /**
  33140. * Updates the sample count of a render target texture
  33141. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  33142. * @param texture defines the texture to update
  33143. * @param samples defines the sample count to set
  33144. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  33145. */
  33146. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  33147. /**
  33148. * Updates a depth texture Comparison Mode and Function.
  33149. * If the comparison Function is equal to 0, the mode will be set to none.
  33150. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  33151. * @param texture The texture to set the comparison function for
  33152. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  33153. */
  33154. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  33155. /**
  33156. * Creates a webGL buffer to use with instanciation
  33157. * @param capacity defines the size of the buffer
  33158. * @returns the webGL buffer
  33159. */
  33160. createInstancesBuffer(capacity: number): DataBuffer;
  33161. /**
  33162. * Delete a webGL buffer used with instanciation
  33163. * @param buffer defines the webGL buffer to delete
  33164. */
  33165. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  33166. /** @hidden */
  33167. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  33168. dispose(): void;
  33169. private _disableTouchAction;
  33170. /**
  33171. * Display the loading screen
  33172. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33173. */
  33174. displayLoadingUI(): void;
  33175. /**
  33176. * Hide the loading screen
  33177. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33178. */
  33179. hideLoadingUI(): void;
  33180. /**
  33181. * Gets the current loading screen object
  33182. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33183. */
  33184. /**
  33185. * Sets the current loading screen object
  33186. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33187. */
  33188. loadingScreen: ILoadingScreen;
  33189. /**
  33190. * Sets the current loading screen text
  33191. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33192. */
  33193. loadingUIText: string;
  33194. /**
  33195. * Sets the current loading screen background color
  33196. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33197. */
  33198. loadingUIBackgroundColor: string;
  33199. /** Pointerlock and fullscreen */
  33200. /**
  33201. * Ask the browser to promote the current element to pointerlock mode
  33202. * @param element defines the DOM element to promote
  33203. */
  33204. static _RequestPointerlock(element: HTMLElement): void;
  33205. /**
  33206. * Asks the browser to exit pointerlock mode
  33207. */
  33208. static _ExitPointerlock(): void;
  33209. /**
  33210. * Ask the browser to promote the current element to fullscreen rendering mode
  33211. * @param element defines the DOM element to promote
  33212. */
  33213. static _RequestFullscreen(element: HTMLElement): void;
  33214. /**
  33215. * Asks the browser to exit fullscreen mode
  33216. */
  33217. static _ExitFullscreen(): void;
  33218. }
  33219. }
  33220. declare module "babylonjs/Engines/engineStore" {
  33221. import { Nullable } from "babylonjs/types";
  33222. import { Engine } from "babylonjs/Engines/engine";
  33223. import { Scene } from "babylonjs/scene";
  33224. /**
  33225. * The engine store class is responsible to hold all the instances of Engine and Scene created
  33226. * during the life time of the application.
  33227. */
  33228. export class EngineStore {
  33229. /** Gets the list of created engines */
  33230. static Instances: import("babylonjs/Engines/engine").Engine[];
  33231. /** @hidden */
  33232. static _LastCreatedScene: Nullable<Scene>;
  33233. /**
  33234. * Gets the latest created engine
  33235. */
  33236. static readonly LastCreatedEngine: Nullable<Engine>;
  33237. /**
  33238. * Gets the latest created scene
  33239. */
  33240. static readonly LastCreatedScene: Nullable<Scene>;
  33241. /**
  33242. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  33243. * @ignorenaming
  33244. */
  33245. static UseFallbackTexture: boolean;
  33246. /**
  33247. * Texture content used if a texture cannot loaded
  33248. * @ignorenaming
  33249. */
  33250. static FallbackTexture: string;
  33251. }
  33252. }
  33253. declare module "babylonjs/Misc/promise" {
  33254. /**
  33255. * Helper class that provides a small promise polyfill
  33256. */
  33257. export class PromisePolyfill {
  33258. /**
  33259. * Static function used to check if the polyfill is required
  33260. * If this is the case then the function will inject the polyfill to window.Promise
  33261. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  33262. */
  33263. static Apply(force?: boolean): void;
  33264. }
  33265. }
  33266. declare module "babylonjs/Misc/interfaces/screenshotSize" {
  33267. /**
  33268. * Interface for screenshot methods with describe argument called `size` as object with options
  33269. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  33270. */
  33271. export interface IScreenshotSize {
  33272. /**
  33273. * number in pixels for canvas height
  33274. */
  33275. height?: number;
  33276. /**
  33277. * multiplier allowing render at a higher or lower resolution
  33278. * If value is defined then height and width will be ignored and taken from camera
  33279. */
  33280. precision?: number;
  33281. /**
  33282. * number in pixels for canvas width
  33283. */
  33284. width?: number;
  33285. }
  33286. }
  33287. declare module "babylonjs/Misc/tools" {
  33288. import { Nullable, float } from "babylonjs/types";
  33289. import { DomManagement } from "babylonjs/Misc/domManagement";
  33290. import { WebRequest } from "babylonjs/Misc/webRequest";
  33291. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  33292. import { ReadFileError } from "babylonjs/Misc/fileTools";
  33293. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  33294. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  33295. import { Camera } from "babylonjs/Cameras/camera";
  33296. import { Engine } from "babylonjs/Engines/engine";
  33297. interface IColor4Like {
  33298. r: float;
  33299. g: float;
  33300. b: float;
  33301. a: float;
  33302. }
  33303. /**
  33304. * Class containing a set of static utilities functions
  33305. */
  33306. export class Tools {
  33307. /**
  33308. * Gets or sets the base URL to use to load assets
  33309. */
  33310. static BaseUrl: string;
  33311. /**
  33312. * Enable/Disable Custom HTTP Request Headers globally.
  33313. * default = false
  33314. * @see CustomRequestHeaders
  33315. */
  33316. static UseCustomRequestHeaders: boolean;
  33317. /**
  33318. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  33319. * i.e. when loading files, where the server/service expects an Authorization header
  33320. */
  33321. static CustomRequestHeaders: {
  33322. [key: string]: string;
  33323. };
  33324. /**
  33325. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  33326. */
  33327. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  33328. /**
  33329. * Default behaviour for cors in the application.
  33330. * It can be a string if the expected behavior is identical in the entire app.
  33331. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  33332. */
  33333. static CorsBehavior: string | ((url: string | string[]) => string);
  33334. /**
  33335. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  33336. * @ignorenaming
  33337. */
  33338. static UseFallbackTexture: boolean;
  33339. /**
  33340. * Use this object to register external classes like custom textures or material
  33341. * to allow the laoders to instantiate them
  33342. */
  33343. static RegisteredExternalClasses: {
  33344. [key: string]: Object;
  33345. };
  33346. /**
  33347. * Texture content used if a texture cannot loaded
  33348. * @ignorenaming
  33349. */
  33350. static fallbackTexture: string;
  33351. /**
  33352. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  33353. * @param u defines the coordinate on X axis
  33354. * @param v defines the coordinate on Y axis
  33355. * @param width defines the width of the source data
  33356. * @param height defines the height of the source data
  33357. * @param pixels defines the source byte array
  33358. * @param color defines the output color
  33359. */
  33360. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  33361. /**
  33362. * Interpolates between a and b via alpha
  33363. * @param a The lower value (returned when alpha = 0)
  33364. * @param b The upper value (returned when alpha = 1)
  33365. * @param alpha The interpolation-factor
  33366. * @return The mixed value
  33367. */
  33368. static Mix(a: number, b: number, alpha: number): number;
  33369. /**
  33370. * Tries to instantiate a new object from a given class name
  33371. * @param className defines the class name to instantiate
  33372. * @returns the new object or null if the system was not able to do the instantiation
  33373. */
  33374. static Instantiate(className: string): any;
  33375. /**
  33376. * Provides a slice function that will work even on IE
  33377. * @param data defines the array to slice
  33378. * @param start defines the start of the data (optional)
  33379. * @param end defines the end of the data (optional)
  33380. * @returns the new sliced array
  33381. */
  33382. static Slice<T>(data: T, start?: number, end?: number): T;
  33383. /**
  33384. * Polyfill for setImmediate
  33385. * @param action defines the action to execute after the current execution block
  33386. */
  33387. static SetImmediate(action: () => void): void;
  33388. /**
  33389. * Function indicating if a number is an exponent of 2
  33390. * @param value defines the value to test
  33391. * @returns true if the value is an exponent of 2
  33392. */
  33393. static IsExponentOfTwo(value: number): boolean;
  33394. private static _tmpFloatArray;
  33395. /**
  33396. * Returns the nearest 32-bit single precision float representation of a Number
  33397. * @param value A Number. If the parameter is of a different type, it will get converted
  33398. * to a number or to NaN if it cannot be converted
  33399. * @returns number
  33400. */
  33401. static FloatRound(value: number): number;
  33402. /**
  33403. * Extracts the filename from a path
  33404. * @param path defines the path to use
  33405. * @returns the filename
  33406. */
  33407. static GetFilename(path: string): string;
  33408. /**
  33409. * Extracts the "folder" part of a path (everything before the filename).
  33410. * @param uri The URI to extract the info from
  33411. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  33412. * @returns The "folder" part of the path
  33413. */
  33414. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  33415. /**
  33416. * Extracts text content from a DOM element hierarchy
  33417. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  33418. */
  33419. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  33420. /**
  33421. * Convert an angle in radians to degrees
  33422. * @param angle defines the angle to convert
  33423. * @returns the angle in degrees
  33424. */
  33425. static ToDegrees(angle: number): number;
  33426. /**
  33427. * Convert an angle in degrees to radians
  33428. * @param angle defines the angle to convert
  33429. * @returns the angle in radians
  33430. */
  33431. static ToRadians(angle: number): number;
  33432. /**
  33433. * Returns an array if obj is not an array
  33434. * @param obj defines the object to evaluate as an array
  33435. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  33436. * @returns either obj directly if obj is an array or a new array containing obj
  33437. */
  33438. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  33439. /**
  33440. * Gets the pointer prefix to use
  33441. * @returns "pointer" if touch is enabled. Else returns "mouse"
  33442. */
  33443. static GetPointerPrefix(): string;
  33444. /**
  33445. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  33446. * @param url define the url we are trying
  33447. * @param element define the dom element where to configure the cors policy
  33448. */
  33449. static SetCorsBehavior(url: string | string[], element: {
  33450. crossOrigin: string | null;
  33451. }): void;
  33452. /**
  33453. * Removes unwanted characters from an url
  33454. * @param url defines the url to clean
  33455. * @returns the cleaned url
  33456. */
  33457. static CleanUrl(url: string): string;
  33458. /**
  33459. * Gets or sets a function used to pre-process url before using them to load assets
  33460. */
  33461. static PreprocessUrl: (url: string) => string;
  33462. /**
  33463. * Loads an image as an HTMLImageElement.
  33464. * @param input url string, ArrayBuffer, or Blob to load
  33465. * @param onLoad callback called when the image successfully loads
  33466. * @param onError callback called when the image fails to load
  33467. * @param offlineProvider offline provider for caching
  33468. * @param mimeType optional mime type
  33469. * @returns the HTMLImageElement of the loaded image
  33470. */
  33471. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  33472. /**
  33473. * Loads a file from a url
  33474. * @param url url string, ArrayBuffer, or Blob to load
  33475. * @param onSuccess callback called when the file successfully loads
  33476. * @param onProgress callback called while file is loading (if the server supports this mode)
  33477. * @param offlineProvider defines the offline provider for caching
  33478. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  33479. * @param onError callback called when the file fails to load
  33480. * @returns a file request object
  33481. */
  33482. 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;
  33483. /**
  33484. * Loads a file from a url
  33485. * @param url the file url to load
  33486. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  33487. */
  33488. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  33489. /**
  33490. * Load a script (identified by an url). When the url returns, the
  33491. * content of this file is added into a new script element, attached to the DOM (body element)
  33492. * @param scriptUrl defines the url of the script to laod
  33493. * @param onSuccess defines the callback called when the script is loaded
  33494. * @param onError defines the callback to call if an error occurs
  33495. * @param scriptId defines the id of the script element
  33496. */
  33497. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  33498. /**
  33499. * Load an asynchronous script (identified by an url). When the url returns, the
  33500. * content of this file is added into a new script element, attached to the DOM (body element)
  33501. * @param scriptUrl defines the url of the script to laod
  33502. * @param scriptId defines the id of the script element
  33503. * @returns a promise request object
  33504. */
  33505. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  33506. /**
  33507. * Loads a file from a blob
  33508. * @param fileToLoad defines the blob to use
  33509. * @param callback defines the callback to call when data is loaded
  33510. * @param progressCallback defines the callback to call during loading process
  33511. * @returns a file request object
  33512. */
  33513. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  33514. /**
  33515. * Reads a file from a File object
  33516. * @param file defines the file to load
  33517. * @param onSuccess defines the callback to call when data is loaded
  33518. * @param onProgress defines the callback to call during loading process
  33519. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  33520. * @param onError defines the callback to call when an error occurs
  33521. * @returns a file request object
  33522. */
  33523. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  33524. /**
  33525. * Creates a data url from a given string content
  33526. * @param content defines the content to convert
  33527. * @returns the new data url link
  33528. */
  33529. static FileAsURL(content: string): string;
  33530. /**
  33531. * Format the given number to a specific decimal format
  33532. * @param value defines the number to format
  33533. * @param decimals defines the number of decimals to use
  33534. * @returns the formatted string
  33535. */
  33536. static Format(value: number, decimals?: number): string;
  33537. /**
  33538. * Tries to copy an object by duplicating every property
  33539. * @param source defines the source object
  33540. * @param destination defines the target object
  33541. * @param doNotCopyList defines a list of properties to avoid
  33542. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  33543. */
  33544. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  33545. /**
  33546. * Gets a boolean indicating if the given object has no own property
  33547. * @param obj defines the object to test
  33548. * @returns true if object has no own property
  33549. */
  33550. static IsEmpty(obj: any): boolean;
  33551. /**
  33552. * Function used to register events at window level
  33553. * @param windowElement defines the Window object to use
  33554. * @param events defines the events to register
  33555. */
  33556. static RegisterTopRootEvents(windowElement: Window, events: {
  33557. name: string;
  33558. handler: Nullable<(e: FocusEvent) => any>;
  33559. }[]): void;
  33560. /**
  33561. * Function used to unregister events from window level
  33562. * @param windowElement defines the Window object to use
  33563. * @param events defines the events to unregister
  33564. */
  33565. static UnregisterTopRootEvents(windowElement: Window, events: {
  33566. name: string;
  33567. handler: Nullable<(e: FocusEvent) => any>;
  33568. }[]): void;
  33569. /**
  33570. * @ignore
  33571. */
  33572. static _ScreenshotCanvas: HTMLCanvasElement;
  33573. /**
  33574. * Dumps the current bound framebuffer
  33575. * @param width defines the rendering width
  33576. * @param height defines the rendering height
  33577. * @param engine defines the hosting engine
  33578. * @param successCallback defines the callback triggered once the data are available
  33579. * @param mimeType defines the mime type of the result
  33580. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  33581. */
  33582. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  33583. /**
  33584. * Converts the canvas data to blob.
  33585. * This acts as a polyfill for browsers not supporting the to blob function.
  33586. * @param canvas Defines the canvas to extract the data from
  33587. * @param successCallback Defines the callback triggered once the data are available
  33588. * @param mimeType Defines the mime type of the result
  33589. */
  33590. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  33591. /**
  33592. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  33593. * @param successCallback defines the callback triggered once the data are available
  33594. * @param mimeType defines the mime type of the result
  33595. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  33596. */
  33597. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  33598. /**
  33599. * Downloads a blob in the browser
  33600. * @param blob defines the blob to download
  33601. * @param fileName defines the name of the downloaded file
  33602. */
  33603. static Download(blob: Blob, fileName: string): void;
  33604. /**
  33605. * Captures a screenshot of the current rendering
  33606. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  33607. * @param engine defines the rendering engine
  33608. * @param camera defines the source camera
  33609. * @param size This parameter can be set to a single number or to an object with the
  33610. * following (optional) properties: precision, width, height. If a single number is passed,
  33611. * it will be used for both width and height. If an object is passed, the screenshot size
  33612. * will be derived from the parameters. The precision property is a multiplier allowing
  33613. * rendering at a higher or lower resolution
  33614. * @param successCallback defines the callback receives a single parameter which contains the
  33615. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  33616. * src parameter of an <img> to display it
  33617. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  33618. * Check your browser for supported MIME types
  33619. */
  33620. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  33621. /**
  33622. * Captures a screenshot of the current rendering
  33623. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  33624. * @param engine defines the rendering engine
  33625. * @param camera defines the source camera
  33626. * @param size This parameter can be set to a single number or to an object with the
  33627. * following (optional) properties: precision, width, height. If a single number is passed,
  33628. * it will be used for both width and height. If an object is passed, the screenshot size
  33629. * will be derived from the parameters. The precision property is a multiplier allowing
  33630. * rendering at a higher or lower resolution
  33631. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  33632. * Check your browser for supported MIME types
  33633. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  33634. * to the src parameter of an <img> to display it
  33635. */
  33636. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  33637. /**
  33638. * Generates an image screenshot from the specified camera.
  33639. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  33640. * @param engine The engine to use for rendering
  33641. * @param camera The camera to use for rendering
  33642. * @param size This parameter can be set to a single number or to an object with the
  33643. * following (optional) properties: precision, width, height. If a single number is passed,
  33644. * it will be used for both width and height. If an object is passed, the screenshot size
  33645. * will be derived from the parameters. The precision property is a multiplier allowing
  33646. * rendering at a higher or lower resolution
  33647. * @param successCallback The callback receives a single parameter which contains the
  33648. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  33649. * src parameter of an <img> to display it
  33650. * @param mimeType The MIME type of the screenshot image (default: image/png).
  33651. * Check your browser for supported MIME types
  33652. * @param samples Texture samples (default: 1)
  33653. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  33654. * @param fileName A name for for the downloaded file.
  33655. */
  33656. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  33657. /**
  33658. * Generates an image screenshot from the specified camera.
  33659. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  33660. * @param engine The engine to use for rendering
  33661. * @param camera The camera to use for rendering
  33662. * @param size This parameter can be set to a single number or to an object with the
  33663. * following (optional) properties: precision, width, height. If a single number is passed,
  33664. * it will be used for both width and height. If an object is passed, the screenshot size
  33665. * will be derived from the parameters. The precision property is a multiplier allowing
  33666. * rendering at a higher or lower resolution
  33667. * @param mimeType The MIME type of the screenshot image (default: image/png).
  33668. * Check your browser for supported MIME types
  33669. * @param samples Texture samples (default: 1)
  33670. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  33671. * @param fileName A name for for the downloaded file.
  33672. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  33673. * to the src parameter of an <img> to display it
  33674. */
  33675. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  33676. /**
  33677. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  33678. * Be aware Math.random() could cause collisions, but:
  33679. * "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"
  33680. * @returns a pseudo random id
  33681. */
  33682. static RandomId(): string;
  33683. /**
  33684. * Test if the given uri is a base64 string
  33685. * @param uri The uri to test
  33686. * @return True if the uri is a base64 string or false otherwise
  33687. */
  33688. static IsBase64(uri: string): boolean;
  33689. /**
  33690. * Decode the given base64 uri.
  33691. * @param uri The uri to decode
  33692. * @return The decoded base64 data.
  33693. */
  33694. static DecodeBase64(uri: string): ArrayBuffer;
  33695. /**
  33696. * Gets the absolute url.
  33697. * @param url the input url
  33698. * @return the absolute url
  33699. */
  33700. static GetAbsoluteUrl(url: string): string;
  33701. /**
  33702. * No log
  33703. */
  33704. static readonly NoneLogLevel: number;
  33705. /**
  33706. * Only message logs
  33707. */
  33708. static readonly MessageLogLevel: number;
  33709. /**
  33710. * Only warning logs
  33711. */
  33712. static readonly WarningLogLevel: number;
  33713. /**
  33714. * Only error logs
  33715. */
  33716. static readonly ErrorLogLevel: number;
  33717. /**
  33718. * All logs
  33719. */
  33720. static readonly AllLogLevel: number;
  33721. /**
  33722. * Gets a value indicating the number of loading errors
  33723. * @ignorenaming
  33724. */
  33725. static readonly errorsCount: number;
  33726. /**
  33727. * Callback called when a new log is added
  33728. */
  33729. static OnNewCacheEntry: (entry: string) => void;
  33730. /**
  33731. * Log a message to the console
  33732. * @param message defines the message to log
  33733. */
  33734. static Log(message: string): void;
  33735. /**
  33736. * Write a warning message to the console
  33737. * @param message defines the message to log
  33738. */
  33739. static Warn(message: string): void;
  33740. /**
  33741. * Write an error message to the console
  33742. * @param message defines the message to log
  33743. */
  33744. static Error(message: string): void;
  33745. /**
  33746. * Gets current log cache (list of logs)
  33747. */
  33748. static readonly LogCache: string;
  33749. /**
  33750. * Clears the log cache
  33751. */
  33752. static ClearLogCache(): void;
  33753. /**
  33754. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  33755. */
  33756. static LogLevels: number;
  33757. /**
  33758. * Checks if the window object exists
  33759. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  33760. */
  33761. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  33762. /**
  33763. * No performance log
  33764. */
  33765. static readonly PerformanceNoneLogLevel: number;
  33766. /**
  33767. * Use user marks to log performance
  33768. */
  33769. static readonly PerformanceUserMarkLogLevel: number;
  33770. /**
  33771. * Log performance to the console
  33772. */
  33773. static readonly PerformanceConsoleLogLevel: number;
  33774. private static _performance;
  33775. /**
  33776. * Sets the current performance log level
  33777. */
  33778. static PerformanceLogLevel: number;
  33779. private static _StartPerformanceCounterDisabled;
  33780. private static _EndPerformanceCounterDisabled;
  33781. private static _StartUserMark;
  33782. private static _EndUserMark;
  33783. private static _StartPerformanceConsole;
  33784. private static _EndPerformanceConsole;
  33785. /**
  33786. * Starts a performance counter
  33787. */
  33788. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  33789. /**
  33790. * Ends a specific performance coutner
  33791. */
  33792. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  33793. /**
  33794. * Gets either window.performance.now() if supported or Date.now() else
  33795. */
  33796. static readonly Now: number;
  33797. /**
  33798. * This method will return the name of the class used to create the instance of the given object.
  33799. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  33800. * @param object the object to get the class name from
  33801. * @param isType defines if the object is actually a type
  33802. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  33803. */
  33804. static GetClassName(object: any, isType?: boolean): string;
  33805. /**
  33806. * Gets the first element of an array satisfying a given predicate
  33807. * @param array defines the array to browse
  33808. * @param predicate defines the predicate to use
  33809. * @returns null if not found or the element
  33810. */
  33811. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  33812. /**
  33813. * This method will return the name of the full name of the class, including its owning module (if any).
  33814. * 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).
  33815. * @param object the object to get the class name from
  33816. * @param isType defines if the object is actually a type
  33817. * @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.
  33818. * @ignorenaming
  33819. */
  33820. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  33821. /**
  33822. * Returns a promise that resolves after the given amount of time.
  33823. * @param delay Number of milliseconds to delay
  33824. * @returns Promise that resolves after the given amount of time
  33825. */
  33826. static DelayAsync(delay: number): Promise<void>;
  33827. }
  33828. /**
  33829. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  33830. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  33831. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  33832. * @param name The name of the class, case should be preserved
  33833. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  33834. */
  33835. export function className(name: string, module?: string): (target: Object) => void;
  33836. /**
  33837. * An implementation of a loop for asynchronous functions.
  33838. */
  33839. export class AsyncLoop {
  33840. /**
  33841. * Defines the number of iterations for the loop
  33842. */
  33843. iterations: number;
  33844. /**
  33845. * Defines the current index of the loop.
  33846. */
  33847. index: number;
  33848. private _done;
  33849. private _fn;
  33850. private _successCallback;
  33851. /**
  33852. * Constructor.
  33853. * @param iterations the number of iterations.
  33854. * @param func the function to run each iteration
  33855. * @param successCallback the callback that will be called upon succesful execution
  33856. * @param offset starting offset.
  33857. */
  33858. constructor(
  33859. /**
  33860. * Defines the number of iterations for the loop
  33861. */
  33862. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  33863. /**
  33864. * Execute the next iteration. Must be called after the last iteration was finished.
  33865. */
  33866. executeNext(): void;
  33867. /**
  33868. * Break the loop and run the success callback.
  33869. */
  33870. breakLoop(): void;
  33871. /**
  33872. * Create and run an async loop.
  33873. * @param iterations the number of iterations.
  33874. * @param fn the function to run each iteration
  33875. * @param successCallback the callback that will be called upon succesful execution
  33876. * @param offset starting offset.
  33877. * @returns the created async loop object
  33878. */
  33879. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  33880. /**
  33881. * A for-loop that will run a given number of iterations synchronous and the rest async.
  33882. * @param iterations total number of iterations
  33883. * @param syncedIterations number of synchronous iterations in each async iteration.
  33884. * @param fn the function to call each iteration.
  33885. * @param callback a success call back that will be called when iterating stops.
  33886. * @param breakFunction a break condition (optional)
  33887. * @param timeout timeout settings for the setTimeout function. default - 0.
  33888. * @returns the created async loop object
  33889. */
  33890. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  33891. }
  33892. }
  33893. declare module "babylonjs/Misc/stringDictionary" {
  33894. import { Nullable } from "babylonjs/types";
  33895. /**
  33896. * This class implement a typical dictionary using a string as key and the generic type T as value.
  33897. * The underlying implementation relies on an associative array to ensure the best performances.
  33898. * The value can be anything including 'null' but except 'undefined'
  33899. */
  33900. export class StringDictionary<T> {
  33901. /**
  33902. * This will clear this dictionary and copy the content from the 'source' one.
  33903. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  33904. * @param source the dictionary to take the content from and copy to this dictionary
  33905. */
  33906. copyFrom(source: StringDictionary<T>): void;
  33907. /**
  33908. * Get a value based from its key
  33909. * @param key the given key to get the matching value from
  33910. * @return the value if found, otherwise undefined is returned
  33911. */
  33912. get(key: string): T | undefined;
  33913. /**
  33914. * Get a value from its key or add it if it doesn't exist.
  33915. * This method will ensure you that a given key/data will be present in the dictionary.
  33916. * @param key the given key to get the matching value from
  33917. * @param factory the factory that will create the value if the key is not present in the dictionary.
  33918. * The factory will only be invoked if there's no data for the given key.
  33919. * @return the value corresponding to the key.
  33920. */
  33921. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  33922. /**
  33923. * Get a value from its key if present in the dictionary otherwise add it
  33924. * @param key the key to get the value from
  33925. * @param val if there's no such key/value pair in the dictionary add it with this value
  33926. * @return the value corresponding to the key
  33927. */
  33928. getOrAdd(key: string, val: T): T;
  33929. /**
  33930. * Check if there's a given key in the dictionary
  33931. * @param key the key to check for
  33932. * @return true if the key is present, false otherwise
  33933. */
  33934. contains(key: string): boolean;
  33935. /**
  33936. * Add a new key and its corresponding value
  33937. * @param key the key to add
  33938. * @param value the value corresponding to the key
  33939. * @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
  33940. */
  33941. add(key: string, value: T): boolean;
  33942. /**
  33943. * Update a specific value associated to a key
  33944. * @param key defines the key to use
  33945. * @param value defines the value to store
  33946. * @returns true if the value was updated (or false if the key was not found)
  33947. */
  33948. set(key: string, value: T): boolean;
  33949. /**
  33950. * Get the element of the given key and remove it from the dictionary
  33951. * @param key defines the key to search
  33952. * @returns the value associated with the key or null if not found
  33953. */
  33954. getAndRemove(key: string): Nullable<T>;
  33955. /**
  33956. * Remove a key/value from the dictionary.
  33957. * @param key the key to remove
  33958. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  33959. */
  33960. remove(key: string): boolean;
  33961. /**
  33962. * Clear the whole content of the dictionary
  33963. */
  33964. clear(): void;
  33965. /**
  33966. * Gets the current count
  33967. */
  33968. readonly count: number;
  33969. /**
  33970. * Execute a callback on each key/val of the dictionary.
  33971. * Note that you can remove any element in this dictionary in the callback implementation
  33972. * @param callback the callback to execute on a given key/value pair
  33973. */
  33974. forEach(callback: (key: string, val: T) => void): void;
  33975. /**
  33976. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  33977. * If the callback returns null or undefined the method will iterate to the next key/value pair
  33978. * Note that you can remove any element in this dictionary in the callback implementation
  33979. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  33980. * @returns the first item
  33981. */
  33982. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  33983. private _count;
  33984. private _data;
  33985. }
  33986. }
  33987. declare module "babylonjs/Collisions/collisionCoordinator" {
  33988. import { Nullable } from "babylonjs/types";
  33989. import { Scene } from "babylonjs/scene";
  33990. import { Vector3 } from "babylonjs/Maths/math.vector";
  33991. import { Collider } from "babylonjs/Collisions/collider";
  33992. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33993. /** @hidden */
  33994. export interface ICollisionCoordinator {
  33995. createCollider(): Collider;
  33996. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  33997. init(scene: Scene): void;
  33998. }
  33999. /** @hidden */
  34000. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  34001. private _scene;
  34002. private _scaledPosition;
  34003. private _scaledVelocity;
  34004. private _finalPosition;
  34005. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  34006. createCollider(): Collider;
  34007. init(scene: Scene): void;
  34008. private _collideWithWorld;
  34009. }
  34010. }
  34011. declare module "babylonjs/Inputs/scene.inputManager" {
  34012. import { Nullable } from "babylonjs/types";
  34013. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  34014. import { Vector2 } from "babylonjs/Maths/math.vector";
  34015. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  34016. import { Scene } from "babylonjs/scene";
  34017. /**
  34018. * Class used to manage all inputs for the scene.
  34019. */
  34020. export class InputManager {
  34021. /** The distance in pixel that you have to move to prevent some events */
  34022. static DragMovementThreshold: number;
  34023. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  34024. static LongPressDelay: number;
  34025. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  34026. static DoubleClickDelay: number;
  34027. /** If you need to check double click without raising a single click at first click, enable this flag */
  34028. static ExclusiveDoubleClickMode: boolean;
  34029. private _wheelEventName;
  34030. private _onPointerMove;
  34031. private _onPointerDown;
  34032. private _onPointerUp;
  34033. private _initClickEvent;
  34034. private _initActionManager;
  34035. private _delayedSimpleClick;
  34036. private _delayedSimpleClickTimeout;
  34037. private _previousDelayedSimpleClickTimeout;
  34038. private _meshPickProceed;
  34039. private _previousButtonPressed;
  34040. private _currentPickResult;
  34041. private _previousPickResult;
  34042. private _totalPointersPressed;
  34043. private _doubleClickOccured;
  34044. private _pointerOverMesh;
  34045. private _pickedDownMesh;
  34046. private _pickedUpMesh;
  34047. private _pointerX;
  34048. private _pointerY;
  34049. private _unTranslatedPointerX;
  34050. private _unTranslatedPointerY;
  34051. private _startingPointerPosition;
  34052. private _previousStartingPointerPosition;
  34053. private _startingPointerTime;
  34054. private _previousStartingPointerTime;
  34055. private _pointerCaptures;
  34056. private _onKeyDown;
  34057. private _onKeyUp;
  34058. private _onCanvasFocusObserver;
  34059. private _onCanvasBlurObserver;
  34060. private _scene;
  34061. /**
  34062. * Creates a new InputManager
  34063. * @param scene defines the hosting scene
  34064. */
  34065. constructor(scene: Scene);
  34066. /**
  34067. * Gets the mesh that is currently under the pointer
  34068. */
  34069. readonly meshUnderPointer: Nullable<AbstractMesh>;
  34070. /**
  34071. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  34072. */
  34073. readonly unTranslatedPointer: Vector2;
  34074. /**
  34075. * Gets or sets the current on-screen X position of the pointer
  34076. */
  34077. pointerX: number;
  34078. /**
  34079. * Gets or sets the current on-screen Y position of the pointer
  34080. */
  34081. pointerY: number;
  34082. private _updatePointerPosition;
  34083. private _processPointerMove;
  34084. private _setRayOnPointerInfo;
  34085. private _checkPrePointerObservable;
  34086. /**
  34087. * Use this method to simulate a pointer move on a mesh
  34088. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34089. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34090. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34091. */
  34092. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  34093. /**
  34094. * Use this method to simulate a pointer down on a mesh
  34095. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34096. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34097. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34098. */
  34099. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  34100. private _processPointerDown;
  34101. /** @hidden */
  34102. _isPointerSwiping(): boolean;
  34103. /**
  34104. * Use this method to simulate a pointer up on a mesh
  34105. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34106. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34107. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34108. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  34109. */
  34110. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  34111. private _processPointerUp;
  34112. /**
  34113. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  34114. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  34115. * @returns true if the pointer was captured
  34116. */
  34117. isPointerCaptured(pointerId?: number): boolean;
  34118. /**
  34119. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  34120. * @param attachUp defines if you want to attach events to pointerup
  34121. * @param attachDown defines if you want to attach events to pointerdown
  34122. * @param attachMove defines if you want to attach events to pointermove
  34123. */
  34124. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  34125. /**
  34126. * Detaches all event handlers
  34127. */
  34128. detachControl(): void;
  34129. /**
  34130. * Force the value of meshUnderPointer
  34131. * @param mesh defines the mesh to use
  34132. */
  34133. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  34134. /**
  34135. * Gets the mesh under the pointer
  34136. * @returns a Mesh or null if no mesh is under the pointer
  34137. */
  34138. getPointerOverMesh(): Nullable<AbstractMesh>;
  34139. }
  34140. }
  34141. declare module "babylonjs/Misc/uniqueIdGenerator" {
  34142. /**
  34143. * Helper class used to generate session unique ID
  34144. */
  34145. export class UniqueIdGenerator {
  34146. private static _UniqueIdCounter;
  34147. /**
  34148. * Gets an unique (relatively to the current scene) Id
  34149. */
  34150. static readonly UniqueId: number;
  34151. }
  34152. }
  34153. declare module "babylonjs/Animations/animationGroup" {
  34154. import { Animatable } from "babylonjs/Animations/animatable";
  34155. import { Animation } from "babylonjs/Animations/animation";
  34156. import { Scene, IDisposable } from "babylonjs/scene";
  34157. import { Observable } from "babylonjs/Misc/observable";
  34158. import { Nullable } from "babylonjs/types";
  34159. import "babylonjs/Animations/animatable";
  34160. /**
  34161. * This class defines the direct association between an animation and a target
  34162. */
  34163. export class TargetedAnimation {
  34164. /**
  34165. * Animation to perform
  34166. */
  34167. animation: Animation;
  34168. /**
  34169. * Target to animate
  34170. */
  34171. target: any;
  34172. /**
  34173. * Serialize the object
  34174. * @returns the JSON object representing the current entity
  34175. */
  34176. serialize(): any;
  34177. }
  34178. /**
  34179. * Use this class to create coordinated animations on multiple targets
  34180. */
  34181. export class AnimationGroup implements IDisposable {
  34182. /** The name of the animation group */
  34183. name: string;
  34184. private _scene;
  34185. private _targetedAnimations;
  34186. private _animatables;
  34187. private _from;
  34188. private _to;
  34189. private _isStarted;
  34190. private _isPaused;
  34191. private _speedRatio;
  34192. private _loopAnimation;
  34193. /**
  34194. * Gets or sets the unique id of the node
  34195. */
  34196. uniqueId: number;
  34197. /**
  34198. * This observable will notify when one animation have ended
  34199. */
  34200. onAnimationEndObservable: Observable<TargetedAnimation>;
  34201. /**
  34202. * Observer raised when one animation loops
  34203. */
  34204. onAnimationLoopObservable: Observable<TargetedAnimation>;
  34205. /**
  34206. * Observer raised when all animations have looped
  34207. */
  34208. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  34209. /**
  34210. * This observable will notify when all animations have ended.
  34211. */
  34212. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  34213. /**
  34214. * This observable will notify when all animations have paused.
  34215. */
  34216. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  34217. /**
  34218. * This observable will notify when all animations are playing.
  34219. */
  34220. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  34221. /**
  34222. * Gets the first frame
  34223. */
  34224. readonly from: number;
  34225. /**
  34226. * Gets the last frame
  34227. */
  34228. readonly to: number;
  34229. /**
  34230. * Define if the animations are started
  34231. */
  34232. readonly isStarted: boolean;
  34233. /**
  34234. * Gets a value indicating that the current group is playing
  34235. */
  34236. readonly isPlaying: boolean;
  34237. /**
  34238. * Gets or sets the speed ratio to use for all animations
  34239. */
  34240. /**
  34241. * Gets or sets the speed ratio to use for all animations
  34242. */
  34243. speedRatio: number;
  34244. /**
  34245. * Gets or sets if all animations should loop or not
  34246. */
  34247. loopAnimation: boolean;
  34248. /**
  34249. * Gets the targeted animations for this animation group
  34250. */
  34251. readonly targetedAnimations: Array<TargetedAnimation>;
  34252. /**
  34253. * returning the list of animatables controlled by this animation group.
  34254. */
  34255. readonly animatables: Array<Animatable>;
  34256. /**
  34257. * Instantiates a new Animation Group.
  34258. * This helps managing several animations at once.
  34259. * @see http://doc.babylonjs.com/how_to/group
  34260. * @param name Defines the name of the group
  34261. * @param scene Defines the scene the group belongs to
  34262. */
  34263. constructor(
  34264. /** The name of the animation group */
  34265. name: string, scene?: Nullable<Scene>);
  34266. /**
  34267. * Add an animation (with its target) in the group
  34268. * @param animation defines the animation we want to add
  34269. * @param target defines the target of the animation
  34270. * @returns the TargetedAnimation object
  34271. */
  34272. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  34273. /**
  34274. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  34275. * It can add constant keys at begin or end
  34276. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  34277. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  34278. * @returns the animation group
  34279. */
  34280. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  34281. private _animationLoopCount;
  34282. private _animationLoopFlags;
  34283. private _processLoop;
  34284. /**
  34285. * Start all animations on given targets
  34286. * @param loop defines if animations must loop
  34287. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  34288. * @param from defines the from key (optional)
  34289. * @param to defines the to key (optional)
  34290. * @returns the current animation group
  34291. */
  34292. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  34293. /**
  34294. * Pause all animations
  34295. * @returns the animation group
  34296. */
  34297. pause(): AnimationGroup;
  34298. /**
  34299. * Play all animations to initial state
  34300. * This function will start() the animations if they were not started or will restart() them if they were paused
  34301. * @param loop defines if animations must loop
  34302. * @returns the animation group
  34303. */
  34304. play(loop?: boolean): AnimationGroup;
  34305. /**
  34306. * Reset all animations to initial state
  34307. * @returns the animation group
  34308. */
  34309. reset(): AnimationGroup;
  34310. /**
  34311. * Restart animations from key 0
  34312. * @returns the animation group
  34313. */
  34314. restart(): AnimationGroup;
  34315. /**
  34316. * Stop all animations
  34317. * @returns the animation group
  34318. */
  34319. stop(): AnimationGroup;
  34320. /**
  34321. * Set animation weight for all animatables
  34322. * @param weight defines the weight to use
  34323. * @return the animationGroup
  34324. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  34325. */
  34326. setWeightForAllAnimatables(weight: number): AnimationGroup;
  34327. /**
  34328. * Synchronize and normalize all animatables with a source animatable
  34329. * @param root defines the root animatable to synchronize with
  34330. * @return the animationGroup
  34331. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  34332. */
  34333. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  34334. /**
  34335. * Goes to a specific frame in this animation group
  34336. * @param frame the frame number to go to
  34337. * @return the animationGroup
  34338. */
  34339. goToFrame(frame: number): AnimationGroup;
  34340. /**
  34341. * Dispose all associated resources
  34342. */
  34343. dispose(): void;
  34344. private _checkAnimationGroupEnded;
  34345. /**
  34346. * Clone the current animation group and returns a copy
  34347. * @param newName defines the name of the new group
  34348. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  34349. * @returns the new aniamtion group
  34350. */
  34351. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  34352. /**
  34353. * Serializes the animationGroup to an object
  34354. * @returns Serialized object
  34355. */
  34356. serialize(): any;
  34357. /**
  34358. * Returns a new AnimationGroup object parsed from the source provided.
  34359. * @param parsedAnimationGroup defines the source
  34360. * @param scene defines the scene that will receive the animationGroup
  34361. * @returns a new AnimationGroup
  34362. */
  34363. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  34364. /**
  34365. * Returns the string "AnimationGroup"
  34366. * @returns "AnimationGroup"
  34367. */
  34368. getClassName(): string;
  34369. /**
  34370. * Creates a detailled string about the object
  34371. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  34372. * @returns a string representing the object
  34373. */
  34374. toString(fullDetails?: boolean): string;
  34375. }
  34376. }
  34377. declare module "babylonjs/scene" {
  34378. import { Nullable } from "babylonjs/types";
  34379. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  34380. import { Observable } from "babylonjs/Misc/observable";
  34381. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  34382. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  34383. import { Geometry } from "babylonjs/Meshes/geometry";
  34384. import { TransformNode } from "babylonjs/Meshes/transformNode";
  34385. import { SubMesh } from "babylonjs/Meshes/subMesh";
  34386. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  34387. import { Mesh } from "babylonjs/Meshes/mesh";
  34388. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  34389. import { Bone } from "babylonjs/Bones/bone";
  34390. import { Skeleton } from "babylonjs/Bones/skeleton";
  34391. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  34392. import { Camera } from "babylonjs/Cameras/camera";
  34393. import { AbstractScene } from "babylonjs/abstractScene";
  34394. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  34395. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  34396. import { Material } from "babylonjs/Materials/material";
  34397. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  34398. import { Effect } from "babylonjs/Materials/effect";
  34399. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  34400. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  34401. import { Light } from "babylonjs/Lights/light";
  34402. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  34403. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  34404. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  34405. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  34406. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  34407. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  34408. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  34409. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  34410. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  34411. import { Engine } from "babylonjs/Engines/engine";
  34412. import { Node } from "babylonjs/node";
  34413. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  34414. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  34415. import { WebRequest } from "babylonjs/Misc/webRequest";
  34416. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  34417. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  34418. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  34419. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  34420. import { Plane } from "babylonjs/Maths/math.plane";
  34421. import { LoadFileError, RequestFileError, ReadFileError } from "babylonjs/Misc/fileTools";
  34422. import { Ray } from "babylonjs/Culling/ray";
  34423. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  34424. import { Animation } from "babylonjs/Animations/animation";
  34425. import { Animatable } from "babylonjs/Animations/animatable";
  34426. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  34427. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  34428. import { Collider } from "babylonjs/Collisions/collider";
  34429. /**
  34430. * Define an interface for all classes that will hold resources
  34431. */
  34432. export interface IDisposable {
  34433. /**
  34434. * Releases all held resources
  34435. */
  34436. dispose(): void;
  34437. }
  34438. /** Interface defining initialization parameters for Scene class */
  34439. export interface SceneOptions {
  34440. /**
  34441. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  34442. * It will improve performance when the number of geometries becomes important.
  34443. */
  34444. useGeometryUniqueIdsMap?: boolean;
  34445. /**
  34446. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  34447. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  34448. */
  34449. useMaterialMeshMap?: boolean;
  34450. /**
  34451. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  34452. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  34453. */
  34454. useClonedMeshhMap?: boolean;
  34455. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  34456. virtual?: boolean;
  34457. }
  34458. /**
  34459. * Represents a scene to be rendered by the engine.
  34460. * @see http://doc.babylonjs.com/features/scene
  34461. */
  34462. export class Scene extends AbstractScene implements IAnimatable {
  34463. /** The fog is deactivated */
  34464. static readonly FOGMODE_NONE: number;
  34465. /** The fog density is following an exponential function */
  34466. static readonly FOGMODE_EXP: number;
  34467. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  34468. static readonly FOGMODE_EXP2: number;
  34469. /** The fog density is following a linear function. */
  34470. static readonly FOGMODE_LINEAR: number;
  34471. /**
  34472. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  34473. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34474. */
  34475. static MinDeltaTime: number;
  34476. /**
  34477. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  34478. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34479. */
  34480. static MaxDeltaTime: number;
  34481. /**
  34482. * Factory used to create the default material.
  34483. * @param name The name of the material to create
  34484. * @param scene The scene to create the material for
  34485. * @returns The default material
  34486. */
  34487. static DefaultMaterialFactory(scene: Scene): Material;
  34488. /**
  34489. * Factory used to create the a collision coordinator.
  34490. * @returns The collision coordinator
  34491. */
  34492. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  34493. /** @hidden */
  34494. _inputManager: InputManager;
  34495. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  34496. cameraToUseForPointers: Nullable<Camera>;
  34497. /** @hidden */
  34498. readonly _isScene: boolean;
  34499. /**
  34500. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  34501. */
  34502. autoClear: boolean;
  34503. /**
  34504. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  34505. */
  34506. autoClearDepthAndStencil: boolean;
  34507. /**
  34508. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  34509. */
  34510. clearColor: Color4;
  34511. /**
  34512. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  34513. */
  34514. ambientColor: Color3;
  34515. /**
  34516. * This is use to store the default BRDF lookup for PBR materials in your scene.
  34517. * It should only be one of the following (if not the default embedded one):
  34518. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  34519. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  34520. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  34521. * The material properties need to be setup according to the type of texture in use.
  34522. */
  34523. environmentBRDFTexture: BaseTexture;
  34524. /** @hidden */
  34525. protected _environmentTexture: Nullable<BaseTexture>;
  34526. /**
  34527. * Texture used in all pbr material as the reflection texture.
  34528. * As in the majority of the scene they are the same (exception for multi room and so on),
  34529. * this is easier to reference from here than from all the materials.
  34530. */
  34531. /**
  34532. * Texture used in all pbr material as the reflection texture.
  34533. * As in the majority of the scene they are the same (exception for multi room and so on),
  34534. * this is easier to set here than in all the materials.
  34535. */
  34536. environmentTexture: Nullable<BaseTexture>;
  34537. /** @hidden */
  34538. protected _environmentIntensity: number;
  34539. /**
  34540. * Intensity of the environment in all pbr material.
  34541. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  34542. * As in the majority of the scene they are the same (exception for multi room and so on),
  34543. * this is easier to reference from here than from all the materials.
  34544. */
  34545. /**
  34546. * Intensity of the environment in all pbr material.
  34547. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  34548. * As in the majority of the scene they are the same (exception for multi room and so on),
  34549. * this is easier to set here than in all the materials.
  34550. */
  34551. environmentIntensity: number;
  34552. /** @hidden */
  34553. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  34554. /**
  34555. * Default image processing configuration used either in the rendering
  34556. * Forward main pass or through the imageProcessingPostProcess if present.
  34557. * As in the majority of the scene they are the same (exception for multi camera),
  34558. * this is easier to reference from here than from all the materials and post process.
  34559. *
  34560. * No setter as we it is a shared configuration, you can set the values instead.
  34561. */
  34562. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  34563. private _forceWireframe;
  34564. /**
  34565. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  34566. */
  34567. forceWireframe: boolean;
  34568. private _forcePointsCloud;
  34569. /**
  34570. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  34571. */
  34572. forcePointsCloud: boolean;
  34573. /**
  34574. * Gets or sets the active clipplane 1
  34575. */
  34576. clipPlane: Nullable<Plane>;
  34577. /**
  34578. * Gets or sets the active clipplane 2
  34579. */
  34580. clipPlane2: Nullable<Plane>;
  34581. /**
  34582. * Gets or sets the active clipplane 3
  34583. */
  34584. clipPlane3: Nullable<Plane>;
  34585. /**
  34586. * Gets or sets the active clipplane 4
  34587. */
  34588. clipPlane4: Nullable<Plane>;
  34589. /**
  34590. * Gets or sets a boolean indicating if animations are enabled
  34591. */
  34592. animationsEnabled: boolean;
  34593. private _animationPropertiesOverride;
  34594. /**
  34595. * Gets or sets the animation properties override
  34596. */
  34597. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  34598. /**
  34599. * Gets or sets a boolean indicating if a constant deltatime has to be used
  34600. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  34601. */
  34602. useConstantAnimationDeltaTime: boolean;
  34603. /**
  34604. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  34605. * Please note that it requires to run a ray cast through the scene on every frame
  34606. */
  34607. constantlyUpdateMeshUnderPointer: boolean;
  34608. /**
  34609. * Defines the HTML cursor to use when hovering over interactive elements
  34610. */
  34611. hoverCursor: string;
  34612. /**
  34613. * Defines the HTML default cursor to use (empty by default)
  34614. */
  34615. defaultCursor: string;
  34616. /**
  34617. * Defines wether cursors are handled by the scene.
  34618. */
  34619. doNotHandleCursors: boolean;
  34620. /**
  34621. * This is used to call preventDefault() on pointer down
  34622. * in order to block unwanted artifacts like system double clicks
  34623. */
  34624. preventDefaultOnPointerDown: boolean;
  34625. /**
  34626. * This is used to call preventDefault() on pointer up
  34627. * in order to block unwanted artifacts like system double clicks
  34628. */
  34629. preventDefaultOnPointerUp: boolean;
  34630. /**
  34631. * Gets or sets user defined metadata
  34632. */
  34633. metadata: any;
  34634. /**
  34635. * For internal use only. Please do not use.
  34636. */
  34637. reservedDataStore: any;
  34638. /**
  34639. * Gets the name of the plugin used to load this scene (null by default)
  34640. */
  34641. loadingPluginName: string;
  34642. /**
  34643. * Use this array to add regular expressions used to disable offline support for specific urls
  34644. */
  34645. disableOfflineSupportExceptionRules: RegExp[];
  34646. /**
  34647. * An event triggered when the scene is disposed.
  34648. */
  34649. onDisposeObservable: Observable<Scene>;
  34650. private _onDisposeObserver;
  34651. /** Sets a function to be executed when this scene is disposed. */
  34652. onDispose: () => void;
  34653. /**
  34654. * An event triggered before rendering the scene (right after animations and physics)
  34655. */
  34656. onBeforeRenderObservable: Observable<Scene>;
  34657. private _onBeforeRenderObserver;
  34658. /** Sets a function to be executed before rendering this scene */
  34659. beforeRender: Nullable<() => void>;
  34660. /**
  34661. * An event triggered after rendering the scene
  34662. */
  34663. onAfterRenderObservable: Observable<Scene>;
  34664. /**
  34665. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  34666. */
  34667. onAfterRenderCameraObservable: Observable<Camera>;
  34668. private _onAfterRenderObserver;
  34669. /** Sets a function to be executed after rendering this scene */
  34670. afterRender: Nullable<() => void>;
  34671. /**
  34672. * An event triggered before animating the scene
  34673. */
  34674. onBeforeAnimationsObservable: Observable<Scene>;
  34675. /**
  34676. * An event triggered after animations processing
  34677. */
  34678. onAfterAnimationsObservable: Observable<Scene>;
  34679. /**
  34680. * An event triggered before draw calls are ready to be sent
  34681. */
  34682. onBeforeDrawPhaseObservable: Observable<Scene>;
  34683. /**
  34684. * An event triggered after draw calls have been sent
  34685. */
  34686. onAfterDrawPhaseObservable: Observable<Scene>;
  34687. /**
  34688. * An event triggered when the scene is ready
  34689. */
  34690. onReadyObservable: Observable<Scene>;
  34691. /**
  34692. * An event triggered before rendering a camera
  34693. */
  34694. onBeforeCameraRenderObservable: Observable<Camera>;
  34695. private _onBeforeCameraRenderObserver;
  34696. /** Sets a function to be executed before rendering a camera*/
  34697. beforeCameraRender: () => void;
  34698. /**
  34699. * An event triggered after rendering a camera
  34700. */
  34701. onAfterCameraRenderObservable: Observable<Camera>;
  34702. private _onAfterCameraRenderObserver;
  34703. /** Sets a function to be executed after rendering a camera*/
  34704. afterCameraRender: () => void;
  34705. /**
  34706. * An event triggered when active meshes evaluation is about to start
  34707. */
  34708. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  34709. /**
  34710. * An event triggered when active meshes evaluation is done
  34711. */
  34712. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  34713. /**
  34714. * An event triggered when particles rendering is about to start
  34715. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  34716. */
  34717. onBeforeParticlesRenderingObservable: Observable<Scene>;
  34718. /**
  34719. * An event triggered when particles rendering is done
  34720. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  34721. */
  34722. onAfterParticlesRenderingObservable: Observable<Scene>;
  34723. /**
  34724. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  34725. */
  34726. onDataLoadedObservable: Observable<Scene>;
  34727. /**
  34728. * An event triggered when a camera is created
  34729. */
  34730. onNewCameraAddedObservable: Observable<Camera>;
  34731. /**
  34732. * An event triggered when a camera is removed
  34733. */
  34734. onCameraRemovedObservable: Observable<Camera>;
  34735. /**
  34736. * An event triggered when a light is created
  34737. */
  34738. onNewLightAddedObservable: Observable<Light>;
  34739. /**
  34740. * An event triggered when a light is removed
  34741. */
  34742. onLightRemovedObservable: Observable<Light>;
  34743. /**
  34744. * An event triggered when a geometry is created
  34745. */
  34746. onNewGeometryAddedObservable: Observable<Geometry>;
  34747. /**
  34748. * An event triggered when a geometry is removed
  34749. */
  34750. onGeometryRemovedObservable: Observable<Geometry>;
  34751. /**
  34752. * An event triggered when a transform node is created
  34753. */
  34754. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  34755. /**
  34756. * An event triggered when a transform node is removed
  34757. */
  34758. onTransformNodeRemovedObservable: Observable<TransformNode>;
  34759. /**
  34760. * An event triggered when a mesh is created
  34761. */
  34762. onNewMeshAddedObservable: Observable<AbstractMesh>;
  34763. /**
  34764. * An event triggered when a mesh is removed
  34765. */
  34766. onMeshRemovedObservable: Observable<AbstractMesh>;
  34767. /**
  34768. * An event triggered when a skeleton is created
  34769. */
  34770. onNewSkeletonAddedObservable: Observable<Skeleton>;
  34771. /**
  34772. * An event triggered when a skeleton is removed
  34773. */
  34774. onSkeletonRemovedObservable: Observable<Skeleton>;
  34775. /**
  34776. * An event triggered when a material is created
  34777. */
  34778. onNewMaterialAddedObservable: Observable<Material>;
  34779. /**
  34780. * An event triggered when a material is removed
  34781. */
  34782. onMaterialRemovedObservable: Observable<Material>;
  34783. /**
  34784. * An event triggered when a texture is created
  34785. */
  34786. onNewTextureAddedObservable: Observable<BaseTexture>;
  34787. /**
  34788. * An event triggered when a texture is removed
  34789. */
  34790. onTextureRemovedObservable: Observable<BaseTexture>;
  34791. /**
  34792. * An event triggered when render targets are about to be rendered
  34793. * Can happen multiple times per frame.
  34794. */
  34795. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  34796. /**
  34797. * An event triggered when render targets were rendered.
  34798. * Can happen multiple times per frame.
  34799. */
  34800. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  34801. /**
  34802. * An event triggered before calculating deterministic simulation step
  34803. */
  34804. onBeforeStepObservable: Observable<Scene>;
  34805. /**
  34806. * An event triggered after calculating deterministic simulation step
  34807. */
  34808. onAfterStepObservable: Observable<Scene>;
  34809. /**
  34810. * An event triggered when the activeCamera property is updated
  34811. */
  34812. onActiveCameraChanged: Observable<Scene>;
  34813. /**
  34814. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  34815. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  34816. * 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)
  34817. */
  34818. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  34819. /**
  34820. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  34821. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  34822. * 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)
  34823. */
  34824. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  34825. /**
  34826. * This Observable will when a mesh has been imported into the scene.
  34827. */
  34828. onMeshImportedObservable: Observable<AbstractMesh>;
  34829. /**
  34830. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  34831. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  34832. */
  34833. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  34834. /** @hidden */
  34835. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  34836. /**
  34837. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  34838. */
  34839. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  34840. /**
  34841. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  34842. */
  34843. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  34844. /**
  34845. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  34846. */
  34847. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  34848. /** Callback called when a pointer move is detected */
  34849. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  34850. /** Callback called when a pointer down is detected */
  34851. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  34852. /** Callback called when a pointer up is detected */
  34853. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  34854. /** Callback called when a pointer pick is detected */
  34855. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  34856. /**
  34857. * 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).
  34858. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  34859. */
  34860. onPrePointerObservable: Observable<PointerInfoPre>;
  34861. /**
  34862. * Observable event triggered each time an input event is received from the rendering canvas
  34863. */
  34864. onPointerObservable: Observable<PointerInfo>;
  34865. /**
  34866. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  34867. */
  34868. readonly unTranslatedPointer: Vector2;
  34869. /**
  34870. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  34871. */
  34872. static DragMovementThreshold: number;
  34873. /**
  34874. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  34875. */
  34876. static LongPressDelay: number;
  34877. /**
  34878. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  34879. */
  34880. static DoubleClickDelay: number;
  34881. /** If you need to check double click without raising a single click at first click, enable this flag */
  34882. static ExclusiveDoubleClickMode: boolean;
  34883. /** @hidden */
  34884. _mirroredCameraPosition: Nullable<Vector3>;
  34885. /**
  34886. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  34887. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  34888. */
  34889. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  34890. /**
  34891. * Observable event triggered each time an keyboard event is received from the hosting window
  34892. */
  34893. onKeyboardObservable: Observable<KeyboardInfo>;
  34894. private _useRightHandedSystem;
  34895. /**
  34896. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  34897. */
  34898. useRightHandedSystem: boolean;
  34899. private _timeAccumulator;
  34900. private _currentStepId;
  34901. private _currentInternalStep;
  34902. /**
  34903. * Sets the step Id used by deterministic lock step
  34904. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34905. * @param newStepId defines the step Id
  34906. */
  34907. setStepId(newStepId: number): void;
  34908. /**
  34909. * Gets the step Id used by deterministic lock step
  34910. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34911. * @returns the step Id
  34912. */
  34913. getStepId(): number;
  34914. /**
  34915. * Gets the internal step used by deterministic lock step
  34916. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34917. * @returns the internal step
  34918. */
  34919. getInternalStep(): number;
  34920. private _fogEnabled;
  34921. /**
  34922. * Gets or sets a boolean indicating if fog is enabled on this scene
  34923. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34924. * (Default is true)
  34925. */
  34926. fogEnabled: boolean;
  34927. private _fogMode;
  34928. /**
  34929. * Gets or sets the fog mode to use
  34930. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34931. * | mode | value |
  34932. * | --- | --- |
  34933. * | FOGMODE_NONE | 0 |
  34934. * | FOGMODE_EXP | 1 |
  34935. * | FOGMODE_EXP2 | 2 |
  34936. * | FOGMODE_LINEAR | 3 |
  34937. */
  34938. fogMode: number;
  34939. /**
  34940. * Gets or sets the fog color to use
  34941. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34942. * (Default is Color3(0.2, 0.2, 0.3))
  34943. */
  34944. fogColor: Color3;
  34945. /**
  34946. * Gets or sets the fog density to use
  34947. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34948. * (Default is 0.1)
  34949. */
  34950. fogDensity: number;
  34951. /**
  34952. * Gets or sets the fog start distance to use
  34953. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34954. * (Default is 0)
  34955. */
  34956. fogStart: number;
  34957. /**
  34958. * Gets or sets the fog end distance to use
  34959. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34960. * (Default is 1000)
  34961. */
  34962. fogEnd: number;
  34963. private _shadowsEnabled;
  34964. /**
  34965. * Gets or sets a boolean indicating if shadows are enabled on this scene
  34966. */
  34967. shadowsEnabled: boolean;
  34968. private _lightsEnabled;
  34969. /**
  34970. * Gets or sets a boolean indicating if lights are enabled on this scene
  34971. */
  34972. lightsEnabled: boolean;
  34973. /** All of the active cameras added to this scene. */
  34974. activeCameras: Camera[];
  34975. /** @hidden */
  34976. _activeCamera: Nullable<Camera>;
  34977. /** Gets or sets the current active camera */
  34978. activeCamera: Nullable<Camera>;
  34979. private _defaultMaterial;
  34980. /** The default material used on meshes when no material is affected */
  34981. /** The default material used on meshes when no material is affected */
  34982. defaultMaterial: Material;
  34983. private _texturesEnabled;
  34984. /**
  34985. * Gets or sets a boolean indicating if textures are enabled on this scene
  34986. */
  34987. texturesEnabled: boolean;
  34988. /**
  34989. * Gets or sets a boolean indicating if particles are enabled on this scene
  34990. */
  34991. particlesEnabled: boolean;
  34992. /**
  34993. * Gets or sets a boolean indicating if sprites are enabled on this scene
  34994. */
  34995. spritesEnabled: boolean;
  34996. private _skeletonsEnabled;
  34997. /**
  34998. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  34999. */
  35000. skeletonsEnabled: boolean;
  35001. /**
  35002. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  35003. */
  35004. lensFlaresEnabled: boolean;
  35005. /**
  35006. * Gets or sets a boolean indicating if collisions are enabled on this scene
  35007. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  35008. */
  35009. collisionsEnabled: boolean;
  35010. private _collisionCoordinator;
  35011. /** @hidden */
  35012. readonly collisionCoordinator: ICollisionCoordinator;
  35013. /**
  35014. * Defines the gravity applied to this scene (used only for collisions)
  35015. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  35016. */
  35017. gravity: Vector3;
  35018. /**
  35019. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  35020. */
  35021. postProcessesEnabled: boolean;
  35022. /**
  35023. * The list of postprocesses added to the scene
  35024. */
  35025. postProcesses: PostProcess[];
  35026. /**
  35027. * Gets the current postprocess manager
  35028. */
  35029. postProcessManager: PostProcessManager;
  35030. /**
  35031. * Gets or sets a boolean indicating if render targets are enabled on this scene
  35032. */
  35033. renderTargetsEnabled: boolean;
  35034. /**
  35035. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  35036. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  35037. */
  35038. dumpNextRenderTargets: boolean;
  35039. /**
  35040. * The list of user defined render targets added to the scene
  35041. */
  35042. customRenderTargets: RenderTargetTexture[];
  35043. /**
  35044. * Defines if texture loading must be delayed
  35045. * If true, textures will only be loaded when they need to be rendered
  35046. */
  35047. useDelayedTextureLoading: boolean;
  35048. /**
  35049. * Gets the list of meshes imported to the scene through SceneLoader
  35050. */
  35051. importedMeshesFiles: String[];
  35052. /**
  35053. * Gets or sets a boolean indicating if probes are enabled on this scene
  35054. */
  35055. probesEnabled: boolean;
  35056. /**
  35057. * Gets or sets the current offline provider to use to store scene data
  35058. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  35059. */
  35060. offlineProvider: IOfflineProvider;
  35061. /**
  35062. * Gets or sets the action manager associated with the scene
  35063. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  35064. */
  35065. actionManager: AbstractActionManager;
  35066. private _meshesForIntersections;
  35067. /**
  35068. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  35069. */
  35070. proceduralTexturesEnabled: boolean;
  35071. private _engine;
  35072. private _totalVertices;
  35073. /** @hidden */
  35074. _activeIndices: PerfCounter;
  35075. /** @hidden */
  35076. _activeParticles: PerfCounter;
  35077. /** @hidden */
  35078. _activeBones: PerfCounter;
  35079. private _animationRatio;
  35080. /** @hidden */
  35081. _animationTimeLast: number;
  35082. /** @hidden */
  35083. _animationTime: number;
  35084. /**
  35085. * Gets or sets a general scale for animation speed
  35086. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  35087. */
  35088. animationTimeScale: number;
  35089. /** @hidden */
  35090. _cachedMaterial: Nullable<Material>;
  35091. /** @hidden */
  35092. _cachedEffect: Nullable<Effect>;
  35093. /** @hidden */
  35094. _cachedVisibility: Nullable<number>;
  35095. private _renderId;
  35096. private _frameId;
  35097. private _executeWhenReadyTimeoutId;
  35098. private _intermediateRendering;
  35099. private _viewUpdateFlag;
  35100. private _projectionUpdateFlag;
  35101. /** @hidden */
  35102. _toBeDisposed: Nullable<IDisposable>[];
  35103. private _activeRequests;
  35104. /** @hidden */
  35105. _pendingData: any[];
  35106. private _isDisposed;
  35107. /**
  35108. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  35109. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  35110. */
  35111. dispatchAllSubMeshesOfActiveMeshes: boolean;
  35112. private _activeMeshes;
  35113. private _processedMaterials;
  35114. private _renderTargets;
  35115. /** @hidden */
  35116. _activeParticleSystems: SmartArray<IParticleSystem>;
  35117. private _activeSkeletons;
  35118. private _softwareSkinnedMeshes;
  35119. private _renderingManager;
  35120. /** @hidden */
  35121. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  35122. private _transformMatrix;
  35123. private _sceneUbo;
  35124. /** @hidden */
  35125. _viewMatrix: Matrix;
  35126. private _projectionMatrix;
  35127. /** @hidden */
  35128. _forcedViewPosition: Nullable<Vector3>;
  35129. /** @hidden */
  35130. _frustumPlanes: Plane[];
  35131. /**
  35132. * Gets the list of frustum planes (built from the active camera)
  35133. */
  35134. readonly frustumPlanes: Plane[];
  35135. /**
  35136. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  35137. * This is useful if there are more lights that the maximum simulteanous authorized
  35138. */
  35139. requireLightSorting: boolean;
  35140. /** @hidden */
  35141. readonly useMaterialMeshMap: boolean;
  35142. /** @hidden */
  35143. readonly useClonedMeshhMap: boolean;
  35144. private _externalData;
  35145. private _uid;
  35146. /**
  35147. * @hidden
  35148. * Backing store of defined scene components.
  35149. */
  35150. _components: ISceneComponent[];
  35151. /**
  35152. * @hidden
  35153. * Backing store of defined scene components.
  35154. */
  35155. _serializableComponents: ISceneSerializableComponent[];
  35156. /**
  35157. * List of components to register on the next registration step.
  35158. */
  35159. private _transientComponents;
  35160. /**
  35161. * Registers the transient components if needed.
  35162. */
  35163. private _registerTransientComponents;
  35164. /**
  35165. * @hidden
  35166. * Add a component to the scene.
  35167. * Note that the ccomponent could be registered on th next frame if this is called after
  35168. * the register component stage.
  35169. * @param component Defines the component to add to the scene
  35170. */
  35171. _addComponent(component: ISceneComponent): void;
  35172. /**
  35173. * @hidden
  35174. * Gets a component from the scene.
  35175. * @param name defines the name of the component to retrieve
  35176. * @returns the component or null if not present
  35177. */
  35178. _getComponent(name: string): Nullable<ISceneComponent>;
  35179. /**
  35180. * @hidden
  35181. * Defines the actions happening before camera updates.
  35182. */
  35183. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  35184. /**
  35185. * @hidden
  35186. * Defines the actions happening before clear the canvas.
  35187. */
  35188. _beforeClearStage: Stage<SimpleStageAction>;
  35189. /**
  35190. * @hidden
  35191. * Defines the actions when collecting render targets for the frame.
  35192. */
  35193. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  35194. /**
  35195. * @hidden
  35196. * Defines the actions happening for one camera in the frame.
  35197. */
  35198. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  35199. /**
  35200. * @hidden
  35201. * Defines the actions happening during the per mesh ready checks.
  35202. */
  35203. _isReadyForMeshStage: Stage<MeshStageAction>;
  35204. /**
  35205. * @hidden
  35206. * Defines the actions happening before evaluate active mesh checks.
  35207. */
  35208. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  35209. /**
  35210. * @hidden
  35211. * Defines the actions happening during the evaluate sub mesh checks.
  35212. */
  35213. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  35214. /**
  35215. * @hidden
  35216. * Defines the actions happening during the active mesh stage.
  35217. */
  35218. _activeMeshStage: Stage<ActiveMeshStageAction>;
  35219. /**
  35220. * @hidden
  35221. * Defines the actions happening during the per camera render target step.
  35222. */
  35223. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  35224. /**
  35225. * @hidden
  35226. * Defines the actions happening just before the active camera is drawing.
  35227. */
  35228. _beforeCameraDrawStage: Stage<CameraStageAction>;
  35229. /**
  35230. * @hidden
  35231. * Defines the actions happening just before a render target is drawing.
  35232. */
  35233. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  35234. /**
  35235. * @hidden
  35236. * Defines the actions happening just before a rendering group is drawing.
  35237. */
  35238. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  35239. /**
  35240. * @hidden
  35241. * Defines the actions happening just before a mesh is drawing.
  35242. */
  35243. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  35244. /**
  35245. * @hidden
  35246. * Defines the actions happening just after a mesh has been drawn.
  35247. */
  35248. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  35249. /**
  35250. * @hidden
  35251. * Defines the actions happening just after a rendering group has been drawn.
  35252. */
  35253. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  35254. /**
  35255. * @hidden
  35256. * Defines the actions happening just after the active camera has been drawn.
  35257. */
  35258. _afterCameraDrawStage: Stage<CameraStageAction>;
  35259. /**
  35260. * @hidden
  35261. * Defines the actions happening just after a render target has been drawn.
  35262. */
  35263. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  35264. /**
  35265. * @hidden
  35266. * Defines the actions happening just after rendering all cameras and computing intersections.
  35267. */
  35268. _afterRenderStage: Stage<SimpleStageAction>;
  35269. /**
  35270. * @hidden
  35271. * Defines the actions happening when a pointer move event happens.
  35272. */
  35273. _pointerMoveStage: Stage<PointerMoveStageAction>;
  35274. /**
  35275. * @hidden
  35276. * Defines the actions happening when a pointer down event happens.
  35277. */
  35278. _pointerDownStage: Stage<PointerUpDownStageAction>;
  35279. /**
  35280. * @hidden
  35281. * Defines the actions happening when a pointer up event happens.
  35282. */
  35283. _pointerUpStage: Stage<PointerUpDownStageAction>;
  35284. /**
  35285. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  35286. */
  35287. private geometriesByUniqueId;
  35288. /**
  35289. * Creates a new Scene
  35290. * @param engine defines the engine to use to render this scene
  35291. * @param options defines the scene options
  35292. */
  35293. constructor(engine: Engine, options?: SceneOptions);
  35294. /**
  35295. * Gets a string idenfifying the name of the class
  35296. * @returns "Scene" string
  35297. */
  35298. getClassName(): string;
  35299. private _defaultMeshCandidates;
  35300. /**
  35301. * @hidden
  35302. */
  35303. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  35304. private _defaultSubMeshCandidates;
  35305. /**
  35306. * @hidden
  35307. */
  35308. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  35309. /**
  35310. * Sets the default candidate providers for the scene.
  35311. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  35312. * and getCollidingSubMeshCandidates to their default function
  35313. */
  35314. setDefaultCandidateProviders(): void;
  35315. /**
  35316. * Gets the mesh that is currently under the pointer
  35317. */
  35318. readonly meshUnderPointer: Nullable<AbstractMesh>;
  35319. /**
  35320. * Gets or sets the current on-screen X position of the pointer
  35321. */
  35322. pointerX: number;
  35323. /**
  35324. * Gets or sets the current on-screen Y position of the pointer
  35325. */
  35326. pointerY: number;
  35327. /**
  35328. * Gets the cached material (ie. the latest rendered one)
  35329. * @returns the cached material
  35330. */
  35331. getCachedMaterial(): Nullable<Material>;
  35332. /**
  35333. * Gets the cached effect (ie. the latest rendered one)
  35334. * @returns the cached effect
  35335. */
  35336. getCachedEffect(): Nullable<Effect>;
  35337. /**
  35338. * Gets the cached visibility state (ie. the latest rendered one)
  35339. * @returns the cached visibility state
  35340. */
  35341. getCachedVisibility(): Nullable<number>;
  35342. /**
  35343. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  35344. * @param material defines the current material
  35345. * @param effect defines the current effect
  35346. * @param visibility defines the current visibility state
  35347. * @returns true if one parameter is not cached
  35348. */
  35349. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  35350. /**
  35351. * Gets the engine associated with the scene
  35352. * @returns an Engine
  35353. */
  35354. getEngine(): Engine;
  35355. /**
  35356. * Gets the total number of vertices rendered per frame
  35357. * @returns the total number of vertices rendered per frame
  35358. */
  35359. getTotalVertices(): number;
  35360. /**
  35361. * Gets the performance counter for total vertices
  35362. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  35363. */
  35364. readonly totalVerticesPerfCounter: PerfCounter;
  35365. /**
  35366. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  35367. * @returns the total number of active indices rendered per frame
  35368. */
  35369. getActiveIndices(): number;
  35370. /**
  35371. * Gets the performance counter for active indices
  35372. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  35373. */
  35374. readonly totalActiveIndicesPerfCounter: PerfCounter;
  35375. /**
  35376. * Gets the total number of active particles rendered per frame
  35377. * @returns the total number of active particles rendered per frame
  35378. */
  35379. getActiveParticles(): number;
  35380. /**
  35381. * Gets the performance counter for active particles
  35382. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  35383. */
  35384. readonly activeParticlesPerfCounter: PerfCounter;
  35385. /**
  35386. * Gets the total number of active bones rendered per frame
  35387. * @returns the total number of active bones rendered per frame
  35388. */
  35389. getActiveBones(): number;
  35390. /**
  35391. * Gets the performance counter for active bones
  35392. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  35393. */
  35394. readonly activeBonesPerfCounter: PerfCounter;
  35395. /**
  35396. * Gets the array of active meshes
  35397. * @returns an array of AbstractMesh
  35398. */
  35399. getActiveMeshes(): SmartArray<AbstractMesh>;
  35400. /**
  35401. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  35402. * @returns a number
  35403. */
  35404. getAnimationRatio(): number;
  35405. /**
  35406. * Gets an unique Id for the current render phase
  35407. * @returns a number
  35408. */
  35409. getRenderId(): number;
  35410. /**
  35411. * Gets an unique Id for the current frame
  35412. * @returns a number
  35413. */
  35414. getFrameId(): number;
  35415. /** Call this function if you want to manually increment the render Id*/
  35416. incrementRenderId(): void;
  35417. private _createUbo;
  35418. /**
  35419. * Use this method to simulate a pointer move on a mesh
  35420. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35421. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35422. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35423. * @returns the current scene
  35424. */
  35425. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  35426. /**
  35427. * Use this method to simulate a pointer down on a mesh
  35428. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35429. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35430. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35431. * @returns the current scene
  35432. */
  35433. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  35434. /**
  35435. * Use this method to simulate a pointer up on a mesh
  35436. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35437. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35438. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35439. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  35440. * @returns the current scene
  35441. */
  35442. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  35443. /**
  35444. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  35445. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  35446. * @returns true if the pointer was captured
  35447. */
  35448. isPointerCaptured(pointerId?: number): boolean;
  35449. /**
  35450. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  35451. * @param attachUp defines if you want to attach events to pointerup
  35452. * @param attachDown defines if you want to attach events to pointerdown
  35453. * @param attachMove defines if you want to attach events to pointermove
  35454. */
  35455. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  35456. /** Detaches all event handlers*/
  35457. detachControl(): void;
  35458. /**
  35459. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  35460. * Delay loaded resources are not taking in account
  35461. * @return true if all required resources are ready
  35462. */
  35463. isReady(): boolean;
  35464. /** Resets all cached information relative to material (including effect and visibility) */
  35465. resetCachedMaterial(): void;
  35466. /**
  35467. * Registers a function to be called before every frame render
  35468. * @param func defines the function to register
  35469. */
  35470. registerBeforeRender(func: () => void): void;
  35471. /**
  35472. * Unregisters a function called before every frame render
  35473. * @param func defines the function to unregister
  35474. */
  35475. unregisterBeforeRender(func: () => void): void;
  35476. /**
  35477. * Registers a function to be called after every frame render
  35478. * @param func defines the function to register
  35479. */
  35480. registerAfterRender(func: () => void): void;
  35481. /**
  35482. * Unregisters a function called after every frame render
  35483. * @param func defines the function to unregister
  35484. */
  35485. unregisterAfterRender(func: () => void): void;
  35486. private _executeOnceBeforeRender;
  35487. /**
  35488. * The provided function will run before render once and will be disposed afterwards.
  35489. * A timeout delay can be provided so that the function will be executed in N ms.
  35490. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  35491. * @param func The function to be executed.
  35492. * @param timeout optional delay in ms
  35493. */
  35494. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  35495. /** @hidden */
  35496. _addPendingData(data: any): void;
  35497. /** @hidden */
  35498. _removePendingData(data: any): void;
  35499. /**
  35500. * Returns the number of items waiting to be loaded
  35501. * @returns the number of items waiting to be loaded
  35502. */
  35503. getWaitingItemsCount(): number;
  35504. /**
  35505. * Returns a boolean indicating if the scene is still loading data
  35506. */
  35507. readonly isLoading: boolean;
  35508. /**
  35509. * Registers a function to be executed when the scene is ready
  35510. * @param {Function} func - the function to be executed
  35511. */
  35512. executeWhenReady(func: () => void): void;
  35513. /**
  35514. * Returns a promise that resolves when the scene is ready
  35515. * @returns A promise that resolves when the scene is ready
  35516. */
  35517. whenReadyAsync(): Promise<void>;
  35518. /** @hidden */
  35519. _checkIsReady(): void;
  35520. /**
  35521. * Gets all animatable attached to the scene
  35522. */
  35523. readonly animatables: Animatable[];
  35524. /**
  35525. * Resets the last animation time frame.
  35526. * Useful to override when animations start running when loading a scene for the first time.
  35527. */
  35528. resetLastAnimationTimeFrame(): void;
  35529. /**
  35530. * Gets the current view matrix
  35531. * @returns a Matrix
  35532. */
  35533. getViewMatrix(): Matrix;
  35534. /**
  35535. * Gets the current projection matrix
  35536. * @returns a Matrix
  35537. */
  35538. getProjectionMatrix(): Matrix;
  35539. /**
  35540. * Gets the current transform matrix
  35541. * @returns a Matrix made of View * Projection
  35542. */
  35543. getTransformMatrix(): Matrix;
  35544. /**
  35545. * Sets the current transform matrix
  35546. * @param viewL defines the View matrix to use
  35547. * @param projectionL defines the Projection matrix to use
  35548. * @param viewR defines the right View matrix to use (if provided)
  35549. * @param projectionR defines the right Projection matrix to use (if provided)
  35550. */
  35551. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  35552. /**
  35553. * Gets the uniform buffer used to store scene data
  35554. * @returns a UniformBuffer
  35555. */
  35556. getSceneUniformBuffer(): UniformBuffer;
  35557. /**
  35558. * Gets an unique (relatively to the current scene) Id
  35559. * @returns an unique number for the scene
  35560. */
  35561. getUniqueId(): number;
  35562. /**
  35563. * Add a mesh to the list of scene's meshes
  35564. * @param newMesh defines the mesh to add
  35565. * @param recursive if all child meshes should also be added to the scene
  35566. */
  35567. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  35568. /**
  35569. * Remove a mesh for the list of scene's meshes
  35570. * @param toRemove defines the mesh to remove
  35571. * @param recursive if all child meshes should also be removed from the scene
  35572. * @returns the index where the mesh was in the mesh list
  35573. */
  35574. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  35575. /**
  35576. * Add a transform node to the list of scene's transform nodes
  35577. * @param newTransformNode defines the transform node to add
  35578. */
  35579. addTransformNode(newTransformNode: TransformNode): void;
  35580. /**
  35581. * Remove a transform node for the list of scene's transform nodes
  35582. * @param toRemove defines the transform node to remove
  35583. * @returns the index where the transform node was in the transform node list
  35584. */
  35585. removeTransformNode(toRemove: TransformNode): number;
  35586. /**
  35587. * Remove a skeleton for the list of scene's skeletons
  35588. * @param toRemove defines the skeleton to remove
  35589. * @returns the index where the skeleton was in the skeleton list
  35590. */
  35591. removeSkeleton(toRemove: Skeleton): number;
  35592. /**
  35593. * Remove a morph target for the list of scene's morph targets
  35594. * @param toRemove defines the morph target to remove
  35595. * @returns the index where the morph target was in the morph target list
  35596. */
  35597. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  35598. /**
  35599. * Remove a light for the list of scene's lights
  35600. * @param toRemove defines the light to remove
  35601. * @returns the index where the light was in the light list
  35602. */
  35603. removeLight(toRemove: Light): number;
  35604. /**
  35605. * Remove a camera for the list of scene's cameras
  35606. * @param toRemove defines the camera to remove
  35607. * @returns the index where the camera was in the camera list
  35608. */
  35609. removeCamera(toRemove: Camera): number;
  35610. /**
  35611. * Remove a particle system for the list of scene's particle systems
  35612. * @param toRemove defines the particle system to remove
  35613. * @returns the index where the particle system was in the particle system list
  35614. */
  35615. removeParticleSystem(toRemove: IParticleSystem): number;
  35616. /**
  35617. * Remove a animation for the list of scene's animations
  35618. * @param toRemove defines the animation to remove
  35619. * @returns the index where the animation was in the animation list
  35620. */
  35621. removeAnimation(toRemove: Animation): number;
  35622. /**
  35623. * Will stop the animation of the given target
  35624. * @param target - the target
  35625. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  35626. * @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)
  35627. */
  35628. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  35629. /**
  35630. * Removes the given animation group from this scene.
  35631. * @param toRemove The animation group to remove
  35632. * @returns The index of the removed animation group
  35633. */
  35634. removeAnimationGroup(toRemove: AnimationGroup): number;
  35635. /**
  35636. * Removes the given multi-material from this scene.
  35637. * @param toRemove The multi-material to remove
  35638. * @returns The index of the removed multi-material
  35639. */
  35640. removeMultiMaterial(toRemove: MultiMaterial): number;
  35641. /**
  35642. * Removes the given material from this scene.
  35643. * @param toRemove The material to remove
  35644. * @returns The index of the removed material
  35645. */
  35646. removeMaterial(toRemove: Material): number;
  35647. /**
  35648. * Removes the given action manager from this scene.
  35649. * @param toRemove The action manager to remove
  35650. * @returns The index of the removed action manager
  35651. */
  35652. removeActionManager(toRemove: AbstractActionManager): number;
  35653. /**
  35654. * Removes the given texture from this scene.
  35655. * @param toRemove The texture to remove
  35656. * @returns The index of the removed texture
  35657. */
  35658. removeTexture(toRemove: BaseTexture): number;
  35659. /**
  35660. * Adds the given light to this scene
  35661. * @param newLight The light to add
  35662. */
  35663. addLight(newLight: Light): void;
  35664. /**
  35665. * Sorts the list list based on light priorities
  35666. */
  35667. sortLightsByPriority(): void;
  35668. /**
  35669. * Adds the given camera to this scene
  35670. * @param newCamera The camera to add
  35671. */
  35672. addCamera(newCamera: Camera): void;
  35673. /**
  35674. * Adds the given skeleton to this scene
  35675. * @param newSkeleton The skeleton to add
  35676. */
  35677. addSkeleton(newSkeleton: Skeleton): void;
  35678. /**
  35679. * Adds the given particle system to this scene
  35680. * @param newParticleSystem The particle system to add
  35681. */
  35682. addParticleSystem(newParticleSystem: IParticleSystem): void;
  35683. /**
  35684. * Adds the given animation to this scene
  35685. * @param newAnimation The animation to add
  35686. */
  35687. addAnimation(newAnimation: Animation): void;
  35688. /**
  35689. * Adds the given animation group to this scene.
  35690. * @param newAnimationGroup The animation group to add
  35691. */
  35692. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  35693. /**
  35694. * Adds the given multi-material to this scene
  35695. * @param newMultiMaterial The multi-material to add
  35696. */
  35697. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  35698. /**
  35699. * Adds the given material to this scene
  35700. * @param newMaterial The material to add
  35701. */
  35702. addMaterial(newMaterial: Material): void;
  35703. /**
  35704. * Adds the given morph target to this scene
  35705. * @param newMorphTargetManager The morph target to add
  35706. */
  35707. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  35708. /**
  35709. * Adds the given geometry to this scene
  35710. * @param newGeometry The geometry to add
  35711. */
  35712. addGeometry(newGeometry: Geometry): void;
  35713. /**
  35714. * Adds the given action manager to this scene
  35715. * @param newActionManager The action manager to add
  35716. */
  35717. addActionManager(newActionManager: AbstractActionManager): void;
  35718. /**
  35719. * Adds the given texture to this scene.
  35720. * @param newTexture The texture to add
  35721. */
  35722. addTexture(newTexture: BaseTexture): void;
  35723. /**
  35724. * Switch active camera
  35725. * @param newCamera defines the new active camera
  35726. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  35727. */
  35728. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  35729. /**
  35730. * sets the active camera of the scene using its ID
  35731. * @param id defines the camera's ID
  35732. * @return the new active camera or null if none found.
  35733. */
  35734. setActiveCameraByID(id: string): Nullable<Camera>;
  35735. /**
  35736. * sets the active camera of the scene using its name
  35737. * @param name defines the camera's name
  35738. * @returns the new active camera or null if none found.
  35739. */
  35740. setActiveCameraByName(name: string): Nullable<Camera>;
  35741. /**
  35742. * get an animation group using its name
  35743. * @param name defines the material's name
  35744. * @return the animation group or null if none found.
  35745. */
  35746. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  35747. /**
  35748. * Get a material using its unique id
  35749. * @param uniqueId defines the material's unique id
  35750. * @return the material or null if none found.
  35751. */
  35752. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  35753. /**
  35754. * get a material using its id
  35755. * @param id defines the material's ID
  35756. * @return the material or null if none found.
  35757. */
  35758. getMaterialByID(id: string): Nullable<Material>;
  35759. /**
  35760. * Gets a the last added material using a given id
  35761. * @param id defines the material's ID
  35762. * @return the last material with the given id or null if none found.
  35763. */
  35764. getLastMaterialByID(id: string): Nullable<Material>;
  35765. /**
  35766. * Gets a material using its name
  35767. * @param name defines the material's name
  35768. * @return the material or null if none found.
  35769. */
  35770. getMaterialByName(name: string): Nullable<Material>;
  35771. /**
  35772. * Get a texture using its unique id
  35773. * @param uniqueId defines the texture's unique id
  35774. * @return the texture or null if none found.
  35775. */
  35776. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  35777. /**
  35778. * Gets a camera using its id
  35779. * @param id defines the id to look for
  35780. * @returns the camera or null if not found
  35781. */
  35782. getCameraByID(id: string): Nullable<Camera>;
  35783. /**
  35784. * Gets a camera using its unique id
  35785. * @param uniqueId defines the unique id to look for
  35786. * @returns the camera or null if not found
  35787. */
  35788. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  35789. /**
  35790. * Gets a camera using its name
  35791. * @param name defines the camera's name
  35792. * @return the camera or null if none found.
  35793. */
  35794. getCameraByName(name: string): Nullable<Camera>;
  35795. /**
  35796. * Gets a bone using its id
  35797. * @param id defines the bone's id
  35798. * @return the bone or null if not found
  35799. */
  35800. getBoneByID(id: string): Nullable<Bone>;
  35801. /**
  35802. * Gets a bone using its id
  35803. * @param name defines the bone's name
  35804. * @return the bone or null if not found
  35805. */
  35806. getBoneByName(name: string): Nullable<Bone>;
  35807. /**
  35808. * Gets a light node using its name
  35809. * @param name defines the the light's name
  35810. * @return the light or null if none found.
  35811. */
  35812. getLightByName(name: string): Nullable<Light>;
  35813. /**
  35814. * Gets a light node using its id
  35815. * @param id defines the light's id
  35816. * @return the light or null if none found.
  35817. */
  35818. getLightByID(id: string): Nullable<Light>;
  35819. /**
  35820. * Gets a light node using its scene-generated unique ID
  35821. * @param uniqueId defines the light's unique id
  35822. * @return the light or null if none found.
  35823. */
  35824. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  35825. /**
  35826. * Gets a particle system by id
  35827. * @param id defines the particle system id
  35828. * @return the corresponding system or null if none found
  35829. */
  35830. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  35831. /**
  35832. * Gets a geometry using its ID
  35833. * @param id defines the geometry's id
  35834. * @return the geometry or null if none found.
  35835. */
  35836. getGeometryByID(id: string): Nullable<Geometry>;
  35837. private _getGeometryByUniqueID;
  35838. /**
  35839. * Add a new geometry to this scene
  35840. * @param geometry defines the geometry to be added to the scene.
  35841. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  35842. * @return a boolean defining if the geometry was added or not
  35843. */
  35844. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  35845. /**
  35846. * Removes an existing geometry
  35847. * @param geometry defines the geometry to be removed from the scene
  35848. * @return a boolean defining if the geometry was removed or not
  35849. */
  35850. removeGeometry(geometry: Geometry): boolean;
  35851. /**
  35852. * Gets the list of geometries attached to the scene
  35853. * @returns an array of Geometry
  35854. */
  35855. getGeometries(): Geometry[];
  35856. /**
  35857. * Gets the first added mesh found of a given ID
  35858. * @param id defines the id to search for
  35859. * @return the mesh found or null if not found at all
  35860. */
  35861. getMeshByID(id: string): Nullable<AbstractMesh>;
  35862. /**
  35863. * Gets a list of meshes using their id
  35864. * @param id defines the id to search for
  35865. * @returns a list of meshes
  35866. */
  35867. getMeshesByID(id: string): Array<AbstractMesh>;
  35868. /**
  35869. * Gets the first added transform node found of a given ID
  35870. * @param id defines the id to search for
  35871. * @return the found transform node or null if not found at all.
  35872. */
  35873. getTransformNodeByID(id: string): Nullable<TransformNode>;
  35874. /**
  35875. * Gets a transform node with its auto-generated unique id
  35876. * @param uniqueId efines the unique id to search for
  35877. * @return the found transform node or null if not found at all.
  35878. */
  35879. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  35880. /**
  35881. * Gets a list of transform nodes using their id
  35882. * @param id defines the id to search for
  35883. * @returns a list of transform nodes
  35884. */
  35885. getTransformNodesByID(id: string): Array<TransformNode>;
  35886. /**
  35887. * Gets a mesh with its auto-generated unique id
  35888. * @param uniqueId defines the unique id to search for
  35889. * @return the found mesh or null if not found at all.
  35890. */
  35891. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  35892. /**
  35893. * Gets a the last added mesh using a given id
  35894. * @param id defines the id to search for
  35895. * @return the found mesh or null if not found at all.
  35896. */
  35897. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  35898. /**
  35899. * Gets a the last added node (Mesh, Camera, Light) using a given id
  35900. * @param id defines the id to search for
  35901. * @return the found node or null if not found at all
  35902. */
  35903. getLastEntryByID(id: string): Nullable<Node>;
  35904. /**
  35905. * Gets a node (Mesh, Camera, Light) using a given id
  35906. * @param id defines the id to search for
  35907. * @return the found node or null if not found at all
  35908. */
  35909. getNodeByID(id: string): Nullable<Node>;
  35910. /**
  35911. * Gets a node (Mesh, Camera, Light) using a given name
  35912. * @param name defines the name to search for
  35913. * @return the found node or null if not found at all.
  35914. */
  35915. getNodeByName(name: string): Nullable<Node>;
  35916. /**
  35917. * Gets a mesh using a given name
  35918. * @param name defines the name to search for
  35919. * @return the found mesh or null if not found at all.
  35920. */
  35921. getMeshByName(name: string): Nullable<AbstractMesh>;
  35922. /**
  35923. * Gets a transform node using a given name
  35924. * @param name defines the name to search for
  35925. * @return the found transform node or null if not found at all.
  35926. */
  35927. getTransformNodeByName(name: string): Nullable<TransformNode>;
  35928. /**
  35929. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  35930. * @param id defines the id to search for
  35931. * @return the found skeleton or null if not found at all.
  35932. */
  35933. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  35934. /**
  35935. * Gets a skeleton using a given auto generated unique id
  35936. * @param uniqueId defines the unique id to search for
  35937. * @return the found skeleton or null if not found at all.
  35938. */
  35939. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  35940. /**
  35941. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  35942. * @param id defines the id to search for
  35943. * @return the found skeleton or null if not found at all.
  35944. */
  35945. getSkeletonById(id: string): Nullable<Skeleton>;
  35946. /**
  35947. * Gets a skeleton using a given name
  35948. * @param name defines the name to search for
  35949. * @return the found skeleton or null if not found at all.
  35950. */
  35951. getSkeletonByName(name: string): Nullable<Skeleton>;
  35952. /**
  35953. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  35954. * @param id defines the id to search for
  35955. * @return the found morph target manager or null if not found at all.
  35956. */
  35957. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  35958. /**
  35959. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  35960. * @param id defines the id to search for
  35961. * @return the found morph target or null if not found at all.
  35962. */
  35963. getMorphTargetById(id: string): Nullable<MorphTarget>;
  35964. /**
  35965. * Gets a boolean indicating if the given mesh is active
  35966. * @param mesh defines the mesh to look for
  35967. * @returns true if the mesh is in the active list
  35968. */
  35969. isActiveMesh(mesh: AbstractMesh): boolean;
  35970. /**
  35971. * Return a unique id as a string which can serve as an identifier for the scene
  35972. */
  35973. readonly uid: string;
  35974. /**
  35975. * Add an externaly attached data from its key.
  35976. * This method call will fail and return false, if such key already exists.
  35977. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  35978. * @param key the unique key that identifies the data
  35979. * @param data the data object to associate to the key for this Engine instance
  35980. * @return true if no such key were already present and the data was added successfully, false otherwise
  35981. */
  35982. addExternalData<T>(key: string, data: T): boolean;
  35983. /**
  35984. * Get an externaly attached data from its key
  35985. * @param key the unique key that identifies the data
  35986. * @return the associated data, if present (can be null), or undefined if not present
  35987. */
  35988. getExternalData<T>(key: string): Nullable<T>;
  35989. /**
  35990. * Get an externaly attached data from its key, create it using a factory if it's not already present
  35991. * @param key the unique key that identifies the data
  35992. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  35993. * @return the associated data, can be null if the factory returned null.
  35994. */
  35995. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  35996. /**
  35997. * Remove an externaly attached data from the Engine instance
  35998. * @param key the unique key that identifies the data
  35999. * @return true if the data was successfully removed, false if it doesn't exist
  36000. */
  36001. removeExternalData(key: string): boolean;
  36002. private _evaluateSubMesh;
  36003. /**
  36004. * Clear the processed materials smart array preventing retention point in material dispose.
  36005. */
  36006. freeProcessedMaterials(): void;
  36007. private _preventFreeActiveMeshesAndRenderingGroups;
  36008. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  36009. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  36010. * when disposing several meshes in a row or a hierarchy of meshes.
  36011. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  36012. */
  36013. blockfreeActiveMeshesAndRenderingGroups: boolean;
  36014. /**
  36015. * Clear the active meshes smart array preventing retention point in mesh dispose.
  36016. */
  36017. freeActiveMeshes(): void;
  36018. /**
  36019. * Clear the info related to rendering groups preventing retention points during dispose.
  36020. */
  36021. freeRenderingGroups(): void;
  36022. /** @hidden */
  36023. _isInIntermediateRendering(): boolean;
  36024. /**
  36025. * Lambda returning the list of potentially active meshes.
  36026. */
  36027. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  36028. /**
  36029. * Lambda returning the list of potentially active sub meshes.
  36030. */
  36031. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  36032. /**
  36033. * Lambda returning the list of potentially intersecting sub meshes.
  36034. */
  36035. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  36036. /**
  36037. * Lambda returning the list of potentially colliding sub meshes.
  36038. */
  36039. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  36040. private _activeMeshesFrozen;
  36041. private _skipEvaluateActiveMeshesCompletely;
  36042. /**
  36043. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  36044. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  36045. * @returns the current scene
  36046. */
  36047. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  36048. /**
  36049. * Use this function to restart evaluating active meshes on every frame
  36050. * @returns the current scene
  36051. */
  36052. unfreezeActiveMeshes(): Scene;
  36053. private _evaluateActiveMeshes;
  36054. private _activeMesh;
  36055. /**
  36056. * Update the transform matrix to update from the current active camera
  36057. * @param force defines a boolean used to force the update even if cache is up to date
  36058. */
  36059. updateTransformMatrix(force?: boolean): void;
  36060. private _bindFrameBuffer;
  36061. /** @hidden */
  36062. _allowPostProcessClearColor: boolean;
  36063. /** @hidden */
  36064. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  36065. private _processSubCameras;
  36066. private _checkIntersections;
  36067. /** @hidden */
  36068. _advancePhysicsEngineStep(step: number): void;
  36069. /**
  36070. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  36071. */
  36072. getDeterministicFrameTime: () => number;
  36073. /** @hidden */
  36074. _animate(): void;
  36075. /** Execute all animations (for a frame) */
  36076. animate(): void;
  36077. /**
  36078. * Render the scene
  36079. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  36080. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  36081. */
  36082. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  36083. /**
  36084. * Freeze all materials
  36085. * A frozen material will not be updatable but should be faster to render
  36086. */
  36087. freezeMaterials(): void;
  36088. /**
  36089. * Unfreeze all materials
  36090. * A frozen material will not be updatable but should be faster to render
  36091. */
  36092. unfreezeMaterials(): void;
  36093. /**
  36094. * Releases all held ressources
  36095. */
  36096. dispose(): void;
  36097. /**
  36098. * Gets if the scene is already disposed
  36099. */
  36100. readonly isDisposed: boolean;
  36101. /**
  36102. * Call this function to reduce memory footprint of the scene.
  36103. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  36104. */
  36105. clearCachedVertexData(): void;
  36106. /**
  36107. * This function will remove the local cached buffer data from texture.
  36108. * It will save memory but will prevent the texture from being rebuilt
  36109. */
  36110. cleanCachedTextureBuffer(): void;
  36111. /**
  36112. * Get the world extend vectors with an optional filter
  36113. *
  36114. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  36115. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  36116. */
  36117. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  36118. min: Vector3;
  36119. max: Vector3;
  36120. };
  36121. /**
  36122. * Creates a ray that can be used to pick in the scene
  36123. * @param x defines the x coordinate of the origin (on-screen)
  36124. * @param y defines the y coordinate of the origin (on-screen)
  36125. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  36126. * @param camera defines the camera to use for the picking
  36127. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  36128. * @returns a Ray
  36129. */
  36130. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  36131. /**
  36132. * Creates a ray that can be used to pick in the scene
  36133. * @param x defines the x coordinate of the origin (on-screen)
  36134. * @param y defines the y coordinate of the origin (on-screen)
  36135. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  36136. * @param result defines the ray where to store the picking ray
  36137. * @param camera defines the camera to use for the picking
  36138. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  36139. * @returns the current scene
  36140. */
  36141. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  36142. /**
  36143. * Creates a ray that can be used to pick in the scene
  36144. * @param x defines the x coordinate of the origin (on-screen)
  36145. * @param y defines the y coordinate of the origin (on-screen)
  36146. * @param camera defines the camera to use for the picking
  36147. * @returns a Ray
  36148. */
  36149. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  36150. /**
  36151. * Creates a ray that can be used to pick in the scene
  36152. * @param x defines the x coordinate of the origin (on-screen)
  36153. * @param y defines the y coordinate of the origin (on-screen)
  36154. * @param result defines the ray where to store the picking ray
  36155. * @param camera defines the camera to use for the picking
  36156. * @returns the current scene
  36157. */
  36158. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  36159. /** Launch a ray to try to pick a mesh in the scene
  36160. * @param x position on screen
  36161. * @param y position on screen
  36162. * @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
  36163. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  36164. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  36165. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  36166. * @returns a PickingInfo
  36167. */
  36168. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  36169. /** Use the given ray to pick a mesh in the scene
  36170. * @param ray The ray to use to pick meshes
  36171. * @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
  36172. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  36173. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  36174. * @returns a PickingInfo
  36175. */
  36176. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  36177. /**
  36178. * Launch a ray to try to pick a mesh in the scene
  36179. * @param x X position on screen
  36180. * @param y Y position on screen
  36181. * @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
  36182. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  36183. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  36184. * @returns an array of PickingInfo
  36185. */
  36186. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  36187. /**
  36188. * Launch a ray to try to pick a mesh in the scene
  36189. * @param ray Ray to use
  36190. * @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
  36191. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  36192. * @returns an array of PickingInfo
  36193. */
  36194. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  36195. /**
  36196. * Force the value of meshUnderPointer
  36197. * @param mesh defines the mesh to use
  36198. */
  36199. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  36200. /**
  36201. * Gets the mesh under the pointer
  36202. * @returns a Mesh or null if no mesh is under the pointer
  36203. */
  36204. getPointerOverMesh(): Nullable<AbstractMesh>;
  36205. /** @hidden */
  36206. _rebuildGeometries(): void;
  36207. /** @hidden */
  36208. _rebuildTextures(): void;
  36209. private _getByTags;
  36210. /**
  36211. * Get a list of meshes by tags
  36212. * @param tagsQuery defines the tags query to use
  36213. * @param forEach defines a predicate used to filter results
  36214. * @returns an array of Mesh
  36215. */
  36216. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  36217. /**
  36218. * Get a list of cameras by tags
  36219. * @param tagsQuery defines the tags query to use
  36220. * @param forEach defines a predicate used to filter results
  36221. * @returns an array of Camera
  36222. */
  36223. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  36224. /**
  36225. * Get a list of lights by tags
  36226. * @param tagsQuery defines the tags query to use
  36227. * @param forEach defines a predicate used to filter results
  36228. * @returns an array of Light
  36229. */
  36230. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  36231. /**
  36232. * Get a list of materials by tags
  36233. * @param tagsQuery defines the tags query to use
  36234. * @param forEach defines a predicate used to filter results
  36235. * @returns an array of Material
  36236. */
  36237. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  36238. /**
  36239. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  36240. * This allowed control for front to back rendering or reversly depending of the special needs.
  36241. *
  36242. * @param renderingGroupId The rendering group id corresponding to its index
  36243. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  36244. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  36245. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  36246. */
  36247. 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;
  36248. /**
  36249. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  36250. *
  36251. * @param renderingGroupId The rendering group id corresponding to its index
  36252. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  36253. * @param depth Automatically clears depth between groups if true and autoClear is true.
  36254. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  36255. */
  36256. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  36257. /**
  36258. * Gets the current auto clear configuration for one rendering group of the rendering
  36259. * manager.
  36260. * @param index the rendering group index to get the information for
  36261. * @returns The auto clear setup for the requested rendering group
  36262. */
  36263. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  36264. private _blockMaterialDirtyMechanism;
  36265. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  36266. blockMaterialDirtyMechanism: boolean;
  36267. /**
  36268. * Will flag all materials as dirty to trigger new shader compilation
  36269. * @param flag defines the flag used to specify which material part must be marked as dirty
  36270. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  36271. */
  36272. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  36273. /** @hidden */
  36274. _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;
  36275. /** @hidden */
  36276. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  36277. /** @hidden */
  36278. _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;
  36279. /** @hidden */
  36280. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  36281. /** @hidden */
  36282. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  36283. /** @hidden */
  36284. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  36285. }
  36286. }
  36287. declare module "babylonjs/assetContainer" {
  36288. import { AbstractScene } from "babylonjs/abstractScene";
  36289. import { Scene } from "babylonjs/scene";
  36290. import { Mesh } from "babylonjs/Meshes/mesh";
  36291. import { TransformNode } from "babylonjs/Meshes/transformNode";
  36292. import { Skeleton } from "babylonjs/Bones/skeleton";
  36293. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  36294. /**
  36295. * Set of assets to keep when moving a scene into an asset container.
  36296. */
  36297. export class KeepAssets extends AbstractScene {
  36298. }
  36299. /**
  36300. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  36301. */
  36302. export class InstantiatedEntries {
  36303. /**
  36304. * List of new root nodes (eg. nodes with no parent)
  36305. */
  36306. rootNodes: TransformNode[];
  36307. /**
  36308. * List of new skeletons
  36309. */
  36310. skeletons: Skeleton[];
  36311. /**
  36312. * List of new animation groups
  36313. */
  36314. animationGroups: AnimationGroup[];
  36315. }
  36316. /**
  36317. * Container with a set of assets that can be added or removed from a scene.
  36318. */
  36319. export class AssetContainer extends AbstractScene {
  36320. /**
  36321. * The scene the AssetContainer belongs to.
  36322. */
  36323. scene: Scene;
  36324. /**
  36325. * Instantiates an AssetContainer.
  36326. * @param scene The scene the AssetContainer belongs to.
  36327. */
  36328. constructor(scene: Scene);
  36329. /**
  36330. * Instantiate or clone all meshes and add the new ones to the scene.
  36331. * Skeletons and animation groups will all be cloned
  36332. * @param nameFunction defines an optional function used to get new names for clones
  36333. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  36334. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  36335. */
  36336. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  36337. /**
  36338. * Adds all the assets from the container to the scene.
  36339. */
  36340. addAllToScene(): void;
  36341. /**
  36342. * Removes all the assets in the container from the scene
  36343. */
  36344. removeAllFromScene(): void;
  36345. /**
  36346. * Disposes all the assets in the container
  36347. */
  36348. dispose(): void;
  36349. private _moveAssets;
  36350. /**
  36351. * Removes all the assets contained in the scene and adds them to the container.
  36352. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  36353. */
  36354. moveAllFromScene(keepAssets?: KeepAssets): void;
  36355. /**
  36356. * 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.
  36357. * @returns the root mesh
  36358. */
  36359. createRootMesh(): Mesh;
  36360. }
  36361. }
  36362. declare module "babylonjs/abstractScene" {
  36363. import { Scene } from "babylonjs/scene";
  36364. import { Nullable } from "babylonjs/types";
  36365. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36366. import { TransformNode } from "babylonjs/Meshes/transformNode";
  36367. import { Geometry } from "babylonjs/Meshes/geometry";
  36368. import { Skeleton } from "babylonjs/Bones/skeleton";
  36369. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  36370. import { AssetContainer } from "babylonjs/assetContainer";
  36371. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  36372. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  36373. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  36374. import { Material } from "babylonjs/Materials/material";
  36375. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  36376. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  36377. import { Camera } from "babylonjs/Cameras/camera";
  36378. import { Light } from "babylonjs/Lights/light";
  36379. import { Node } from "babylonjs/node";
  36380. import { Animation } from "babylonjs/Animations/animation";
  36381. /**
  36382. * Defines how the parser contract is defined.
  36383. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  36384. */
  36385. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  36386. /**
  36387. * Defines how the individual parser contract is defined.
  36388. * These parser can parse an individual asset
  36389. */
  36390. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  36391. /**
  36392. * Base class of the scene acting as a container for the different elements composing a scene.
  36393. * This class is dynamically extended by the different components of the scene increasing
  36394. * flexibility and reducing coupling
  36395. */
  36396. export abstract class AbstractScene {
  36397. /**
  36398. * Stores the list of available parsers in the application.
  36399. */
  36400. private static _BabylonFileParsers;
  36401. /**
  36402. * Stores the list of available individual parsers in the application.
  36403. */
  36404. private static _IndividualBabylonFileParsers;
  36405. /**
  36406. * Adds a parser in the list of available ones
  36407. * @param name Defines the name of the parser
  36408. * @param parser Defines the parser to add
  36409. */
  36410. static AddParser(name: string, parser: BabylonFileParser): void;
  36411. /**
  36412. * Gets a general parser from the list of avaialble ones
  36413. * @param name Defines the name of the parser
  36414. * @returns the requested parser or null
  36415. */
  36416. static GetParser(name: string): Nullable<BabylonFileParser>;
  36417. /**
  36418. * Adds n individual parser in the list of available ones
  36419. * @param name Defines the name of the parser
  36420. * @param parser Defines the parser to add
  36421. */
  36422. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  36423. /**
  36424. * Gets an individual parser from the list of avaialble ones
  36425. * @param name Defines the name of the parser
  36426. * @returns the requested parser or null
  36427. */
  36428. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  36429. /**
  36430. * Parser json data and populate both a scene and its associated container object
  36431. * @param jsonData Defines the data to parse
  36432. * @param scene Defines the scene to parse the data for
  36433. * @param container Defines the container attached to the parsing sequence
  36434. * @param rootUrl Defines the root url of the data
  36435. */
  36436. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  36437. /**
  36438. * Gets the list of root nodes (ie. nodes with no parent)
  36439. */
  36440. rootNodes: Node[];
  36441. /** All of the cameras added to this scene
  36442. * @see http://doc.babylonjs.com/babylon101/cameras
  36443. */
  36444. cameras: Camera[];
  36445. /**
  36446. * All of the lights added to this scene
  36447. * @see http://doc.babylonjs.com/babylon101/lights
  36448. */
  36449. lights: Light[];
  36450. /**
  36451. * All of the (abstract) meshes added to this scene
  36452. */
  36453. meshes: AbstractMesh[];
  36454. /**
  36455. * The list of skeletons added to the scene
  36456. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  36457. */
  36458. skeletons: Skeleton[];
  36459. /**
  36460. * All of the particle systems added to this scene
  36461. * @see http://doc.babylonjs.com/babylon101/particles
  36462. */
  36463. particleSystems: IParticleSystem[];
  36464. /**
  36465. * Gets a list of Animations associated with the scene
  36466. */
  36467. animations: Animation[];
  36468. /**
  36469. * All of the animation groups added to this scene
  36470. * @see http://doc.babylonjs.com/how_to/group
  36471. */
  36472. animationGroups: AnimationGroup[];
  36473. /**
  36474. * All of the multi-materials added to this scene
  36475. * @see http://doc.babylonjs.com/how_to/multi_materials
  36476. */
  36477. multiMaterials: MultiMaterial[];
  36478. /**
  36479. * All of the materials added to this scene
  36480. * In the context of a Scene, it is not supposed to be modified manually.
  36481. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  36482. * Note also that the order of the Material within the array is not significant and might change.
  36483. * @see http://doc.babylonjs.com/babylon101/materials
  36484. */
  36485. materials: Material[];
  36486. /**
  36487. * The list of morph target managers added to the scene
  36488. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  36489. */
  36490. morphTargetManagers: MorphTargetManager[];
  36491. /**
  36492. * The list of geometries used in the scene.
  36493. */
  36494. geometries: Geometry[];
  36495. /**
  36496. * All of the tranform nodes added to this scene
  36497. * In the context of a Scene, it is not supposed to be modified manually.
  36498. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  36499. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  36500. * @see http://doc.babylonjs.com/how_to/transformnode
  36501. */
  36502. transformNodes: TransformNode[];
  36503. /**
  36504. * ActionManagers available on the scene.
  36505. */
  36506. actionManagers: AbstractActionManager[];
  36507. /**
  36508. * Textures to keep.
  36509. */
  36510. textures: BaseTexture[];
  36511. /**
  36512. * Environment texture for the scene
  36513. */
  36514. environmentTexture: Nullable<BaseTexture>;
  36515. }
  36516. }
  36517. declare module "babylonjs/Audio/sound" {
  36518. import { Observable } from "babylonjs/Misc/observable";
  36519. import { Vector3 } from "babylonjs/Maths/math.vector";
  36520. import { Nullable } from "babylonjs/types";
  36521. import { Scene } from "babylonjs/scene";
  36522. import { TransformNode } from "babylonjs/Meshes/transformNode";
  36523. /**
  36524. * Interface used to define options for Sound class
  36525. */
  36526. export interface ISoundOptions {
  36527. /**
  36528. * Does the sound autoplay once loaded.
  36529. */
  36530. autoplay?: boolean;
  36531. /**
  36532. * Does the sound loop after it finishes playing once.
  36533. */
  36534. loop?: boolean;
  36535. /**
  36536. * Sound's volume
  36537. */
  36538. volume?: number;
  36539. /**
  36540. * Is it a spatial sound?
  36541. */
  36542. spatialSound?: boolean;
  36543. /**
  36544. * Maximum distance to hear that sound
  36545. */
  36546. maxDistance?: number;
  36547. /**
  36548. * Uses user defined attenuation function
  36549. */
  36550. useCustomAttenuation?: boolean;
  36551. /**
  36552. * Define the roll off factor of spatial sounds.
  36553. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36554. */
  36555. rolloffFactor?: number;
  36556. /**
  36557. * Define the reference distance the sound should be heard perfectly.
  36558. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36559. */
  36560. refDistance?: number;
  36561. /**
  36562. * Define the distance attenuation model the sound will follow.
  36563. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36564. */
  36565. distanceModel?: string;
  36566. /**
  36567. * Defines the playback speed (1 by default)
  36568. */
  36569. playbackRate?: number;
  36570. /**
  36571. * Defines if the sound is from a streaming source
  36572. */
  36573. streaming?: boolean;
  36574. /**
  36575. * Defines an optional length (in seconds) inside the sound file
  36576. */
  36577. length?: number;
  36578. /**
  36579. * Defines an optional offset (in seconds) inside the sound file
  36580. */
  36581. offset?: number;
  36582. /**
  36583. * If true, URLs will not be required to state the audio file codec to use.
  36584. */
  36585. skipCodecCheck?: boolean;
  36586. }
  36587. /**
  36588. * Defines a sound that can be played in the application.
  36589. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  36590. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36591. */
  36592. export class Sound {
  36593. /**
  36594. * The name of the sound in the scene.
  36595. */
  36596. name: string;
  36597. /**
  36598. * Does the sound autoplay once loaded.
  36599. */
  36600. autoplay: boolean;
  36601. /**
  36602. * Does the sound loop after it finishes playing once.
  36603. */
  36604. loop: boolean;
  36605. /**
  36606. * Does the sound use a custom attenuation curve to simulate the falloff
  36607. * happening when the source gets further away from the camera.
  36608. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  36609. */
  36610. useCustomAttenuation: boolean;
  36611. /**
  36612. * The sound track id this sound belongs to.
  36613. */
  36614. soundTrackId: number;
  36615. /**
  36616. * Is this sound currently played.
  36617. */
  36618. isPlaying: boolean;
  36619. /**
  36620. * Is this sound currently paused.
  36621. */
  36622. isPaused: boolean;
  36623. /**
  36624. * Does this sound enables spatial sound.
  36625. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36626. */
  36627. spatialSound: boolean;
  36628. /**
  36629. * Define the reference distance the sound should be heard perfectly.
  36630. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36631. */
  36632. refDistance: number;
  36633. /**
  36634. * Define the roll off factor of spatial sounds.
  36635. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36636. */
  36637. rolloffFactor: number;
  36638. /**
  36639. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  36640. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36641. */
  36642. maxDistance: number;
  36643. /**
  36644. * Define the distance attenuation model the sound will follow.
  36645. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36646. */
  36647. distanceModel: string;
  36648. /**
  36649. * @hidden
  36650. * Back Compat
  36651. **/
  36652. onended: () => any;
  36653. /**
  36654. * Observable event when the current playing sound finishes.
  36655. */
  36656. onEndedObservable: Observable<Sound>;
  36657. private _panningModel;
  36658. private _playbackRate;
  36659. private _streaming;
  36660. private _startTime;
  36661. private _startOffset;
  36662. private _position;
  36663. /** @hidden */
  36664. _positionInEmitterSpace: boolean;
  36665. private _localDirection;
  36666. private _volume;
  36667. private _isReadyToPlay;
  36668. private _isDirectional;
  36669. private _readyToPlayCallback;
  36670. private _audioBuffer;
  36671. private _soundSource;
  36672. private _streamingSource;
  36673. private _soundPanner;
  36674. private _soundGain;
  36675. private _inputAudioNode;
  36676. private _outputAudioNode;
  36677. private _coneInnerAngle;
  36678. private _coneOuterAngle;
  36679. private _coneOuterGain;
  36680. private _scene;
  36681. private _connectedTransformNode;
  36682. private _customAttenuationFunction;
  36683. private _registerFunc;
  36684. private _isOutputConnected;
  36685. private _htmlAudioElement;
  36686. private _urlType;
  36687. private _length?;
  36688. private _offset?;
  36689. /** @hidden */
  36690. static _SceneComponentInitialization: (scene: Scene) => void;
  36691. /**
  36692. * Create a sound and attach it to a scene
  36693. * @param name Name of your sound
  36694. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  36695. * @param scene defines the scene the sound belongs to
  36696. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  36697. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  36698. */
  36699. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  36700. /**
  36701. * Release the sound and its associated resources
  36702. */
  36703. dispose(): void;
  36704. /**
  36705. * Gets if the sounds is ready to be played or not.
  36706. * @returns true if ready, otherwise false
  36707. */
  36708. isReady(): boolean;
  36709. private _soundLoaded;
  36710. /**
  36711. * Sets the data of the sound from an audiobuffer
  36712. * @param audioBuffer The audioBuffer containing the data
  36713. */
  36714. setAudioBuffer(audioBuffer: AudioBuffer): void;
  36715. /**
  36716. * Updates the current sounds options such as maxdistance, loop...
  36717. * @param options A JSON object containing values named as the object properties
  36718. */
  36719. updateOptions(options: ISoundOptions): void;
  36720. private _createSpatialParameters;
  36721. private _updateSpatialParameters;
  36722. /**
  36723. * Switch the panning model to HRTF:
  36724. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  36725. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36726. */
  36727. switchPanningModelToHRTF(): void;
  36728. /**
  36729. * Switch the panning model to Equal Power:
  36730. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  36731. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36732. */
  36733. switchPanningModelToEqualPower(): void;
  36734. private _switchPanningModel;
  36735. /**
  36736. * Connect this sound to a sound track audio node like gain...
  36737. * @param soundTrackAudioNode the sound track audio node to connect to
  36738. */
  36739. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  36740. /**
  36741. * Transform this sound into a directional source
  36742. * @param coneInnerAngle Size of the inner cone in degree
  36743. * @param coneOuterAngle Size of the outer cone in degree
  36744. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  36745. */
  36746. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  36747. /**
  36748. * Gets or sets the inner angle for the directional cone.
  36749. */
  36750. /**
  36751. * Gets or sets the inner angle for the directional cone.
  36752. */
  36753. directionalConeInnerAngle: number;
  36754. /**
  36755. * Gets or sets the outer angle for the directional cone.
  36756. */
  36757. /**
  36758. * Gets or sets the outer angle for the directional cone.
  36759. */
  36760. directionalConeOuterAngle: number;
  36761. /**
  36762. * Sets the position of the emitter if spatial sound is enabled
  36763. * @param newPosition Defines the new posisiton
  36764. */
  36765. setPosition(newPosition: Vector3): void;
  36766. /**
  36767. * Sets the local direction of the emitter if spatial sound is enabled
  36768. * @param newLocalDirection Defines the new local direction
  36769. */
  36770. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  36771. private _updateDirection;
  36772. /** @hidden */
  36773. updateDistanceFromListener(): void;
  36774. /**
  36775. * Sets a new custom attenuation function for the sound.
  36776. * @param callback Defines the function used for the attenuation
  36777. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  36778. */
  36779. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  36780. /**
  36781. * Play the sound
  36782. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  36783. * @param offset (optional) Start the sound at a specific time in seconds
  36784. * @param length (optional) Sound duration (in seconds)
  36785. */
  36786. play(time?: number, offset?: number, length?: number): void;
  36787. private _onended;
  36788. /**
  36789. * Stop the sound
  36790. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  36791. */
  36792. stop(time?: number): void;
  36793. /**
  36794. * Put the sound in pause
  36795. */
  36796. pause(): void;
  36797. /**
  36798. * Sets a dedicated volume for this sounds
  36799. * @param newVolume Define the new volume of the sound
  36800. * @param time Define time for gradual change to new volume
  36801. */
  36802. setVolume(newVolume: number, time?: number): void;
  36803. /**
  36804. * Set the sound play back rate
  36805. * @param newPlaybackRate Define the playback rate the sound should be played at
  36806. */
  36807. setPlaybackRate(newPlaybackRate: number): void;
  36808. /**
  36809. * Gets the volume of the sound.
  36810. * @returns the volume of the sound
  36811. */
  36812. getVolume(): number;
  36813. /**
  36814. * Attach the sound to a dedicated mesh
  36815. * @param transformNode The transform node to connect the sound with
  36816. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  36817. */
  36818. attachToMesh(transformNode: TransformNode): void;
  36819. /**
  36820. * Detach the sound from the previously attached mesh
  36821. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  36822. */
  36823. detachFromMesh(): void;
  36824. private _onRegisterAfterWorldMatrixUpdate;
  36825. /**
  36826. * Clone the current sound in the scene.
  36827. * @returns the new sound clone
  36828. */
  36829. clone(): Nullable<Sound>;
  36830. /**
  36831. * Gets the current underlying audio buffer containing the data
  36832. * @returns the audio buffer
  36833. */
  36834. getAudioBuffer(): Nullable<AudioBuffer>;
  36835. /**
  36836. * Serializes the Sound in a JSON representation
  36837. * @returns the JSON representation of the sound
  36838. */
  36839. serialize(): any;
  36840. /**
  36841. * Parse a JSON representation of a sound to innstantiate in a given scene
  36842. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  36843. * @param scene Define the scene the new parsed sound should be created in
  36844. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  36845. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  36846. * @returns the newly parsed sound
  36847. */
  36848. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  36849. }
  36850. }
  36851. declare module "babylonjs/Actions/directAudioActions" {
  36852. import { Action } from "babylonjs/Actions/action";
  36853. import { Condition } from "babylonjs/Actions/condition";
  36854. import { Sound } from "babylonjs/Audio/sound";
  36855. /**
  36856. * This defines an action helpful to play a defined sound on a triggered action.
  36857. */
  36858. export class PlaySoundAction extends Action {
  36859. private _sound;
  36860. /**
  36861. * Instantiate the action
  36862. * @param triggerOptions defines the trigger options
  36863. * @param sound defines the sound to play
  36864. * @param condition defines the trigger related conditions
  36865. */
  36866. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  36867. /** @hidden */
  36868. _prepare(): void;
  36869. /**
  36870. * Execute the action and play the sound.
  36871. */
  36872. execute(): void;
  36873. /**
  36874. * Serializes the actions and its related information.
  36875. * @param parent defines the object to serialize in
  36876. * @returns the serialized object
  36877. */
  36878. serialize(parent: any): any;
  36879. }
  36880. /**
  36881. * This defines an action helpful to stop a defined sound on a triggered action.
  36882. */
  36883. export class StopSoundAction extends Action {
  36884. private _sound;
  36885. /**
  36886. * Instantiate the action
  36887. * @param triggerOptions defines the trigger options
  36888. * @param sound defines the sound to stop
  36889. * @param condition defines the trigger related conditions
  36890. */
  36891. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  36892. /** @hidden */
  36893. _prepare(): void;
  36894. /**
  36895. * Execute the action and stop the sound.
  36896. */
  36897. execute(): void;
  36898. /**
  36899. * Serializes the actions and its related information.
  36900. * @param parent defines the object to serialize in
  36901. * @returns the serialized object
  36902. */
  36903. serialize(parent: any): any;
  36904. }
  36905. }
  36906. declare module "babylonjs/Actions/interpolateValueAction" {
  36907. import { Action } from "babylonjs/Actions/action";
  36908. import { Condition } from "babylonjs/Actions/condition";
  36909. import { Observable } from "babylonjs/Misc/observable";
  36910. /**
  36911. * This defines an action responsible to change the value of a property
  36912. * by interpolating between its current value and the newly set one once triggered.
  36913. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  36914. */
  36915. export class InterpolateValueAction extends Action {
  36916. /**
  36917. * Defines the path of the property where the value should be interpolated
  36918. */
  36919. propertyPath: string;
  36920. /**
  36921. * Defines the target value at the end of the interpolation.
  36922. */
  36923. value: any;
  36924. /**
  36925. * Defines the time it will take for the property to interpolate to the value.
  36926. */
  36927. duration: number;
  36928. /**
  36929. * Defines if the other scene animations should be stopped when the action has been triggered
  36930. */
  36931. stopOtherAnimations?: boolean;
  36932. /**
  36933. * Defines a callback raised once the interpolation animation has been done.
  36934. */
  36935. onInterpolationDone?: () => void;
  36936. /**
  36937. * Observable triggered once the interpolation animation has been done.
  36938. */
  36939. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  36940. private _target;
  36941. private _effectiveTarget;
  36942. private _property;
  36943. /**
  36944. * Instantiate the action
  36945. * @param triggerOptions defines the trigger options
  36946. * @param target defines the object containing the value to interpolate
  36947. * @param propertyPath defines the path to the property in the target object
  36948. * @param value defines the target value at the end of the interpolation
  36949. * @param duration deines the time it will take for the property to interpolate to the value.
  36950. * @param condition defines the trigger related conditions
  36951. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  36952. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  36953. */
  36954. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  36955. /** @hidden */
  36956. _prepare(): void;
  36957. /**
  36958. * Execute the action starts the value interpolation.
  36959. */
  36960. execute(): void;
  36961. /**
  36962. * Serializes the actions and its related information.
  36963. * @param parent defines the object to serialize in
  36964. * @returns the serialized object
  36965. */
  36966. serialize(parent: any): any;
  36967. }
  36968. }
  36969. declare module "babylonjs/Actions/index" {
  36970. export * from "babylonjs/Actions/abstractActionManager";
  36971. export * from "babylonjs/Actions/action";
  36972. export * from "babylonjs/Actions/actionEvent";
  36973. export * from "babylonjs/Actions/actionManager";
  36974. export * from "babylonjs/Actions/condition";
  36975. export * from "babylonjs/Actions/directActions";
  36976. export * from "babylonjs/Actions/directAudioActions";
  36977. export * from "babylonjs/Actions/interpolateValueAction";
  36978. }
  36979. declare module "babylonjs/Animations/index" {
  36980. export * from "babylonjs/Animations/animatable";
  36981. export * from "babylonjs/Animations/animation";
  36982. export * from "babylonjs/Animations/animationGroup";
  36983. export * from "babylonjs/Animations/animationPropertiesOverride";
  36984. export * from "babylonjs/Animations/easing";
  36985. export * from "babylonjs/Animations/runtimeAnimation";
  36986. export * from "babylonjs/Animations/animationEvent";
  36987. export * from "babylonjs/Animations/animationGroup";
  36988. export * from "babylonjs/Animations/animationKey";
  36989. export * from "babylonjs/Animations/animationRange";
  36990. export * from "babylonjs/Animations/animatable.interface";
  36991. }
  36992. declare module "babylonjs/Audio/soundTrack" {
  36993. import { Sound } from "babylonjs/Audio/sound";
  36994. import { Analyser } from "babylonjs/Audio/analyser";
  36995. import { Scene } from "babylonjs/scene";
  36996. /**
  36997. * Options allowed during the creation of a sound track.
  36998. */
  36999. export interface ISoundTrackOptions {
  37000. /**
  37001. * The volume the sound track should take during creation
  37002. */
  37003. volume?: number;
  37004. /**
  37005. * Define if the sound track is the main sound track of the scene
  37006. */
  37007. mainTrack?: boolean;
  37008. }
  37009. /**
  37010. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  37011. * It will be also used in a future release to apply effects on a specific track.
  37012. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  37013. */
  37014. export class SoundTrack {
  37015. /**
  37016. * The unique identifier of the sound track in the scene.
  37017. */
  37018. id: number;
  37019. /**
  37020. * The list of sounds included in the sound track.
  37021. */
  37022. soundCollection: Array<Sound>;
  37023. private _outputAudioNode;
  37024. private _scene;
  37025. private _connectedAnalyser;
  37026. private _options;
  37027. private _isInitialized;
  37028. /**
  37029. * Creates a new sound track.
  37030. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  37031. * @param scene Define the scene the sound track belongs to
  37032. * @param options
  37033. */
  37034. constructor(scene: Scene, options?: ISoundTrackOptions);
  37035. private _initializeSoundTrackAudioGraph;
  37036. /**
  37037. * Release the sound track and its associated resources
  37038. */
  37039. dispose(): void;
  37040. /**
  37041. * Adds a sound to this sound track
  37042. * @param sound define the cound to add
  37043. * @ignoreNaming
  37044. */
  37045. AddSound(sound: Sound): void;
  37046. /**
  37047. * Removes a sound to this sound track
  37048. * @param sound define the cound to remove
  37049. * @ignoreNaming
  37050. */
  37051. RemoveSound(sound: Sound): void;
  37052. /**
  37053. * Set a global volume for the full sound track.
  37054. * @param newVolume Define the new volume of the sound track
  37055. */
  37056. setVolume(newVolume: number): void;
  37057. /**
  37058. * Switch the panning model to HRTF:
  37059. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  37060. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37061. */
  37062. switchPanningModelToHRTF(): void;
  37063. /**
  37064. * Switch the panning model to Equal Power:
  37065. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  37066. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37067. */
  37068. switchPanningModelToEqualPower(): void;
  37069. /**
  37070. * Connect the sound track to an audio analyser allowing some amazing
  37071. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  37072. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  37073. * @param analyser The analyser to connect to the engine
  37074. */
  37075. connectToAnalyser(analyser: Analyser): void;
  37076. }
  37077. }
  37078. declare module "babylonjs/Audio/audioSceneComponent" {
  37079. import { Sound } from "babylonjs/Audio/sound";
  37080. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  37081. import { Nullable } from "babylonjs/types";
  37082. import { Vector3 } from "babylonjs/Maths/math.vector";
  37083. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  37084. import { Scene } from "babylonjs/scene";
  37085. import { AbstractScene } from "babylonjs/abstractScene";
  37086. import "babylonjs/Audio/audioEngine";
  37087. module "babylonjs/abstractScene" {
  37088. interface AbstractScene {
  37089. /**
  37090. * The list of sounds used in the scene.
  37091. */
  37092. sounds: Nullable<Array<Sound>>;
  37093. }
  37094. }
  37095. module "babylonjs/scene" {
  37096. interface Scene {
  37097. /**
  37098. * @hidden
  37099. * Backing field
  37100. */
  37101. _mainSoundTrack: SoundTrack;
  37102. /**
  37103. * The main sound track played by the scene.
  37104. * It cotains your primary collection of sounds.
  37105. */
  37106. mainSoundTrack: SoundTrack;
  37107. /**
  37108. * The list of sound tracks added to the scene
  37109. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37110. */
  37111. soundTracks: Nullable<Array<SoundTrack>>;
  37112. /**
  37113. * Gets a sound using a given name
  37114. * @param name defines the name to search for
  37115. * @return the found sound or null if not found at all.
  37116. */
  37117. getSoundByName(name: string): Nullable<Sound>;
  37118. /**
  37119. * Gets or sets if audio support is enabled
  37120. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37121. */
  37122. audioEnabled: boolean;
  37123. /**
  37124. * Gets or sets if audio will be output to headphones
  37125. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37126. */
  37127. headphone: boolean;
  37128. /**
  37129. * Gets or sets custom audio listener position provider
  37130. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37131. */
  37132. audioListenerPositionProvider: Nullable<() => Vector3>;
  37133. /**
  37134. * Gets or sets a refresh rate when using 3D audio positioning
  37135. */
  37136. audioPositioningRefreshRate: number;
  37137. }
  37138. }
  37139. /**
  37140. * Defines the sound scene component responsible to manage any sounds
  37141. * in a given scene.
  37142. */
  37143. export class AudioSceneComponent implements ISceneSerializableComponent {
  37144. /**
  37145. * The component name helpfull to identify the component in the list of scene components.
  37146. */
  37147. readonly name: string;
  37148. /**
  37149. * The scene the component belongs to.
  37150. */
  37151. scene: Scene;
  37152. private _audioEnabled;
  37153. /**
  37154. * Gets whether audio is enabled or not.
  37155. * Please use related enable/disable method to switch state.
  37156. */
  37157. readonly audioEnabled: boolean;
  37158. private _headphone;
  37159. /**
  37160. * Gets whether audio is outputing to headphone or not.
  37161. * Please use the according Switch methods to change output.
  37162. */
  37163. readonly headphone: boolean;
  37164. /**
  37165. * Gets or sets a refresh rate when using 3D audio positioning
  37166. */
  37167. audioPositioningRefreshRate: number;
  37168. private _audioListenerPositionProvider;
  37169. /**
  37170. * Gets the current audio listener position provider
  37171. */
  37172. /**
  37173. * Sets a custom listener position for all sounds in the scene
  37174. * By default, this is the position of the first active camera
  37175. */
  37176. audioListenerPositionProvider: Nullable<() => Vector3>;
  37177. /**
  37178. * Creates a new instance of the component for the given scene
  37179. * @param scene Defines the scene to register the component in
  37180. */
  37181. constructor(scene: Scene);
  37182. /**
  37183. * Registers the component in a given scene
  37184. */
  37185. register(): void;
  37186. /**
  37187. * Rebuilds the elements related to this component in case of
  37188. * context lost for instance.
  37189. */
  37190. rebuild(): void;
  37191. /**
  37192. * Serializes the component data to the specified json object
  37193. * @param serializationObject The object to serialize to
  37194. */
  37195. serialize(serializationObject: any): void;
  37196. /**
  37197. * Adds all the elements from the container to the scene
  37198. * @param container the container holding the elements
  37199. */
  37200. addFromContainer(container: AbstractScene): void;
  37201. /**
  37202. * Removes all the elements in the container from the scene
  37203. * @param container contains the elements to remove
  37204. * @param dispose if the removed element should be disposed (default: false)
  37205. */
  37206. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  37207. /**
  37208. * Disposes the component and the associated ressources.
  37209. */
  37210. dispose(): void;
  37211. /**
  37212. * Disables audio in the associated scene.
  37213. */
  37214. disableAudio(): void;
  37215. /**
  37216. * Enables audio in the associated scene.
  37217. */
  37218. enableAudio(): void;
  37219. /**
  37220. * Switch audio to headphone output.
  37221. */
  37222. switchAudioModeForHeadphones(): void;
  37223. /**
  37224. * Switch audio to normal speakers.
  37225. */
  37226. switchAudioModeForNormalSpeakers(): void;
  37227. private _cachedCameraDirection;
  37228. private _cachedCameraPosition;
  37229. private _lastCheck;
  37230. private _afterRender;
  37231. }
  37232. }
  37233. declare module "babylonjs/Audio/weightedsound" {
  37234. import { Sound } from "babylonjs/Audio/sound";
  37235. /**
  37236. * Wraps one or more Sound objects and selects one with random weight for playback.
  37237. */
  37238. export class WeightedSound {
  37239. /** When true a Sound will be selected and played when the current playing Sound completes. */
  37240. loop: boolean;
  37241. private _coneInnerAngle;
  37242. private _coneOuterAngle;
  37243. private _volume;
  37244. /** A Sound is currently playing. */
  37245. isPlaying: boolean;
  37246. /** A Sound is currently paused. */
  37247. isPaused: boolean;
  37248. private _sounds;
  37249. private _weights;
  37250. private _currentIndex?;
  37251. /**
  37252. * Creates a new WeightedSound from the list of sounds given.
  37253. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  37254. * @param sounds Array of Sounds that will be selected from.
  37255. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  37256. */
  37257. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  37258. /**
  37259. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  37260. */
  37261. /**
  37262. * The size of cone in degress for a directional sound in which there will be no attenuation.
  37263. */
  37264. directionalConeInnerAngle: number;
  37265. /**
  37266. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  37267. * Listener angles between innerAngle and outerAngle will falloff linearly.
  37268. */
  37269. /**
  37270. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  37271. * Listener angles between innerAngle and outerAngle will falloff linearly.
  37272. */
  37273. directionalConeOuterAngle: number;
  37274. /**
  37275. * Playback volume.
  37276. */
  37277. /**
  37278. * Playback volume.
  37279. */
  37280. volume: number;
  37281. private _onended;
  37282. /**
  37283. * Suspend playback
  37284. */
  37285. pause(): void;
  37286. /**
  37287. * Stop playback
  37288. */
  37289. stop(): void;
  37290. /**
  37291. * Start playback.
  37292. * @param startOffset Position the clip head at a specific time in seconds.
  37293. */
  37294. play(startOffset?: number): void;
  37295. }
  37296. }
  37297. declare module "babylonjs/Audio/index" {
  37298. export * from "babylonjs/Audio/analyser";
  37299. export * from "babylonjs/Audio/audioEngine";
  37300. export * from "babylonjs/Audio/audioSceneComponent";
  37301. export * from "babylonjs/Audio/sound";
  37302. export * from "babylonjs/Audio/soundTrack";
  37303. export * from "babylonjs/Audio/weightedsound";
  37304. }
  37305. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  37306. import { Behavior } from "babylonjs/Behaviors/behavior";
  37307. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37308. import { BackEase } from "babylonjs/Animations/easing";
  37309. /**
  37310. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  37311. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  37312. */
  37313. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  37314. /**
  37315. * Gets the name of the behavior.
  37316. */
  37317. readonly name: string;
  37318. /**
  37319. * The easing function used by animations
  37320. */
  37321. static EasingFunction: BackEase;
  37322. /**
  37323. * The easing mode used by animations
  37324. */
  37325. static EasingMode: number;
  37326. /**
  37327. * The duration of the animation, in milliseconds
  37328. */
  37329. transitionDuration: number;
  37330. /**
  37331. * Length of the distance animated by the transition when lower radius is reached
  37332. */
  37333. lowerRadiusTransitionRange: number;
  37334. /**
  37335. * Length of the distance animated by the transition when upper radius is reached
  37336. */
  37337. upperRadiusTransitionRange: number;
  37338. private _autoTransitionRange;
  37339. /**
  37340. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  37341. */
  37342. /**
  37343. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  37344. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  37345. */
  37346. autoTransitionRange: boolean;
  37347. private _attachedCamera;
  37348. private _onAfterCheckInputsObserver;
  37349. private _onMeshTargetChangedObserver;
  37350. /**
  37351. * Initializes the behavior.
  37352. */
  37353. init(): void;
  37354. /**
  37355. * Attaches the behavior to its arc rotate camera.
  37356. * @param camera Defines the camera to attach the behavior to
  37357. */
  37358. attach(camera: ArcRotateCamera): void;
  37359. /**
  37360. * Detaches the behavior from its current arc rotate camera.
  37361. */
  37362. detach(): void;
  37363. private _radiusIsAnimating;
  37364. private _radiusBounceTransition;
  37365. private _animatables;
  37366. private _cachedWheelPrecision;
  37367. /**
  37368. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  37369. * @param radiusLimit The limit to check against.
  37370. * @return Bool to indicate if at limit.
  37371. */
  37372. private _isRadiusAtLimit;
  37373. /**
  37374. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  37375. * @param radiusDelta The delta by which to animate to. Can be negative.
  37376. */
  37377. private _applyBoundRadiusAnimation;
  37378. /**
  37379. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  37380. */
  37381. protected _clearAnimationLocks(): void;
  37382. /**
  37383. * Stops and removes all animations that have been applied to the camera
  37384. */
  37385. stopAllAnimations(): void;
  37386. }
  37387. }
  37388. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  37389. import { Behavior } from "babylonjs/Behaviors/behavior";
  37390. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37391. import { ExponentialEase } from "babylonjs/Animations/easing";
  37392. import { Nullable } from "babylonjs/types";
  37393. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37394. import { Vector3 } from "babylonjs/Maths/math.vector";
  37395. /**
  37396. * 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.
  37397. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  37398. */
  37399. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  37400. /**
  37401. * Gets the name of the behavior.
  37402. */
  37403. readonly name: string;
  37404. private _mode;
  37405. private _radiusScale;
  37406. private _positionScale;
  37407. private _defaultElevation;
  37408. private _elevationReturnTime;
  37409. private _elevationReturnWaitTime;
  37410. private _zoomStopsAnimation;
  37411. private _framingTime;
  37412. /**
  37413. * The easing function used by animations
  37414. */
  37415. static EasingFunction: ExponentialEase;
  37416. /**
  37417. * The easing mode used by animations
  37418. */
  37419. static EasingMode: number;
  37420. /**
  37421. * Sets the current mode used by the behavior
  37422. */
  37423. /**
  37424. * Gets current mode used by the behavior.
  37425. */
  37426. mode: number;
  37427. /**
  37428. * Sets the scale applied to the radius (1 by default)
  37429. */
  37430. /**
  37431. * Gets the scale applied to the radius
  37432. */
  37433. radiusScale: number;
  37434. /**
  37435. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  37436. */
  37437. /**
  37438. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  37439. */
  37440. positionScale: number;
  37441. /**
  37442. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  37443. * behaviour is triggered, in radians.
  37444. */
  37445. /**
  37446. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  37447. * behaviour is triggered, in radians.
  37448. */
  37449. defaultElevation: number;
  37450. /**
  37451. * Sets the time (in milliseconds) taken to return to the default beta position.
  37452. * Negative value indicates camera should not return to default.
  37453. */
  37454. /**
  37455. * Gets the time (in milliseconds) taken to return to the default beta position.
  37456. * Negative value indicates camera should not return to default.
  37457. */
  37458. elevationReturnTime: number;
  37459. /**
  37460. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  37461. */
  37462. /**
  37463. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  37464. */
  37465. elevationReturnWaitTime: number;
  37466. /**
  37467. * Sets the flag that indicates if user zooming should stop animation.
  37468. */
  37469. /**
  37470. * Gets the flag that indicates if user zooming should stop animation.
  37471. */
  37472. zoomStopsAnimation: boolean;
  37473. /**
  37474. * Sets the transition time when framing the mesh, in milliseconds
  37475. */
  37476. /**
  37477. * Gets the transition time when framing the mesh, in milliseconds
  37478. */
  37479. framingTime: number;
  37480. /**
  37481. * Define if the behavior should automatically change the configured
  37482. * camera limits and sensibilities.
  37483. */
  37484. autoCorrectCameraLimitsAndSensibility: boolean;
  37485. private _onPrePointerObservableObserver;
  37486. private _onAfterCheckInputsObserver;
  37487. private _onMeshTargetChangedObserver;
  37488. private _attachedCamera;
  37489. private _isPointerDown;
  37490. private _lastInteractionTime;
  37491. /**
  37492. * Initializes the behavior.
  37493. */
  37494. init(): void;
  37495. /**
  37496. * Attaches the behavior to its arc rotate camera.
  37497. * @param camera Defines the camera to attach the behavior to
  37498. */
  37499. attach(camera: ArcRotateCamera): void;
  37500. /**
  37501. * Detaches the behavior from its current arc rotate camera.
  37502. */
  37503. detach(): void;
  37504. private _animatables;
  37505. private _betaIsAnimating;
  37506. private _betaTransition;
  37507. private _radiusTransition;
  37508. private _vectorTransition;
  37509. /**
  37510. * Targets the given mesh and updates zoom level accordingly.
  37511. * @param mesh The mesh to target.
  37512. * @param radius Optional. If a cached radius position already exists, overrides default.
  37513. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  37514. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  37515. * @param onAnimationEnd Callback triggered at the end of the framing animation
  37516. */
  37517. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  37518. /**
  37519. * Targets the given mesh with its children and updates zoom level accordingly.
  37520. * @param mesh The mesh to target.
  37521. * @param radius Optional. If a cached radius position already exists, overrides default.
  37522. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  37523. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  37524. * @param onAnimationEnd Callback triggered at the end of the framing animation
  37525. */
  37526. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  37527. /**
  37528. * Targets the given meshes with their children and updates zoom level accordingly.
  37529. * @param meshes The mesh to target.
  37530. * @param radius Optional. If a cached radius position already exists, overrides default.
  37531. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  37532. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  37533. * @param onAnimationEnd Callback triggered at the end of the framing animation
  37534. */
  37535. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  37536. /**
  37537. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  37538. * @param minimumWorld Determines the smaller position of the bounding box extend
  37539. * @param maximumWorld Determines the bigger position of the bounding box extend
  37540. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  37541. * @param onAnimationEnd Callback triggered at the end of the framing animation
  37542. */
  37543. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  37544. /**
  37545. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  37546. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  37547. * frustum width.
  37548. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  37549. * to fully enclose the mesh in the viewing frustum.
  37550. */
  37551. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  37552. /**
  37553. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  37554. * is automatically returned to its default position (expected to be above ground plane).
  37555. */
  37556. private _maintainCameraAboveGround;
  37557. /**
  37558. * Returns the frustum slope based on the canvas ratio and camera FOV
  37559. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  37560. */
  37561. private _getFrustumSlope;
  37562. /**
  37563. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  37564. */
  37565. private _clearAnimationLocks;
  37566. /**
  37567. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  37568. */
  37569. private _applyUserInteraction;
  37570. /**
  37571. * Stops and removes all animations that have been applied to the camera
  37572. */
  37573. stopAllAnimations(): void;
  37574. /**
  37575. * Gets a value indicating if the user is moving the camera
  37576. */
  37577. readonly isUserIsMoving: boolean;
  37578. /**
  37579. * The camera can move all the way towards the mesh.
  37580. */
  37581. static IgnoreBoundsSizeMode: number;
  37582. /**
  37583. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  37584. */
  37585. static FitFrustumSidesMode: number;
  37586. }
  37587. }
  37588. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  37589. import { Nullable } from "babylonjs/types";
  37590. import { Camera } from "babylonjs/Cameras/camera";
  37591. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37592. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  37593. /**
  37594. * Base class for Camera Pointer Inputs.
  37595. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  37596. * for example usage.
  37597. */
  37598. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  37599. /**
  37600. * Defines the camera the input is attached to.
  37601. */
  37602. abstract camera: Camera;
  37603. /**
  37604. * Whether keyboard modifier keys are pressed at time of last mouse event.
  37605. */
  37606. protected _altKey: boolean;
  37607. protected _ctrlKey: boolean;
  37608. protected _metaKey: boolean;
  37609. protected _shiftKey: boolean;
  37610. /**
  37611. * Which mouse buttons were pressed at time of last mouse event.
  37612. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  37613. */
  37614. protected _buttonsPressed: number;
  37615. /**
  37616. * Defines the buttons associated with the input to handle camera move.
  37617. */
  37618. buttons: number[];
  37619. /**
  37620. * Attach the input controls to a specific dom element to get the input from.
  37621. * @param element Defines the element the controls should be listened from
  37622. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37623. */
  37624. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37625. /**
  37626. * Detach the current controls from the specified dom element.
  37627. * @param element Defines the element to stop listening the inputs from
  37628. */
  37629. detachControl(element: Nullable<HTMLElement>): void;
  37630. /**
  37631. * Gets the class name of the current input.
  37632. * @returns the class name
  37633. */
  37634. getClassName(): string;
  37635. /**
  37636. * Get the friendly name associated with the input class.
  37637. * @returns the input friendly name
  37638. */
  37639. getSimpleName(): string;
  37640. /**
  37641. * Called on pointer POINTERDOUBLETAP event.
  37642. * Override this method to provide functionality on POINTERDOUBLETAP event.
  37643. */
  37644. protected onDoubleTap(type: string): void;
  37645. /**
  37646. * Called on pointer POINTERMOVE event if only a single touch is active.
  37647. * Override this method to provide functionality.
  37648. */
  37649. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  37650. /**
  37651. * Called on pointer POINTERMOVE event if multiple touches are active.
  37652. * Override this method to provide functionality.
  37653. */
  37654. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  37655. /**
  37656. * Called on JS contextmenu event.
  37657. * Override this method to provide functionality.
  37658. */
  37659. protected onContextMenu(evt: PointerEvent): void;
  37660. /**
  37661. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  37662. * press.
  37663. * Override this method to provide functionality.
  37664. */
  37665. protected onButtonDown(evt: PointerEvent): void;
  37666. /**
  37667. * Called each time a new POINTERUP event occurs. Ie, for each button
  37668. * release.
  37669. * Override this method to provide functionality.
  37670. */
  37671. protected onButtonUp(evt: PointerEvent): void;
  37672. /**
  37673. * Called when window becomes inactive.
  37674. * Override this method to provide functionality.
  37675. */
  37676. protected onLostFocus(): void;
  37677. private _pointerInput;
  37678. private _observer;
  37679. private _onLostFocus;
  37680. private pointA;
  37681. private pointB;
  37682. }
  37683. }
  37684. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  37685. import { Nullable } from "babylonjs/types";
  37686. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37687. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  37688. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  37689. /**
  37690. * Manage the pointers inputs to control an arc rotate camera.
  37691. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37692. */
  37693. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  37694. /**
  37695. * Defines the camera the input is attached to.
  37696. */
  37697. camera: ArcRotateCamera;
  37698. /**
  37699. * Gets the class name of the current input.
  37700. * @returns the class name
  37701. */
  37702. getClassName(): string;
  37703. /**
  37704. * Defines the buttons associated with the input to handle camera move.
  37705. */
  37706. buttons: number[];
  37707. /**
  37708. * Defines the pointer angular sensibility along the X axis or how fast is
  37709. * the camera rotating.
  37710. */
  37711. angularSensibilityX: number;
  37712. /**
  37713. * Defines the pointer angular sensibility along the Y axis or how fast is
  37714. * the camera rotating.
  37715. */
  37716. angularSensibilityY: number;
  37717. /**
  37718. * Defines the pointer pinch precision or how fast is the camera zooming.
  37719. */
  37720. pinchPrecision: number;
  37721. /**
  37722. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  37723. * from 0.
  37724. * It defines the percentage of current camera.radius to use as delta when
  37725. * pinch zoom is used.
  37726. */
  37727. pinchDeltaPercentage: number;
  37728. /**
  37729. * Defines the pointer panning sensibility or how fast is the camera moving.
  37730. */
  37731. panningSensibility: number;
  37732. /**
  37733. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  37734. */
  37735. multiTouchPanning: boolean;
  37736. /**
  37737. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  37738. * zoom (pinch) through multitouch.
  37739. */
  37740. multiTouchPanAndZoom: boolean;
  37741. /**
  37742. * Revers pinch action direction.
  37743. */
  37744. pinchInwards: boolean;
  37745. private _isPanClick;
  37746. private _twoFingerActivityCount;
  37747. private _isPinching;
  37748. /**
  37749. * Called on pointer POINTERMOVE event if only a single touch is active.
  37750. */
  37751. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  37752. /**
  37753. * Called on pointer POINTERDOUBLETAP event.
  37754. */
  37755. protected onDoubleTap(type: string): void;
  37756. /**
  37757. * Called on pointer POINTERMOVE event if multiple touches are active.
  37758. */
  37759. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  37760. /**
  37761. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  37762. * press.
  37763. */
  37764. protected onButtonDown(evt: PointerEvent): void;
  37765. /**
  37766. * Called each time a new POINTERUP event occurs. Ie, for each button
  37767. * release.
  37768. */
  37769. protected onButtonUp(evt: PointerEvent): void;
  37770. /**
  37771. * Called when window becomes inactive.
  37772. */
  37773. protected onLostFocus(): void;
  37774. }
  37775. }
  37776. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  37777. import { Nullable } from "babylonjs/types";
  37778. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37779. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37780. /**
  37781. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  37782. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37783. */
  37784. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  37785. /**
  37786. * Defines the camera the input is attached to.
  37787. */
  37788. camera: ArcRotateCamera;
  37789. /**
  37790. * Defines the list of key codes associated with the up action (increase alpha)
  37791. */
  37792. keysUp: number[];
  37793. /**
  37794. * Defines the list of key codes associated with the down action (decrease alpha)
  37795. */
  37796. keysDown: number[];
  37797. /**
  37798. * Defines the list of key codes associated with the left action (increase beta)
  37799. */
  37800. keysLeft: number[];
  37801. /**
  37802. * Defines the list of key codes associated with the right action (decrease beta)
  37803. */
  37804. keysRight: number[];
  37805. /**
  37806. * Defines the list of key codes associated with the reset action.
  37807. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  37808. */
  37809. keysReset: number[];
  37810. /**
  37811. * Defines the panning sensibility of the inputs.
  37812. * (How fast is the camera paning)
  37813. */
  37814. panningSensibility: number;
  37815. /**
  37816. * Defines the zooming sensibility of the inputs.
  37817. * (How fast is the camera zooming)
  37818. */
  37819. zoomingSensibility: number;
  37820. /**
  37821. * Defines wether maintaining the alt key down switch the movement mode from
  37822. * orientation to zoom.
  37823. */
  37824. useAltToZoom: boolean;
  37825. /**
  37826. * Rotation speed of the camera
  37827. */
  37828. angularSpeed: number;
  37829. private _keys;
  37830. private _ctrlPressed;
  37831. private _altPressed;
  37832. private _onCanvasBlurObserver;
  37833. private _onKeyboardObserver;
  37834. private _engine;
  37835. private _scene;
  37836. /**
  37837. * Attach the input controls to a specific dom element to get the input from.
  37838. * @param element Defines the element the controls should be listened from
  37839. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37840. */
  37841. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37842. /**
  37843. * Detach the current controls from the specified dom element.
  37844. * @param element Defines the element to stop listening the inputs from
  37845. */
  37846. detachControl(element: Nullable<HTMLElement>): void;
  37847. /**
  37848. * Update the current camera state depending on the inputs that have been used this frame.
  37849. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37850. */
  37851. checkInputs(): void;
  37852. /**
  37853. * Gets the class name of the current intput.
  37854. * @returns the class name
  37855. */
  37856. getClassName(): string;
  37857. /**
  37858. * Get the friendly name associated with the input class.
  37859. * @returns the input friendly name
  37860. */
  37861. getSimpleName(): string;
  37862. }
  37863. }
  37864. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  37865. import { Nullable } from "babylonjs/types";
  37866. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37867. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37868. /**
  37869. * Manage the mouse wheel inputs to control an arc rotate camera.
  37870. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37871. */
  37872. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  37873. /**
  37874. * Defines the camera the input is attached to.
  37875. */
  37876. camera: ArcRotateCamera;
  37877. /**
  37878. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  37879. */
  37880. wheelPrecision: number;
  37881. /**
  37882. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  37883. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  37884. */
  37885. wheelDeltaPercentage: number;
  37886. private _wheel;
  37887. private _observer;
  37888. private computeDeltaFromMouseWheelLegacyEvent;
  37889. /**
  37890. * Attach the input controls to a specific dom element to get the input from.
  37891. * @param element Defines the element the controls should be listened from
  37892. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37893. */
  37894. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37895. /**
  37896. * Detach the current controls from the specified dom element.
  37897. * @param element Defines the element to stop listening the inputs from
  37898. */
  37899. detachControl(element: Nullable<HTMLElement>): void;
  37900. /**
  37901. * Gets the class name of the current intput.
  37902. * @returns the class name
  37903. */
  37904. getClassName(): string;
  37905. /**
  37906. * Get the friendly name associated with the input class.
  37907. * @returns the input friendly name
  37908. */
  37909. getSimpleName(): string;
  37910. }
  37911. }
  37912. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  37913. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37914. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  37915. /**
  37916. * Default Inputs manager for the ArcRotateCamera.
  37917. * It groups all the default supported inputs for ease of use.
  37918. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37919. */
  37920. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  37921. /**
  37922. * Instantiates a new ArcRotateCameraInputsManager.
  37923. * @param camera Defines the camera the inputs belong to
  37924. */
  37925. constructor(camera: ArcRotateCamera);
  37926. /**
  37927. * Add mouse wheel input support to the input manager.
  37928. * @returns the current input manager
  37929. */
  37930. addMouseWheel(): ArcRotateCameraInputsManager;
  37931. /**
  37932. * Add pointers input support to the input manager.
  37933. * @returns the current input manager
  37934. */
  37935. addPointers(): ArcRotateCameraInputsManager;
  37936. /**
  37937. * Add keyboard input support to the input manager.
  37938. * @returns the current input manager
  37939. */
  37940. addKeyboard(): ArcRotateCameraInputsManager;
  37941. }
  37942. }
  37943. declare module "babylonjs/Cameras/arcRotateCamera" {
  37944. import { Observable } from "babylonjs/Misc/observable";
  37945. import { Nullable } from "babylonjs/types";
  37946. import { Scene } from "babylonjs/scene";
  37947. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  37948. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37949. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  37950. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  37951. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  37952. import { Camera } from "babylonjs/Cameras/camera";
  37953. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  37954. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  37955. import { Collider } from "babylonjs/Collisions/collider";
  37956. /**
  37957. * This represents an orbital type of camera.
  37958. *
  37959. * 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.
  37960. * 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.
  37961. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  37962. */
  37963. export class ArcRotateCamera extends TargetCamera {
  37964. /**
  37965. * Defines the rotation angle of the camera along the longitudinal axis.
  37966. */
  37967. alpha: number;
  37968. /**
  37969. * Defines the rotation angle of the camera along the latitudinal axis.
  37970. */
  37971. beta: number;
  37972. /**
  37973. * Defines the radius of the camera from it s target point.
  37974. */
  37975. radius: number;
  37976. protected _target: Vector3;
  37977. protected _targetHost: Nullable<AbstractMesh>;
  37978. /**
  37979. * Defines the target point of the camera.
  37980. * The camera looks towards it form the radius distance.
  37981. */
  37982. target: Vector3;
  37983. /**
  37984. * Define the current local position of the camera in the scene
  37985. */
  37986. position: Vector3;
  37987. protected _upVector: Vector3;
  37988. protected _upToYMatrix: Matrix;
  37989. protected _YToUpMatrix: Matrix;
  37990. /**
  37991. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  37992. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  37993. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  37994. */
  37995. upVector: Vector3;
  37996. /**
  37997. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  37998. */
  37999. setMatUp(): void;
  38000. /**
  38001. * Current inertia value on the longitudinal axis.
  38002. * The bigger this number the longer it will take for the camera to stop.
  38003. */
  38004. inertialAlphaOffset: number;
  38005. /**
  38006. * Current inertia value on the latitudinal axis.
  38007. * The bigger this number the longer it will take for the camera to stop.
  38008. */
  38009. inertialBetaOffset: number;
  38010. /**
  38011. * Current inertia value on the radius axis.
  38012. * The bigger this number the longer it will take for the camera to stop.
  38013. */
  38014. inertialRadiusOffset: number;
  38015. /**
  38016. * Minimum allowed angle on the longitudinal axis.
  38017. * This can help limiting how the Camera is able to move in the scene.
  38018. */
  38019. lowerAlphaLimit: Nullable<number>;
  38020. /**
  38021. * Maximum allowed angle on the longitudinal axis.
  38022. * This can help limiting how the Camera is able to move in the scene.
  38023. */
  38024. upperAlphaLimit: Nullable<number>;
  38025. /**
  38026. * Minimum allowed angle on the latitudinal axis.
  38027. * This can help limiting how the Camera is able to move in the scene.
  38028. */
  38029. lowerBetaLimit: number;
  38030. /**
  38031. * Maximum allowed angle on the latitudinal axis.
  38032. * This can help limiting how the Camera is able to move in the scene.
  38033. */
  38034. upperBetaLimit: number;
  38035. /**
  38036. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  38037. * This can help limiting how the Camera is able to move in the scene.
  38038. */
  38039. lowerRadiusLimit: Nullable<number>;
  38040. /**
  38041. * Maximum allowed distance of the camera to the target (The camera can not get further).
  38042. * This can help limiting how the Camera is able to move in the scene.
  38043. */
  38044. upperRadiusLimit: Nullable<number>;
  38045. /**
  38046. * Defines the current inertia value used during panning of the camera along the X axis.
  38047. */
  38048. inertialPanningX: number;
  38049. /**
  38050. * Defines the current inertia value used during panning of the camera along the Y axis.
  38051. */
  38052. inertialPanningY: number;
  38053. /**
  38054. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  38055. * Basically if your fingers moves away from more than this distance you will be considered
  38056. * in pinch mode.
  38057. */
  38058. pinchToPanMaxDistance: number;
  38059. /**
  38060. * Defines the maximum distance the camera can pan.
  38061. * This could help keeping the cammera always in your scene.
  38062. */
  38063. panningDistanceLimit: Nullable<number>;
  38064. /**
  38065. * Defines the target of the camera before paning.
  38066. */
  38067. panningOriginTarget: Vector3;
  38068. /**
  38069. * Defines the value of the inertia used during panning.
  38070. * 0 would mean stop inertia and one would mean no decelleration at all.
  38071. */
  38072. panningInertia: number;
  38073. /**
  38074. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  38075. */
  38076. angularSensibilityX: number;
  38077. /**
  38078. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  38079. */
  38080. angularSensibilityY: number;
  38081. /**
  38082. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  38083. */
  38084. pinchPrecision: number;
  38085. /**
  38086. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  38087. * It will be used instead of pinchDeltaPrecision if different from 0.
  38088. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  38089. */
  38090. pinchDeltaPercentage: number;
  38091. /**
  38092. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  38093. */
  38094. panningSensibility: number;
  38095. /**
  38096. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  38097. */
  38098. keysUp: number[];
  38099. /**
  38100. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  38101. */
  38102. keysDown: number[];
  38103. /**
  38104. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  38105. */
  38106. keysLeft: number[];
  38107. /**
  38108. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  38109. */
  38110. keysRight: number[];
  38111. /**
  38112. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  38113. */
  38114. wheelPrecision: number;
  38115. /**
  38116. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  38117. * It will be used instead of pinchDeltaPrecision if different from 0.
  38118. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  38119. */
  38120. wheelDeltaPercentage: number;
  38121. /**
  38122. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  38123. */
  38124. zoomOnFactor: number;
  38125. /**
  38126. * Defines a screen offset for the camera position.
  38127. */
  38128. targetScreenOffset: Vector2;
  38129. /**
  38130. * Allows the camera to be completely reversed.
  38131. * If false the camera can not arrive upside down.
  38132. */
  38133. allowUpsideDown: boolean;
  38134. /**
  38135. * Define if double tap/click is used to restore the previously saved state of the camera.
  38136. */
  38137. useInputToRestoreState: boolean;
  38138. /** @hidden */
  38139. _viewMatrix: Matrix;
  38140. /** @hidden */
  38141. _useCtrlForPanning: boolean;
  38142. /** @hidden */
  38143. _panningMouseButton: number;
  38144. /**
  38145. * Defines the input associated to the camera.
  38146. */
  38147. inputs: ArcRotateCameraInputsManager;
  38148. /** @hidden */
  38149. _reset: () => void;
  38150. /**
  38151. * Defines the allowed panning axis.
  38152. */
  38153. panningAxis: Vector3;
  38154. protected _localDirection: Vector3;
  38155. protected _transformedDirection: Vector3;
  38156. private _bouncingBehavior;
  38157. /**
  38158. * Gets the bouncing behavior of the camera if it has been enabled.
  38159. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  38160. */
  38161. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  38162. /**
  38163. * Defines if the bouncing behavior of the camera is enabled on the camera.
  38164. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  38165. */
  38166. useBouncingBehavior: boolean;
  38167. private _framingBehavior;
  38168. /**
  38169. * Gets the framing behavior of the camera if it has been enabled.
  38170. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  38171. */
  38172. readonly framingBehavior: Nullable<FramingBehavior>;
  38173. /**
  38174. * Defines if the framing behavior of the camera is enabled on the camera.
  38175. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  38176. */
  38177. useFramingBehavior: boolean;
  38178. private _autoRotationBehavior;
  38179. /**
  38180. * Gets the auto rotation behavior of the camera if it has been enabled.
  38181. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  38182. */
  38183. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  38184. /**
  38185. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  38186. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  38187. */
  38188. useAutoRotationBehavior: boolean;
  38189. /**
  38190. * Observable triggered when the mesh target has been changed on the camera.
  38191. */
  38192. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  38193. /**
  38194. * Event raised when the camera is colliding with a mesh.
  38195. */
  38196. onCollide: (collidedMesh: AbstractMesh) => void;
  38197. /**
  38198. * Defines whether the camera should check collision with the objects oh the scene.
  38199. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  38200. */
  38201. checkCollisions: boolean;
  38202. /**
  38203. * Defines the collision radius of the camera.
  38204. * This simulates a sphere around the camera.
  38205. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  38206. */
  38207. collisionRadius: Vector3;
  38208. protected _collider: Collider;
  38209. protected _previousPosition: Vector3;
  38210. protected _collisionVelocity: Vector3;
  38211. protected _newPosition: Vector3;
  38212. protected _previousAlpha: number;
  38213. protected _previousBeta: number;
  38214. protected _previousRadius: number;
  38215. protected _collisionTriggered: boolean;
  38216. protected _targetBoundingCenter: Nullable<Vector3>;
  38217. private _computationVector;
  38218. /**
  38219. * Instantiates a new ArcRotateCamera in a given scene
  38220. * @param name Defines the name of the camera
  38221. * @param alpha Defines the camera rotation along the logitudinal axis
  38222. * @param beta Defines the camera rotation along the latitudinal axis
  38223. * @param radius Defines the camera distance from its target
  38224. * @param target Defines the camera target
  38225. * @param scene Defines the scene the camera belongs to
  38226. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  38227. */
  38228. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  38229. /** @hidden */
  38230. _initCache(): void;
  38231. /** @hidden */
  38232. _updateCache(ignoreParentClass?: boolean): void;
  38233. protected _getTargetPosition(): Vector3;
  38234. private _storedAlpha;
  38235. private _storedBeta;
  38236. private _storedRadius;
  38237. private _storedTarget;
  38238. private _storedTargetScreenOffset;
  38239. /**
  38240. * Stores the current state of the camera (alpha, beta, radius and target)
  38241. * @returns the camera itself
  38242. */
  38243. storeState(): Camera;
  38244. /**
  38245. * @hidden
  38246. * Restored camera state. You must call storeState() first
  38247. */
  38248. _restoreStateValues(): boolean;
  38249. /** @hidden */
  38250. _isSynchronizedViewMatrix(): boolean;
  38251. /**
  38252. * Attached controls to the current camera.
  38253. * @param element Defines the element the controls should be listened from
  38254. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38255. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  38256. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  38257. */
  38258. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  38259. /**
  38260. * Detach the current controls from the camera.
  38261. * The camera will stop reacting to inputs.
  38262. * @param element Defines the element to stop listening the inputs from
  38263. */
  38264. detachControl(element: HTMLElement): void;
  38265. /** @hidden */
  38266. _checkInputs(): void;
  38267. protected _checkLimits(): void;
  38268. /**
  38269. * Rebuilds angles (alpha, beta) and radius from the give position and target
  38270. */
  38271. rebuildAnglesAndRadius(): void;
  38272. /**
  38273. * Use a position to define the current camera related information like alpha, beta and radius
  38274. * @param position Defines the position to set the camera at
  38275. */
  38276. setPosition(position: Vector3): void;
  38277. /**
  38278. * Defines the target the camera should look at.
  38279. * This will automatically adapt alpha beta and radius to fit within the new target.
  38280. * @param target Defines the new target as a Vector or a mesh
  38281. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  38282. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  38283. */
  38284. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  38285. /** @hidden */
  38286. _getViewMatrix(): Matrix;
  38287. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  38288. /**
  38289. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  38290. * @param meshes Defines the mesh to zoom on
  38291. * @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)
  38292. */
  38293. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  38294. /**
  38295. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  38296. * The target will be changed but the radius
  38297. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  38298. * @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)
  38299. */
  38300. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  38301. min: Vector3;
  38302. max: Vector3;
  38303. distance: number;
  38304. }, doNotUpdateMaxZ?: boolean): void;
  38305. /**
  38306. * @override
  38307. * Override Camera.createRigCamera
  38308. */
  38309. createRigCamera(name: string, cameraIndex: number): Camera;
  38310. /**
  38311. * @hidden
  38312. * @override
  38313. * Override Camera._updateRigCameras
  38314. */
  38315. _updateRigCameras(): void;
  38316. /**
  38317. * Destroy the camera and release the current resources hold by it.
  38318. */
  38319. dispose(): void;
  38320. /**
  38321. * Gets the current object class name.
  38322. * @return the class name
  38323. */
  38324. getClassName(): string;
  38325. }
  38326. }
  38327. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  38328. import { Behavior } from "babylonjs/Behaviors/behavior";
  38329. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38330. /**
  38331. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  38332. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  38333. */
  38334. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  38335. /**
  38336. * Gets the name of the behavior.
  38337. */
  38338. readonly name: string;
  38339. private _zoomStopsAnimation;
  38340. private _idleRotationSpeed;
  38341. private _idleRotationWaitTime;
  38342. private _idleRotationSpinupTime;
  38343. /**
  38344. * Sets the flag that indicates if user zooming should stop animation.
  38345. */
  38346. /**
  38347. * Gets the flag that indicates if user zooming should stop animation.
  38348. */
  38349. zoomStopsAnimation: boolean;
  38350. /**
  38351. * Sets the default speed at which the camera rotates around the model.
  38352. */
  38353. /**
  38354. * Gets the default speed at which the camera rotates around the model.
  38355. */
  38356. idleRotationSpeed: number;
  38357. /**
  38358. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  38359. */
  38360. /**
  38361. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  38362. */
  38363. idleRotationWaitTime: number;
  38364. /**
  38365. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  38366. */
  38367. /**
  38368. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  38369. */
  38370. idleRotationSpinupTime: number;
  38371. /**
  38372. * Gets a value indicating if the camera is currently rotating because of this behavior
  38373. */
  38374. readonly rotationInProgress: boolean;
  38375. private _onPrePointerObservableObserver;
  38376. private _onAfterCheckInputsObserver;
  38377. private _attachedCamera;
  38378. private _isPointerDown;
  38379. private _lastFrameTime;
  38380. private _lastInteractionTime;
  38381. private _cameraRotationSpeed;
  38382. /**
  38383. * Initializes the behavior.
  38384. */
  38385. init(): void;
  38386. /**
  38387. * Attaches the behavior to its arc rotate camera.
  38388. * @param camera Defines the camera to attach the behavior to
  38389. */
  38390. attach(camera: ArcRotateCamera): void;
  38391. /**
  38392. * Detaches the behavior from its current arc rotate camera.
  38393. */
  38394. detach(): void;
  38395. /**
  38396. * Returns true if user is scrolling.
  38397. * @return true if user is scrolling.
  38398. */
  38399. private _userIsZooming;
  38400. private _lastFrameRadius;
  38401. private _shouldAnimationStopForInteraction;
  38402. /**
  38403. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  38404. */
  38405. private _applyUserInteraction;
  38406. private _userIsMoving;
  38407. }
  38408. }
  38409. declare module "babylonjs/Behaviors/Cameras/index" {
  38410. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  38411. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  38412. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  38413. }
  38414. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  38415. import { Mesh } from "babylonjs/Meshes/mesh";
  38416. import { TransformNode } from "babylonjs/Meshes/transformNode";
  38417. import { Behavior } from "babylonjs/Behaviors/behavior";
  38418. /**
  38419. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  38420. */
  38421. export class AttachToBoxBehavior implements Behavior<Mesh> {
  38422. private ui;
  38423. /**
  38424. * The name of the behavior
  38425. */
  38426. name: string;
  38427. /**
  38428. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  38429. */
  38430. distanceAwayFromFace: number;
  38431. /**
  38432. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  38433. */
  38434. distanceAwayFromBottomOfFace: number;
  38435. private _faceVectors;
  38436. private _target;
  38437. private _scene;
  38438. private _onRenderObserver;
  38439. private _tmpMatrix;
  38440. private _tmpVector;
  38441. /**
  38442. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  38443. * @param ui The transform node that should be attched to the mesh
  38444. */
  38445. constructor(ui: TransformNode);
  38446. /**
  38447. * Initializes the behavior
  38448. */
  38449. init(): void;
  38450. private _closestFace;
  38451. private _zeroVector;
  38452. private _lookAtTmpMatrix;
  38453. private _lookAtToRef;
  38454. /**
  38455. * Attaches the AttachToBoxBehavior to the passed in mesh
  38456. * @param target The mesh that the specified node will be attached to
  38457. */
  38458. attach(target: Mesh): void;
  38459. /**
  38460. * Detaches the behavior from the mesh
  38461. */
  38462. detach(): void;
  38463. }
  38464. }
  38465. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  38466. import { Behavior } from "babylonjs/Behaviors/behavior";
  38467. import { Mesh } from "babylonjs/Meshes/mesh";
  38468. /**
  38469. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  38470. */
  38471. export class FadeInOutBehavior implements Behavior<Mesh> {
  38472. /**
  38473. * Time in milliseconds to delay before fading in (Default: 0)
  38474. */
  38475. delay: number;
  38476. /**
  38477. * Time in milliseconds for the mesh to fade in (Default: 300)
  38478. */
  38479. fadeInTime: number;
  38480. private _millisecondsPerFrame;
  38481. private _hovered;
  38482. private _hoverValue;
  38483. private _ownerNode;
  38484. /**
  38485. * Instatiates the FadeInOutBehavior
  38486. */
  38487. constructor();
  38488. /**
  38489. * The name of the behavior
  38490. */
  38491. readonly name: string;
  38492. /**
  38493. * Initializes the behavior
  38494. */
  38495. init(): void;
  38496. /**
  38497. * Attaches the fade behavior on the passed in mesh
  38498. * @param ownerNode The mesh that will be faded in/out once attached
  38499. */
  38500. attach(ownerNode: Mesh): void;
  38501. /**
  38502. * Detaches the behavior from the mesh
  38503. */
  38504. detach(): void;
  38505. /**
  38506. * Triggers the mesh to begin fading in or out
  38507. * @param value if the object should fade in or out (true to fade in)
  38508. */
  38509. fadeIn(value: boolean): void;
  38510. private _update;
  38511. private _setAllVisibility;
  38512. }
  38513. }
  38514. declare module "babylonjs/Misc/pivotTools" {
  38515. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38516. /**
  38517. * Class containing a set of static utilities functions for managing Pivots
  38518. * @hidden
  38519. */
  38520. export class PivotTools {
  38521. private static _PivotCached;
  38522. private static _OldPivotPoint;
  38523. private static _PivotTranslation;
  38524. private static _PivotTmpVector;
  38525. /** @hidden */
  38526. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  38527. /** @hidden */
  38528. static _RestorePivotPoint(mesh: AbstractMesh): void;
  38529. }
  38530. }
  38531. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  38532. import { Scene } from "babylonjs/scene";
  38533. import { Vector4 } from "babylonjs/Maths/math.vector";
  38534. import { Mesh } from "babylonjs/Meshes/mesh";
  38535. import { Nullable } from "babylonjs/types";
  38536. import { Plane } from "babylonjs/Maths/math.plane";
  38537. /**
  38538. * Class containing static functions to help procedurally build meshes
  38539. */
  38540. export class PlaneBuilder {
  38541. /**
  38542. * Creates a plane mesh
  38543. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  38544. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  38545. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  38546. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  38547. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  38548. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  38549. * @param name defines the name of the mesh
  38550. * @param options defines the options used to create the mesh
  38551. * @param scene defines the hosting scene
  38552. * @returns the plane mesh
  38553. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  38554. */
  38555. static CreatePlane(name: string, options: {
  38556. size?: number;
  38557. width?: number;
  38558. height?: number;
  38559. sideOrientation?: number;
  38560. frontUVs?: Vector4;
  38561. backUVs?: Vector4;
  38562. updatable?: boolean;
  38563. sourcePlane?: Plane;
  38564. }, scene?: Nullable<Scene>): Mesh;
  38565. }
  38566. }
  38567. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  38568. import { Behavior } from "babylonjs/Behaviors/behavior";
  38569. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38570. import { Observable } from "babylonjs/Misc/observable";
  38571. import { Vector3 } from "babylonjs/Maths/math.vector";
  38572. import { Ray } from "babylonjs/Culling/ray";
  38573. import "babylonjs/Meshes/Builders/planeBuilder";
  38574. /**
  38575. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  38576. */
  38577. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  38578. private static _AnyMouseID;
  38579. /**
  38580. * Abstract mesh the behavior is set on
  38581. */
  38582. attachedNode: AbstractMesh;
  38583. private _dragPlane;
  38584. private _scene;
  38585. private _pointerObserver;
  38586. private _beforeRenderObserver;
  38587. private static _planeScene;
  38588. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  38589. /**
  38590. * 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)
  38591. */
  38592. maxDragAngle: number;
  38593. /**
  38594. * @hidden
  38595. */
  38596. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  38597. /**
  38598. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  38599. */
  38600. currentDraggingPointerID: number;
  38601. /**
  38602. * The last position where the pointer hit the drag plane in world space
  38603. */
  38604. lastDragPosition: Vector3;
  38605. /**
  38606. * If the behavior is currently in a dragging state
  38607. */
  38608. dragging: boolean;
  38609. /**
  38610. * 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)
  38611. */
  38612. dragDeltaRatio: number;
  38613. /**
  38614. * If the drag plane orientation should be updated during the dragging (Default: true)
  38615. */
  38616. updateDragPlane: boolean;
  38617. private _debugMode;
  38618. private _moving;
  38619. /**
  38620. * Fires each time the attached mesh is dragged with the pointer
  38621. * * delta between last drag position and current drag position in world space
  38622. * * dragDistance along the drag axis
  38623. * * dragPlaneNormal normal of the current drag plane used during the drag
  38624. * * dragPlanePoint in world space where the drag intersects the drag plane
  38625. */
  38626. onDragObservable: Observable<{
  38627. delta: Vector3;
  38628. dragPlanePoint: Vector3;
  38629. dragPlaneNormal: Vector3;
  38630. dragDistance: number;
  38631. pointerId: number;
  38632. }>;
  38633. /**
  38634. * Fires each time a drag begins (eg. mouse down on mesh)
  38635. */
  38636. onDragStartObservable: Observable<{
  38637. dragPlanePoint: Vector3;
  38638. pointerId: number;
  38639. }>;
  38640. /**
  38641. * Fires each time a drag ends (eg. mouse release after drag)
  38642. */
  38643. onDragEndObservable: Observable<{
  38644. dragPlanePoint: Vector3;
  38645. pointerId: number;
  38646. }>;
  38647. /**
  38648. * If the attached mesh should be moved when dragged
  38649. */
  38650. moveAttached: boolean;
  38651. /**
  38652. * If the drag behavior will react to drag events (Default: true)
  38653. */
  38654. enabled: boolean;
  38655. /**
  38656. * If pointer events should start and release the drag (Default: true)
  38657. */
  38658. startAndReleaseDragOnPointerEvents: boolean;
  38659. /**
  38660. * If camera controls should be detached during the drag
  38661. */
  38662. detachCameraControls: boolean;
  38663. /**
  38664. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  38665. */
  38666. useObjectOrienationForDragging: boolean;
  38667. private _options;
  38668. /**
  38669. * Creates a pointer drag behavior that can be attached to a mesh
  38670. * @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)
  38671. */
  38672. constructor(options?: {
  38673. dragAxis?: Vector3;
  38674. dragPlaneNormal?: Vector3;
  38675. });
  38676. /**
  38677. * Predicate to determine if it is valid to move the object to a new position when it is moved
  38678. */
  38679. validateDrag: (targetPosition: Vector3) => boolean;
  38680. /**
  38681. * The name of the behavior
  38682. */
  38683. readonly name: string;
  38684. /**
  38685. * Initializes the behavior
  38686. */
  38687. init(): void;
  38688. private _tmpVector;
  38689. private _alternatePickedPoint;
  38690. private _worldDragAxis;
  38691. private _targetPosition;
  38692. private _attachedElement;
  38693. /**
  38694. * Attaches the drag behavior the passed in mesh
  38695. * @param ownerNode The mesh that will be dragged around once attached
  38696. * @param predicate Predicate to use for pick filtering
  38697. */
  38698. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  38699. /**
  38700. * Force relase the drag action by code.
  38701. */
  38702. releaseDrag(): void;
  38703. private _startDragRay;
  38704. private _lastPointerRay;
  38705. /**
  38706. * Simulates the start of a pointer drag event on the behavior
  38707. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  38708. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  38709. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  38710. */
  38711. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  38712. private _startDrag;
  38713. private _dragDelta;
  38714. private _moveDrag;
  38715. private _pickWithRayOnDragPlane;
  38716. private _pointA;
  38717. private _pointB;
  38718. private _pointC;
  38719. private _lineA;
  38720. private _lineB;
  38721. private _localAxis;
  38722. private _lookAt;
  38723. private _updateDragPlanePosition;
  38724. /**
  38725. * Detaches the behavior from the mesh
  38726. */
  38727. detach(): void;
  38728. }
  38729. }
  38730. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  38731. import { Mesh } from "babylonjs/Meshes/mesh";
  38732. import { Behavior } from "babylonjs/Behaviors/behavior";
  38733. /**
  38734. * A behavior that when attached to a mesh will allow the mesh to be scaled
  38735. */
  38736. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  38737. private _dragBehaviorA;
  38738. private _dragBehaviorB;
  38739. private _startDistance;
  38740. private _initialScale;
  38741. private _targetScale;
  38742. private _ownerNode;
  38743. private _sceneRenderObserver;
  38744. /**
  38745. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  38746. */
  38747. constructor();
  38748. /**
  38749. * The name of the behavior
  38750. */
  38751. readonly name: string;
  38752. /**
  38753. * Initializes the behavior
  38754. */
  38755. init(): void;
  38756. private _getCurrentDistance;
  38757. /**
  38758. * Attaches the scale behavior the passed in mesh
  38759. * @param ownerNode The mesh that will be scaled around once attached
  38760. */
  38761. attach(ownerNode: Mesh): void;
  38762. /**
  38763. * Detaches the behavior from the mesh
  38764. */
  38765. detach(): void;
  38766. }
  38767. }
  38768. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  38769. import { Behavior } from "babylonjs/Behaviors/behavior";
  38770. import { Mesh } from "babylonjs/Meshes/mesh";
  38771. import { Observable } from "babylonjs/Misc/observable";
  38772. /**
  38773. * 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
  38774. */
  38775. export class SixDofDragBehavior implements Behavior<Mesh> {
  38776. private static _virtualScene;
  38777. private _ownerNode;
  38778. private _sceneRenderObserver;
  38779. private _scene;
  38780. private _targetPosition;
  38781. private _virtualOriginMesh;
  38782. private _virtualDragMesh;
  38783. private _pointerObserver;
  38784. private _moving;
  38785. private _startingOrientation;
  38786. /**
  38787. * 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)
  38788. */
  38789. private zDragFactor;
  38790. /**
  38791. * If the object should rotate to face the drag origin
  38792. */
  38793. rotateDraggedObject: boolean;
  38794. /**
  38795. * If the behavior is currently in a dragging state
  38796. */
  38797. dragging: boolean;
  38798. /**
  38799. * 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)
  38800. */
  38801. dragDeltaRatio: number;
  38802. /**
  38803. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  38804. */
  38805. currentDraggingPointerID: number;
  38806. /**
  38807. * If camera controls should be detached during the drag
  38808. */
  38809. detachCameraControls: boolean;
  38810. /**
  38811. * Fires each time a drag starts
  38812. */
  38813. onDragStartObservable: Observable<{}>;
  38814. /**
  38815. * Fires each time a drag ends (eg. mouse release after drag)
  38816. */
  38817. onDragEndObservable: Observable<{}>;
  38818. /**
  38819. * 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
  38820. */
  38821. constructor();
  38822. /**
  38823. * The name of the behavior
  38824. */
  38825. readonly name: string;
  38826. /**
  38827. * Initializes the behavior
  38828. */
  38829. init(): void;
  38830. /**
  38831. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  38832. */
  38833. private readonly _pointerCamera;
  38834. /**
  38835. * Attaches the scale behavior the passed in mesh
  38836. * @param ownerNode The mesh that will be scaled around once attached
  38837. */
  38838. attach(ownerNode: Mesh): void;
  38839. /**
  38840. * Detaches the behavior from the mesh
  38841. */
  38842. detach(): void;
  38843. }
  38844. }
  38845. declare module "babylonjs/Behaviors/Meshes/index" {
  38846. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  38847. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  38848. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  38849. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  38850. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  38851. }
  38852. declare module "babylonjs/Behaviors/index" {
  38853. export * from "babylonjs/Behaviors/behavior";
  38854. export * from "babylonjs/Behaviors/Cameras/index";
  38855. export * from "babylonjs/Behaviors/Meshes/index";
  38856. }
  38857. declare module "babylonjs/Bones/boneIKController" {
  38858. import { Bone } from "babylonjs/Bones/bone";
  38859. import { Vector3 } from "babylonjs/Maths/math.vector";
  38860. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38861. import { Nullable } from "babylonjs/types";
  38862. /**
  38863. * Class used to apply inverse kinematics to bones
  38864. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  38865. */
  38866. export class BoneIKController {
  38867. private static _tmpVecs;
  38868. private static _tmpQuat;
  38869. private static _tmpMats;
  38870. /**
  38871. * Gets or sets the target mesh
  38872. */
  38873. targetMesh: AbstractMesh;
  38874. /** Gets or sets the mesh used as pole */
  38875. poleTargetMesh: AbstractMesh;
  38876. /**
  38877. * Gets or sets the bone used as pole
  38878. */
  38879. poleTargetBone: Nullable<Bone>;
  38880. /**
  38881. * Gets or sets the target position
  38882. */
  38883. targetPosition: Vector3;
  38884. /**
  38885. * Gets or sets the pole target position
  38886. */
  38887. poleTargetPosition: Vector3;
  38888. /**
  38889. * Gets or sets the pole target local offset
  38890. */
  38891. poleTargetLocalOffset: Vector3;
  38892. /**
  38893. * Gets or sets the pole angle
  38894. */
  38895. poleAngle: number;
  38896. /**
  38897. * Gets or sets the mesh associated with the controller
  38898. */
  38899. mesh: AbstractMesh;
  38900. /**
  38901. * The amount to slerp (spherical linear interpolation) to the target. Set this to a value between 0 and 1 (a value of 1 disables slerp)
  38902. */
  38903. slerpAmount: number;
  38904. private _bone1Quat;
  38905. private _bone1Mat;
  38906. private _bone2Ang;
  38907. private _bone1;
  38908. private _bone2;
  38909. private _bone1Length;
  38910. private _bone2Length;
  38911. private _maxAngle;
  38912. private _maxReach;
  38913. private _rightHandedSystem;
  38914. private _bendAxis;
  38915. private _slerping;
  38916. private _adjustRoll;
  38917. /**
  38918. * Gets or sets maximum allowed angle
  38919. */
  38920. maxAngle: number;
  38921. /**
  38922. * Creates a new BoneIKController
  38923. * @param mesh defines the mesh to control
  38924. * @param bone defines the bone to control
  38925. * @param options defines options to set up the controller
  38926. */
  38927. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  38928. targetMesh?: AbstractMesh;
  38929. poleTargetMesh?: AbstractMesh;
  38930. poleTargetBone?: Bone;
  38931. poleTargetLocalOffset?: Vector3;
  38932. poleAngle?: number;
  38933. bendAxis?: Vector3;
  38934. maxAngle?: number;
  38935. slerpAmount?: number;
  38936. });
  38937. private _setMaxAngle;
  38938. /**
  38939. * Force the controller to update the bones
  38940. */
  38941. update(): void;
  38942. }
  38943. }
  38944. declare module "babylonjs/Bones/boneLookController" {
  38945. import { Vector3 } from "babylonjs/Maths/math.vector";
  38946. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38947. import { Bone } from "babylonjs/Bones/bone";
  38948. import { Space } from "babylonjs/Maths/math.axis";
  38949. /**
  38950. * Class used to make a bone look toward a point in space
  38951. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  38952. */
  38953. export class BoneLookController {
  38954. private static _tmpVecs;
  38955. private static _tmpQuat;
  38956. private static _tmpMats;
  38957. /**
  38958. * The target Vector3 that the bone will look at
  38959. */
  38960. target: Vector3;
  38961. /**
  38962. * The mesh that the bone is attached to
  38963. */
  38964. mesh: AbstractMesh;
  38965. /**
  38966. * The bone that will be looking to the target
  38967. */
  38968. bone: Bone;
  38969. /**
  38970. * The up axis of the coordinate system that is used when the bone is rotated
  38971. */
  38972. upAxis: Vector3;
  38973. /**
  38974. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  38975. */
  38976. upAxisSpace: Space;
  38977. /**
  38978. * Used to make an adjustment to the yaw of the bone
  38979. */
  38980. adjustYaw: number;
  38981. /**
  38982. * Used to make an adjustment to the pitch of the bone
  38983. */
  38984. adjustPitch: number;
  38985. /**
  38986. * Used to make an adjustment to the roll of the bone
  38987. */
  38988. adjustRoll: number;
  38989. /**
  38990. * 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)
  38991. */
  38992. slerpAmount: number;
  38993. private _minYaw;
  38994. private _maxYaw;
  38995. private _minPitch;
  38996. private _maxPitch;
  38997. private _minYawSin;
  38998. private _minYawCos;
  38999. private _maxYawSin;
  39000. private _maxYawCos;
  39001. private _midYawConstraint;
  39002. private _minPitchTan;
  39003. private _maxPitchTan;
  39004. private _boneQuat;
  39005. private _slerping;
  39006. private _transformYawPitch;
  39007. private _transformYawPitchInv;
  39008. private _firstFrameSkipped;
  39009. private _yawRange;
  39010. private _fowardAxis;
  39011. /**
  39012. * Gets or sets the minimum yaw angle that the bone can look to
  39013. */
  39014. minYaw: number;
  39015. /**
  39016. * Gets or sets the maximum yaw angle that the bone can look to
  39017. */
  39018. maxYaw: number;
  39019. /**
  39020. * Gets or sets the minimum pitch angle that the bone can look to
  39021. */
  39022. minPitch: number;
  39023. /**
  39024. * Gets or sets the maximum pitch angle that the bone can look to
  39025. */
  39026. maxPitch: number;
  39027. /**
  39028. * Create a BoneLookController
  39029. * @param mesh the mesh that the bone belongs to
  39030. * @param bone the bone that will be looking to the target
  39031. * @param target the target Vector3 to look at
  39032. * @param options optional settings:
  39033. * * maxYaw: the maximum angle the bone will yaw to
  39034. * * minYaw: the minimum angle the bone will yaw to
  39035. * * maxPitch: the maximum angle the bone will pitch to
  39036. * * minPitch: the minimum angle the bone will yaw to
  39037. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  39038. * * upAxis: the up axis of the coordinate system
  39039. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  39040. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  39041. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  39042. * * adjustYaw: used to make an adjustment to the yaw of the bone
  39043. * * adjustPitch: used to make an adjustment to the pitch of the bone
  39044. * * adjustRoll: used to make an adjustment to the roll of the bone
  39045. **/
  39046. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  39047. maxYaw?: number;
  39048. minYaw?: number;
  39049. maxPitch?: number;
  39050. minPitch?: number;
  39051. slerpAmount?: number;
  39052. upAxis?: Vector3;
  39053. upAxisSpace?: Space;
  39054. yawAxis?: Vector3;
  39055. pitchAxis?: Vector3;
  39056. adjustYaw?: number;
  39057. adjustPitch?: number;
  39058. adjustRoll?: number;
  39059. });
  39060. /**
  39061. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  39062. */
  39063. update(): void;
  39064. private _getAngleDiff;
  39065. private _getAngleBetween;
  39066. private _isAngleBetween;
  39067. }
  39068. }
  39069. declare module "babylonjs/Bones/index" {
  39070. export * from "babylonjs/Bones/bone";
  39071. export * from "babylonjs/Bones/boneIKController";
  39072. export * from "babylonjs/Bones/boneLookController";
  39073. export * from "babylonjs/Bones/skeleton";
  39074. }
  39075. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  39076. import { Nullable } from "babylonjs/types";
  39077. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39078. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39079. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  39080. /**
  39081. * Manage the gamepad inputs to control an arc rotate camera.
  39082. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39083. */
  39084. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  39085. /**
  39086. * Defines the camera the input is attached to.
  39087. */
  39088. camera: ArcRotateCamera;
  39089. /**
  39090. * Defines the gamepad the input is gathering event from.
  39091. */
  39092. gamepad: Nullable<Gamepad>;
  39093. /**
  39094. * Defines the gamepad rotation sensiblity.
  39095. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  39096. */
  39097. gamepadRotationSensibility: number;
  39098. /**
  39099. * Defines the gamepad move sensiblity.
  39100. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  39101. */
  39102. gamepadMoveSensibility: number;
  39103. private _yAxisScale;
  39104. /**
  39105. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  39106. */
  39107. invertYAxis: boolean;
  39108. private _onGamepadConnectedObserver;
  39109. private _onGamepadDisconnectedObserver;
  39110. /**
  39111. * Attach the input controls to a specific dom element to get the input from.
  39112. * @param element Defines the element the controls should be listened from
  39113. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39114. */
  39115. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39116. /**
  39117. * Detach the current controls from the specified dom element.
  39118. * @param element Defines the element to stop listening the inputs from
  39119. */
  39120. detachControl(element: Nullable<HTMLElement>): void;
  39121. /**
  39122. * Update the current camera state depending on the inputs that have been used this frame.
  39123. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39124. */
  39125. checkInputs(): void;
  39126. /**
  39127. * Gets the class name of the current intput.
  39128. * @returns the class name
  39129. */
  39130. getClassName(): string;
  39131. /**
  39132. * Get the friendly name associated with the input class.
  39133. * @returns the input friendly name
  39134. */
  39135. getSimpleName(): string;
  39136. }
  39137. }
  39138. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  39139. import { Nullable } from "babylonjs/types";
  39140. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39141. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39142. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  39143. interface ArcRotateCameraInputsManager {
  39144. /**
  39145. * Add orientation input support to the input manager.
  39146. * @returns the current input manager
  39147. */
  39148. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  39149. }
  39150. }
  39151. /**
  39152. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  39153. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39154. */
  39155. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  39156. /**
  39157. * Defines the camera the input is attached to.
  39158. */
  39159. camera: ArcRotateCamera;
  39160. /**
  39161. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  39162. */
  39163. alphaCorrection: number;
  39164. /**
  39165. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  39166. */
  39167. gammaCorrection: number;
  39168. private _alpha;
  39169. private _gamma;
  39170. private _dirty;
  39171. private _deviceOrientationHandler;
  39172. /**
  39173. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  39174. */
  39175. constructor();
  39176. /**
  39177. * Attach the input controls to a specific dom element to get the input from.
  39178. * @param element Defines the element the controls should be listened from
  39179. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39180. */
  39181. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39182. /** @hidden */
  39183. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  39184. /**
  39185. * Update the current camera state depending on the inputs that have been used this frame.
  39186. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39187. */
  39188. checkInputs(): void;
  39189. /**
  39190. * Detach the current controls from the specified dom element.
  39191. * @param element Defines the element to stop listening the inputs from
  39192. */
  39193. detachControl(element: Nullable<HTMLElement>): void;
  39194. /**
  39195. * Gets the class name of the current intput.
  39196. * @returns the class name
  39197. */
  39198. getClassName(): string;
  39199. /**
  39200. * Get the friendly name associated with the input class.
  39201. * @returns the input friendly name
  39202. */
  39203. getSimpleName(): string;
  39204. }
  39205. }
  39206. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  39207. import { Nullable } from "babylonjs/types";
  39208. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39209. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  39210. /**
  39211. * Listen to mouse events to control the camera.
  39212. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39213. */
  39214. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  39215. /**
  39216. * Defines the camera the input is attached to.
  39217. */
  39218. camera: FlyCamera;
  39219. /**
  39220. * Defines if touch is enabled. (Default is true.)
  39221. */
  39222. touchEnabled: boolean;
  39223. /**
  39224. * Defines the buttons associated with the input to handle camera rotation.
  39225. */
  39226. buttons: number[];
  39227. /**
  39228. * Assign buttons for Yaw control.
  39229. */
  39230. buttonsYaw: number[];
  39231. /**
  39232. * Assign buttons for Pitch control.
  39233. */
  39234. buttonsPitch: number[];
  39235. /**
  39236. * Assign buttons for Roll control.
  39237. */
  39238. buttonsRoll: number[];
  39239. /**
  39240. * Detect if any button is being pressed while mouse is moved.
  39241. * -1 = Mouse locked.
  39242. * 0 = Left button.
  39243. * 1 = Middle Button.
  39244. * 2 = Right Button.
  39245. */
  39246. activeButton: number;
  39247. /**
  39248. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  39249. * Higher values reduce its sensitivity.
  39250. */
  39251. angularSensibility: number;
  39252. private _mousemoveCallback;
  39253. private _observer;
  39254. private _rollObserver;
  39255. private previousPosition;
  39256. private noPreventDefault;
  39257. private element;
  39258. /**
  39259. * Listen to mouse events to control the camera.
  39260. * @param touchEnabled Define if touch is enabled. (Default is true.)
  39261. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39262. */
  39263. constructor(touchEnabled?: boolean);
  39264. /**
  39265. * Attach the mouse control to the HTML DOM element.
  39266. * @param element Defines the element that listens to the input events.
  39267. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  39268. */
  39269. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39270. /**
  39271. * Detach the current controls from the specified dom element.
  39272. * @param element Defines the element to stop listening the inputs from
  39273. */
  39274. detachControl(element: Nullable<HTMLElement>): void;
  39275. /**
  39276. * Gets the class name of the current input.
  39277. * @returns the class name.
  39278. */
  39279. getClassName(): string;
  39280. /**
  39281. * Get the friendly name associated with the input class.
  39282. * @returns the input's friendly name.
  39283. */
  39284. getSimpleName(): string;
  39285. private _pointerInput;
  39286. private _onMouseMove;
  39287. /**
  39288. * Rotate camera by mouse offset.
  39289. */
  39290. private rotateCamera;
  39291. }
  39292. }
  39293. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  39294. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  39295. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  39296. /**
  39297. * Default Inputs manager for the FlyCamera.
  39298. * It groups all the default supported inputs for ease of use.
  39299. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39300. */
  39301. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  39302. /**
  39303. * Instantiates a new FlyCameraInputsManager.
  39304. * @param camera Defines the camera the inputs belong to.
  39305. */
  39306. constructor(camera: FlyCamera);
  39307. /**
  39308. * Add keyboard input support to the input manager.
  39309. * @returns the new FlyCameraKeyboardMoveInput().
  39310. */
  39311. addKeyboard(): FlyCameraInputsManager;
  39312. /**
  39313. * Add mouse input support to the input manager.
  39314. * @param touchEnabled Enable touch screen support.
  39315. * @returns the new FlyCameraMouseInput().
  39316. */
  39317. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  39318. }
  39319. }
  39320. declare module "babylonjs/Cameras/flyCamera" {
  39321. import { Scene } from "babylonjs/scene";
  39322. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  39323. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39324. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  39325. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  39326. /**
  39327. * This is a flying camera, designed for 3D movement and rotation in all directions,
  39328. * such as in a 3D Space Shooter or a Flight Simulator.
  39329. */
  39330. export class FlyCamera extends TargetCamera {
  39331. /**
  39332. * Define the collision ellipsoid of the camera.
  39333. * This is helpful for simulating a camera body, like a player's body.
  39334. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  39335. */
  39336. ellipsoid: Vector3;
  39337. /**
  39338. * Define an offset for the position of the ellipsoid around the camera.
  39339. * This can be helpful if the camera is attached away from the player's body center,
  39340. * such as at its head.
  39341. */
  39342. ellipsoidOffset: Vector3;
  39343. /**
  39344. * Enable or disable collisions of the camera with the rest of the scene objects.
  39345. */
  39346. checkCollisions: boolean;
  39347. /**
  39348. * Enable or disable gravity on the camera.
  39349. */
  39350. applyGravity: boolean;
  39351. /**
  39352. * Define the current direction the camera is moving to.
  39353. */
  39354. cameraDirection: Vector3;
  39355. /**
  39356. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  39357. * This overrides and empties cameraRotation.
  39358. */
  39359. rotationQuaternion: Quaternion;
  39360. /**
  39361. * Track Roll to maintain the wanted Rolling when looking around.
  39362. */
  39363. _trackRoll: number;
  39364. /**
  39365. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  39366. */
  39367. rollCorrect: number;
  39368. /**
  39369. * Mimic a banked turn, Rolling the camera when Yawing.
  39370. * It's recommended to use rollCorrect = 10 for faster banking correction.
  39371. */
  39372. bankedTurn: boolean;
  39373. /**
  39374. * Limit in radians for how much Roll banking will add. (Default: 90°)
  39375. */
  39376. bankedTurnLimit: number;
  39377. /**
  39378. * Value of 0 disables the banked Roll.
  39379. * Value of 1 is equal to the Yaw angle in radians.
  39380. */
  39381. bankedTurnMultiplier: number;
  39382. /**
  39383. * The inputs manager loads all the input sources, such as keyboard and mouse.
  39384. */
  39385. inputs: FlyCameraInputsManager;
  39386. /**
  39387. * Gets the input sensibility for mouse input.
  39388. * Higher values reduce sensitivity.
  39389. */
  39390. /**
  39391. * Sets the input sensibility for a mouse input.
  39392. * Higher values reduce sensitivity.
  39393. */
  39394. angularSensibility: number;
  39395. /**
  39396. * Get the keys for camera movement forward.
  39397. */
  39398. /**
  39399. * Set the keys for camera movement forward.
  39400. */
  39401. keysForward: number[];
  39402. /**
  39403. * Get the keys for camera movement backward.
  39404. */
  39405. keysBackward: number[];
  39406. /**
  39407. * Get the keys for camera movement up.
  39408. */
  39409. /**
  39410. * Set the keys for camera movement up.
  39411. */
  39412. keysUp: number[];
  39413. /**
  39414. * Get the keys for camera movement down.
  39415. */
  39416. /**
  39417. * Set the keys for camera movement down.
  39418. */
  39419. keysDown: number[];
  39420. /**
  39421. * Get the keys for camera movement left.
  39422. */
  39423. /**
  39424. * Set the keys for camera movement left.
  39425. */
  39426. keysLeft: number[];
  39427. /**
  39428. * Set the keys for camera movement right.
  39429. */
  39430. /**
  39431. * Set the keys for camera movement right.
  39432. */
  39433. keysRight: number[];
  39434. /**
  39435. * Event raised when the camera collides with a mesh in the scene.
  39436. */
  39437. onCollide: (collidedMesh: AbstractMesh) => void;
  39438. private _collider;
  39439. private _needMoveForGravity;
  39440. private _oldPosition;
  39441. private _diffPosition;
  39442. private _newPosition;
  39443. /** @hidden */
  39444. _localDirection: Vector3;
  39445. /** @hidden */
  39446. _transformedDirection: Vector3;
  39447. /**
  39448. * Instantiates a FlyCamera.
  39449. * This is a flying camera, designed for 3D movement and rotation in all directions,
  39450. * such as in a 3D Space Shooter or a Flight Simulator.
  39451. * @param name Define the name of the camera in the scene.
  39452. * @param position Define the starting position of the camera in the scene.
  39453. * @param scene Define the scene the camera belongs to.
  39454. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  39455. */
  39456. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  39457. /**
  39458. * Attach a control to the HTML DOM element.
  39459. * @param element Defines the element that listens to the input events.
  39460. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  39461. */
  39462. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39463. /**
  39464. * Detach a control from the HTML DOM element.
  39465. * The camera will stop reacting to that input.
  39466. * @param element Defines the element that listens to the input events.
  39467. */
  39468. detachControl(element: HTMLElement): void;
  39469. private _collisionMask;
  39470. /**
  39471. * Get the mask that the camera ignores in collision events.
  39472. */
  39473. /**
  39474. * Set the mask that the camera ignores in collision events.
  39475. */
  39476. collisionMask: number;
  39477. /** @hidden */
  39478. _collideWithWorld(displacement: Vector3): void;
  39479. /** @hidden */
  39480. private _onCollisionPositionChange;
  39481. /** @hidden */
  39482. _checkInputs(): void;
  39483. /** @hidden */
  39484. _decideIfNeedsToMove(): boolean;
  39485. /** @hidden */
  39486. _updatePosition(): void;
  39487. /**
  39488. * Restore the Roll to its target value at the rate specified.
  39489. * @param rate - Higher means slower restoring.
  39490. * @hidden
  39491. */
  39492. restoreRoll(rate: number): void;
  39493. /**
  39494. * Destroy the camera and release the current resources held by it.
  39495. */
  39496. dispose(): void;
  39497. /**
  39498. * Get the current object class name.
  39499. * @returns the class name.
  39500. */
  39501. getClassName(): string;
  39502. }
  39503. }
  39504. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  39505. import { Nullable } from "babylonjs/types";
  39506. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39507. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  39508. /**
  39509. * Listen to keyboard events to control the camera.
  39510. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39511. */
  39512. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  39513. /**
  39514. * Defines the camera the input is attached to.
  39515. */
  39516. camera: FlyCamera;
  39517. /**
  39518. * The list of keyboard keys used to control the forward move of the camera.
  39519. */
  39520. keysForward: number[];
  39521. /**
  39522. * The list of keyboard keys used to control the backward move of the camera.
  39523. */
  39524. keysBackward: number[];
  39525. /**
  39526. * The list of keyboard keys used to control the forward move of the camera.
  39527. */
  39528. keysUp: number[];
  39529. /**
  39530. * The list of keyboard keys used to control the backward move of the camera.
  39531. */
  39532. keysDown: number[];
  39533. /**
  39534. * The list of keyboard keys used to control the right strafe move of the camera.
  39535. */
  39536. keysRight: number[];
  39537. /**
  39538. * The list of keyboard keys used to control the left strafe move of the camera.
  39539. */
  39540. keysLeft: number[];
  39541. private _keys;
  39542. private _onCanvasBlurObserver;
  39543. private _onKeyboardObserver;
  39544. private _engine;
  39545. private _scene;
  39546. /**
  39547. * Attach the input controls to a specific dom element to get the input from.
  39548. * @param element Defines the element the controls should be listened from
  39549. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39550. */
  39551. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39552. /**
  39553. * Detach the current controls from the specified dom element.
  39554. * @param element Defines the element to stop listening the inputs from
  39555. */
  39556. detachControl(element: Nullable<HTMLElement>): void;
  39557. /**
  39558. * Gets the class name of the current intput.
  39559. * @returns the class name
  39560. */
  39561. getClassName(): string;
  39562. /** @hidden */
  39563. _onLostFocus(e: FocusEvent): void;
  39564. /**
  39565. * Get the friendly name associated with the input class.
  39566. * @returns the input friendly name
  39567. */
  39568. getSimpleName(): string;
  39569. /**
  39570. * Update the current camera state depending on the inputs that have been used this frame.
  39571. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39572. */
  39573. checkInputs(): void;
  39574. }
  39575. }
  39576. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  39577. import { Nullable } from "babylonjs/types";
  39578. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  39579. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39580. /**
  39581. * Manage the mouse wheel inputs to control a follow camera.
  39582. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39583. */
  39584. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  39585. /**
  39586. * Defines the camera the input is attached to.
  39587. */
  39588. camera: FollowCamera;
  39589. /**
  39590. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  39591. */
  39592. axisControlRadius: boolean;
  39593. /**
  39594. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  39595. */
  39596. axisControlHeight: boolean;
  39597. /**
  39598. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  39599. */
  39600. axisControlRotation: boolean;
  39601. /**
  39602. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  39603. * relation to mouseWheel events.
  39604. */
  39605. wheelPrecision: number;
  39606. /**
  39607. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  39608. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  39609. */
  39610. wheelDeltaPercentage: number;
  39611. private _wheel;
  39612. private _observer;
  39613. /**
  39614. * Attach the input controls to a specific dom element to get the input from.
  39615. * @param element Defines the element the controls should be listened from
  39616. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39617. */
  39618. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39619. /**
  39620. * Detach the current controls from the specified dom element.
  39621. * @param element Defines the element to stop listening the inputs from
  39622. */
  39623. detachControl(element: Nullable<HTMLElement>): void;
  39624. /**
  39625. * Gets the class name of the current intput.
  39626. * @returns the class name
  39627. */
  39628. getClassName(): string;
  39629. /**
  39630. * Get the friendly name associated with the input class.
  39631. * @returns the input friendly name
  39632. */
  39633. getSimpleName(): string;
  39634. }
  39635. }
  39636. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  39637. import { Nullable } from "babylonjs/types";
  39638. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  39639. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  39640. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  39641. /**
  39642. * Manage the pointers inputs to control an follow camera.
  39643. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39644. */
  39645. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  39646. /**
  39647. * Defines the camera the input is attached to.
  39648. */
  39649. camera: FollowCamera;
  39650. /**
  39651. * Gets the class name of the current input.
  39652. * @returns the class name
  39653. */
  39654. getClassName(): string;
  39655. /**
  39656. * Defines the pointer angular sensibility along the X axis or how fast is
  39657. * the camera rotating.
  39658. * A negative number will reverse the axis direction.
  39659. */
  39660. angularSensibilityX: number;
  39661. /**
  39662. * Defines the pointer angular sensibility along the Y axis or how fast is
  39663. * the camera rotating.
  39664. * A negative number will reverse the axis direction.
  39665. */
  39666. angularSensibilityY: number;
  39667. /**
  39668. * Defines the pointer pinch precision or how fast is the camera zooming.
  39669. * A negative number will reverse the axis direction.
  39670. */
  39671. pinchPrecision: number;
  39672. /**
  39673. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  39674. * from 0.
  39675. * It defines the percentage of current camera.radius to use as delta when
  39676. * pinch zoom is used.
  39677. */
  39678. pinchDeltaPercentage: number;
  39679. /**
  39680. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  39681. */
  39682. axisXControlRadius: boolean;
  39683. /**
  39684. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  39685. */
  39686. axisXControlHeight: boolean;
  39687. /**
  39688. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  39689. */
  39690. axisXControlRotation: boolean;
  39691. /**
  39692. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  39693. */
  39694. axisYControlRadius: boolean;
  39695. /**
  39696. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  39697. */
  39698. axisYControlHeight: boolean;
  39699. /**
  39700. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  39701. */
  39702. axisYControlRotation: boolean;
  39703. /**
  39704. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  39705. */
  39706. axisPinchControlRadius: boolean;
  39707. /**
  39708. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  39709. */
  39710. axisPinchControlHeight: boolean;
  39711. /**
  39712. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  39713. */
  39714. axisPinchControlRotation: boolean;
  39715. /**
  39716. * Log error messages if basic misconfiguration has occurred.
  39717. */
  39718. warningEnable: boolean;
  39719. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  39720. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  39721. private _warningCounter;
  39722. private _warning;
  39723. }
  39724. }
  39725. declare module "babylonjs/Cameras/followCameraInputsManager" {
  39726. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  39727. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  39728. /**
  39729. * Default Inputs manager for the FollowCamera.
  39730. * It groups all the default supported inputs for ease of use.
  39731. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39732. */
  39733. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  39734. /**
  39735. * Instantiates a new FollowCameraInputsManager.
  39736. * @param camera Defines the camera the inputs belong to
  39737. */
  39738. constructor(camera: FollowCamera);
  39739. /**
  39740. * Add keyboard input support to the input manager.
  39741. * @returns the current input manager
  39742. */
  39743. addKeyboard(): FollowCameraInputsManager;
  39744. /**
  39745. * Add mouse wheel input support to the input manager.
  39746. * @returns the current input manager
  39747. */
  39748. addMouseWheel(): FollowCameraInputsManager;
  39749. /**
  39750. * Add pointers input support to the input manager.
  39751. * @returns the current input manager
  39752. */
  39753. addPointers(): FollowCameraInputsManager;
  39754. /**
  39755. * Add orientation input support to the input manager.
  39756. * @returns the current input manager
  39757. */
  39758. addVRDeviceOrientation(): FollowCameraInputsManager;
  39759. }
  39760. }
  39761. declare module "babylonjs/Cameras/followCamera" {
  39762. import { Nullable } from "babylonjs/types";
  39763. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  39764. import { Scene } from "babylonjs/scene";
  39765. import { Vector3 } from "babylonjs/Maths/math.vector";
  39766. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39767. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  39768. /**
  39769. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  39770. * an arc rotate version arcFollowCamera are available.
  39771. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39772. */
  39773. export class FollowCamera extends TargetCamera {
  39774. /**
  39775. * Distance the follow camera should follow an object at
  39776. */
  39777. radius: number;
  39778. /**
  39779. * Minimum allowed distance of the camera to the axis of rotation
  39780. * (The camera can not get closer).
  39781. * This can help limiting how the Camera is able to move in the scene.
  39782. */
  39783. lowerRadiusLimit: Nullable<number>;
  39784. /**
  39785. * Maximum allowed distance of the camera to the axis of rotation
  39786. * (The camera can not get further).
  39787. * This can help limiting how the Camera is able to move in the scene.
  39788. */
  39789. upperRadiusLimit: Nullable<number>;
  39790. /**
  39791. * Define a rotation offset between the camera and the object it follows
  39792. */
  39793. rotationOffset: number;
  39794. /**
  39795. * Minimum allowed angle to camera position relative to target object.
  39796. * This can help limiting how the Camera is able to move in the scene.
  39797. */
  39798. lowerRotationOffsetLimit: Nullable<number>;
  39799. /**
  39800. * Maximum allowed angle to camera position relative to target object.
  39801. * This can help limiting how the Camera is able to move in the scene.
  39802. */
  39803. upperRotationOffsetLimit: Nullable<number>;
  39804. /**
  39805. * Define a height offset between the camera and the object it follows.
  39806. * It can help following an object from the top (like a car chaing a plane)
  39807. */
  39808. heightOffset: number;
  39809. /**
  39810. * Minimum allowed height of camera position relative to target object.
  39811. * This can help limiting how the Camera is able to move in the scene.
  39812. */
  39813. lowerHeightOffsetLimit: Nullable<number>;
  39814. /**
  39815. * Maximum allowed height of camera position relative to target object.
  39816. * This can help limiting how the Camera is able to move in the scene.
  39817. */
  39818. upperHeightOffsetLimit: Nullable<number>;
  39819. /**
  39820. * Define how fast the camera can accelerate to follow it s target.
  39821. */
  39822. cameraAcceleration: number;
  39823. /**
  39824. * Define the speed limit of the camera following an object.
  39825. */
  39826. maxCameraSpeed: number;
  39827. /**
  39828. * Define the target of the camera.
  39829. */
  39830. lockedTarget: Nullable<AbstractMesh>;
  39831. /**
  39832. * Defines the input associated with the camera.
  39833. */
  39834. inputs: FollowCameraInputsManager;
  39835. /**
  39836. * Instantiates the follow camera.
  39837. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39838. * @param name Define the name of the camera in the scene
  39839. * @param position Define the position of the camera
  39840. * @param scene Define the scene the camera belong to
  39841. * @param lockedTarget Define the target of the camera
  39842. */
  39843. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  39844. private _follow;
  39845. /**
  39846. * Attached controls to the current camera.
  39847. * @param element Defines the element the controls should be listened from
  39848. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39849. */
  39850. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39851. /**
  39852. * Detach the current controls from the camera.
  39853. * The camera will stop reacting to inputs.
  39854. * @param element Defines the element to stop listening the inputs from
  39855. */
  39856. detachControl(element: HTMLElement): void;
  39857. /** @hidden */
  39858. _checkInputs(): void;
  39859. private _checkLimits;
  39860. /**
  39861. * Gets the camera class name.
  39862. * @returns the class name
  39863. */
  39864. getClassName(): string;
  39865. }
  39866. /**
  39867. * Arc Rotate version of the follow camera.
  39868. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  39869. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39870. */
  39871. export class ArcFollowCamera extends TargetCamera {
  39872. /** The longitudinal angle of the camera */
  39873. alpha: number;
  39874. /** The latitudinal angle of the camera */
  39875. beta: number;
  39876. /** The radius of the camera from its target */
  39877. radius: number;
  39878. /** Define the camera target (the messh it should follow) */
  39879. target: Nullable<AbstractMesh>;
  39880. private _cartesianCoordinates;
  39881. /**
  39882. * Instantiates a new ArcFollowCamera
  39883. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39884. * @param name Define the name of the camera
  39885. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  39886. * @param beta Define the rotation angle of the camera around the elevation axis
  39887. * @param radius Define the radius of the camera from its target point
  39888. * @param target Define the target of the camera
  39889. * @param scene Define the scene the camera belongs to
  39890. */
  39891. constructor(name: string,
  39892. /** The longitudinal angle of the camera */
  39893. alpha: number,
  39894. /** The latitudinal angle of the camera */
  39895. beta: number,
  39896. /** The radius of the camera from its target */
  39897. radius: number,
  39898. /** Define the camera target (the messh it should follow) */
  39899. target: Nullable<AbstractMesh>, scene: Scene);
  39900. private _follow;
  39901. /** @hidden */
  39902. _checkInputs(): void;
  39903. /**
  39904. * Returns the class name of the object.
  39905. * It is mostly used internally for serialization purposes.
  39906. */
  39907. getClassName(): string;
  39908. }
  39909. }
  39910. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  39911. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39912. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  39913. import { Nullable } from "babylonjs/types";
  39914. /**
  39915. * Manage the keyboard inputs to control the movement of a follow camera.
  39916. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39917. */
  39918. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  39919. /**
  39920. * Defines the camera the input is attached to.
  39921. */
  39922. camera: FollowCamera;
  39923. /**
  39924. * Defines the list of key codes associated with the up action (increase heightOffset)
  39925. */
  39926. keysHeightOffsetIncr: number[];
  39927. /**
  39928. * Defines the list of key codes associated with the down action (decrease heightOffset)
  39929. */
  39930. keysHeightOffsetDecr: number[];
  39931. /**
  39932. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  39933. */
  39934. keysHeightOffsetModifierAlt: boolean;
  39935. /**
  39936. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  39937. */
  39938. keysHeightOffsetModifierCtrl: boolean;
  39939. /**
  39940. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  39941. */
  39942. keysHeightOffsetModifierShift: boolean;
  39943. /**
  39944. * Defines the list of key codes associated with the left action (increase rotationOffset)
  39945. */
  39946. keysRotationOffsetIncr: number[];
  39947. /**
  39948. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  39949. */
  39950. keysRotationOffsetDecr: number[];
  39951. /**
  39952. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  39953. */
  39954. keysRotationOffsetModifierAlt: boolean;
  39955. /**
  39956. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  39957. */
  39958. keysRotationOffsetModifierCtrl: boolean;
  39959. /**
  39960. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  39961. */
  39962. keysRotationOffsetModifierShift: boolean;
  39963. /**
  39964. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  39965. */
  39966. keysRadiusIncr: number[];
  39967. /**
  39968. * Defines the list of key codes associated with the zoom-out action (increase radius)
  39969. */
  39970. keysRadiusDecr: number[];
  39971. /**
  39972. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  39973. */
  39974. keysRadiusModifierAlt: boolean;
  39975. /**
  39976. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  39977. */
  39978. keysRadiusModifierCtrl: boolean;
  39979. /**
  39980. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  39981. */
  39982. keysRadiusModifierShift: boolean;
  39983. /**
  39984. * Defines the rate of change of heightOffset.
  39985. */
  39986. heightSensibility: number;
  39987. /**
  39988. * Defines the rate of change of rotationOffset.
  39989. */
  39990. rotationSensibility: number;
  39991. /**
  39992. * Defines the rate of change of radius.
  39993. */
  39994. radiusSensibility: number;
  39995. private _keys;
  39996. private _ctrlPressed;
  39997. private _altPressed;
  39998. private _shiftPressed;
  39999. private _onCanvasBlurObserver;
  40000. private _onKeyboardObserver;
  40001. private _engine;
  40002. private _scene;
  40003. /**
  40004. * Attach the input controls to a specific dom element to get the input from.
  40005. * @param element Defines the element the controls should be listened from
  40006. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40007. */
  40008. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40009. /**
  40010. * Detach the current controls from the specified dom element.
  40011. * @param element Defines the element to stop listening the inputs from
  40012. */
  40013. detachControl(element: Nullable<HTMLElement>): void;
  40014. /**
  40015. * Update the current camera state depending on the inputs that have been used this frame.
  40016. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40017. */
  40018. checkInputs(): void;
  40019. /**
  40020. * Gets the class name of the current input.
  40021. * @returns the class name
  40022. */
  40023. getClassName(): string;
  40024. /**
  40025. * Get the friendly name associated with the input class.
  40026. * @returns the input friendly name
  40027. */
  40028. getSimpleName(): string;
  40029. /**
  40030. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  40031. * allow modification of the heightOffset value.
  40032. */
  40033. private _modifierHeightOffset;
  40034. /**
  40035. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  40036. * allow modification of the rotationOffset value.
  40037. */
  40038. private _modifierRotationOffset;
  40039. /**
  40040. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  40041. * allow modification of the radius value.
  40042. */
  40043. private _modifierRadius;
  40044. }
  40045. }
  40046. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  40047. import { Nullable } from "babylonjs/types";
  40048. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  40049. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40050. import { Observable } from "babylonjs/Misc/observable";
  40051. module "babylonjs/Cameras/freeCameraInputsManager" {
  40052. interface FreeCameraInputsManager {
  40053. /**
  40054. * @hidden
  40055. */
  40056. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  40057. /**
  40058. * Add orientation input support to the input manager.
  40059. * @returns the current input manager
  40060. */
  40061. addDeviceOrientation(): FreeCameraInputsManager;
  40062. }
  40063. }
  40064. /**
  40065. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  40066. * Screen rotation is taken into account.
  40067. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40068. */
  40069. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  40070. private _camera;
  40071. private _screenOrientationAngle;
  40072. private _constantTranform;
  40073. private _screenQuaternion;
  40074. private _alpha;
  40075. private _beta;
  40076. private _gamma;
  40077. /**
  40078. * Can be used to detect if a device orientation sensor is availible on a device
  40079. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  40080. * @returns a promise that will resolve on orientation change
  40081. */
  40082. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  40083. /**
  40084. * @hidden
  40085. */
  40086. _onDeviceOrientationChangedObservable: Observable<void>;
  40087. /**
  40088. * Instantiates a new input
  40089. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40090. */
  40091. constructor();
  40092. /**
  40093. * Define the camera controlled by the input.
  40094. */
  40095. camera: FreeCamera;
  40096. /**
  40097. * Attach the input controls to a specific dom element to get the input from.
  40098. * @param element Defines the element the controls should be listened from
  40099. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40100. */
  40101. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40102. private _orientationChanged;
  40103. private _deviceOrientation;
  40104. /**
  40105. * Detach the current controls from the specified dom element.
  40106. * @param element Defines the element to stop listening the inputs from
  40107. */
  40108. detachControl(element: Nullable<HTMLElement>): void;
  40109. /**
  40110. * Update the current camera state depending on the inputs that have been used this frame.
  40111. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40112. */
  40113. checkInputs(): void;
  40114. /**
  40115. * Gets the class name of the current intput.
  40116. * @returns the class name
  40117. */
  40118. getClassName(): string;
  40119. /**
  40120. * Get the friendly name associated with the input class.
  40121. * @returns the input friendly name
  40122. */
  40123. getSimpleName(): string;
  40124. }
  40125. }
  40126. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  40127. import { Nullable } from "babylonjs/types";
  40128. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  40129. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40130. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  40131. /**
  40132. * Manage the gamepad inputs to control a free camera.
  40133. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40134. */
  40135. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  40136. /**
  40137. * Define the camera the input is attached to.
  40138. */
  40139. camera: FreeCamera;
  40140. /**
  40141. * Define the Gamepad controlling the input
  40142. */
  40143. gamepad: Nullable<Gamepad>;
  40144. /**
  40145. * Defines the gamepad rotation sensiblity.
  40146. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  40147. */
  40148. gamepadAngularSensibility: number;
  40149. /**
  40150. * Defines the gamepad move sensiblity.
  40151. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  40152. */
  40153. gamepadMoveSensibility: number;
  40154. private _yAxisScale;
  40155. /**
  40156. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  40157. */
  40158. invertYAxis: boolean;
  40159. private _onGamepadConnectedObserver;
  40160. private _onGamepadDisconnectedObserver;
  40161. private _cameraTransform;
  40162. private _deltaTransform;
  40163. private _vector3;
  40164. private _vector2;
  40165. /**
  40166. * Attach the input controls to a specific dom element to get the input from.
  40167. * @param element Defines the element the controls should be listened from
  40168. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40169. */
  40170. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40171. /**
  40172. * Detach the current controls from the specified dom element.
  40173. * @param element Defines the element to stop listening the inputs from
  40174. */
  40175. detachControl(element: Nullable<HTMLElement>): void;
  40176. /**
  40177. * Update the current camera state depending on the inputs that have been used this frame.
  40178. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40179. */
  40180. checkInputs(): void;
  40181. /**
  40182. * Gets the class name of the current intput.
  40183. * @returns the class name
  40184. */
  40185. getClassName(): string;
  40186. /**
  40187. * Get the friendly name associated with the input class.
  40188. * @returns the input friendly name
  40189. */
  40190. getSimpleName(): string;
  40191. }
  40192. }
  40193. declare module "babylonjs/Misc/virtualJoystick" {
  40194. import { Nullable } from "babylonjs/types";
  40195. import { Vector3 } from "babylonjs/Maths/math.vector";
  40196. /**
  40197. * Defines the potential axis of a Joystick
  40198. */
  40199. export enum JoystickAxis {
  40200. /** X axis */
  40201. X = 0,
  40202. /** Y axis */
  40203. Y = 1,
  40204. /** Z axis */
  40205. Z = 2
  40206. }
  40207. /**
  40208. * Class used to define virtual joystick (used in touch mode)
  40209. */
  40210. export class VirtualJoystick {
  40211. /**
  40212. * Gets or sets a boolean indicating that left and right values must be inverted
  40213. */
  40214. reverseLeftRight: boolean;
  40215. /**
  40216. * Gets or sets a boolean indicating that up and down values must be inverted
  40217. */
  40218. reverseUpDown: boolean;
  40219. /**
  40220. * Gets the offset value for the position (ie. the change of the position value)
  40221. */
  40222. deltaPosition: Vector3;
  40223. /**
  40224. * Gets a boolean indicating if the virtual joystick was pressed
  40225. */
  40226. pressed: boolean;
  40227. /**
  40228. * Canvas the virtual joystick will render onto, default z-index of this is 5
  40229. */
  40230. static Canvas: Nullable<HTMLCanvasElement>;
  40231. private static _globalJoystickIndex;
  40232. private static vjCanvasContext;
  40233. private static vjCanvasWidth;
  40234. private static vjCanvasHeight;
  40235. private static halfWidth;
  40236. private _action;
  40237. private _axisTargetedByLeftAndRight;
  40238. private _axisTargetedByUpAndDown;
  40239. private _joystickSensibility;
  40240. private _inversedSensibility;
  40241. private _joystickPointerID;
  40242. private _joystickColor;
  40243. private _joystickPointerPos;
  40244. private _joystickPreviousPointerPos;
  40245. private _joystickPointerStartPos;
  40246. private _deltaJoystickVector;
  40247. private _leftJoystick;
  40248. private _touches;
  40249. private _onPointerDownHandlerRef;
  40250. private _onPointerMoveHandlerRef;
  40251. private _onPointerUpHandlerRef;
  40252. private _onResize;
  40253. /**
  40254. * Creates a new virtual joystick
  40255. * @param leftJoystick defines that the joystick is for left hand (false by default)
  40256. */
  40257. constructor(leftJoystick?: boolean);
  40258. /**
  40259. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  40260. * @param newJoystickSensibility defines the new sensibility
  40261. */
  40262. setJoystickSensibility(newJoystickSensibility: number): void;
  40263. private _onPointerDown;
  40264. private _onPointerMove;
  40265. private _onPointerUp;
  40266. /**
  40267. * Change the color of the virtual joystick
  40268. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  40269. */
  40270. setJoystickColor(newColor: string): void;
  40271. /**
  40272. * Defines a callback to call when the joystick is touched
  40273. * @param action defines the callback
  40274. */
  40275. setActionOnTouch(action: () => any): void;
  40276. /**
  40277. * Defines which axis you'd like to control for left & right
  40278. * @param axis defines the axis to use
  40279. */
  40280. setAxisForLeftRight(axis: JoystickAxis): void;
  40281. /**
  40282. * Defines which axis you'd like to control for up & down
  40283. * @param axis defines the axis to use
  40284. */
  40285. setAxisForUpDown(axis: JoystickAxis): void;
  40286. private _drawVirtualJoystick;
  40287. /**
  40288. * Release internal HTML canvas
  40289. */
  40290. releaseCanvas(): void;
  40291. }
  40292. }
  40293. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  40294. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  40295. import { Nullable } from "babylonjs/types";
  40296. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  40297. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40298. module "babylonjs/Cameras/freeCameraInputsManager" {
  40299. interface FreeCameraInputsManager {
  40300. /**
  40301. * Add virtual joystick input support to the input manager.
  40302. * @returns the current input manager
  40303. */
  40304. addVirtualJoystick(): FreeCameraInputsManager;
  40305. }
  40306. }
  40307. /**
  40308. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  40309. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40310. */
  40311. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  40312. /**
  40313. * Defines the camera the input is attached to.
  40314. */
  40315. camera: FreeCamera;
  40316. private _leftjoystick;
  40317. private _rightjoystick;
  40318. /**
  40319. * Gets the left stick of the virtual joystick.
  40320. * @returns The virtual Joystick
  40321. */
  40322. getLeftJoystick(): VirtualJoystick;
  40323. /**
  40324. * Gets the right stick of the virtual joystick.
  40325. * @returns The virtual Joystick
  40326. */
  40327. getRightJoystick(): VirtualJoystick;
  40328. /**
  40329. * Update the current camera state depending on the inputs that have been used this frame.
  40330. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40331. */
  40332. checkInputs(): void;
  40333. /**
  40334. * Attach the input controls to a specific dom element to get the input from.
  40335. * @param element Defines the element the controls should be listened from
  40336. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40337. */
  40338. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40339. /**
  40340. * Detach the current controls from the specified dom element.
  40341. * @param element Defines the element to stop listening the inputs from
  40342. */
  40343. detachControl(element: Nullable<HTMLElement>): void;
  40344. /**
  40345. * Gets the class name of the current intput.
  40346. * @returns the class name
  40347. */
  40348. getClassName(): string;
  40349. /**
  40350. * Get the friendly name associated with the input class.
  40351. * @returns the input friendly name
  40352. */
  40353. getSimpleName(): string;
  40354. }
  40355. }
  40356. declare module "babylonjs/Cameras/Inputs/index" {
  40357. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  40358. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  40359. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  40360. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  40361. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  40362. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  40363. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  40364. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  40365. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  40366. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  40367. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  40368. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  40369. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  40370. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  40371. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  40372. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  40373. }
  40374. declare module "babylonjs/Cameras/touchCamera" {
  40375. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40376. import { Scene } from "babylonjs/scene";
  40377. import { Vector3 } from "babylonjs/Maths/math.vector";
  40378. /**
  40379. * This represents a FPS type of camera controlled by touch.
  40380. * This is like a universal camera minus the Gamepad controls.
  40381. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40382. */
  40383. export class TouchCamera extends FreeCamera {
  40384. /**
  40385. * Defines the touch sensibility for rotation.
  40386. * The higher the faster.
  40387. */
  40388. touchAngularSensibility: number;
  40389. /**
  40390. * Defines the touch sensibility for move.
  40391. * The higher the faster.
  40392. */
  40393. touchMoveSensibility: number;
  40394. /**
  40395. * Instantiates a new touch camera.
  40396. * This represents a FPS type of camera controlled by touch.
  40397. * This is like a universal camera minus the Gamepad controls.
  40398. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40399. * @param name Define the name of the camera in the scene
  40400. * @param position Define the start position of the camera in the scene
  40401. * @param scene Define the scene the camera belongs to
  40402. */
  40403. constructor(name: string, position: Vector3, scene: Scene);
  40404. /**
  40405. * Gets the current object class name.
  40406. * @return the class name
  40407. */
  40408. getClassName(): string;
  40409. /** @hidden */
  40410. _setupInputs(): void;
  40411. }
  40412. }
  40413. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  40414. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40415. import { Scene } from "babylonjs/scene";
  40416. import { Vector3 } from "babylonjs/Maths/math.vector";
  40417. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  40418. import { Axis } from "babylonjs/Maths/math.axis";
  40419. /**
  40420. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  40421. * being tilted forward or back and left or right.
  40422. */
  40423. export class DeviceOrientationCamera extends FreeCamera {
  40424. private _initialQuaternion;
  40425. private _quaternionCache;
  40426. private _tmpDragQuaternion;
  40427. private _disablePointerInputWhenUsingDeviceOrientation;
  40428. /**
  40429. * Creates a new device orientation camera
  40430. * @param name The name of the camera
  40431. * @param position The start position camera
  40432. * @param scene The scene the camera belongs to
  40433. */
  40434. constructor(name: string, position: Vector3, scene: Scene);
  40435. /**
  40436. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  40437. */
  40438. disablePointerInputWhenUsingDeviceOrientation: boolean;
  40439. private _dragFactor;
  40440. /**
  40441. * Enabled turning on the y axis when the orientation sensor is active
  40442. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  40443. */
  40444. enableHorizontalDragging(dragFactor?: number): void;
  40445. /**
  40446. * Gets the current instance class name ("DeviceOrientationCamera").
  40447. * This helps avoiding instanceof at run time.
  40448. * @returns the class name
  40449. */
  40450. getClassName(): string;
  40451. /**
  40452. * @hidden
  40453. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  40454. */
  40455. _checkInputs(): void;
  40456. /**
  40457. * Reset the camera to its default orientation on the specified axis only.
  40458. * @param axis The axis to reset
  40459. */
  40460. resetToCurrentRotation(axis?: Axis): void;
  40461. }
  40462. }
  40463. declare module "babylonjs/Gamepads/xboxGamepad" {
  40464. import { Observable } from "babylonjs/Misc/observable";
  40465. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  40466. /**
  40467. * Defines supported buttons for XBox360 compatible gamepads
  40468. */
  40469. export enum Xbox360Button {
  40470. /** A */
  40471. A = 0,
  40472. /** B */
  40473. B = 1,
  40474. /** X */
  40475. X = 2,
  40476. /** Y */
  40477. Y = 3,
  40478. /** Start */
  40479. Start = 4,
  40480. /** Back */
  40481. Back = 5,
  40482. /** Left button */
  40483. LB = 6,
  40484. /** Right button */
  40485. RB = 7,
  40486. /** Left stick */
  40487. LeftStick = 8,
  40488. /** Right stick */
  40489. RightStick = 9
  40490. }
  40491. /** Defines values for XBox360 DPad */
  40492. export enum Xbox360Dpad {
  40493. /** Up */
  40494. Up = 0,
  40495. /** Down */
  40496. Down = 1,
  40497. /** Left */
  40498. Left = 2,
  40499. /** Right */
  40500. Right = 3
  40501. }
  40502. /**
  40503. * Defines a XBox360 gamepad
  40504. */
  40505. export class Xbox360Pad extends Gamepad {
  40506. private _leftTrigger;
  40507. private _rightTrigger;
  40508. private _onlefttriggerchanged;
  40509. private _onrighttriggerchanged;
  40510. private _onbuttondown;
  40511. private _onbuttonup;
  40512. private _ondpaddown;
  40513. private _ondpadup;
  40514. /** Observable raised when a button is pressed */
  40515. onButtonDownObservable: Observable<Xbox360Button>;
  40516. /** Observable raised when a button is released */
  40517. onButtonUpObservable: Observable<Xbox360Button>;
  40518. /** Observable raised when a pad is pressed */
  40519. onPadDownObservable: Observable<Xbox360Dpad>;
  40520. /** Observable raised when a pad is released */
  40521. onPadUpObservable: Observable<Xbox360Dpad>;
  40522. private _buttonA;
  40523. private _buttonB;
  40524. private _buttonX;
  40525. private _buttonY;
  40526. private _buttonBack;
  40527. private _buttonStart;
  40528. private _buttonLB;
  40529. private _buttonRB;
  40530. private _buttonLeftStick;
  40531. private _buttonRightStick;
  40532. private _dPadUp;
  40533. private _dPadDown;
  40534. private _dPadLeft;
  40535. private _dPadRight;
  40536. private _isXboxOnePad;
  40537. /**
  40538. * Creates a new XBox360 gamepad object
  40539. * @param id defines the id of this gamepad
  40540. * @param index defines its index
  40541. * @param gamepad defines the internal HTML gamepad object
  40542. * @param xboxOne defines if it is a XBox One gamepad
  40543. */
  40544. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  40545. /**
  40546. * Defines the callback to call when left trigger is pressed
  40547. * @param callback defines the callback to use
  40548. */
  40549. onlefttriggerchanged(callback: (value: number) => void): void;
  40550. /**
  40551. * Defines the callback to call when right trigger is pressed
  40552. * @param callback defines the callback to use
  40553. */
  40554. onrighttriggerchanged(callback: (value: number) => void): void;
  40555. /**
  40556. * Gets the left trigger value
  40557. */
  40558. /**
  40559. * Sets the left trigger value
  40560. */
  40561. leftTrigger: number;
  40562. /**
  40563. * Gets the right trigger value
  40564. */
  40565. /**
  40566. * Sets the right trigger value
  40567. */
  40568. rightTrigger: number;
  40569. /**
  40570. * Defines the callback to call when a button is pressed
  40571. * @param callback defines the callback to use
  40572. */
  40573. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  40574. /**
  40575. * Defines the callback to call when a button is released
  40576. * @param callback defines the callback to use
  40577. */
  40578. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  40579. /**
  40580. * Defines the callback to call when a pad is pressed
  40581. * @param callback defines the callback to use
  40582. */
  40583. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  40584. /**
  40585. * Defines the callback to call when a pad is released
  40586. * @param callback defines the callback to use
  40587. */
  40588. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  40589. private _setButtonValue;
  40590. private _setDPadValue;
  40591. /**
  40592. * Gets the value of the `A` button
  40593. */
  40594. /**
  40595. * Sets the value of the `A` button
  40596. */
  40597. buttonA: number;
  40598. /**
  40599. * Gets the value of the `B` button
  40600. */
  40601. /**
  40602. * Sets the value of the `B` button
  40603. */
  40604. buttonB: number;
  40605. /**
  40606. * Gets the value of the `X` button
  40607. */
  40608. /**
  40609. * Sets the value of the `X` button
  40610. */
  40611. buttonX: number;
  40612. /**
  40613. * Gets the value of the `Y` button
  40614. */
  40615. /**
  40616. * Sets the value of the `Y` button
  40617. */
  40618. buttonY: number;
  40619. /**
  40620. * Gets the value of the `Start` button
  40621. */
  40622. /**
  40623. * Sets the value of the `Start` button
  40624. */
  40625. buttonStart: number;
  40626. /**
  40627. * Gets the value of the `Back` button
  40628. */
  40629. /**
  40630. * Sets the value of the `Back` button
  40631. */
  40632. buttonBack: number;
  40633. /**
  40634. * Gets the value of the `Left` button
  40635. */
  40636. /**
  40637. * Sets the value of the `Left` button
  40638. */
  40639. buttonLB: number;
  40640. /**
  40641. * Gets the value of the `Right` button
  40642. */
  40643. /**
  40644. * Sets the value of the `Right` button
  40645. */
  40646. buttonRB: number;
  40647. /**
  40648. * Gets the value of the Left joystick
  40649. */
  40650. /**
  40651. * Sets the value of the Left joystick
  40652. */
  40653. buttonLeftStick: number;
  40654. /**
  40655. * Gets the value of the Right joystick
  40656. */
  40657. /**
  40658. * Sets the value of the Right joystick
  40659. */
  40660. buttonRightStick: number;
  40661. /**
  40662. * Gets the value of D-pad up
  40663. */
  40664. /**
  40665. * Sets the value of D-pad up
  40666. */
  40667. dPadUp: number;
  40668. /**
  40669. * Gets the value of D-pad down
  40670. */
  40671. /**
  40672. * Sets the value of D-pad down
  40673. */
  40674. dPadDown: number;
  40675. /**
  40676. * Gets the value of D-pad left
  40677. */
  40678. /**
  40679. * Sets the value of D-pad left
  40680. */
  40681. dPadLeft: number;
  40682. /**
  40683. * Gets the value of D-pad right
  40684. */
  40685. /**
  40686. * Sets the value of D-pad right
  40687. */
  40688. dPadRight: number;
  40689. /**
  40690. * Force the gamepad to synchronize with device values
  40691. */
  40692. update(): void;
  40693. /**
  40694. * Disposes the gamepad
  40695. */
  40696. dispose(): void;
  40697. }
  40698. }
  40699. declare module "babylonjs/Gamepads/dualShockGamepad" {
  40700. import { Observable } from "babylonjs/Misc/observable";
  40701. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  40702. /**
  40703. * Defines supported buttons for DualShock compatible gamepads
  40704. */
  40705. export enum DualShockButton {
  40706. /** Cross */
  40707. Cross = 0,
  40708. /** Circle */
  40709. Circle = 1,
  40710. /** Square */
  40711. Square = 2,
  40712. /** Triangle */
  40713. Triangle = 3,
  40714. /** Options */
  40715. Options = 4,
  40716. /** Share */
  40717. Share = 5,
  40718. /** L1 */
  40719. L1 = 6,
  40720. /** R1 */
  40721. R1 = 7,
  40722. /** Left stick */
  40723. LeftStick = 8,
  40724. /** Right stick */
  40725. RightStick = 9
  40726. }
  40727. /** Defines values for DualShock DPad */
  40728. export enum DualShockDpad {
  40729. /** Up */
  40730. Up = 0,
  40731. /** Down */
  40732. Down = 1,
  40733. /** Left */
  40734. Left = 2,
  40735. /** Right */
  40736. Right = 3
  40737. }
  40738. /**
  40739. * Defines a DualShock gamepad
  40740. */
  40741. export class DualShockPad extends Gamepad {
  40742. private _leftTrigger;
  40743. private _rightTrigger;
  40744. private _onlefttriggerchanged;
  40745. private _onrighttriggerchanged;
  40746. private _onbuttondown;
  40747. private _onbuttonup;
  40748. private _ondpaddown;
  40749. private _ondpadup;
  40750. /** Observable raised when a button is pressed */
  40751. onButtonDownObservable: Observable<DualShockButton>;
  40752. /** Observable raised when a button is released */
  40753. onButtonUpObservable: Observable<DualShockButton>;
  40754. /** Observable raised when a pad is pressed */
  40755. onPadDownObservable: Observable<DualShockDpad>;
  40756. /** Observable raised when a pad is released */
  40757. onPadUpObservable: Observable<DualShockDpad>;
  40758. private _buttonCross;
  40759. private _buttonCircle;
  40760. private _buttonSquare;
  40761. private _buttonTriangle;
  40762. private _buttonShare;
  40763. private _buttonOptions;
  40764. private _buttonL1;
  40765. private _buttonR1;
  40766. private _buttonLeftStick;
  40767. private _buttonRightStick;
  40768. private _dPadUp;
  40769. private _dPadDown;
  40770. private _dPadLeft;
  40771. private _dPadRight;
  40772. /**
  40773. * Creates a new DualShock gamepad object
  40774. * @param id defines the id of this gamepad
  40775. * @param index defines its index
  40776. * @param gamepad defines the internal HTML gamepad object
  40777. */
  40778. constructor(id: string, index: number, gamepad: any);
  40779. /**
  40780. * Defines the callback to call when left trigger is pressed
  40781. * @param callback defines the callback to use
  40782. */
  40783. onlefttriggerchanged(callback: (value: number) => void): void;
  40784. /**
  40785. * Defines the callback to call when right trigger is pressed
  40786. * @param callback defines the callback to use
  40787. */
  40788. onrighttriggerchanged(callback: (value: number) => void): void;
  40789. /**
  40790. * Gets the left trigger value
  40791. */
  40792. /**
  40793. * Sets the left trigger value
  40794. */
  40795. leftTrigger: number;
  40796. /**
  40797. * Gets the right trigger value
  40798. */
  40799. /**
  40800. * Sets the right trigger value
  40801. */
  40802. rightTrigger: number;
  40803. /**
  40804. * Defines the callback to call when a button is pressed
  40805. * @param callback defines the callback to use
  40806. */
  40807. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  40808. /**
  40809. * Defines the callback to call when a button is released
  40810. * @param callback defines the callback to use
  40811. */
  40812. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  40813. /**
  40814. * Defines the callback to call when a pad is pressed
  40815. * @param callback defines the callback to use
  40816. */
  40817. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  40818. /**
  40819. * Defines the callback to call when a pad is released
  40820. * @param callback defines the callback to use
  40821. */
  40822. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  40823. private _setButtonValue;
  40824. private _setDPadValue;
  40825. /**
  40826. * Gets the value of the `Cross` button
  40827. */
  40828. /**
  40829. * Sets the value of the `Cross` button
  40830. */
  40831. buttonCross: number;
  40832. /**
  40833. * Gets the value of the `Circle` button
  40834. */
  40835. /**
  40836. * Sets the value of the `Circle` button
  40837. */
  40838. buttonCircle: number;
  40839. /**
  40840. * Gets the value of the `Square` button
  40841. */
  40842. /**
  40843. * Sets the value of the `Square` button
  40844. */
  40845. buttonSquare: number;
  40846. /**
  40847. * Gets the value of the `Triangle` button
  40848. */
  40849. /**
  40850. * Sets the value of the `Triangle` button
  40851. */
  40852. buttonTriangle: number;
  40853. /**
  40854. * Gets the value of the `Options` button
  40855. */
  40856. /**
  40857. * Sets the value of the `Options` button
  40858. */
  40859. buttonOptions: number;
  40860. /**
  40861. * Gets the value of the `Share` button
  40862. */
  40863. /**
  40864. * Sets the value of the `Share` button
  40865. */
  40866. buttonShare: number;
  40867. /**
  40868. * Gets the value of the `L1` button
  40869. */
  40870. /**
  40871. * Sets the value of the `L1` button
  40872. */
  40873. buttonL1: number;
  40874. /**
  40875. * Gets the value of the `R1` button
  40876. */
  40877. /**
  40878. * Sets the value of the `R1` button
  40879. */
  40880. buttonR1: number;
  40881. /**
  40882. * Gets the value of the Left joystick
  40883. */
  40884. /**
  40885. * Sets the value of the Left joystick
  40886. */
  40887. buttonLeftStick: number;
  40888. /**
  40889. * Gets the value of the Right joystick
  40890. */
  40891. /**
  40892. * Sets the value of the Right joystick
  40893. */
  40894. buttonRightStick: number;
  40895. /**
  40896. * Gets the value of D-pad up
  40897. */
  40898. /**
  40899. * Sets the value of D-pad up
  40900. */
  40901. dPadUp: number;
  40902. /**
  40903. * Gets the value of D-pad down
  40904. */
  40905. /**
  40906. * Sets the value of D-pad down
  40907. */
  40908. dPadDown: number;
  40909. /**
  40910. * Gets the value of D-pad left
  40911. */
  40912. /**
  40913. * Sets the value of D-pad left
  40914. */
  40915. dPadLeft: number;
  40916. /**
  40917. * Gets the value of D-pad right
  40918. */
  40919. /**
  40920. * Sets the value of D-pad right
  40921. */
  40922. dPadRight: number;
  40923. /**
  40924. * Force the gamepad to synchronize with device values
  40925. */
  40926. update(): void;
  40927. /**
  40928. * Disposes the gamepad
  40929. */
  40930. dispose(): void;
  40931. }
  40932. }
  40933. declare module "babylonjs/Gamepads/gamepadManager" {
  40934. import { Observable } from "babylonjs/Misc/observable";
  40935. import { Nullable } from "babylonjs/types";
  40936. import { Scene } from "babylonjs/scene";
  40937. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  40938. /**
  40939. * Manager for handling gamepads
  40940. */
  40941. export class GamepadManager {
  40942. private _scene?;
  40943. private _babylonGamepads;
  40944. private _oneGamepadConnected;
  40945. /** @hidden */
  40946. _isMonitoring: boolean;
  40947. private _gamepadEventSupported;
  40948. private _gamepadSupport;
  40949. /**
  40950. * observable to be triggered when the gamepad controller has been connected
  40951. */
  40952. onGamepadConnectedObservable: Observable<Gamepad>;
  40953. /**
  40954. * observable to be triggered when the gamepad controller has been disconnected
  40955. */
  40956. onGamepadDisconnectedObservable: Observable<Gamepad>;
  40957. private _onGamepadConnectedEvent;
  40958. private _onGamepadDisconnectedEvent;
  40959. /**
  40960. * Initializes the gamepad manager
  40961. * @param _scene BabylonJS scene
  40962. */
  40963. constructor(_scene?: Scene | undefined);
  40964. /**
  40965. * The gamepads in the game pad manager
  40966. */
  40967. readonly gamepads: Gamepad[];
  40968. /**
  40969. * Get the gamepad controllers based on type
  40970. * @param type The type of gamepad controller
  40971. * @returns Nullable gamepad
  40972. */
  40973. getGamepadByType(type?: number): Nullable<Gamepad>;
  40974. /**
  40975. * Disposes the gamepad manager
  40976. */
  40977. dispose(): void;
  40978. private _addNewGamepad;
  40979. private _startMonitoringGamepads;
  40980. private _stopMonitoringGamepads;
  40981. /** @hidden */
  40982. _checkGamepadsStatus(): void;
  40983. private _updateGamepadObjects;
  40984. }
  40985. }
  40986. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  40987. import { Nullable } from "babylonjs/types";
  40988. import { Scene } from "babylonjs/scene";
  40989. import { ISceneComponent } from "babylonjs/sceneComponent";
  40990. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  40991. module "babylonjs/scene" {
  40992. interface Scene {
  40993. /** @hidden */
  40994. _gamepadManager: Nullable<GamepadManager>;
  40995. /**
  40996. * Gets the gamepad manager associated with the scene
  40997. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  40998. */
  40999. gamepadManager: GamepadManager;
  41000. }
  41001. }
  41002. module "babylonjs/Cameras/freeCameraInputsManager" {
  41003. /**
  41004. * Interface representing a free camera inputs manager
  41005. */
  41006. interface FreeCameraInputsManager {
  41007. /**
  41008. * Adds gamepad input support to the FreeCameraInputsManager.
  41009. * @returns the FreeCameraInputsManager
  41010. */
  41011. addGamepad(): FreeCameraInputsManager;
  41012. }
  41013. }
  41014. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  41015. /**
  41016. * Interface representing an arc rotate camera inputs manager
  41017. */
  41018. interface ArcRotateCameraInputsManager {
  41019. /**
  41020. * Adds gamepad input support to the ArcRotateCamera InputManager.
  41021. * @returns the camera inputs manager
  41022. */
  41023. addGamepad(): ArcRotateCameraInputsManager;
  41024. }
  41025. }
  41026. /**
  41027. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  41028. */
  41029. export class GamepadSystemSceneComponent implements ISceneComponent {
  41030. /**
  41031. * The component name helpfull to identify the component in the list of scene components.
  41032. */
  41033. readonly name: string;
  41034. /**
  41035. * The scene the component belongs to.
  41036. */
  41037. scene: Scene;
  41038. /**
  41039. * Creates a new instance of the component for the given scene
  41040. * @param scene Defines the scene to register the component in
  41041. */
  41042. constructor(scene: Scene);
  41043. /**
  41044. * Registers the component in a given scene
  41045. */
  41046. register(): void;
  41047. /**
  41048. * Rebuilds the elements related to this component in case of
  41049. * context lost for instance.
  41050. */
  41051. rebuild(): void;
  41052. /**
  41053. * Disposes the component and the associated ressources
  41054. */
  41055. dispose(): void;
  41056. private _beforeCameraUpdate;
  41057. }
  41058. }
  41059. declare module "babylonjs/Cameras/universalCamera" {
  41060. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  41061. import { Scene } from "babylonjs/scene";
  41062. import { Vector3 } from "babylonjs/Maths/math.vector";
  41063. import "babylonjs/Gamepads/gamepadSceneComponent";
  41064. /**
  41065. * 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,
  41066. * which still works and will still be found in many Playgrounds.
  41067. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41068. */
  41069. export class UniversalCamera extends TouchCamera {
  41070. /**
  41071. * Defines the gamepad rotation sensiblity.
  41072. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  41073. */
  41074. gamepadAngularSensibility: number;
  41075. /**
  41076. * Defines the gamepad move sensiblity.
  41077. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  41078. */
  41079. gamepadMoveSensibility: number;
  41080. /**
  41081. * 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,
  41082. * which still works and will still be found in many Playgrounds.
  41083. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41084. * @param name Define the name of the camera in the scene
  41085. * @param position Define the start position of the camera in the scene
  41086. * @param scene Define the scene the camera belongs to
  41087. */
  41088. constructor(name: string, position: Vector3, scene: Scene);
  41089. /**
  41090. * Gets the current object class name.
  41091. * @return the class name
  41092. */
  41093. getClassName(): string;
  41094. }
  41095. }
  41096. declare module "babylonjs/Cameras/gamepadCamera" {
  41097. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  41098. import { Scene } from "babylonjs/scene";
  41099. import { Vector3 } from "babylonjs/Maths/math.vector";
  41100. /**
  41101. * This represents a FPS type of camera. This is only here for back compat purpose.
  41102. * Please use the UniversalCamera instead as both are identical.
  41103. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41104. */
  41105. export class GamepadCamera extends UniversalCamera {
  41106. /**
  41107. * Instantiates a new Gamepad Camera
  41108. * This represents a FPS type of camera. This is only here for back compat purpose.
  41109. * Please use the UniversalCamera instead as both are identical.
  41110. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41111. * @param name Define the name of the camera in the scene
  41112. * @param position Define the start position of the camera in the scene
  41113. * @param scene Define the scene the camera belongs to
  41114. */
  41115. constructor(name: string, position: Vector3, scene: Scene);
  41116. /**
  41117. * Gets the current object class name.
  41118. * @return the class name
  41119. */
  41120. getClassName(): string;
  41121. }
  41122. }
  41123. declare module "babylonjs/Shaders/pass.fragment" {
  41124. /** @hidden */
  41125. export var passPixelShader: {
  41126. name: string;
  41127. shader: string;
  41128. };
  41129. }
  41130. declare module "babylonjs/Shaders/passCube.fragment" {
  41131. /** @hidden */
  41132. export var passCubePixelShader: {
  41133. name: string;
  41134. shader: string;
  41135. };
  41136. }
  41137. declare module "babylonjs/PostProcesses/passPostProcess" {
  41138. import { Nullable } from "babylonjs/types";
  41139. import { Camera } from "babylonjs/Cameras/camera";
  41140. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  41141. import { Engine } from "babylonjs/Engines/engine";
  41142. import "babylonjs/Shaders/pass.fragment";
  41143. import "babylonjs/Shaders/passCube.fragment";
  41144. /**
  41145. * PassPostProcess which produces an output the same as it's input
  41146. */
  41147. export class PassPostProcess extends PostProcess {
  41148. /**
  41149. * Creates the PassPostProcess
  41150. * @param name The name of the effect.
  41151. * @param options The required width/height ratio to downsize to before computing the render pass.
  41152. * @param camera The camera to apply the render pass to.
  41153. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  41154. * @param engine The engine which the post process will be applied. (default: current engine)
  41155. * @param reusable If the post process can be reused on the same frame. (default: false)
  41156. * @param textureType The type of texture to be used when performing the post processing.
  41157. * @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)
  41158. */
  41159. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  41160. }
  41161. /**
  41162. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  41163. */
  41164. export class PassCubePostProcess extends PostProcess {
  41165. private _face;
  41166. /**
  41167. * Gets or sets the cube face to display.
  41168. * * 0 is +X
  41169. * * 1 is -X
  41170. * * 2 is +Y
  41171. * * 3 is -Y
  41172. * * 4 is +Z
  41173. * * 5 is -Z
  41174. */
  41175. face: number;
  41176. /**
  41177. * Creates the PassCubePostProcess
  41178. * @param name The name of the effect.
  41179. * @param options The required width/height ratio to downsize to before computing the render pass.
  41180. * @param camera The camera to apply the render pass to.
  41181. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  41182. * @param engine The engine which the post process will be applied. (default: current engine)
  41183. * @param reusable If the post process can be reused on the same frame. (default: false)
  41184. * @param textureType The type of texture to be used when performing the post processing.
  41185. * @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)
  41186. */
  41187. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  41188. }
  41189. }
  41190. declare module "babylonjs/Shaders/anaglyph.fragment" {
  41191. /** @hidden */
  41192. export var anaglyphPixelShader: {
  41193. name: string;
  41194. shader: string;
  41195. };
  41196. }
  41197. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  41198. import { Engine } from "babylonjs/Engines/engine";
  41199. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  41200. import { Camera } from "babylonjs/Cameras/camera";
  41201. import "babylonjs/Shaders/anaglyph.fragment";
  41202. /**
  41203. * Postprocess used to generate anaglyphic rendering
  41204. */
  41205. export class AnaglyphPostProcess extends PostProcess {
  41206. private _passedProcess;
  41207. /**
  41208. * Creates a new AnaglyphPostProcess
  41209. * @param name defines postprocess name
  41210. * @param options defines creation options or target ratio scale
  41211. * @param rigCameras defines cameras using this postprocess
  41212. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  41213. * @param engine defines hosting engine
  41214. * @param reusable defines if the postprocess will be reused multiple times per frame
  41215. */
  41216. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  41217. }
  41218. }
  41219. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  41220. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  41221. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  41222. import { Scene } from "babylonjs/scene";
  41223. import { Vector3 } from "babylonjs/Maths/math.vector";
  41224. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  41225. /**
  41226. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  41227. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41228. */
  41229. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  41230. /**
  41231. * Creates a new AnaglyphArcRotateCamera
  41232. * @param name defines camera name
  41233. * @param alpha defines alpha angle (in radians)
  41234. * @param beta defines beta angle (in radians)
  41235. * @param radius defines radius
  41236. * @param target defines camera target
  41237. * @param interaxialDistance defines distance between each color axis
  41238. * @param scene defines the hosting scene
  41239. */
  41240. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  41241. /**
  41242. * Gets camera class name
  41243. * @returns AnaglyphArcRotateCamera
  41244. */
  41245. getClassName(): string;
  41246. }
  41247. }
  41248. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  41249. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41250. import { Scene } from "babylonjs/scene";
  41251. import { Vector3 } from "babylonjs/Maths/math.vector";
  41252. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  41253. /**
  41254. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  41255. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41256. */
  41257. export class AnaglyphFreeCamera extends FreeCamera {
  41258. /**
  41259. * Creates a new AnaglyphFreeCamera
  41260. * @param name defines camera name
  41261. * @param position defines initial position
  41262. * @param interaxialDistance defines distance between each color axis
  41263. * @param scene defines the hosting scene
  41264. */
  41265. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  41266. /**
  41267. * Gets camera class name
  41268. * @returns AnaglyphFreeCamera
  41269. */
  41270. getClassName(): string;
  41271. }
  41272. }
  41273. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  41274. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  41275. import { Scene } from "babylonjs/scene";
  41276. import { Vector3 } from "babylonjs/Maths/math.vector";
  41277. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  41278. /**
  41279. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  41280. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41281. */
  41282. export class AnaglyphGamepadCamera extends GamepadCamera {
  41283. /**
  41284. * Creates a new AnaglyphGamepadCamera
  41285. * @param name defines camera name
  41286. * @param position defines initial position
  41287. * @param interaxialDistance defines distance between each color axis
  41288. * @param scene defines the hosting scene
  41289. */
  41290. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  41291. /**
  41292. * Gets camera class name
  41293. * @returns AnaglyphGamepadCamera
  41294. */
  41295. getClassName(): string;
  41296. }
  41297. }
  41298. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  41299. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  41300. import { Scene } from "babylonjs/scene";
  41301. import { Vector3 } from "babylonjs/Maths/math.vector";
  41302. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  41303. /**
  41304. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  41305. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41306. */
  41307. export class AnaglyphUniversalCamera extends UniversalCamera {
  41308. /**
  41309. * Creates a new AnaglyphUniversalCamera
  41310. * @param name defines camera name
  41311. * @param position defines initial position
  41312. * @param interaxialDistance defines distance between each color axis
  41313. * @param scene defines the hosting scene
  41314. */
  41315. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  41316. /**
  41317. * Gets camera class name
  41318. * @returns AnaglyphUniversalCamera
  41319. */
  41320. getClassName(): string;
  41321. }
  41322. }
  41323. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  41324. /** @hidden */
  41325. export var stereoscopicInterlacePixelShader: {
  41326. name: string;
  41327. shader: string;
  41328. };
  41329. }
  41330. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  41331. import { Camera } from "babylonjs/Cameras/camera";
  41332. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  41333. import { Engine } from "babylonjs/Engines/engine";
  41334. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  41335. /**
  41336. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  41337. */
  41338. export class StereoscopicInterlacePostProcess extends PostProcess {
  41339. private _stepSize;
  41340. private _passedProcess;
  41341. /**
  41342. * Initializes a StereoscopicInterlacePostProcess
  41343. * @param name The name of the effect.
  41344. * @param rigCameras The rig cameras to be appled to the post process
  41345. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  41346. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  41347. * @param engine The engine which the post process will be applied. (default: current engine)
  41348. * @param reusable If the post process can be reused on the same frame. (default: false)
  41349. */
  41350. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  41351. }
  41352. }
  41353. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  41354. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  41355. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  41356. import { Scene } from "babylonjs/scene";
  41357. import { Vector3 } from "babylonjs/Maths/math.vector";
  41358. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  41359. /**
  41360. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  41361. * @see http://doc.babylonjs.com/features/cameras
  41362. */
  41363. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  41364. /**
  41365. * Creates a new StereoscopicArcRotateCamera
  41366. * @param name defines camera name
  41367. * @param alpha defines alpha angle (in radians)
  41368. * @param beta defines beta angle (in radians)
  41369. * @param radius defines radius
  41370. * @param target defines camera target
  41371. * @param interaxialDistance defines distance between each color axis
  41372. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41373. * @param scene defines the hosting scene
  41374. */
  41375. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41376. /**
  41377. * Gets camera class name
  41378. * @returns StereoscopicArcRotateCamera
  41379. */
  41380. getClassName(): string;
  41381. }
  41382. }
  41383. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  41384. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41385. import { Scene } from "babylonjs/scene";
  41386. import { Vector3 } from "babylonjs/Maths/math.vector";
  41387. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  41388. /**
  41389. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  41390. * @see http://doc.babylonjs.com/features/cameras
  41391. */
  41392. export class StereoscopicFreeCamera extends FreeCamera {
  41393. /**
  41394. * Creates a new StereoscopicFreeCamera
  41395. * @param name defines camera name
  41396. * @param position defines initial position
  41397. * @param interaxialDistance defines distance between each color axis
  41398. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41399. * @param scene defines the hosting scene
  41400. */
  41401. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41402. /**
  41403. * Gets camera class name
  41404. * @returns StereoscopicFreeCamera
  41405. */
  41406. getClassName(): string;
  41407. }
  41408. }
  41409. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  41410. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  41411. import { Scene } from "babylonjs/scene";
  41412. import { Vector3 } from "babylonjs/Maths/math.vector";
  41413. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  41414. /**
  41415. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  41416. * @see http://doc.babylonjs.com/features/cameras
  41417. */
  41418. export class StereoscopicGamepadCamera extends GamepadCamera {
  41419. /**
  41420. * Creates a new StereoscopicGamepadCamera
  41421. * @param name defines camera name
  41422. * @param position defines initial position
  41423. * @param interaxialDistance defines distance between each color axis
  41424. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41425. * @param scene defines the hosting scene
  41426. */
  41427. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41428. /**
  41429. * Gets camera class name
  41430. * @returns StereoscopicGamepadCamera
  41431. */
  41432. getClassName(): string;
  41433. }
  41434. }
  41435. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  41436. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  41437. import { Scene } from "babylonjs/scene";
  41438. import { Vector3 } from "babylonjs/Maths/math.vector";
  41439. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  41440. /**
  41441. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  41442. * @see http://doc.babylonjs.com/features/cameras
  41443. */
  41444. export class StereoscopicUniversalCamera extends UniversalCamera {
  41445. /**
  41446. * Creates a new StereoscopicUniversalCamera
  41447. * @param name defines camera name
  41448. * @param position defines initial position
  41449. * @param interaxialDistance defines distance between each color axis
  41450. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41451. * @param scene defines the hosting scene
  41452. */
  41453. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41454. /**
  41455. * Gets camera class name
  41456. * @returns StereoscopicUniversalCamera
  41457. */
  41458. getClassName(): string;
  41459. }
  41460. }
  41461. declare module "babylonjs/Cameras/Stereoscopic/index" {
  41462. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  41463. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  41464. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  41465. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  41466. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  41467. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  41468. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  41469. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  41470. }
  41471. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  41472. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41473. import { Scene } from "babylonjs/scene";
  41474. import { Vector3 } from "babylonjs/Maths/math.vector";
  41475. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  41476. /**
  41477. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  41478. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  41479. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  41480. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  41481. */
  41482. export class VirtualJoysticksCamera extends FreeCamera {
  41483. /**
  41484. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  41485. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  41486. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  41487. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  41488. * @param name Define the name of the camera in the scene
  41489. * @param position Define the start position of the camera in the scene
  41490. * @param scene Define the scene the camera belongs to
  41491. */
  41492. constructor(name: string, position: Vector3, scene: Scene);
  41493. /**
  41494. * Gets the current object class name.
  41495. * @return the class name
  41496. */
  41497. getClassName(): string;
  41498. }
  41499. }
  41500. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  41501. import { Matrix } from "babylonjs/Maths/math.vector";
  41502. /**
  41503. * This represents all the required metrics to create a VR camera.
  41504. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  41505. */
  41506. export class VRCameraMetrics {
  41507. /**
  41508. * Define the horizontal resolution off the screen.
  41509. */
  41510. hResolution: number;
  41511. /**
  41512. * Define the vertical resolution off the screen.
  41513. */
  41514. vResolution: number;
  41515. /**
  41516. * Define the horizontal screen size.
  41517. */
  41518. hScreenSize: number;
  41519. /**
  41520. * Define the vertical screen size.
  41521. */
  41522. vScreenSize: number;
  41523. /**
  41524. * Define the vertical screen center position.
  41525. */
  41526. vScreenCenter: number;
  41527. /**
  41528. * Define the distance of the eyes to the screen.
  41529. */
  41530. eyeToScreenDistance: number;
  41531. /**
  41532. * Define the distance between both lenses
  41533. */
  41534. lensSeparationDistance: number;
  41535. /**
  41536. * Define the distance between both viewer's eyes.
  41537. */
  41538. interpupillaryDistance: number;
  41539. /**
  41540. * Define the distortion factor of the VR postprocess.
  41541. * Please, touch with care.
  41542. */
  41543. distortionK: number[];
  41544. /**
  41545. * Define the chromatic aberration correction factors for the VR post process.
  41546. */
  41547. chromaAbCorrection: number[];
  41548. /**
  41549. * Define the scale factor of the post process.
  41550. * The smaller the better but the slower.
  41551. */
  41552. postProcessScaleFactor: number;
  41553. /**
  41554. * Define an offset for the lens center.
  41555. */
  41556. lensCenterOffset: number;
  41557. /**
  41558. * Define if the current vr camera should compensate the distortion of the lense or not.
  41559. */
  41560. compensateDistortion: boolean;
  41561. /**
  41562. * Defines if multiview should be enabled when rendering (Default: false)
  41563. */
  41564. multiviewEnabled: boolean;
  41565. /**
  41566. * Gets the rendering aspect ratio based on the provided resolutions.
  41567. */
  41568. readonly aspectRatio: number;
  41569. /**
  41570. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  41571. */
  41572. readonly aspectRatioFov: number;
  41573. /**
  41574. * @hidden
  41575. */
  41576. readonly leftHMatrix: Matrix;
  41577. /**
  41578. * @hidden
  41579. */
  41580. readonly rightHMatrix: Matrix;
  41581. /**
  41582. * @hidden
  41583. */
  41584. readonly leftPreViewMatrix: Matrix;
  41585. /**
  41586. * @hidden
  41587. */
  41588. readonly rightPreViewMatrix: Matrix;
  41589. /**
  41590. * Get the default VRMetrics based on the most generic setup.
  41591. * @returns the default vr metrics
  41592. */
  41593. static GetDefault(): VRCameraMetrics;
  41594. }
  41595. }
  41596. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  41597. /** @hidden */
  41598. export var vrDistortionCorrectionPixelShader: {
  41599. name: string;
  41600. shader: string;
  41601. };
  41602. }
  41603. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  41604. import { Camera } from "babylonjs/Cameras/camera";
  41605. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  41606. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  41607. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  41608. /**
  41609. * VRDistortionCorrectionPostProcess used for mobile VR
  41610. */
  41611. export class VRDistortionCorrectionPostProcess extends PostProcess {
  41612. private _isRightEye;
  41613. private _distortionFactors;
  41614. private _postProcessScaleFactor;
  41615. private _lensCenterOffset;
  41616. private _scaleIn;
  41617. private _scaleFactor;
  41618. private _lensCenter;
  41619. /**
  41620. * Initializes the VRDistortionCorrectionPostProcess
  41621. * @param name The name of the effect.
  41622. * @param camera The camera to apply the render pass to.
  41623. * @param isRightEye If this is for the right eye distortion
  41624. * @param vrMetrics All the required metrics for the VR camera
  41625. */
  41626. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  41627. }
  41628. }
  41629. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  41630. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  41631. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  41632. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  41633. import { Scene } from "babylonjs/scene";
  41634. import { Vector3 } from "babylonjs/Maths/math.vector";
  41635. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  41636. import "babylonjs/Cameras/RigModes/vrRigMode";
  41637. /**
  41638. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  41639. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  41640. */
  41641. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  41642. /**
  41643. * Creates a new VRDeviceOrientationArcRotateCamera
  41644. * @param name defines camera name
  41645. * @param alpha defines the camera rotation along the logitudinal axis
  41646. * @param beta defines the camera rotation along the latitudinal axis
  41647. * @param radius defines the camera distance from its target
  41648. * @param target defines the camera target
  41649. * @param scene defines the scene the camera belongs to
  41650. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  41651. * @param vrCameraMetrics defines the vr metrics associated to the camera
  41652. */
  41653. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  41654. /**
  41655. * Gets camera class name
  41656. * @returns VRDeviceOrientationArcRotateCamera
  41657. */
  41658. getClassName(): string;
  41659. }
  41660. }
  41661. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  41662. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  41663. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  41664. import { Scene } from "babylonjs/scene";
  41665. import { Vector3 } from "babylonjs/Maths/math.vector";
  41666. import "babylonjs/Cameras/RigModes/vrRigMode";
  41667. /**
  41668. * Camera used to simulate VR rendering (based on FreeCamera)
  41669. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  41670. */
  41671. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  41672. /**
  41673. * Creates a new VRDeviceOrientationFreeCamera
  41674. * @param name defines camera name
  41675. * @param position defines the start position of the camera
  41676. * @param scene defines the scene the camera belongs to
  41677. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  41678. * @param vrCameraMetrics defines the vr metrics associated to the camera
  41679. */
  41680. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  41681. /**
  41682. * Gets camera class name
  41683. * @returns VRDeviceOrientationFreeCamera
  41684. */
  41685. getClassName(): string;
  41686. }
  41687. }
  41688. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  41689. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  41690. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  41691. import { Scene } from "babylonjs/scene";
  41692. import { Vector3 } from "babylonjs/Maths/math.vector";
  41693. import "babylonjs/Gamepads/gamepadSceneComponent";
  41694. /**
  41695. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  41696. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  41697. */
  41698. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  41699. /**
  41700. * Creates a new VRDeviceOrientationGamepadCamera
  41701. * @param name defines camera name
  41702. * @param position defines the start position of the camera
  41703. * @param scene defines the scene the camera belongs to
  41704. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  41705. * @param vrCameraMetrics defines the vr metrics associated to the camera
  41706. */
  41707. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  41708. /**
  41709. * Gets camera class name
  41710. * @returns VRDeviceOrientationGamepadCamera
  41711. */
  41712. getClassName(): string;
  41713. }
  41714. }
  41715. declare module "babylonjs/Materials/pushMaterial" {
  41716. import { Nullable } from "babylonjs/types";
  41717. import { Scene } from "babylonjs/scene";
  41718. import { Matrix } from "babylonjs/Maths/math.vector";
  41719. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41720. import { Mesh } from "babylonjs/Meshes/mesh";
  41721. import { Material } from "babylonjs/Materials/material";
  41722. import { Effect } from "babylonjs/Materials/effect";
  41723. /**
  41724. * Base class of materials working in push mode in babylon JS
  41725. * @hidden
  41726. */
  41727. export class PushMaterial extends Material {
  41728. protected _activeEffect: Effect;
  41729. protected _normalMatrix: Matrix;
  41730. /**
  41731. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  41732. * This means that the material can keep using a previous shader while a new one is being compiled.
  41733. * This is mostly used when shader parallel compilation is supported (true by default)
  41734. */
  41735. allowShaderHotSwapping: boolean;
  41736. constructor(name: string, scene: Scene);
  41737. getEffect(): Effect;
  41738. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  41739. /**
  41740. * Binds the given world matrix to the active effect
  41741. *
  41742. * @param world the matrix to bind
  41743. */
  41744. bindOnlyWorldMatrix(world: Matrix): void;
  41745. /**
  41746. * Binds the given normal matrix to the active effect
  41747. *
  41748. * @param normalMatrix the matrix to bind
  41749. */
  41750. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  41751. bind(world: Matrix, mesh?: Mesh): void;
  41752. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  41753. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  41754. }
  41755. }
  41756. declare module "babylonjs/Materials/materialFlags" {
  41757. /**
  41758. * This groups all the flags used to control the materials channel.
  41759. */
  41760. export class MaterialFlags {
  41761. private static _DiffuseTextureEnabled;
  41762. /**
  41763. * Are diffuse textures enabled in the application.
  41764. */
  41765. static DiffuseTextureEnabled: boolean;
  41766. private static _AmbientTextureEnabled;
  41767. /**
  41768. * Are ambient textures enabled in the application.
  41769. */
  41770. static AmbientTextureEnabled: boolean;
  41771. private static _OpacityTextureEnabled;
  41772. /**
  41773. * Are opacity textures enabled in the application.
  41774. */
  41775. static OpacityTextureEnabled: boolean;
  41776. private static _ReflectionTextureEnabled;
  41777. /**
  41778. * Are reflection textures enabled in the application.
  41779. */
  41780. static ReflectionTextureEnabled: boolean;
  41781. private static _EmissiveTextureEnabled;
  41782. /**
  41783. * Are emissive textures enabled in the application.
  41784. */
  41785. static EmissiveTextureEnabled: boolean;
  41786. private static _SpecularTextureEnabled;
  41787. /**
  41788. * Are specular textures enabled in the application.
  41789. */
  41790. static SpecularTextureEnabled: boolean;
  41791. private static _BumpTextureEnabled;
  41792. /**
  41793. * Are bump textures enabled in the application.
  41794. */
  41795. static BumpTextureEnabled: boolean;
  41796. private static _LightmapTextureEnabled;
  41797. /**
  41798. * Are lightmap textures enabled in the application.
  41799. */
  41800. static LightmapTextureEnabled: boolean;
  41801. private static _RefractionTextureEnabled;
  41802. /**
  41803. * Are refraction textures enabled in the application.
  41804. */
  41805. static RefractionTextureEnabled: boolean;
  41806. private static _ColorGradingTextureEnabled;
  41807. /**
  41808. * Are color grading textures enabled in the application.
  41809. */
  41810. static ColorGradingTextureEnabled: boolean;
  41811. private static _FresnelEnabled;
  41812. /**
  41813. * Are fresnels enabled in the application.
  41814. */
  41815. static FresnelEnabled: boolean;
  41816. private static _ClearCoatTextureEnabled;
  41817. /**
  41818. * Are clear coat textures enabled in the application.
  41819. */
  41820. static ClearCoatTextureEnabled: boolean;
  41821. private static _ClearCoatBumpTextureEnabled;
  41822. /**
  41823. * Are clear coat bump textures enabled in the application.
  41824. */
  41825. static ClearCoatBumpTextureEnabled: boolean;
  41826. private static _ClearCoatTintTextureEnabled;
  41827. /**
  41828. * Are clear coat tint textures enabled in the application.
  41829. */
  41830. static ClearCoatTintTextureEnabled: boolean;
  41831. private static _SheenTextureEnabled;
  41832. /**
  41833. * Are sheen textures enabled in the application.
  41834. */
  41835. static SheenTextureEnabled: boolean;
  41836. private static _AnisotropicTextureEnabled;
  41837. /**
  41838. * Are anisotropic textures enabled in the application.
  41839. */
  41840. static AnisotropicTextureEnabled: boolean;
  41841. private static _ThicknessTextureEnabled;
  41842. /**
  41843. * Are thickness textures enabled in the application.
  41844. */
  41845. static ThicknessTextureEnabled: boolean;
  41846. }
  41847. }
  41848. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  41849. /** @hidden */
  41850. export var defaultFragmentDeclaration: {
  41851. name: string;
  41852. shader: string;
  41853. };
  41854. }
  41855. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  41856. /** @hidden */
  41857. export var defaultUboDeclaration: {
  41858. name: string;
  41859. shader: string;
  41860. };
  41861. }
  41862. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  41863. /** @hidden */
  41864. export var lightFragmentDeclaration: {
  41865. name: string;
  41866. shader: string;
  41867. };
  41868. }
  41869. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  41870. /** @hidden */
  41871. export var lightUboDeclaration: {
  41872. name: string;
  41873. shader: string;
  41874. };
  41875. }
  41876. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  41877. /** @hidden */
  41878. export var lightsFragmentFunctions: {
  41879. name: string;
  41880. shader: string;
  41881. };
  41882. }
  41883. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  41884. /** @hidden */
  41885. export var shadowsFragmentFunctions: {
  41886. name: string;
  41887. shader: string;
  41888. };
  41889. }
  41890. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  41891. /** @hidden */
  41892. export var fresnelFunction: {
  41893. name: string;
  41894. shader: string;
  41895. };
  41896. }
  41897. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  41898. /** @hidden */
  41899. export var reflectionFunction: {
  41900. name: string;
  41901. shader: string;
  41902. };
  41903. }
  41904. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  41905. /** @hidden */
  41906. export var bumpFragmentFunctions: {
  41907. name: string;
  41908. shader: string;
  41909. };
  41910. }
  41911. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  41912. /** @hidden */
  41913. export var logDepthDeclaration: {
  41914. name: string;
  41915. shader: string;
  41916. };
  41917. }
  41918. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  41919. /** @hidden */
  41920. export var bumpFragment: {
  41921. name: string;
  41922. shader: string;
  41923. };
  41924. }
  41925. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  41926. /** @hidden */
  41927. export var depthPrePass: {
  41928. name: string;
  41929. shader: string;
  41930. };
  41931. }
  41932. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  41933. /** @hidden */
  41934. export var lightFragment: {
  41935. name: string;
  41936. shader: string;
  41937. };
  41938. }
  41939. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  41940. /** @hidden */
  41941. export var logDepthFragment: {
  41942. name: string;
  41943. shader: string;
  41944. };
  41945. }
  41946. declare module "babylonjs/Shaders/default.fragment" {
  41947. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  41948. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  41949. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  41950. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  41951. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  41952. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  41953. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  41954. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  41955. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  41956. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  41957. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  41958. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  41959. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  41960. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  41961. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  41962. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  41963. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  41964. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  41965. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  41966. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  41967. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  41968. /** @hidden */
  41969. export var defaultPixelShader: {
  41970. name: string;
  41971. shader: string;
  41972. };
  41973. }
  41974. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  41975. /** @hidden */
  41976. export var defaultVertexDeclaration: {
  41977. name: string;
  41978. shader: string;
  41979. };
  41980. }
  41981. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  41982. /** @hidden */
  41983. export var bumpVertexDeclaration: {
  41984. name: string;
  41985. shader: string;
  41986. };
  41987. }
  41988. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  41989. /** @hidden */
  41990. export var bumpVertex: {
  41991. name: string;
  41992. shader: string;
  41993. };
  41994. }
  41995. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  41996. /** @hidden */
  41997. export var fogVertex: {
  41998. name: string;
  41999. shader: string;
  42000. };
  42001. }
  42002. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  42003. /** @hidden */
  42004. export var shadowsVertex: {
  42005. name: string;
  42006. shader: string;
  42007. };
  42008. }
  42009. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  42010. /** @hidden */
  42011. export var pointCloudVertex: {
  42012. name: string;
  42013. shader: string;
  42014. };
  42015. }
  42016. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  42017. /** @hidden */
  42018. export var logDepthVertex: {
  42019. name: string;
  42020. shader: string;
  42021. };
  42022. }
  42023. declare module "babylonjs/Shaders/default.vertex" {
  42024. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  42025. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  42026. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  42027. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  42028. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  42029. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  42030. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  42031. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  42032. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  42033. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  42034. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  42035. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  42036. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  42037. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  42038. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  42039. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  42040. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  42041. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  42042. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  42043. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  42044. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  42045. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  42046. /** @hidden */
  42047. export var defaultVertexShader: {
  42048. name: string;
  42049. shader: string;
  42050. };
  42051. }
  42052. declare module "babylonjs/Materials/standardMaterial" {
  42053. import { SmartArray } from "babylonjs/Misc/smartArray";
  42054. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  42055. import { Nullable } from "babylonjs/types";
  42056. import { Scene } from "babylonjs/scene";
  42057. import { Matrix } from "babylonjs/Maths/math.vector";
  42058. import { Color3 } from "babylonjs/Maths/math.color";
  42059. import { SubMesh } from "babylonjs/Meshes/subMesh";
  42060. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42061. import { Mesh } from "babylonjs/Meshes/mesh";
  42062. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  42063. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  42064. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  42065. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  42066. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  42067. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  42068. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  42069. import "babylonjs/Shaders/default.fragment";
  42070. import "babylonjs/Shaders/default.vertex";
  42071. /** @hidden */
  42072. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  42073. MAINUV1: boolean;
  42074. MAINUV2: boolean;
  42075. DIFFUSE: boolean;
  42076. DIFFUSEDIRECTUV: number;
  42077. AMBIENT: boolean;
  42078. AMBIENTDIRECTUV: number;
  42079. OPACITY: boolean;
  42080. OPACITYDIRECTUV: number;
  42081. OPACITYRGB: boolean;
  42082. REFLECTION: boolean;
  42083. EMISSIVE: boolean;
  42084. EMISSIVEDIRECTUV: number;
  42085. SPECULAR: boolean;
  42086. SPECULARDIRECTUV: number;
  42087. BUMP: boolean;
  42088. BUMPDIRECTUV: number;
  42089. PARALLAX: boolean;
  42090. PARALLAXOCCLUSION: boolean;
  42091. SPECULAROVERALPHA: boolean;
  42092. CLIPPLANE: boolean;
  42093. CLIPPLANE2: boolean;
  42094. CLIPPLANE3: boolean;
  42095. CLIPPLANE4: boolean;
  42096. ALPHATEST: boolean;
  42097. DEPTHPREPASS: boolean;
  42098. ALPHAFROMDIFFUSE: boolean;
  42099. POINTSIZE: boolean;
  42100. FOG: boolean;
  42101. SPECULARTERM: boolean;
  42102. DIFFUSEFRESNEL: boolean;
  42103. OPACITYFRESNEL: boolean;
  42104. REFLECTIONFRESNEL: boolean;
  42105. REFRACTIONFRESNEL: boolean;
  42106. EMISSIVEFRESNEL: boolean;
  42107. FRESNEL: boolean;
  42108. NORMAL: boolean;
  42109. UV1: boolean;
  42110. UV2: boolean;
  42111. VERTEXCOLOR: boolean;
  42112. VERTEXALPHA: boolean;
  42113. NUM_BONE_INFLUENCERS: number;
  42114. BonesPerMesh: number;
  42115. BONETEXTURE: boolean;
  42116. INSTANCES: boolean;
  42117. GLOSSINESS: boolean;
  42118. ROUGHNESS: boolean;
  42119. EMISSIVEASILLUMINATION: boolean;
  42120. LINKEMISSIVEWITHDIFFUSE: boolean;
  42121. REFLECTIONFRESNELFROMSPECULAR: boolean;
  42122. LIGHTMAP: boolean;
  42123. LIGHTMAPDIRECTUV: number;
  42124. OBJECTSPACE_NORMALMAP: boolean;
  42125. USELIGHTMAPASSHADOWMAP: boolean;
  42126. REFLECTIONMAP_3D: boolean;
  42127. REFLECTIONMAP_SPHERICAL: boolean;
  42128. REFLECTIONMAP_PLANAR: boolean;
  42129. REFLECTIONMAP_CUBIC: boolean;
  42130. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  42131. REFLECTIONMAP_PROJECTION: boolean;
  42132. REFLECTIONMAP_SKYBOX: boolean;
  42133. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  42134. REFLECTIONMAP_EXPLICIT: boolean;
  42135. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  42136. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  42137. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  42138. INVERTCUBICMAP: boolean;
  42139. LOGARITHMICDEPTH: boolean;
  42140. REFRACTION: boolean;
  42141. REFRACTIONMAP_3D: boolean;
  42142. REFLECTIONOVERALPHA: boolean;
  42143. TWOSIDEDLIGHTING: boolean;
  42144. SHADOWFLOAT: boolean;
  42145. MORPHTARGETS: boolean;
  42146. MORPHTARGETS_NORMAL: boolean;
  42147. MORPHTARGETS_TANGENT: boolean;
  42148. MORPHTARGETS_UV: boolean;
  42149. NUM_MORPH_INFLUENCERS: number;
  42150. NONUNIFORMSCALING: boolean;
  42151. PREMULTIPLYALPHA: boolean;
  42152. IMAGEPROCESSING: boolean;
  42153. VIGNETTE: boolean;
  42154. VIGNETTEBLENDMODEMULTIPLY: boolean;
  42155. VIGNETTEBLENDMODEOPAQUE: boolean;
  42156. TONEMAPPING: boolean;
  42157. TONEMAPPING_ACES: boolean;
  42158. CONTRAST: boolean;
  42159. COLORCURVES: boolean;
  42160. COLORGRADING: boolean;
  42161. COLORGRADING3D: boolean;
  42162. SAMPLER3DGREENDEPTH: boolean;
  42163. SAMPLER3DBGRMAP: boolean;
  42164. IMAGEPROCESSINGPOSTPROCESS: boolean;
  42165. MULTIVIEW: boolean;
  42166. /**
  42167. * If the reflection texture on this material is in linear color space
  42168. * @hidden
  42169. */
  42170. IS_REFLECTION_LINEAR: boolean;
  42171. /**
  42172. * If the refraction texture on this material is in linear color space
  42173. * @hidden
  42174. */
  42175. IS_REFRACTION_LINEAR: boolean;
  42176. EXPOSURE: boolean;
  42177. constructor();
  42178. setReflectionMode(modeToEnable: string): void;
  42179. }
  42180. /**
  42181. * This is the default material used in Babylon. It is the best trade off between quality
  42182. * and performances.
  42183. * @see http://doc.babylonjs.com/babylon101/materials
  42184. */
  42185. export class StandardMaterial extends PushMaterial {
  42186. private _diffuseTexture;
  42187. /**
  42188. * The basic texture of the material as viewed under a light.
  42189. */
  42190. diffuseTexture: Nullable<BaseTexture>;
  42191. private _ambientTexture;
  42192. /**
  42193. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  42194. */
  42195. ambientTexture: Nullable<BaseTexture>;
  42196. private _opacityTexture;
  42197. /**
  42198. * Define the transparency of the material from a texture.
  42199. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  42200. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  42201. */
  42202. opacityTexture: Nullable<BaseTexture>;
  42203. private _reflectionTexture;
  42204. /**
  42205. * Define the texture used to display the reflection.
  42206. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  42207. */
  42208. reflectionTexture: Nullable<BaseTexture>;
  42209. private _emissiveTexture;
  42210. /**
  42211. * Define texture of the material as if self lit.
  42212. * This will be mixed in the final result even in the absence of light.
  42213. */
  42214. emissiveTexture: Nullable<BaseTexture>;
  42215. private _specularTexture;
  42216. /**
  42217. * Define how the color and intensity of the highlight given by the light in the material.
  42218. */
  42219. specularTexture: Nullable<BaseTexture>;
  42220. private _bumpTexture;
  42221. /**
  42222. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  42223. * 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.
  42224. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  42225. */
  42226. bumpTexture: Nullable<BaseTexture>;
  42227. private _lightmapTexture;
  42228. /**
  42229. * Complex lighting can be computationally expensive to compute at runtime.
  42230. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  42231. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  42232. */
  42233. lightmapTexture: Nullable<BaseTexture>;
  42234. private _refractionTexture;
  42235. /**
  42236. * Define the texture used to display the refraction.
  42237. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  42238. */
  42239. refractionTexture: Nullable<BaseTexture>;
  42240. /**
  42241. * The color of the material lit by the environmental background lighting.
  42242. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  42243. */
  42244. ambientColor: Color3;
  42245. /**
  42246. * The basic color of the material as viewed under a light.
  42247. */
  42248. diffuseColor: Color3;
  42249. /**
  42250. * Define how the color and intensity of the highlight given by the light in the material.
  42251. */
  42252. specularColor: Color3;
  42253. /**
  42254. * Define the color of the material as if self lit.
  42255. * This will be mixed in the final result even in the absence of light.
  42256. */
  42257. emissiveColor: Color3;
  42258. /**
  42259. * Defines how sharp are the highlights in the material.
  42260. * The bigger the value the sharper giving a more glossy feeling to the result.
  42261. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  42262. */
  42263. specularPower: number;
  42264. private _useAlphaFromDiffuseTexture;
  42265. /**
  42266. * Does the transparency come from the diffuse texture alpha channel.
  42267. */
  42268. useAlphaFromDiffuseTexture: boolean;
  42269. private _useEmissiveAsIllumination;
  42270. /**
  42271. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  42272. */
  42273. useEmissiveAsIllumination: boolean;
  42274. private _linkEmissiveWithDiffuse;
  42275. /**
  42276. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  42277. * the emissive level when the final color is close to one.
  42278. */
  42279. linkEmissiveWithDiffuse: boolean;
  42280. private _useSpecularOverAlpha;
  42281. /**
  42282. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  42283. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  42284. */
  42285. useSpecularOverAlpha: boolean;
  42286. private _useReflectionOverAlpha;
  42287. /**
  42288. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  42289. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  42290. */
  42291. useReflectionOverAlpha: boolean;
  42292. private _disableLighting;
  42293. /**
  42294. * Does lights from the scene impacts this material.
  42295. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  42296. */
  42297. disableLighting: boolean;
  42298. private _useObjectSpaceNormalMap;
  42299. /**
  42300. * Allows using an object space normal map (instead of tangent space).
  42301. */
  42302. useObjectSpaceNormalMap: boolean;
  42303. private _useParallax;
  42304. /**
  42305. * Is parallax enabled or not.
  42306. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  42307. */
  42308. useParallax: boolean;
  42309. private _useParallaxOcclusion;
  42310. /**
  42311. * Is parallax occlusion enabled or not.
  42312. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  42313. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  42314. */
  42315. useParallaxOcclusion: boolean;
  42316. /**
  42317. * 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.
  42318. */
  42319. parallaxScaleBias: number;
  42320. private _roughness;
  42321. /**
  42322. * Helps to define how blurry the reflections should appears in the material.
  42323. */
  42324. roughness: number;
  42325. /**
  42326. * In case of refraction, define the value of the index of refraction.
  42327. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  42328. */
  42329. indexOfRefraction: number;
  42330. /**
  42331. * Invert the refraction texture alongside the y axis.
  42332. * It can be useful with procedural textures or probe for instance.
  42333. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  42334. */
  42335. invertRefractionY: boolean;
  42336. /**
  42337. * Defines the alpha limits in alpha test mode.
  42338. */
  42339. alphaCutOff: number;
  42340. private _useLightmapAsShadowmap;
  42341. /**
  42342. * In case of light mapping, define whether the map contains light or shadow informations.
  42343. */
  42344. useLightmapAsShadowmap: boolean;
  42345. private _diffuseFresnelParameters;
  42346. /**
  42347. * Define the diffuse fresnel parameters of the material.
  42348. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  42349. */
  42350. diffuseFresnelParameters: FresnelParameters;
  42351. private _opacityFresnelParameters;
  42352. /**
  42353. * Define the opacity fresnel parameters of the material.
  42354. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  42355. */
  42356. opacityFresnelParameters: FresnelParameters;
  42357. private _reflectionFresnelParameters;
  42358. /**
  42359. * Define the reflection fresnel parameters of the material.
  42360. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  42361. */
  42362. reflectionFresnelParameters: FresnelParameters;
  42363. private _refractionFresnelParameters;
  42364. /**
  42365. * Define the refraction fresnel parameters of the material.
  42366. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  42367. */
  42368. refractionFresnelParameters: FresnelParameters;
  42369. private _emissiveFresnelParameters;
  42370. /**
  42371. * Define the emissive fresnel parameters of the material.
  42372. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  42373. */
  42374. emissiveFresnelParameters: FresnelParameters;
  42375. private _useReflectionFresnelFromSpecular;
  42376. /**
  42377. * If true automatically deducts the fresnels values from the material specularity.
  42378. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  42379. */
  42380. useReflectionFresnelFromSpecular: boolean;
  42381. private _useGlossinessFromSpecularMapAlpha;
  42382. /**
  42383. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  42384. */
  42385. useGlossinessFromSpecularMapAlpha: boolean;
  42386. private _maxSimultaneousLights;
  42387. /**
  42388. * Defines the maximum number of lights that can be used in the material
  42389. */
  42390. maxSimultaneousLights: number;
  42391. private _invertNormalMapX;
  42392. /**
  42393. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  42394. */
  42395. invertNormalMapX: boolean;
  42396. private _invertNormalMapY;
  42397. /**
  42398. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  42399. */
  42400. invertNormalMapY: boolean;
  42401. private _twoSidedLighting;
  42402. /**
  42403. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  42404. */
  42405. twoSidedLighting: boolean;
  42406. /**
  42407. * Default configuration related to image processing available in the standard Material.
  42408. */
  42409. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  42410. /**
  42411. * Gets the image processing configuration used either in this material.
  42412. */
  42413. /**
  42414. * Sets the Default image processing configuration used either in the this material.
  42415. *
  42416. * If sets to null, the scene one is in use.
  42417. */
  42418. imageProcessingConfiguration: ImageProcessingConfiguration;
  42419. /**
  42420. * Keep track of the image processing observer to allow dispose and replace.
  42421. */
  42422. private _imageProcessingObserver;
  42423. /**
  42424. * Attaches a new image processing configuration to the Standard Material.
  42425. * @param configuration
  42426. */
  42427. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  42428. /**
  42429. * Gets wether the color curves effect is enabled.
  42430. */
  42431. /**
  42432. * Sets wether the color curves effect is enabled.
  42433. */
  42434. cameraColorCurvesEnabled: boolean;
  42435. /**
  42436. * Gets wether the color grading effect is enabled.
  42437. */
  42438. /**
  42439. * Gets wether the color grading effect is enabled.
  42440. */
  42441. cameraColorGradingEnabled: boolean;
  42442. /**
  42443. * Gets wether tonemapping is enabled or not.
  42444. */
  42445. /**
  42446. * Sets wether tonemapping is enabled or not
  42447. */
  42448. cameraToneMappingEnabled: boolean;
  42449. /**
  42450. * The camera exposure used on this material.
  42451. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  42452. * This corresponds to a photographic exposure.
  42453. */
  42454. /**
  42455. * The camera exposure used on this material.
  42456. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  42457. * This corresponds to a photographic exposure.
  42458. */
  42459. cameraExposure: number;
  42460. /**
  42461. * Gets The camera contrast used on this material.
  42462. */
  42463. /**
  42464. * Sets The camera contrast used on this material.
  42465. */
  42466. cameraContrast: number;
  42467. /**
  42468. * Gets the Color Grading 2D Lookup Texture.
  42469. */
  42470. /**
  42471. * Sets the Color Grading 2D Lookup Texture.
  42472. */
  42473. cameraColorGradingTexture: Nullable<BaseTexture>;
  42474. /**
  42475. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  42476. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  42477. * 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;
  42478. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  42479. */
  42480. /**
  42481. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  42482. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  42483. * 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;
  42484. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  42485. */
  42486. cameraColorCurves: Nullable<ColorCurves>;
  42487. /**
  42488. * Custom callback helping to override the default shader used in the material.
  42489. */
  42490. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  42491. protected _renderTargets: SmartArray<RenderTargetTexture>;
  42492. protected _worldViewProjectionMatrix: Matrix;
  42493. protected _globalAmbientColor: Color3;
  42494. protected _useLogarithmicDepth: boolean;
  42495. protected _rebuildInParallel: boolean;
  42496. /**
  42497. * Instantiates a new standard material.
  42498. * This is the default material used in Babylon. It is the best trade off between quality
  42499. * and performances.
  42500. * @see http://doc.babylonjs.com/babylon101/materials
  42501. * @param name Define the name of the material in the scene
  42502. * @param scene Define the scene the material belong to
  42503. */
  42504. constructor(name: string, scene: Scene);
  42505. /**
  42506. * Gets a boolean indicating that current material needs to register RTT
  42507. */
  42508. readonly hasRenderTargetTextures: boolean;
  42509. /**
  42510. * Gets the current class name of the material e.g. "StandardMaterial"
  42511. * Mainly use in serialization.
  42512. * @returns the class name
  42513. */
  42514. getClassName(): string;
  42515. /**
  42516. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  42517. * You can try switching to logarithmic depth.
  42518. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  42519. */
  42520. useLogarithmicDepth: boolean;
  42521. /**
  42522. * Specifies if the material will require alpha blending
  42523. * @returns a boolean specifying if alpha blending is needed
  42524. */
  42525. needAlphaBlending(): boolean;
  42526. /**
  42527. * Specifies if this material should be rendered in alpha test mode
  42528. * @returns a boolean specifying if an alpha test is needed.
  42529. */
  42530. needAlphaTesting(): boolean;
  42531. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  42532. /**
  42533. * Get the texture used for alpha test purpose.
  42534. * @returns the diffuse texture in case of the standard material.
  42535. */
  42536. getAlphaTestTexture(): Nullable<BaseTexture>;
  42537. /**
  42538. * Get if the submesh is ready to be used and all its information available.
  42539. * Child classes can use it to update shaders
  42540. * @param mesh defines the mesh to check
  42541. * @param subMesh defines which submesh to check
  42542. * @param useInstances specifies that instances should be used
  42543. * @returns a boolean indicating that the submesh is ready or not
  42544. */
  42545. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  42546. /**
  42547. * Builds the material UBO layouts.
  42548. * Used internally during the effect preparation.
  42549. */
  42550. buildUniformLayout(): void;
  42551. /**
  42552. * Unbinds the material from the mesh
  42553. */
  42554. unbind(): void;
  42555. /**
  42556. * Binds the submesh to this material by preparing the effect and shader to draw
  42557. * @param world defines the world transformation matrix
  42558. * @param mesh defines the mesh containing the submesh
  42559. * @param subMesh defines the submesh to bind the material to
  42560. */
  42561. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  42562. /**
  42563. * Get the list of animatables in the material.
  42564. * @returns the list of animatables object used in the material
  42565. */
  42566. getAnimatables(): IAnimatable[];
  42567. /**
  42568. * Gets the active textures from the material
  42569. * @returns an array of textures
  42570. */
  42571. getActiveTextures(): BaseTexture[];
  42572. /**
  42573. * Specifies if the material uses a texture
  42574. * @param texture defines the texture to check against the material
  42575. * @returns a boolean specifying if the material uses the texture
  42576. */
  42577. hasTexture(texture: BaseTexture): boolean;
  42578. /**
  42579. * Disposes the material
  42580. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  42581. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  42582. */
  42583. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  42584. /**
  42585. * Makes a duplicate of the material, and gives it a new name
  42586. * @param name defines the new name for the duplicated material
  42587. * @returns the cloned material
  42588. */
  42589. clone(name: string): StandardMaterial;
  42590. /**
  42591. * Serializes this material in a JSON representation
  42592. * @returns the serialized material object
  42593. */
  42594. serialize(): any;
  42595. /**
  42596. * Creates a standard material from parsed material data
  42597. * @param source defines the JSON representation of the material
  42598. * @param scene defines the hosting scene
  42599. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  42600. * @returns a new standard material
  42601. */
  42602. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  42603. /**
  42604. * Are diffuse textures enabled in the application.
  42605. */
  42606. static DiffuseTextureEnabled: boolean;
  42607. /**
  42608. * Are ambient textures enabled in the application.
  42609. */
  42610. static AmbientTextureEnabled: boolean;
  42611. /**
  42612. * Are opacity textures enabled in the application.
  42613. */
  42614. static OpacityTextureEnabled: boolean;
  42615. /**
  42616. * Are reflection textures enabled in the application.
  42617. */
  42618. static ReflectionTextureEnabled: boolean;
  42619. /**
  42620. * Are emissive textures enabled in the application.
  42621. */
  42622. static EmissiveTextureEnabled: boolean;
  42623. /**
  42624. * Are specular textures enabled in the application.
  42625. */
  42626. static SpecularTextureEnabled: boolean;
  42627. /**
  42628. * Are bump textures enabled in the application.
  42629. */
  42630. static BumpTextureEnabled: boolean;
  42631. /**
  42632. * Are lightmap textures enabled in the application.
  42633. */
  42634. static LightmapTextureEnabled: boolean;
  42635. /**
  42636. * Are refraction textures enabled in the application.
  42637. */
  42638. static RefractionTextureEnabled: boolean;
  42639. /**
  42640. * Are color grading textures enabled in the application.
  42641. */
  42642. static ColorGradingTextureEnabled: boolean;
  42643. /**
  42644. * Are fresnels enabled in the application.
  42645. */
  42646. static FresnelEnabled: boolean;
  42647. }
  42648. }
  42649. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  42650. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  42651. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  42652. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  42653. /** @hidden */
  42654. export var imageProcessingPixelShader: {
  42655. name: string;
  42656. shader: string;
  42657. };
  42658. }
  42659. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  42660. import { Nullable } from "babylonjs/types";
  42661. import { Color4 } from "babylonjs/Maths/math.color";
  42662. import { Camera } from "babylonjs/Cameras/camera";
  42663. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  42664. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  42665. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  42666. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  42667. import { Engine } from "babylonjs/Engines/engine";
  42668. import "babylonjs/Shaders/imageProcessing.fragment";
  42669. import "babylonjs/Shaders/postprocess.vertex";
  42670. /**
  42671. * ImageProcessingPostProcess
  42672. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  42673. */
  42674. export class ImageProcessingPostProcess extends PostProcess {
  42675. /**
  42676. * Default configuration related to image processing available in the PBR Material.
  42677. */
  42678. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  42679. /**
  42680. * Gets the image processing configuration used either in this material.
  42681. */
  42682. /**
  42683. * Sets the Default image processing configuration used either in the this material.
  42684. *
  42685. * If sets to null, the scene one is in use.
  42686. */
  42687. imageProcessingConfiguration: ImageProcessingConfiguration;
  42688. /**
  42689. * Keep track of the image processing observer to allow dispose and replace.
  42690. */
  42691. private _imageProcessingObserver;
  42692. /**
  42693. * Attaches a new image processing configuration to the PBR Material.
  42694. * @param configuration
  42695. */
  42696. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  42697. /**
  42698. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  42699. */
  42700. /**
  42701. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  42702. */
  42703. colorCurves: Nullable<ColorCurves>;
  42704. /**
  42705. * Gets wether the color curves effect is enabled.
  42706. */
  42707. /**
  42708. * Sets wether the color curves effect is enabled.
  42709. */
  42710. colorCurvesEnabled: boolean;
  42711. /**
  42712. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  42713. */
  42714. /**
  42715. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  42716. */
  42717. colorGradingTexture: Nullable<BaseTexture>;
  42718. /**
  42719. * Gets wether the color grading effect is enabled.
  42720. */
  42721. /**
  42722. * Gets wether the color grading effect is enabled.
  42723. */
  42724. colorGradingEnabled: boolean;
  42725. /**
  42726. * Gets exposure used in the effect.
  42727. */
  42728. /**
  42729. * Sets exposure used in the effect.
  42730. */
  42731. exposure: number;
  42732. /**
  42733. * Gets wether tonemapping is enabled or not.
  42734. */
  42735. /**
  42736. * Sets wether tonemapping is enabled or not
  42737. */
  42738. toneMappingEnabled: boolean;
  42739. /**
  42740. * Gets the type of tone mapping effect.
  42741. */
  42742. /**
  42743. * Sets the type of tone mapping effect.
  42744. */
  42745. toneMappingType: number;
  42746. /**
  42747. * Gets contrast used in the effect.
  42748. */
  42749. /**
  42750. * Sets contrast used in the effect.
  42751. */
  42752. contrast: number;
  42753. /**
  42754. * Gets Vignette stretch size.
  42755. */
  42756. /**
  42757. * Sets Vignette stretch size.
  42758. */
  42759. vignetteStretch: number;
  42760. /**
  42761. * Gets Vignette centre X Offset.
  42762. */
  42763. /**
  42764. * Sets Vignette centre X Offset.
  42765. */
  42766. vignetteCentreX: number;
  42767. /**
  42768. * Gets Vignette centre Y Offset.
  42769. */
  42770. /**
  42771. * Sets Vignette centre Y Offset.
  42772. */
  42773. vignetteCentreY: number;
  42774. /**
  42775. * Gets Vignette weight or intensity of the vignette effect.
  42776. */
  42777. /**
  42778. * Sets Vignette weight or intensity of the vignette effect.
  42779. */
  42780. vignetteWeight: number;
  42781. /**
  42782. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  42783. * if vignetteEnabled is set to true.
  42784. */
  42785. /**
  42786. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  42787. * if vignetteEnabled is set to true.
  42788. */
  42789. vignetteColor: Color4;
  42790. /**
  42791. * Gets Camera field of view used by the Vignette effect.
  42792. */
  42793. /**
  42794. * Sets Camera field of view used by the Vignette effect.
  42795. */
  42796. vignetteCameraFov: number;
  42797. /**
  42798. * Gets the vignette blend mode allowing different kind of effect.
  42799. */
  42800. /**
  42801. * Sets the vignette blend mode allowing different kind of effect.
  42802. */
  42803. vignetteBlendMode: number;
  42804. /**
  42805. * Gets wether the vignette effect is enabled.
  42806. */
  42807. /**
  42808. * Sets wether the vignette effect is enabled.
  42809. */
  42810. vignetteEnabled: boolean;
  42811. private _fromLinearSpace;
  42812. /**
  42813. * Gets wether the input of the processing is in Gamma or Linear Space.
  42814. */
  42815. /**
  42816. * Sets wether the input of the processing is in Gamma or Linear Space.
  42817. */
  42818. fromLinearSpace: boolean;
  42819. /**
  42820. * Defines cache preventing GC.
  42821. */
  42822. private _defines;
  42823. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  42824. /**
  42825. * "ImageProcessingPostProcess"
  42826. * @returns "ImageProcessingPostProcess"
  42827. */
  42828. getClassName(): string;
  42829. protected _updateParameters(): void;
  42830. dispose(camera?: Camera): void;
  42831. }
  42832. }
  42833. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  42834. import { Scene } from "babylonjs/scene";
  42835. import { Color3 } from "babylonjs/Maths/math.color";
  42836. import { Mesh } from "babylonjs/Meshes/mesh";
  42837. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  42838. import { Nullable } from "babylonjs/types";
  42839. /**
  42840. * Class containing static functions to help procedurally build meshes
  42841. */
  42842. export class GroundBuilder {
  42843. /**
  42844. * Creates a ground mesh
  42845. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  42846. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  42847. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42848. * @param name defines the name of the mesh
  42849. * @param options defines the options used to create the mesh
  42850. * @param scene defines the hosting scene
  42851. * @returns the ground mesh
  42852. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  42853. */
  42854. static CreateGround(name: string, options: {
  42855. width?: number;
  42856. height?: number;
  42857. subdivisions?: number;
  42858. subdivisionsX?: number;
  42859. subdivisionsY?: number;
  42860. updatable?: boolean;
  42861. }, scene: any): Mesh;
  42862. /**
  42863. * Creates a tiled ground mesh
  42864. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  42865. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  42866. * * 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
  42867. * * 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
  42868. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42869. * @param name defines the name of the mesh
  42870. * @param options defines the options used to create the mesh
  42871. * @param scene defines the hosting scene
  42872. * @returns the tiled ground mesh
  42873. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  42874. */
  42875. static CreateTiledGround(name: string, options: {
  42876. xmin: number;
  42877. zmin: number;
  42878. xmax: number;
  42879. zmax: number;
  42880. subdivisions?: {
  42881. w: number;
  42882. h: number;
  42883. };
  42884. precision?: {
  42885. w: number;
  42886. h: number;
  42887. };
  42888. updatable?: boolean;
  42889. }, scene?: Nullable<Scene>): Mesh;
  42890. /**
  42891. * Creates a ground mesh from a height map
  42892. * * The parameter `url` sets the URL of the height map image resource.
  42893. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  42894. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  42895. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  42896. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  42897. * * 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.
  42898. * * 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).
  42899. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  42900. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42901. * @param name defines the name of the mesh
  42902. * @param url defines the url to the height map
  42903. * @param options defines the options used to create the mesh
  42904. * @param scene defines the hosting scene
  42905. * @returns the ground mesh
  42906. * @see https://doc.babylonjs.com/babylon101/height_map
  42907. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  42908. */
  42909. static CreateGroundFromHeightMap(name: string, url: string, options: {
  42910. width?: number;
  42911. height?: number;
  42912. subdivisions?: number;
  42913. minHeight?: number;
  42914. maxHeight?: number;
  42915. colorFilter?: Color3;
  42916. alphaFilter?: number;
  42917. updatable?: boolean;
  42918. onReady?: (mesh: GroundMesh) => void;
  42919. }, scene?: Nullable<Scene>): GroundMesh;
  42920. }
  42921. }
  42922. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  42923. import { Vector4 } from "babylonjs/Maths/math.vector";
  42924. import { Mesh } from "babylonjs/Meshes/mesh";
  42925. /**
  42926. * Class containing static functions to help procedurally build meshes
  42927. */
  42928. export class TorusBuilder {
  42929. /**
  42930. * Creates a torus mesh
  42931. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  42932. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  42933. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  42934. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42935. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  42936. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42937. * @param name defines the name of the mesh
  42938. * @param options defines the options used to create the mesh
  42939. * @param scene defines the hosting scene
  42940. * @returns the torus mesh
  42941. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  42942. */
  42943. static CreateTorus(name: string, options: {
  42944. diameter?: number;
  42945. thickness?: number;
  42946. tessellation?: number;
  42947. updatable?: boolean;
  42948. sideOrientation?: number;
  42949. frontUVs?: Vector4;
  42950. backUVs?: Vector4;
  42951. }, scene: any): Mesh;
  42952. }
  42953. }
  42954. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  42955. import { Vector4 } from "babylonjs/Maths/math.vector";
  42956. import { Color4 } from "babylonjs/Maths/math.color";
  42957. import { Mesh } from "babylonjs/Meshes/mesh";
  42958. /**
  42959. * Class containing static functions to help procedurally build meshes
  42960. */
  42961. export class CylinderBuilder {
  42962. /**
  42963. * Creates a cylinder or a cone mesh
  42964. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  42965. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  42966. * * 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.
  42967. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  42968. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  42969. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  42970. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  42971. * * 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).
  42972. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  42973. * * 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).
  42974. * * 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
  42975. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  42976. * * 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
  42977. * * 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.
  42978. * * If `enclose` is false, a ring surface is one element.
  42979. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  42980. * * 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
  42981. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42982. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  42983. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42984. * @param name defines the name of the mesh
  42985. * @param options defines the options used to create the mesh
  42986. * @param scene defines the hosting scene
  42987. * @returns the cylinder mesh
  42988. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  42989. */
  42990. static CreateCylinder(name: string, options: {
  42991. height?: number;
  42992. diameterTop?: number;
  42993. diameterBottom?: number;
  42994. diameter?: number;
  42995. tessellation?: number;
  42996. subdivisions?: number;
  42997. arc?: number;
  42998. faceColors?: Color4[];
  42999. faceUV?: Vector4[];
  43000. updatable?: boolean;
  43001. hasRings?: boolean;
  43002. enclose?: boolean;
  43003. cap?: number;
  43004. sideOrientation?: number;
  43005. frontUVs?: Vector4;
  43006. backUVs?: Vector4;
  43007. }, scene: any): Mesh;
  43008. }
  43009. }
  43010. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  43011. import { Observable } from "babylonjs/Misc/observable";
  43012. import { Nullable } from "babylonjs/types";
  43013. import { Camera } from "babylonjs/Cameras/camera";
  43014. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  43015. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  43016. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  43017. import { Scene } from "babylonjs/scene";
  43018. import { Vector3 } from "babylonjs/Maths/math.vector";
  43019. import { Color3 } from "babylonjs/Maths/math.color";
  43020. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43021. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43022. import { Mesh } from "babylonjs/Meshes/mesh";
  43023. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  43024. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  43025. import "babylonjs/Meshes/Builders/groundBuilder";
  43026. import "babylonjs/Meshes/Builders/torusBuilder";
  43027. import "babylonjs/Meshes/Builders/cylinderBuilder";
  43028. import "babylonjs/Gamepads/gamepadSceneComponent";
  43029. import "babylonjs/Animations/animatable";
  43030. /**
  43031. * Options to modify the vr teleportation behavior.
  43032. */
  43033. export interface VRTeleportationOptions {
  43034. /**
  43035. * The name of the mesh which should be used as the teleportation floor. (default: null)
  43036. */
  43037. floorMeshName?: string;
  43038. /**
  43039. * A list of meshes to be used as the teleportation floor. (default: empty)
  43040. */
  43041. floorMeshes?: Mesh[];
  43042. /**
  43043. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  43044. */
  43045. teleportationMode?: number;
  43046. /**
  43047. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  43048. */
  43049. teleportationTime?: number;
  43050. /**
  43051. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  43052. */
  43053. teleportationSpeed?: number;
  43054. }
  43055. /**
  43056. * Options to modify the vr experience helper's behavior.
  43057. */
  43058. export interface VRExperienceHelperOptions extends WebVROptions {
  43059. /**
  43060. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  43061. */
  43062. createDeviceOrientationCamera?: boolean;
  43063. /**
  43064. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  43065. */
  43066. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  43067. /**
  43068. * Uses the main button on the controller to toggle the laser casted. (default: true)
  43069. */
  43070. laserToggle?: boolean;
  43071. /**
  43072. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  43073. */
  43074. floorMeshes?: Mesh[];
  43075. /**
  43076. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  43077. */
  43078. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  43079. }
  43080. /**
  43081. * Event containing information after VR has been entered
  43082. */
  43083. export class OnAfterEnteringVRObservableEvent {
  43084. /**
  43085. * If entering vr was successful
  43086. */
  43087. success: boolean;
  43088. }
  43089. /**
  43090. * Helps to quickly add VR support to an existing scene.
  43091. * See http://doc.babylonjs.com/how_to/webvr_helper
  43092. */
  43093. export class VRExperienceHelper {
  43094. /** Options to modify the vr experience helper's behavior. */
  43095. webVROptions: VRExperienceHelperOptions;
  43096. private _scene;
  43097. private _position;
  43098. private _btnVR;
  43099. private _btnVRDisplayed;
  43100. private _webVRsupported;
  43101. private _webVRready;
  43102. private _webVRrequesting;
  43103. private _webVRpresenting;
  43104. private _hasEnteredVR;
  43105. private _fullscreenVRpresenting;
  43106. private _inputElement;
  43107. private _webVRCamera;
  43108. private _vrDeviceOrientationCamera;
  43109. private _deviceOrientationCamera;
  43110. private _existingCamera;
  43111. private _onKeyDown;
  43112. private _onVrDisplayPresentChange;
  43113. private _onVRDisplayChanged;
  43114. private _onVRRequestPresentStart;
  43115. private _onVRRequestPresentComplete;
  43116. /**
  43117. * 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)
  43118. */
  43119. enableGazeEvenWhenNoPointerLock: boolean;
  43120. /**
  43121. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  43122. */
  43123. exitVROnDoubleTap: boolean;
  43124. /**
  43125. * Observable raised right before entering VR.
  43126. */
  43127. onEnteringVRObservable: Observable<VRExperienceHelper>;
  43128. /**
  43129. * Observable raised when entering VR has completed.
  43130. */
  43131. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  43132. /**
  43133. * Observable raised when exiting VR.
  43134. */
  43135. onExitingVRObservable: Observable<VRExperienceHelper>;
  43136. /**
  43137. * Observable raised when controller mesh is loaded.
  43138. */
  43139. onControllerMeshLoadedObservable: Observable<WebVRController>;
  43140. /** Return this.onEnteringVRObservable
  43141. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  43142. */
  43143. readonly onEnteringVR: Observable<VRExperienceHelper>;
  43144. /** Return this.onExitingVRObservable
  43145. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  43146. */
  43147. readonly onExitingVR: Observable<VRExperienceHelper>;
  43148. /** Return this.onControllerMeshLoadedObservable
  43149. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  43150. */
  43151. readonly onControllerMeshLoaded: Observable<WebVRController>;
  43152. private _rayLength;
  43153. private _useCustomVRButton;
  43154. private _teleportationRequested;
  43155. private _teleportActive;
  43156. private _floorMeshName;
  43157. private _floorMeshesCollection;
  43158. private _teleportationMode;
  43159. private _teleportationTime;
  43160. private _teleportationSpeed;
  43161. private _rotationAllowed;
  43162. private _teleportBackwardsVector;
  43163. private _teleportationTarget;
  43164. private _isDefaultTeleportationTarget;
  43165. private _postProcessMove;
  43166. private _teleportationFillColor;
  43167. private _teleportationBorderColor;
  43168. private _rotationAngle;
  43169. private _haloCenter;
  43170. private _cameraGazer;
  43171. private _padSensibilityUp;
  43172. private _padSensibilityDown;
  43173. private _leftController;
  43174. private _rightController;
  43175. /**
  43176. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  43177. */
  43178. onNewMeshSelected: Observable<AbstractMesh>;
  43179. /**
  43180. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  43181. * This observable will provide the mesh and the controller used to select the mesh
  43182. */
  43183. onMeshSelectedWithController: Observable<{
  43184. mesh: AbstractMesh;
  43185. controller: WebVRController;
  43186. }>;
  43187. /**
  43188. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  43189. */
  43190. onNewMeshPicked: Observable<PickingInfo>;
  43191. private _circleEase;
  43192. /**
  43193. * Observable raised before camera teleportation
  43194. */
  43195. onBeforeCameraTeleport: Observable<Vector3>;
  43196. /**
  43197. * Observable raised after camera teleportation
  43198. */
  43199. onAfterCameraTeleport: Observable<Vector3>;
  43200. /**
  43201. * Observable raised when current selected mesh gets unselected
  43202. */
  43203. onSelectedMeshUnselected: Observable<AbstractMesh>;
  43204. private _raySelectionPredicate;
  43205. /**
  43206. * To be optionaly changed by user to define custom ray selection
  43207. */
  43208. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  43209. /**
  43210. * To be optionaly changed by user to define custom selection logic (after ray selection)
  43211. */
  43212. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  43213. /**
  43214. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  43215. */
  43216. teleportationEnabled: boolean;
  43217. private _defaultHeight;
  43218. private _teleportationInitialized;
  43219. private _interactionsEnabled;
  43220. private _interactionsRequested;
  43221. private _displayGaze;
  43222. private _displayLaserPointer;
  43223. /**
  43224. * The mesh used to display where the user is going to teleport.
  43225. */
  43226. /**
  43227. * Sets the mesh to be used to display where the user is going to teleport.
  43228. */
  43229. teleportationTarget: Mesh;
  43230. /**
  43231. * 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
  43232. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  43233. * See http://doc.babylonjs.com/resources/baking_transformations
  43234. */
  43235. gazeTrackerMesh: Mesh;
  43236. /**
  43237. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  43238. */
  43239. updateGazeTrackerScale: boolean;
  43240. /**
  43241. * If the gaze trackers color should be updated when selecting meshes
  43242. */
  43243. updateGazeTrackerColor: boolean;
  43244. /**
  43245. * If the controller laser color should be updated when selecting meshes
  43246. */
  43247. updateControllerLaserColor: boolean;
  43248. /**
  43249. * The gaze tracking mesh corresponding to the left controller
  43250. */
  43251. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  43252. /**
  43253. * The gaze tracking mesh corresponding to the right controller
  43254. */
  43255. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  43256. /**
  43257. * If the ray of the gaze should be displayed.
  43258. */
  43259. /**
  43260. * Sets if the ray of the gaze should be displayed.
  43261. */
  43262. displayGaze: boolean;
  43263. /**
  43264. * If the ray of the LaserPointer should be displayed.
  43265. */
  43266. /**
  43267. * Sets if the ray of the LaserPointer should be displayed.
  43268. */
  43269. displayLaserPointer: boolean;
  43270. /**
  43271. * The deviceOrientationCamera used as the camera when not in VR.
  43272. */
  43273. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  43274. /**
  43275. * Based on the current WebVR support, returns the current VR camera used.
  43276. */
  43277. readonly currentVRCamera: Nullable<Camera>;
  43278. /**
  43279. * The webVRCamera which is used when in VR.
  43280. */
  43281. readonly webVRCamera: WebVRFreeCamera;
  43282. /**
  43283. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  43284. */
  43285. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  43286. /**
  43287. * The html button that is used to trigger entering into VR.
  43288. */
  43289. readonly vrButton: Nullable<HTMLButtonElement>;
  43290. private readonly _teleportationRequestInitiated;
  43291. /**
  43292. * Defines wether or not Pointer lock should be requested when switching to
  43293. * full screen.
  43294. */
  43295. requestPointerLockOnFullScreen: boolean;
  43296. /**
  43297. * Instantiates a VRExperienceHelper.
  43298. * Helps to quickly add VR support to an existing scene.
  43299. * @param scene The scene the VRExperienceHelper belongs to.
  43300. * @param webVROptions Options to modify the vr experience helper's behavior.
  43301. */
  43302. constructor(scene: Scene,
  43303. /** Options to modify the vr experience helper's behavior. */
  43304. webVROptions?: VRExperienceHelperOptions);
  43305. private _onDefaultMeshLoaded;
  43306. private _onResize;
  43307. private _onFullscreenChange;
  43308. /**
  43309. * Gets a value indicating if we are currently in VR mode.
  43310. */
  43311. readonly isInVRMode: boolean;
  43312. private onVrDisplayPresentChange;
  43313. private onVRDisplayChanged;
  43314. private moveButtonToBottomRight;
  43315. private displayVRButton;
  43316. private updateButtonVisibility;
  43317. private _cachedAngularSensibility;
  43318. /**
  43319. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  43320. * Otherwise, will use the fullscreen API.
  43321. */
  43322. enterVR(): void;
  43323. /**
  43324. * Attempt to exit VR, or fullscreen.
  43325. */
  43326. exitVR(): void;
  43327. /**
  43328. * The position of the vr experience helper.
  43329. */
  43330. /**
  43331. * Sets the position of the vr experience helper.
  43332. */
  43333. position: Vector3;
  43334. /**
  43335. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  43336. */
  43337. enableInteractions(): void;
  43338. private readonly _noControllerIsActive;
  43339. private beforeRender;
  43340. private _isTeleportationFloor;
  43341. /**
  43342. * Adds a floor mesh to be used for teleportation.
  43343. * @param floorMesh the mesh to be used for teleportation.
  43344. */
  43345. addFloorMesh(floorMesh: Mesh): void;
  43346. /**
  43347. * Removes a floor mesh from being used for teleportation.
  43348. * @param floorMesh the mesh to be removed.
  43349. */
  43350. removeFloorMesh(floorMesh: Mesh): void;
  43351. /**
  43352. * Enables interactions and teleportation using the VR controllers and gaze.
  43353. * @param vrTeleportationOptions options to modify teleportation behavior.
  43354. */
  43355. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  43356. private _onNewGamepadConnected;
  43357. private _tryEnableInteractionOnController;
  43358. private _onNewGamepadDisconnected;
  43359. private _enableInteractionOnController;
  43360. private _checkTeleportWithRay;
  43361. private _checkRotate;
  43362. private _checkTeleportBackwards;
  43363. private _enableTeleportationOnController;
  43364. private _createTeleportationCircles;
  43365. private _displayTeleportationTarget;
  43366. private _hideTeleportationTarget;
  43367. private _rotateCamera;
  43368. private _moveTeleportationSelectorTo;
  43369. private _workingVector;
  43370. private _workingQuaternion;
  43371. private _workingMatrix;
  43372. /**
  43373. * Time Constant Teleportation Mode
  43374. */
  43375. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  43376. /**
  43377. * Speed Constant Teleportation Mode
  43378. */
  43379. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  43380. /**
  43381. * Teleports the users feet to the desired location
  43382. * @param location The location where the user's feet should be placed
  43383. */
  43384. teleportCamera(location: Vector3): void;
  43385. private _convertNormalToDirectionOfRay;
  43386. private _castRayAndSelectObject;
  43387. private _notifySelectedMeshUnselected;
  43388. /**
  43389. * Sets the color of the laser ray from the vr controllers.
  43390. * @param color new color for the ray.
  43391. */
  43392. changeLaserColor(color: Color3): void;
  43393. /**
  43394. * Sets the color of the ray from the vr headsets gaze.
  43395. * @param color new color for the ray.
  43396. */
  43397. changeGazeColor(color: Color3): void;
  43398. /**
  43399. * Exits VR and disposes of the vr experience helper
  43400. */
  43401. dispose(): void;
  43402. /**
  43403. * Gets the name of the VRExperienceHelper class
  43404. * @returns "VRExperienceHelper"
  43405. */
  43406. getClassName(): string;
  43407. }
  43408. }
  43409. declare module "babylonjs/Cameras/VR/index" {
  43410. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  43411. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  43412. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  43413. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  43414. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  43415. export * from "babylonjs/Cameras/VR/webVRCamera";
  43416. }
  43417. declare module "babylonjs/Cameras/XR/webXRTypes" {
  43418. import { Nullable } from "babylonjs/types";
  43419. import { IDisposable } from "babylonjs/scene";
  43420. /**
  43421. * States of the webXR experience
  43422. */
  43423. export enum WebXRState {
  43424. /**
  43425. * Transitioning to being in XR mode
  43426. */
  43427. ENTERING_XR = 0,
  43428. /**
  43429. * Transitioning to non XR mode
  43430. */
  43431. EXITING_XR = 1,
  43432. /**
  43433. * In XR mode and presenting
  43434. */
  43435. IN_XR = 2,
  43436. /**
  43437. * Not entered XR mode
  43438. */
  43439. NOT_IN_XR = 3
  43440. }
  43441. /**
  43442. * Abstraction of the XR render target
  43443. */
  43444. export interface WebXRRenderTarget extends IDisposable {
  43445. /**
  43446. * xrpresent context of the canvas which can be used to display/mirror xr content
  43447. */
  43448. canvasContext: WebGLRenderingContext;
  43449. /**
  43450. * xr layer for the canvas
  43451. */
  43452. xrLayer: Nullable<XRWebGLLayer>;
  43453. /**
  43454. * Initializes the xr layer for the session
  43455. * @param xrSession xr session
  43456. * @returns a promise that will resolve once the XR Layer has been created
  43457. */
  43458. initializeXRLayerAsync(xrSession: XRSession): Promise<void>;
  43459. }
  43460. }
  43461. declare module "babylonjs/Cameras/XR/webXRManagedOutputCanvas" {
  43462. import { Nullable } from "babylonjs/types";
  43463. import { Observable } from "babylonjs/Misc/observable";
  43464. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  43465. import { WebXRState, WebXRRenderTarget } from "babylonjs/Cameras/XR/webXRTypes";
  43466. /**
  43467. * COnfiguration object for WebXR output canvas
  43468. */
  43469. export class WebXRManagedOutputCanvasOptions {
  43470. /**
  43471. * Options for this XR Layer output
  43472. */
  43473. canvasOptions: XRWebGLLayerOptions;
  43474. /**
  43475. * CSS styling for a newly created canvas (if not provided)
  43476. */
  43477. newCanvasCssStyle?: string;
  43478. /**
  43479. * Get the default values of the configuration object
  43480. * @returns default values of this configuration object
  43481. */
  43482. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  43483. }
  43484. /**
  43485. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  43486. */
  43487. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  43488. private configuration;
  43489. private _engine;
  43490. private _canvas;
  43491. /**
  43492. * xrpresent context of the canvas which can be used to display/mirror xr content
  43493. */
  43494. canvasContext: WebGLRenderingContext;
  43495. /**
  43496. * xr layer for the canvas
  43497. */
  43498. xrLayer: Nullable<XRWebGLLayer>;
  43499. /**
  43500. * Initializes the xr layer for the session
  43501. * @param xrSession xr session
  43502. * @returns a promise that will resolve once the XR Layer has been created
  43503. */
  43504. initializeXRLayerAsync(xrSession: any): any;
  43505. /**
  43506. * Initializes the canvas to be added/removed upon entering/exiting xr
  43507. * @param engine the Babylon engine
  43508. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  43509. * @param onStateChangedObservable the mechanism by which the canvas will be added/removed based on XR state
  43510. * @param configuration optional configuration for this canvas output. defaults will be used if not provided
  43511. */
  43512. constructor(engine: ThinEngine, canvas?: HTMLCanvasElement, onStateChangedObservable?: Observable<WebXRState>, configuration?: WebXRManagedOutputCanvasOptions);
  43513. /**
  43514. * Disposes of the object
  43515. */
  43516. dispose(): void;
  43517. private _setManagedOutputCanvas;
  43518. private _addCanvas;
  43519. private _removeCanvas;
  43520. }
  43521. }
  43522. declare module "babylonjs/Cameras/XR/webXRSessionManager" {
  43523. import { Observable } from "babylonjs/Misc/observable";
  43524. import { Nullable } from "babylonjs/types";
  43525. import { IDisposable, Scene } from "babylonjs/scene";
  43526. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  43527. import { WebXRRenderTarget, WebXRState } from "babylonjs/Cameras/XR/webXRTypes";
  43528. import { WebXRManagedOutputCanvasOptions } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  43529. /**
  43530. * Manages an XRSession to work with Babylon's engine
  43531. * @see https://doc.babylonjs.com/how_to/webxr
  43532. */
  43533. export class WebXRSessionManager implements IDisposable {
  43534. private scene;
  43535. /**
  43536. * Fires every time a new xrFrame arrives which can be used to update the camera
  43537. */
  43538. onXRFrameObservable: Observable<any>;
  43539. /**
  43540. * Fires when the xr session is ended either by the device or manually done
  43541. */
  43542. onXRSessionEnded: Observable<any>;
  43543. /**
  43544. * Underlying xr session
  43545. */
  43546. session: XRSession;
  43547. /**
  43548. * Type of reference space used when creating the session
  43549. */
  43550. referenceSpace: XRReferenceSpace;
  43551. /**
  43552. * Current XR frame
  43553. */
  43554. currentFrame: Nullable<XRFrame>;
  43555. private _xrNavigator;
  43556. private baseLayer;
  43557. private _rttProvider;
  43558. private _sessionEnded;
  43559. /**
  43560. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  43561. * @param scene The scene which the session should be created for
  43562. */
  43563. constructor(scene: Scene);
  43564. /**
  43565. * Initializes the manager
  43566. * After initialization enterXR can be called to start an XR session
  43567. * @returns Promise which resolves after it is initialized
  43568. */
  43569. initializeAsync(): Promise<void>;
  43570. /**
  43571. * Initializes an xr session
  43572. * @param xrSessionMode mode to initialize
  43573. * @param optionalFeatures defines optional values to pass to the session builder
  43574. * @returns a promise which will resolve once the session has been initialized
  43575. */
  43576. initializeSessionAsync(xrSessionMode: XRSessionMode, optionalFeatures?: any): Promise<XRSession>;
  43577. /**
  43578. * Sets the reference space on the xr session
  43579. * @param referenceSpace space to set
  43580. * @returns a promise that will resolve once the reference space has been set
  43581. */
  43582. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  43583. /**
  43584. * Updates the render state of the session
  43585. * @param state state to set
  43586. * @returns a promise that resolves once the render state has been updated
  43587. */
  43588. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  43589. /**
  43590. * Starts rendering to the xr layer
  43591. * @returns a promise that will resolve once rendering has started
  43592. */
  43593. startRenderingToXRAsync(): Promise<void>;
  43594. /**
  43595. * Gets the correct render target texture to be rendered this frame for this eye
  43596. * @param eye the eye for which to get the render target
  43597. * @returns the render target for the specified eye
  43598. */
  43599. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  43600. /**
  43601. * Stops the xrSession and restores the renderloop
  43602. * @returns Promise which resolves after it exits XR
  43603. */
  43604. exitXRAsync(): Promise<void>;
  43605. /**
  43606. * Checks if a session would be supported for the creation options specified
  43607. * @param sessionMode session mode to check if supported eg. immersive-vr
  43608. * @returns true if supported
  43609. */
  43610. supportsSessionAsync(sessionMode: XRSessionMode): any;
  43611. /**
  43612. * Creates a WebXRRenderTarget object for the XR session
  43613. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  43614. * @param options optional options to provide when creating a new render target
  43615. * @returns a WebXR render target to which the session can render
  43616. */
  43617. getWebXRRenderTarget(onStateChangedObservable?: Observable<WebXRState>, options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  43618. /**
  43619. * @hidden
  43620. * Converts the render layer of xrSession to a render target
  43621. * @param session session to create render target for
  43622. * @param scene scene the new render target should be created for
  43623. */
  43624. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  43625. /**
  43626. * Disposes of the session manager
  43627. */
  43628. dispose(): void;
  43629. }
  43630. }
  43631. declare module "babylonjs/Cameras/XR/webXRCamera" {
  43632. import { Scene } from "babylonjs/scene";
  43633. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  43634. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  43635. /**
  43636. * WebXR Camera which holds the views for the xrSession
  43637. * @see https://doc.babylonjs.com/how_to/webxr
  43638. */
  43639. export class WebXRCamera extends FreeCamera {
  43640. /**
  43641. * Is the camera in debug mode. Used when using an emulator
  43642. */
  43643. debugMode: boolean;
  43644. /**
  43645. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  43646. * @param name the name of the camera
  43647. * @param scene the scene to add the camera to
  43648. */
  43649. constructor(name: string, scene: Scene);
  43650. private _updateNumberOfRigCameras;
  43651. /** @hidden */
  43652. _updateForDualEyeDebugging(): void;
  43653. /**
  43654. * Updates the cameras position from the current pose information of the XR session
  43655. * @param xrSessionManager the session containing pose information
  43656. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  43657. */
  43658. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  43659. }
  43660. }
  43661. declare module "babylonjs/Cameras/XR/webXRExperienceHelper" {
  43662. import { Observable } from "babylonjs/Misc/observable";
  43663. import { IDisposable, Scene } from "babylonjs/scene";
  43664. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  43665. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43666. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  43667. import { WebXRCamera } from "babylonjs/Cameras/XR/webXRCamera";
  43668. import { WebXRState, WebXRRenderTarget } from "babylonjs/Cameras/XR/webXRTypes";
  43669. /**
  43670. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  43671. * @see https://doc.babylonjs.com/how_to/webxr
  43672. */
  43673. export class WebXRExperienceHelper implements IDisposable {
  43674. private scene;
  43675. /**
  43676. * 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
  43677. */
  43678. container: AbstractMesh;
  43679. /**
  43680. * Camera used to render xr content
  43681. */
  43682. camera: WebXRCamera;
  43683. /**
  43684. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  43685. */
  43686. state: WebXRState;
  43687. private _setState;
  43688. private static _TmpVector;
  43689. /**
  43690. * Fires when the state of the experience helper has changed
  43691. */
  43692. onStateChangedObservable: Observable<WebXRState>;
  43693. /** Session manager used to keep track of xr session */
  43694. sessionManager: WebXRSessionManager;
  43695. private _nonVRCamera;
  43696. private _originalSceneAutoClear;
  43697. private _supported;
  43698. /**
  43699. * Creates the experience helper
  43700. * @param scene the scene to attach the experience helper to
  43701. * @returns a promise for the experience helper
  43702. */
  43703. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  43704. /**
  43705. * Creates a WebXRExperienceHelper
  43706. * @param scene The scene the helper should be created in
  43707. */
  43708. private constructor();
  43709. /**
  43710. * Exits XR mode and returns the scene to its original state
  43711. * @returns promise that resolves after xr mode has exited
  43712. */
  43713. exitXRAsync(): Promise<void>;
  43714. /**
  43715. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  43716. * @param sessionMode options for the XR session
  43717. * @param referenceSpaceType frame of reference of the XR session
  43718. * @param renderTarget the output canvas that will be used to enter XR mode
  43719. * @returns promise that resolves after xr mode has entered
  43720. */
  43721. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget: WebXRRenderTarget): Promise<WebXRSessionManager>;
  43722. /**
  43723. * Updates the global position of the camera by moving the camera's container
  43724. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  43725. * @param position The desired global position of the camera
  43726. */
  43727. setPositionOfCameraUsingContainer(position: Vector3): void;
  43728. /**
  43729. * Rotates the xr camera by rotating the camera's container around the camera's position
  43730. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  43731. * @param rotation the desired quaternion rotation to apply to the camera
  43732. */
  43733. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  43734. /**
  43735. * Disposes of the experience helper
  43736. */
  43737. dispose(): void;
  43738. }
  43739. }
  43740. declare module "babylonjs/Cameras/XR/webXREnterExitUI" {
  43741. import { Nullable } from "babylonjs/types";
  43742. import { Observable } from "babylonjs/Misc/observable";
  43743. import { IDisposable, Scene } from "babylonjs/scene";
  43744. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  43745. import { WebXRRenderTarget } from "babylonjs/Cameras/XR/webXRTypes";
  43746. /**
  43747. * Button which can be used to enter a different mode of XR
  43748. */
  43749. export class WebXREnterExitUIButton {
  43750. /** button element */
  43751. element: HTMLElement;
  43752. /** XR initialization options for the button */
  43753. sessionMode: XRSessionMode;
  43754. /** Reference space type */
  43755. referenceSpaceType: XRReferenceSpaceType;
  43756. /**
  43757. * Creates a WebXREnterExitUIButton
  43758. * @param element button element
  43759. * @param sessionMode XR initialization session mode
  43760. * @param referenceSpaceType the type of reference space to be used
  43761. */
  43762. constructor(
  43763. /** button element */
  43764. element: HTMLElement,
  43765. /** XR initialization options for the button */
  43766. sessionMode: XRSessionMode,
  43767. /** Reference space type */
  43768. referenceSpaceType: XRReferenceSpaceType);
  43769. /**
  43770. * Overwritable function which can be used to update the button's visuals when the state changes
  43771. * @param activeButton the current active button in the UI
  43772. */
  43773. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  43774. }
  43775. /**
  43776. * Options to create the webXR UI
  43777. */
  43778. export class WebXREnterExitUIOptions {
  43779. /**
  43780. * Context to enter xr with
  43781. */
  43782. renderTarget?: Nullable<WebXRRenderTarget>;
  43783. /**
  43784. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  43785. */
  43786. customButtons?: Array<WebXREnterExitUIButton>;
  43787. /**
  43788. * A session mode to use when creating the default button.
  43789. * Default is immersive-vr
  43790. */
  43791. sessionMode?: XRSessionMode;
  43792. /**
  43793. * A reference space type to use when creating the default button.
  43794. * Default is local-floor
  43795. */
  43796. referenceSpaceType?: XRReferenceSpaceType;
  43797. }
  43798. /**
  43799. * UI to allow the user to enter/exit XR mode
  43800. */
  43801. export class WebXREnterExitUI implements IDisposable {
  43802. private scene;
  43803. private _overlay;
  43804. private _buttons;
  43805. private _activeButton;
  43806. /**
  43807. * Fired every time the active button is changed.
  43808. *
  43809. * When xr is entered via a button that launches xr that button will be the callback parameter
  43810. *
  43811. * When exiting xr the callback parameter will be null)
  43812. */
  43813. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  43814. /**
  43815. * Creates UI to allow the user to enter/exit XR mode
  43816. * @param scene the scene to add the ui to
  43817. * @param helper the xr experience helper to enter/exit xr with
  43818. * @param options options to configure the UI
  43819. * @returns the created ui
  43820. */
  43821. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  43822. private constructor();
  43823. private _updateButtons;
  43824. /**
  43825. * Disposes of the object
  43826. */
  43827. dispose(): void;
  43828. }
  43829. }
  43830. declare module "babylonjs/Cameras/XR/webXRController" {
  43831. import { Nullable } from "babylonjs/types";
  43832. import { Observable } from "babylonjs/Misc/observable";
  43833. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43834. import { Ray } from "babylonjs/Culling/ray";
  43835. import { Scene } from "babylonjs/scene";
  43836. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43837. /**
  43838. * Represents an XR input
  43839. */
  43840. export class WebXRController {
  43841. private scene;
  43842. /** The underlying input source for the controller */
  43843. inputSource: XRInputSource;
  43844. private parentContainer;
  43845. /**
  43846. * 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
  43847. */
  43848. grip?: AbstractMesh;
  43849. /**
  43850. * Pointer which can be used to select objects or attach a visible laser to
  43851. */
  43852. pointer: AbstractMesh;
  43853. private _gamepadMode;
  43854. /**
  43855. * If available, this is the gamepad object related to this controller.
  43856. * Using this object it is possible to get click events and trackpad changes of the
  43857. * webxr controller that is currently being used.
  43858. */
  43859. gamepadController?: WebVRController;
  43860. /**
  43861. * Event that fires when the controller is removed/disposed
  43862. */
  43863. onDisposeObservable: Observable<{}>;
  43864. private _tmpMatrix;
  43865. private _tmpQuaternion;
  43866. private _tmpVector;
  43867. /**
  43868. * Creates the controller
  43869. * @see https://doc.babylonjs.com/how_to/webxr
  43870. * @param scene the scene which the controller should be associated to
  43871. * @param inputSource the underlying input source for the controller
  43872. * @param parentContainer parent that the controller meshes should be children of
  43873. */
  43874. constructor(scene: Scene,
  43875. /** The underlying input source for the controller */
  43876. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  43877. /**
  43878. * Updates the controller pose based on the given XRFrame
  43879. * @param xrFrame xr frame to update the pose with
  43880. * @param referenceSpace reference space to use
  43881. */
  43882. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  43883. /**
  43884. * Gets a world space ray coming from the controller
  43885. * @param result the resulting ray
  43886. */
  43887. getWorldPointerRayToRef(result: Ray): void;
  43888. /**
  43889. * Get the scene associated with this controller
  43890. * @returns the scene object
  43891. */
  43892. getScene(): Scene;
  43893. /**
  43894. * Disposes of the object
  43895. */
  43896. dispose(): void;
  43897. }
  43898. }
  43899. declare module "babylonjs/Cameras/XR/webXRInput" {
  43900. import { Observable } from "babylonjs/Misc/observable";
  43901. import { IDisposable } from "babylonjs/scene";
  43902. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  43903. import { WebXRController } from "babylonjs/Cameras/XR/webXRController";
  43904. /**
  43905. * XR input used to track XR inputs such as controllers/rays
  43906. */
  43907. export class WebXRInput implements IDisposable {
  43908. /**
  43909. * Base experience the input listens to
  43910. */
  43911. baseExperience: WebXRExperienceHelper;
  43912. /**
  43913. * XR controllers being tracked
  43914. */
  43915. controllers: Array<WebXRController>;
  43916. private _frameObserver;
  43917. private _stateObserver;
  43918. /**
  43919. * Event when a controller has been connected/added
  43920. */
  43921. onControllerAddedObservable: Observable<WebXRController>;
  43922. /**
  43923. * Event when a controller has been removed/disconnected
  43924. */
  43925. onControllerRemovedObservable: Observable<WebXRController>;
  43926. /**
  43927. * Initializes the WebXRInput
  43928. * @param baseExperience experience helper which the input should be created for
  43929. */
  43930. constructor(
  43931. /**
  43932. * Base experience the input listens to
  43933. */
  43934. baseExperience: WebXRExperienceHelper);
  43935. private _onInputSourcesChange;
  43936. private _addAndRemoveControllers;
  43937. /**
  43938. * Disposes of the object
  43939. */
  43940. dispose(): void;
  43941. }
  43942. }
  43943. declare module "babylonjs/Cameras/XR/webXRControllerTeleportation" {
  43944. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43945. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  43946. /**
  43947. * Enables teleportation
  43948. */
  43949. export class WebXRControllerTeleportation {
  43950. private _teleportationFillColor;
  43951. private _teleportationBorderColor;
  43952. private _tmpRay;
  43953. private _tmpVector;
  43954. /**
  43955. * Creates a WebXRControllerTeleportation
  43956. * @param input input manager to add teleportation to
  43957. * @param floorMeshes floormeshes which can be teleported to
  43958. */
  43959. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  43960. }
  43961. }
  43962. declare module "babylonjs/Cameras/XR/webXRControllerPointerSelection" {
  43963. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  43964. /**
  43965. * Handles pointer input automatically for the pointer of XR controllers
  43966. */
  43967. export class WebXRControllerPointerSelection {
  43968. private static _idCounter;
  43969. private _tmpRay;
  43970. /**
  43971. * Creates a WebXRControllerPointerSelection
  43972. * @param input input manager to setup pointer selection
  43973. */
  43974. constructor(input: WebXRInput);
  43975. private _convertNormalToDirectionOfRay;
  43976. private _updatePointerDistance;
  43977. }
  43978. }
  43979. declare module "babylonjs/Loading/sceneLoader" {
  43980. import { Observable } from "babylonjs/Misc/observable";
  43981. import { Nullable } from "babylonjs/types";
  43982. import { Scene } from "babylonjs/scene";
  43983. import { Engine } from "babylonjs/Engines/engine";
  43984. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43985. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  43986. import { AssetContainer } from "babylonjs/assetContainer";
  43987. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  43988. import { Skeleton } from "babylonjs/Bones/skeleton";
  43989. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  43990. import { WebRequest } from "babylonjs/Misc/webRequest";
  43991. /**
  43992. * Class used to represent data loading progression
  43993. */
  43994. export class SceneLoaderProgressEvent {
  43995. /** defines if data length to load can be evaluated */
  43996. readonly lengthComputable: boolean;
  43997. /** defines the loaded data length */
  43998. readonly loaded: number;
  43999. /** defines the data length to load */
  44000. readonly total: number;
  44001. /**
  44002. * Create a new progress event
  44003. * @param lengthComputable defines if data length to load can be evaluated
  44004. * @param loaded defines the loaded data length
  44005. * @param total defines the data length to load
  44006. */
  44007. constructor(
  44008. /** defines if data length to load can be evaluated */
  44009. lengthComputable: boolean,
  44010. /** defines the loaded data length */
  44011. loaded: number,
  44012. /** defines the data length to load */
  44013. total: number);
  44014. /**
  44015. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  44016. * @param event defines the source event
  44017. * @returns a new SceneLoaderProgressEvent
  44018. */
  44019. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  44020. }
  44021. /**
  44022. * Interface used by SceneLoader plugins to define supported file extensions
  44023. */
  44024. export interface ISceneLoaderPluginExtensions {
  44025. /**
  44026. * Defines the list of supported extensions
  44027. */
  44028. [extension: string]: {
  44029. isBinary: boolean;
  44030. };
  44031. }
  44032. /**
  44033. * Interface used by SceneLoader plugin factory
  44034. */
  44035. export interface ISceneLoaderPluginFactory {
  44036. /**
  44037. * Defines the name of the factory
  44038. */
  44039. name: string;
  44040. /**
  44041. * Function called to create a new plugin
  44042. * @return the new plugin
  44043. */
  44044. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  44045. /**
  44046. * The callback that returns true if the data can be directly loaded.
  44047. * @param data string containing the file data
  44048. * @returns if the data can be loaded directly
  44049. */
  44050. canDirectLoad?(data: string): boolean;
  44051. }
  44052. /**
  44053. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  44054. */
  44055. export interface ISceneLoaderPluginBase {
  44056. /**
  44057. * The friendly name of this plugin.
  44058. */
  44059. name: string;
  44060. /**
  44061. * The file extensions supported by this plugin.
  44062. */
  44063. extensions: string | ISceneLoaderPluginExtensions;
  44064. /**
  44065. * The callback called when loading from a url.
  44066. * @param scene scene loading this url
  44067. * @param url url to load
  44068. * @param onSuccess callback called when the file successfully loads
  44069. * @param onProgress callback called while file is loading (if the server supports this mode)
  44070. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  44071. * @param onError callback called when the file fails to load
  44072. * @returns a file request object
  44073. */
  44074. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  44075. /**
  44076. * The callback called when loading from a file object.
  44077. * @param scene scene loading this file
  44078. * @param file defines the file to load
  44079. * @param onSuccess defines the callback to call when data is loaded
  44080. * @param onProgress defines the callback to call during loading process
  44081. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  44082. * @param onError defines the callback to call when an error occurs
  44083. * @returns a file request object
  44084. */
  44085. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  44086. /**
  44087. * The callback that returns true if the data can be directly loaded.
  44088. * @param data string containing the file data
  44089. * @returns if the data can be loaded directly
  44090. */
  44091. canDirectLoad?(data: string): boolean;
  44092. /**
  44093. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  44094. * @param scene scene loading this data
  44095. * @param data string containing the data
  44096. * @returns data to pass to the plugin
  44097. */
  44098. directLoad?(scene: Scene, data: string): any;
  44099. /**
  44100. * The callback that allows custom handling of the root url based on the response url.
  44101. * @param rootUrl the original root url
  44102. * @param responseURL the response url if available
  44103. * @returns the new root url
  44104. */
  44105. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  44106. }
  44107. /**
  44108. * Interface used to define a SceneLoader plugin
  44109. */
  44110. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  44111. /**
  44112. * Import meshes into a scene.
  44113. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  44114. * @param scene The scene to import into
  44115. * @param data The data to import
  44116. * @param rootUrl The root url for scene and resources
  44117. * @param meshes The meshes array to import into
  44118. * @param particleSystems The particle systems array to import into
  44119. * @param skeletons The skeletons array to import into
  44120. * @param onError The callback when import fails
  44121. * @returns True if successful or false otherwise
  44122. */
  44123. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  44124. /**
  44125. * Load into a scene.
  44126. * @param scene The scene to load into
  44127. * @param data The data to import
  44128. * @param rootUrl The root url for scene and resources
  44129. * @param onError The callback when import fails
  44130. * @returns True if successful or false otherwise
  44131. */
  44132. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  44133. /**
  44134. * Load into an asset container.
  44135. * @param scene The scene to load into
  44136. * @param data The data to import
  44137. * @param rootUrl The root url for scene and resources
  44138. * @param onError The callback when import fails
  44139. * @returns The loaded asset container
  44140. */
  44141. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  44142. }
  44143. /**
  44144. * Interface used to define an async SceneLoader plugin
  44145. */
  44146. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  44147. /**
  44148. * Import meshes into a scene.
  44149. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  44150. * @param scene The scene to import into
  44151. * @param data The data to import
  44152. * @param rootUrl The root url for scene and resources
  44153. * @param onProgress The callback when the load progresses
  44154. * @param fileName Defines the name of the file to load
  44155. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  44156. */
  44157. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  44158. meshes: AbstractMesh[];
  44159. particleSystems: IParticleSystem[];
  44160. skeletons: Skeleton[];
  44161. animationGroups: AnimationGroup[];
  44162. }>;
  44163. /**
  44164. * Load into a scene.
  44165. * @param scene The scene to load into
  44166. * @param data The data to import
  44167. * @param rootUrl The root url for scene and resources
  44168. * @param onProgress The callback when the load progresses
  44169. * @param fileName Defines the name of the file to load
  44170. * @returns Nothing
  44171. */
  44172. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  44173. /**
  44174. * Load into an asset container.
  44175. * @param scene The scene to load into
  44176. * @param data The data to import
  44177. * @param rootUrl The root url for scene and resources
  44178. * @param onProgress The callback when the load progresses
  44179. * @param fileName Defines the name of the file to load
  44180. * @returns The loaded asset container
  44181. */
  44182. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  44183. }
  44184. /**
  44185. * Class used to load scene from various file formats using registered plugins
  44186. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  44187. */
  44188. export class SceneLoader {
  44189. /**
  44190. * No logging while loading
  44191. */
  44192. static readonly NO_LOGGING: number;
  44193. /**
  44194. * Minimal logging while loading
  44195. */
  44196. static readonly MINIMAL_LOGGING: number;
  44197. /**
  44198. * Summary logging while loading
  44199. */
  44200. static readonly SUMMARY_LOGGING: number;
  44201. /**
  44202. * Detailled logging while loading
  44203. */
  44204. static readonly DETAILED_LOGGING: number;
  44205. /**
  44206. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  44207. */
  44208. static ForceFullSceneLoadingForIncremental: boolean;
  44209. /**
  44210. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  44211. */
  44212. static ShowLoadingScreen: boolean;
  44213. /**
  44214. * Defines the current logging level (while loading the scene)
  44215. * @ignorenaming
  44216. */
  44217. static loggingLevel: number;
  44218. /**
  44219. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  44220. */
  44221. static CleanBoneMatrixWeights: boolean;
  44222. /**
  44223. * Event raised when a plugin is used to load a scene
  44224. */
  44225. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  44226. private static _registeredPlugins;
  44227. private static _getDefaultPlugin;
  44228. private static _getPluginForExtension;
  44229. private static _getPluginForDirectLoad;
  44230. private static _getPluginForFilename;
  44231. private static _getDirectLoad;
  44232. private static _loadData;
  44233. private static _getFileInfo;
  44234. /**
  44235. * Gets a plugin that can load the given extension
  44236. * @param extension defines the extension to load
  44237. * @returns a plugin or null if none works
  44238. */
  44239. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  44240. /**
  44241. * Gets a boolean indicating that the given extension can be loaded
  44242. * @param extension defines the extension to load
  44243. * @returns true if the extension is supported
  44244. */
  44245. static IsPluginForExtensionAvailable(extension: string): boolean;
  44246. /**
  44247. * Adds a new plugin to the list of registered plugins
  44248. * @param plugin defines the plugin to add
  44249. */
  44250. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  44251. /**
  44252. * Import meshes into a scene
  44253. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  44254. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
  44255. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
  44256. * @param scene the instance of BABYLON.Scene to append to
  44257. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  44258. * @param onProgress a callback with a progress event for each file being loaded
  44259. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44260. * @param pluginExtension the extension used to determine the plugin
  44261. * @returns The loaded plugin
  44262. */
  44263. static 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>;
  44264. /**
  44265. * Import meshes into a scene
  44266. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  44267. * @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)
  44268. * @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)
  44269. * @param scene the instance of BABYLON.Scene to append to
  44270. * @param onProgress a callback with a progress event for each file being loaded
  44271. * @param pluginExtension the extension used to determine the plugin
  44272. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  44273. */
  44274. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  44275. meshes: AbstractMesh[];
  44276. particleSystems: IParticleSystem[];
  44277. skeletons: Skeleton[];
  44278. animationGroups: AnimationGroup[];
  44279. }>;
  44280. /**
  44281. * Load a scene
  44282. * @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)
  44283. * @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)
  44284. * @param engine is the instance of BABYLON.Engine to use to create the scene
  44285. * @param onSuccess a callback with the scene when import succeeds
  44286. * @param onProgress a callback with a progress event for each file being loaded
  44287. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44288. * @param pluginExtension the extension used to determine the plugin
  44289. * @returns The loaded plugin
  44290. */
  44291. 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>;
  44292. /**
  44293. * Load a scene
  44294. * @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)
  44295. * @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)
  44296. * @param engine is the instance of BABYLON.Engine to use to create the scene
  44297. * @param onProgress a callback with a progress event for each file being loaded
  44298. * @param pluginExtension the extension used to determine the plugin
  44299. * @returns The loaded scene
  44300. */
  44301. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  44302. /**
  44303. * Append a scene
  44304. * @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)
  44305. * @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)
  44306. * @param scene is the instance of BABYLON.Scene to append to
  44307. * @param onSuccess a callback with the scene when import succeeds
  44308. * @param onProgress a callback with a progress event for each file being loaded
  44309. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44310. * @param pluginExtension the extension used to determine the plugin
  44311. * @returns The loaded plugin
  44312. */
  44313. 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>;
  44314. /**
  44315. * Append a scene
  44316. * @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)
  44317. * @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)
  44318. * @param scene is the instance of BABYLON.Scene to append to
  44319. * @param onProgress a callback with a progress event for each file being loaded
  44320. * @param pluginExtension the extension used to determine the plugin
  44321. * @returns The given scene
  44322. */
  44323. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  44324. /**
  44325. * Load a scene into an asset container
  44326. * @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)
  44327. * @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)
  44328. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  44329. * @param onSuccess a callback with the scene when import succeeds
  44330. * @param onProgress a callback with a progress event for each file being loaded
  44331. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44332. * @param pluginExtension the extension used to determine the plugin
  44333. * @returns The loaded plugin
  44334. */
  44335. 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>;
  44336. /**
  44337. * Load a scene into an asset container
  44338. * @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)
  44339. * @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)
  44340. * @param scene is the instance of Scene to append to
  44341. * @param onProgress a callback with a progress event for each file being loaded
  44342. * @param pluginExtension the extension used to determine the plugin
  44343. * @returns The loaded asset container
  44344. */
  44345. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  44346. }
  44347. }
  44348. declare module "babylonjs/Gamepads/Controllers/genericController" {
  44349. import { Scene } from "babylonjs/scene";
  44350. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44351. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44352. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44353. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  44354. /**
  44355. * Generic Controller
  44356. */
  44357. export class GenericController extends WebVRController {
  44358. /**
  44359. * Base Url for the controller model.
  44360. */
  44361. static readonly MODEL_BASE_URL: string;
  44362. /**
  44363. * File name for the controller model.
  44364. */
  44365. static readonly MODEL_FILENAME: string;
  44366. /**
  44367. * Creates a new GenericController from a gamepad
  44368. * @param vrGamepad the gamepad that the controller should be created from
  44369. */
  44370. constructor(vrGamepad: any);
  44371. /**
  44372. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44373. * @param scene scene in which to add meshes
  44374. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44375. */
  44376. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44377. /**
  44378. * Called once for each button that changed state since the last frame
  44379. * @param buttonIdx Which button index changed
  44380. * @param state New state of the button
  44381. * @param changes Which properties on the state changed since last frame
  44382. */
  44383. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44384. }
  44385. }
  44386. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  44387. import { Observable } from "babylonjs/Misc/observable";
  44388. import { Scene } from "babylonjs/scene";
  44389. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44390. import { Ray } from "babylonjs/Culling/ray";
  44391. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44392. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44393. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  44394. /**
  44395. * Defines the WindowsMotionController object that the state of the windows motion controller
  44396. */
  44397. export class WindowsMotionController extends WebVRController {
  44398. /**
  44399. * The base url used to load the left and right controller models
  44400. */
  44401. static MODEL_BASE_URL: string;
  44402. /**
  44403. * The name of the left controller model file
  44404. */
  44405. static MODEL_LEFT_FILENAME: string;
  44406. /**
  44407. * The name of the right controller model file
  44408. */
  44409. static MODEL_RIGHT_FILENAME: string;
  44410. /**
  44411. * The controller name prefix for this controller type
  44412. */
  44413. static readonly GAMEPAD_ID_PREFIX: string;
  44414. /**
  44415. * The controller id pattern for this controller type
  44416. */
  44417. private static readonly GAMEPAD_ID_PATTERN;
  44418. private _loadedMeshInfo;
  44419. private readonly _mapping;
  44420. /**
  44421. * Fired when the trackpad on this controller is clicked
  44422. */
  44423. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  44424. /**
  44425. * Fired when the trackpad on this controller is modified
  44426. */
  44427. onTrackpadValuesChangedObservable: Observable<StickValues>;
  44428. /**
  44429. * The current x and y values of this controller's trackpad
  44430. */
  44431. trackpad: StickValues;
  44432. /**
  44433. * Creates a new WindowsMotionController from a gamepad
  44434. * @param vrGamepad the gamepad that the controller should be created from
  44435. */
  44436. constructor(vrGamepad: any);
  44437. /**
  44438. * Fired when the trigger on this controller is modified
  44439. */
  44440. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44441. /**
  44442. * Fired when the menu button on this controller is modified
  44443. */
  44444. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44445. /**
  44446. * Fired when the grip button on this controller is modified
  44447. */
  44448. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44449. /**
  44450. * Fired when the thumbstick button on this controller is modified
  44451. */
  44452. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44453. /**
  44454. * Fired when the touchpad button on this controller is modified
  44455. */
  44456. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44457. /**
  44458. * Fired when the touchpad values on this controller are modified
  44459. */
  44460. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  44461. private _updateTrackpad;
  44462. /**
  44463. * Called once per frame by the engine.
  44464. */
  44465. update(): void;
  44466. /**
  44467. * Called once for each button that changed state since the last frame
  44468. * @param buttonIdx Which button index changed
  44469. * @param state New state of the button
  44470. * @param changes Which properties on the state changed since last frame
  44471. */
  44472. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44473. /**
  44474. * Moves the buttons on the controller mesh based on their current state
  44475. * @param buttonName the name of the button to move
  44476. * @param buttonValue the value of the button which determines the buttons new position
  44477. */
  44478. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  44479. /**
  44480. * Moves the axis on the controller mesh based on its current state
  44481. * @param axis the index of the axis
  44482. * @param axisValue the value of the axis which determines the meshes new position
  44483. * @hidden
  44484. */
  44485. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  44486. /**
  44487. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44488. * @param scene scene in which to add meshes
  44489. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44490. */
  44491. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  44492. /**
  44493. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  44494. * can be transformed by button presses and axes values, based on this._mapping.
  44495. *
  44496. * @param scene scene in which the meshes exist
  44497. * @param meshes list of meshes that make up the controller model to process
  44498. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  44499. */
  44500. private processModel;
  44501. private createMeshInfo;
  44502. /**
  44503. * Gets the ray of the controller in the direction the controller is pointing
  44504. * @param length the length the resulting ray should be
  44505. * @returns a ray in the direction the controller is pointing
  44506. */
  44507. getForwardRay(length?: number): Ray;
  44508. /**
  44509. * Disposes of the controller
  44510. */
  44511. dispose(): void;
  44512. }
  44513. }
  44514. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  44515. import { Observable } from "babylonjs/Misc/observable";
  44516. import { Scene } from "babylonjs/scene";
  44517. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44518. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44519. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44520. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  44521. /**
  44522. * Oculus Touch Controller
  44523. */
  44524. export class OculusTouchController extends WebVRController {
  44525. /**
  44526. * Base Url for the controller model.
  44527. */
  44528. static MODEL_BASE_URL: string;
  44529. /**
  44530. * File name for the left controller model.
  44531. */
  44532. static MODEL_LEFT_FILENAME: string;
  44533. /**
  44534. * File name for the right controller model.
  44535. */
  44536. static MODEL_RIGHT_FILENAME: string;
  44537. /**
  44538. * Base Url for the Quest controller model.
  44539. */
  44540. static QUEST_MODEL_BASE_URL: string;
  44541. /**
  44542. * @hidden
  44543. * If the controllers are running on a device that needs the updated Quest controller models
  44544. */
  44545. static _IsQuest: boolean;
  44546. /**
  44547. * Fired when the secondary trigger on this controller is modified
  44548. */
  44549. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  44550. /**
  44551. * Fired when the thumb rest on this controller is modified
  44552. */
  44553. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  44554. /**
  44555. * Creates a new OculusTouchController from a gamepad
  44556. * @param vrGamepad the gamepad that the controller should be created from
  44557. */
  44558. constructor(vrGamepad: any);
  44559. /**
  44560. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44561. * @param scene scene in which to add meshes
  44562. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44563. */
  44564. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44565. /**
  44566. * Fired when the A button on this controller is modified
  44567. */
  44568. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44569. /**
  44570. * Fired when the B button on this controller is modified
  44571. */
  44572. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44573. /**
  44574. * Fired when the X button on this controller is modified
  44575. */
  44576. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44577. /**
  44578. * Fired when the Y button on this controller is modified
  44579. */
  44580. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44581. /**
  44582. * Called once for each button that changed state since the last frame
  44583. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  44584. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  44585. * 2) secondary trigger (same)
  44586. * 3) A (right) X (left), touch, pressed = value
  44587. * 4) B / Y
  44588. * 5) thumb rest
  44589. * @param buttonIdx Which button index changed
  44590. * @param state New state of the button
  44591. * @param changes Which properties on the state changed since last frame
  44592. */
  44593. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44594. }
  44595. }
  44596. declare module "babylonjs/Gamepads/Controllers/viveController" {
  44597. import { Scene } from "babylonjs/scene";
  44598. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44599. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44600. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44601. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  44602. import { Observable } from "babylonjs/Misc/observable";
  44603. /**
  44604. * Vive Controller
  44605. */
  44606. export class ViveController extends WebVRController {
  44607. /**
  44608. * Base Url for the controller model.
  44609. */
  44610. static MODEL_BASE_URL: string;
  44611. /**
  44612. * File name for the controller model.
  44613. */
  44614. static MODEL_FILENAME: string;
  44615. /**
  44616. * Creates a new ViveController from a gamepad
  44617. * @param vrGamepad the gamepad that the controller should be created from
  44618. */
  44619. constructor(vrGamepad: any);
  44620. /**
  44621. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44622. * @param scene scene in which to add meshes
  44623. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44624. */
  44625. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44626. /**
  44627. * Fired when the left button on this controller is modified
  44628. */
  44629. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44630. /**
  44631. * Fired when the right button on this controller is modified
  44632. */
  44633. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44634. /**
  44635. * Fired when the menu button on this controller is modified
  44636. */
  44637. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44638. /**
  44639. * Called once for each button that changed state since the last frame
  44640. * Vive mapping:
  44641. * 0: touchpad
  44642. * 1: trigger
  44643. * 2: left AND right buttons
  44644. * 3: menu button
  44645. * @param buttonIdx Which button index changed
  44646. * @param state New state of the button
  44647. * @param changes Which properties on the state changed since last frame
  44648. */
  44649. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44650. }
  44651. }
  44652. declare module "babylonjs/Cameras/XR/webXRControllerModelLoader" {
  44653. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  44654. import { Observable } from "babylonjs/Misc/observable";
  44655. import { WebXRController } from "babylonjs/Cameras/XR/webXRController";
  44656. /**
  44657. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  44658. */
  44659. export class WebXRControllerModelLoader {
  44660. /**
  44661. * an observable that triggers when a new model (the mesh itself) was initialized.
  44662. * To know when the mesh was loaded use the controller's own modelLoaded() method
  44663. */
  44664. onControllerModelLoaded: Observable<WebXRController>;
  44665. /**
  44666. * Creates the WebXRControllerModelLoader
  44667. * @param input xr input that creates the controllers
  44668. */
  44669. constructor(input: WebXRInput);
  44670. }
  44671. }
  44672. declare module "babylonjs/Cameras/XR/webXRDefaultExperience" {
  44673. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  44674. import { Scene } from "babylonjs/scene";
  44675. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  44676. import { WebXRControllerModelLoader } from "babylonjs/Cameras/XR/webXRControllerModelLoader";
  44677. import { WebXRControllerPointerSelection } from "babylonjs/Cameras/XR/webXRControllerPointerSelection";
  44678. import { WebXRControllerTeleportation } from "babylonjs/Cameras/XR/webXRControllerTeleportation";
  44679. import { WebXRRenderTarget } from "babylonjs/Cameras/XR/webXRTypes";
  44680. import { WebXREnterExitUI } from "babylonjs/Cameras/XR/webXREnterExitUI";
  44681. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44682. import { WebXRManagedOutputCanvasOptions } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  44683. /**
  44684. * Options for the default xr helper
  44685. */
  44686. export class WebXRDefaultExperienceOptions {
  44687. /**
  44688. * Floor meshes that should be used for teleporting
  44689. */
  44690. floorMeshes: Array<AbstractMesh>;
  44691. /**
  44692. * Enable or disable default UI to enter XR
  44693. */
  44694. disableDefaultUI: boolean;
  44695. /**
  44696. * optional configuration for the output canvas
  44697. */
  44698. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  44699. }
  44700. /**
  44701. * Default experience which provides a similar setup to the previous webVRExperience
  44702. */
  44703. export class WebXRDefaultExperience {
  44704. /**
  44705. * Base experience
  44706. */
  44707. baseExperience: WebXRExperienceHelper;
  44708. /**
  44709. * Input experience extension
  44710. */
  44711. input: WebXRInput;
  44712. /**
  44713. * Loads the controller models
  44714. */
  44715. controllerModelLoader: WebXRControllerModelLoader;
  44716. /**
  44717. * Enables laser pointer and selection
  44718. */
  44719. pointerSelection: WebXRControllerPointerSelection;
  44720. /**
  44721. * Enables teleportation
  44722. */
  44723. teleportation: WebXRControllerTeleportation;
  44724. /**
  44725. * Enables ui for enetering/exiting xr
  44726. */
  44727. enterExitUI: WebXREnterExitUI;
  44728. /**
  44729. * Default target xr should render to
  44730. */
  44731. renderTarget: WebXRRenderTarget;
  44732. /**
  44733. * Creates the default xr experience
  44734. * @param scene scene
  44735. * @param options options for basic configuration
  44736. * @returns resulting WebXRDefaultExperience
  44737. */
  44738. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  44739. private constructor();
  44740. /**
  44741. * DIsposes of the experience helper
  44742. */
  44743. dispose(): void;
  44744. }
  44745. }
  44746. declare module "babylonjs/Cameras/XR/index" {
  44747. export * from "babylonjs/Cameras/XR/webXRCamera";
  44748. export * from "babylonjs/Cameras/XR/webXREnterExitUI";
  44749. export * from "babylonjs/Cameras/XR/webXRExperienceHelper";
  44750. export * from "babylonjs/Cameras/XR/webXRInput";
  44751. export * from "babylonjs/Cameras/XR/webXRControllerTeleportation";
  44752. export * from "babylonjs/Cameras/XR/webXRControllerPointerSelection";
  44753. export * from "babylonjs/Cameras/XR/webXRControllerModelLoader";
  44754. export * from "babylonjs/Cameras/XR/webXRController";
  44755. export * from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  44756. export * from "babylonjs/Cameras/XR/webXRTypes";
  44757. export * from "babylonjs/Cameras/XR/webXRSessionManager";
  44758. export * from "babylonjs/Cameras/XR/webXRDefaultExperience";
  44759. }
  44760. declare module "babylonjs/Cameras/RigModes/index" {
  44761. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  44762. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  44763. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  44764. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  44765. }
  44766. declare module "babylonjs/Cameras/index" {
  44767. export * from "babylonjs/Cameras/Inputs/index";
  44768. export * from "babylonjs/Cameras/cameraInputsManager";
  44769. export * from "babylonjs/Cameras/camera";
  44770. export * from "babylonjs/Cameras/targetCamera";
  44771. export * from "babylonjs/Cameras/freeCamera";
  44772. export * from "babylonjs/Cameras/freeCameraInputsManager";
  44773. export * from "babylonjs/Cameras/touchCamera";
  44774. export * from "babylonjs/Cameras/arcRotateCamera";
  44775. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  44776. export * from "babylonjs/Cameras/deviceOrientationCamera";
  44777. export * from "babylonjs/Cameras/flyCamera";
  44778. export * from "babylonjs/Cameras/flyCameraInputsManager";
  44779. export * from "babylonjs/Cameras/followCamera";
  44780. export * from "babylonjs/Cameras/followCameraInputsManager";
  44781. export * from "babylonjs/Cameras/gamepadCamera";
  44782. export * from "babylonjs/Cameras/Stereoscopic/index";
  44783. export * from "babylonjs/Cameras/universalCamera";
  44784. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  44785. export * from "babylonjs/Cameras/VR/index";
  44786. export * from "babylonjs/Cameras/XR/index";
  44787. export * from "babylonjs/Cameras/RigModes/index";
  44788. }
  44789. declare module "babylonjs/Collisions/index" {
  44790. export * from "babylonjs/Collisions/collider";
  44791. export * from "babylonjs/Collisions/collisionCoordinator";
  44792. export * from "babylonjs/Collisions/pickingInfo";
  44793. export * from "babylonjs/Collisions/intersectionInfo";
  44794. export * from "babylonjs/Collisions/meshCollisionData";
  44795. }
  44796. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  44797. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  44798. import { Vector3 } from "babylonjs/Maths/math.vector";
  44799. import { Ray } from "babylonjs/Culling/ray";
  44800. import { Plane } from "babylonjs/Maths/math.plane";
  44801. /**
  44802. * Contains an array of blocks representing the octree
  44803. */
  44804. export interface IOctreeContainer<T> {
  44805. /**
  44806. * Blocks within the octree
  44807. */
  44808. blocks: Array<OctreeBlock<T>>;
  44809. }
  44810. /**
  44811. * Class used to store a cell in an octree
  44812. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44813. */
  44814. export class OctreeBlock<T> {
  44815. /**
  44816. * Gets the content of the current block
  44817. */
  44818. entries: T[];
  44819. /**
  44820. * Gets the list of block children
  44821. */
  44822. blocks: Array<OctreeBlock<T>>;
  44823. private _depth;
  44824. private _maxDepth;
  44825. private _capacity;
  44826. private _minPoint;
  44827. private _maxPoint;
  44828. private _boundingVectors;
  44829. private _creationFunc;
  44830. /**
  44831. * Creates a new block
  44832. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  44833. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  44834. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  44835. * @param depth defines the current depth of this block in the octree
  44836. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  44837. * @param creationFunc defines a callback to call when an element is added to the block
  44838. */
  44839. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  44840. /**
  44841. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  44842. */
  44843. readonly capacity: number;
  44844. /**
  44845. * Gets the minimum vector (in world space) of the block's bounding box
  44846. */
  44847. readonly minPoint: Vector3;
  44848. /**
  44849. * Gets the maximum vector (in world space) of the block's bounding box
  44850. */
  44851. readonly maxPoint: Vector3;
  44852. /**
  44853. * Add a new element to this block
  44854. * @param entry defines the element to add
  44855. */
  44856. addEntry(entry: T): void;
  44857. /**
  44858. * Remove an element from this block
  44859. * @param entry defines the element to remove
  44860. */
  44861. removeEntry(entry: T): void;
  44862. /**
  44863. * Add an array of elements to this block
  44864. * @param entries defines the array of elements to add
  44865. */
  44866. addEntries(entries: T[]): void;
  44867. /**
  44868. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  44869. * @param frustumPlanes defines the frustum planes to test
  44870. * @param selection defines the array to store current content if selection is positive
  44871. * @param allowDuplicate defines if the selection array can contains duplicated entries
  44872. */
  44873. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  44874. /**
  44875. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  44876. * @param sphereCenter defines the bounding sphere center
  44877. * @param sphereRadius defines the bounding sphere radius
  44878. * @param selection defines the array to store current content if selection is positive
  44879. * @param allowDuplicate defines if the selection array can contains duplicated entries
  44880. */
  44881. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  44882. /**
  44883. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  44884. * @param ray defines the ray to test with
  44885. * @param selection defines the array to store current content if selection is positive
  44886. */
  44887. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  44888. /**
  44889. * Subdivide the content into child blocks (this block will then be empty)
  44890. */
  44891. createInnerBlocks(): void;
  44892. /**
  44893. * @hidden
  44894. */
  44895. 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;
  44896. }
  44897. }
  44898. declare module "babylonjs/Culling/Octrees/octree" {
  44899. import { SmartArray } from "babylonjs/Misc/smartArray";
  44900. import { Vector3 } from "babylonjs/Maths/math.vector";
  44901. import { SubMesh } from "babylonjs/Meshes/subMesh";
  44902. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44903. import { Ray } from "babylonjs/Culling/ray";
  44904. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  44905. import { Plane } from "babylonjs/Maths/math.plane";
  44906. /**
  44907. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  44908. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44909. */
  44910. export class Octree<T> {
  44911. /** 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.) */
  44912. maxDepth: number;
  44913. /**
  44914. * Blocks within the octree containing objects
  44915. */
  44916. blocks: Array<OctreeBlock<T>>;
  44917. /**
  44918. * Content stored in the octree
  44919. */
  44920. dynamicContent: T[];
  44921. private _maxBlockCapacity;
  44922. private _selectionContent;
  44923. private _creationFunc;
  44924. /**
  44925. * Creates a octree
  44926. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44927. * @param creationFunc function to be used to instatiate the octree
  44928. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  44929. * @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.)
  44930. */
  44931. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  44932. /** 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.) */
  44933. maxDepth?: number);
  44934. /**
  44935. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  44936. * @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);
  44937. * @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);
  44938. * @param entries meshes to be added to the octree blocks
  44939. */
  44940. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  44941. /**
  44942. * Adds a mesh to the octree
  44943. * @param entry Mesh to add to the octree
  44944. */
  44945. addMesh(entry: T): void;
  44946. /**
  44947. * Remove an element from the octree
  44948. * @param entry defines the element to remove
  44949. */
  44950. removeMesh(entry: T): void;
  44951. /**
  44952. * Selects an array of meshes within the frustum
  44953. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  44954. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  44955. * @returns array of meshes within the frustum
  44956. */
  44957. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  44958. /**
  44959. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  44960. * @param sphereCenter defines the bounding sphere center
  44961. * @param sphereRadius defines the bounding sphere radius
  44962. * @param allowDuplicate defines if the selection array can contains duplicated entries
  44963. * @returns an array of objects that intersect the sphere
  44964. */
  44965. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  44966. /**
  44967. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  44968. * @param ray defines the ray to test with
  44969. * @returns array of intersected objects
  44970. */
  44971. intersectsRay(ray: Ray): SmartArray<T>;
  44972. /**
  44973. * Adds a mesh into the octree block if it intersects the block
  44974. */
  44975. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  44976. /**
  44977. * Adds a submesh into the octree block if it intersects the block
  44978. */
  44979. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  44980. }
  44981. }
  44982. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  44983. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  44984. import { Scene } from "babylonjs/scene";
  44985. import { SubMesh } from "babylonjs/Meshes/subMesh";
  44986. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44987. import { Ray } from "babylonjs/Culling/ray";
  44988. import { Octree } from "babylonjs/Culling/Octrees/octree";
  44989. import { Collider } from "babylonjs/Collisions/collider";
  44990. module "babylonjs/scene" {
  44991. interface Scene {
  44992. /**
  44993. * @hidden
  44994. * Backing Filed
  44995. */
  44996. _selectionOctree: Octree<AbstractMesh>;
  44997. /**
  44998. * Gets the octree used to boost mesh selection (picking)
  44999. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45000. */
  45001. selectionOctree: Octree<AbstractMesh>;
  45002. /**
  45003. * Creates or updates the octree used to boost selection (picking)
  45004. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45005. * @param maxCapacity defines the maximum capacity per leaf
  45006. * @param maxDepth defines the maximum depth of the octree
  45007. * @returns an octree of AbstractMesh
  45008. */
  45009. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  45010. }
  45011. }
  45012. module "babylonjs/Meshes/abstractMesh" {
  45013. interface AbstractMesh {
  45014. /**
  45015. * @hidden
  45016. * Backing Field
  45017. */
  45018. _submeshesOctree: Octree<SubMesh>;
  45019. /**
  45020. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  45021. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  45022. * @param maxCapacity defines the maximum size of each block (64 by default)
  45023. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  45024. * @returns the new octree
  45025. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  45026. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45027. */
  45028. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  45029. }
  45030. }
  45031. /**
  45032. * Defines the octree scene component responsible to manage any octrees
  45033. * in a given scene.
  45034. */
  45035. export class OctreeSceneComponent {
  45036. /**
  45037. * The component name help to identify the component in the list of scene components.
  45038. */
  45039. readonly name: string;
  45040. /**
  45041. * The scene the component belongs to.
  45042. */
  45043. scene: Scene;
  45044. /**
  45045. * Indicates if the meshes have been checked to make sure they are isEnabled()
  45046. */
  45047. readonly checksIsEnabled: boolean;
  45048. /**
  45049. * Creates a new instance of the component for the given scene
  45050. * @param scene Defines the scene to register the component in
  45051. */
  45052. constructor(scene: Scene);
  45053. /**
  45054. * Registers the component in a given scene
  45055. */
  45056. register(): void;
  45057. /**
  45058. * Return the list of active meshes
  45059. * @returns the list of active meshes
  45060. */
  45061. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  45062. /**
  45063. * Return the list of active sub meshes
  45064. * @param mesh The mesh to get the candidates sub meshes from
  45065. * @returns the list of active sub meshes
  45066. */
  45067. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  45068. private _tempRay;
  45069. /**
  45070. * Return the list of sub meshes intersecting with a given local ray
  45071. * @param mesh defines the mesh to find the submesh for
  45072. * @param localRay defines the ray in local space
  45073. * @returns the list of intersecting sub meshes
  45074. */
  45075. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  45076. /**
  45077. * Return the list of sub meshes colliding with a collider
  45078. * @param mesh defines the mesh to find the submesh for
  45079. * @param collider defines the collider to evaluate the collision against
  45080. * @returns the list of colliding sub meshes
  45081. */
  45082. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  45083. /**
  45084. * Rebuilds the elements related to this component in case of
  45085. * context lost for instance.
  45086. */
  45087. rebuild(): void;
  45088. /**
  45089. * Disposes the component and the associated ressources.
  45090. */
  45091. dispose(): void;
  45092. }
  45093. }
  45094. declare module "babylonjs/Culling/Octrees/index" {
  45095. export * from "babylonjs/Culling/Octrees/octree";
  45096. export * from "babylonjs/Culling/Octrees/octreeBlock";
  45097. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  45098. }
  45099. declare module "babylonjs/Culling/index" {
  45100. export * from "babylonjs/Culling/boundingBox";
  45101. export * from "babylonjs/Culling/boundingInfo";
  45102. export * from "babylonjs/Culling/boundingSphere";
  45103. export * from "babylonjs/Culling/Octrees/index";
  45104. export * from "babylonjs/Culling/ray";
  45105. }
  45106. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  45107. import { IDisposable, Scene } from "babylonjs/scene";
  45108. import { Nullable } from "babylonjs/types";
  45109. import { Observable } from "babylonjs/Misc/observable";
  45110. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45111. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  45112. import { Camera } from "babylonjs/Cameras/camera";
  45113. /**
  45114. * Renders a layer on top of an existing scene
  45115. */
  45116. export class UtilityLayerRenderer implements IDisposable {
  45117. /** the original scene that will be rendered on top of */
  45118. originalScene: Scene;
  45119. private _pointerCaptures;
  45120. private _lastPointerEvents;
  45121. private static _DefaultUtilityLayer;
  45122. private static _DefaultKeepDepthUtilityLayer;
  45123. private _sharedGizmoLight;
  45124. private _renderCamera;
  45125. /**
  45126. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  45127. * @returns the camera that is used when rendering the utility layer
  45128. */
  45129. getRenderCamera(): Nullable<Camera>;
  45130. /**
  45131. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  45132. * @param cam the camera that should be used when rendering the utility layer
  45133. */
  45134. setRenderCamera(cam: Nullable<Camera>): void;
  45135. /**
  45136. * @hidden
  45137. * Light which used by gizmos to get light shading
  45138. */
  45139. _getSharedGizmoLight(): HemisphericLight;
  45140. /**
  45141. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  45142. */
  45143. pickUtilitySceneFirst: boolean;
  45144. /**
  45145. * 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)
  45146. */
  45147. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  45148. /**
  45149. * 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)
  45150. */
  45151. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  45152. /**
  45153. * The scene that is rendered on top of the original scene
  45154. */
  45155. utilityLayerScene: Scene;
  45156. /**
  45157. * If the utility layer should automatically be rendered on top of existing scene
  45158. */
  45159. shouldRender: boolean;
  45160. /**
  45161. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  45162. */
  45163. onlyCheckPointerDownEvents: boolean;
  45164. /**
  45165. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  45166. */
  45167. processAllEvents: boolean;
  45168. /**
  45169. * Observable raised when the pointer move from the utility layer scene to the main scene
  45170. */
  45171. onPointerOutObservable: Observable<number>;
  45172. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  45173. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  45174. private _afterRenderObserver;
  45175. private _sceneDisposeObserver;
  45176. private _originalPointerObserver;
  45177. /**
  45178. * Instantiates a UtilityLayerRenderer
  45179. * @param originalScene the original scene that will be rendered on top of
  45180. * @param handleEvents boolean indicating if the utility layer should handle events
  45181. */
  45182. constructor(
  45183. /** the original scene that will be rendered on top of */
  45184. originalScene: Scene, handleEvents?: boolean);
  45185. private _notifyObservers;
  45186. /**
  45187. * Renders the utility layers scene on top of the original scene
  45188. */
  45189. render(): void;
  45190. /**
  45191. * Disposes of the renderer
  45192. */
  45193. dispose(): void;
  45194. private _updateCamera;
  45195. }
  45196. }
  45197. declare module "babylonjs/Gizmos/gizmo" {
  45198. import { Nullable } from "babylonjs/types";
  45199. import { IDisposable } from "babylonjs/scene";
  45200. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45201. import { Mesh } from "babylonjs/Meshes/mesh";
  45202. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  45203. /**
  45204. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  45205. */
  45206. export class Gizmo implements IDisposable {
  45207. /** The utility layer the gizmo will be added to */
  45208. gizmoLayer: UtilityLayerRenderer;
  45209. /**
  45210. * The root mesh of the gizmo
  45211. */
  45212. _rootMesh: Mesh;
  45213. private _attachedMesh;
  45214. /**
  45215. * Ratio for the scale of the gizmo (Default: 1)
  45216. */
  45217. scaleRatio: number;
  45218. /**
  45219. * If a custom mesh has been set (Default: false)
  45220. */
  45221. protected _customMeshSet: boolean;
  45222. /**
  45223. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  45224. * * When set, interactions will be enabled
  45225. */
  45226. attachedMesh: Nullable<AbstractMesh>;
  45227. /**
  45228. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  45229. * @param mesh The mesh to replace the default mesh of the gizmo
  45230. */
  45231. setCustomMesh(mesh: Mesh): void;
  45232. /**
  45233. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  45234. */
  45235. updateGizmoRotationToMatchAttachedMesh: boolean;
  45236. /**
  45237. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  45238. */
  45239. updateGizmoPositionToMatchAttachedMesh: boolean;
  45240. /**
  45241. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  45242. */
  45243. updateScale: boolean;
  45244. protected _interactionsEnabled: boolean;
  45245. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45246. private _beforeRenderObserver;
  45247. private _tempVector;
  45248. /**
  45249. * Creates a gizmo
  45250. * @param gizmoLayer The utility layer the gizmo will be added to
  45251. */
  45252. constructor(
  45253. /** The utility layer the gizmo will be added to */
  45254. gizmoLayer?: UtilityLayerRenderer);
  45255. /**
  45256. * Updates the gizmo to match the attached mesh's position/rotation
  45257. */
  45258. protected _update(): void;
  45259. /**
  45260. * Disposes of the gizmo
  45261. */
  45262. dispose(): void;
  45263. }
  45264. }
  45265. declare module "babylonjs/Gizmos/planeDragGizmo" {
  45266. import { Observable } from "babylonjs/Misc/observable";
  45267. import { Nullable } from "babylonjs/types";
  45268. import { Vector3 } from "babylonjs/Maths/math.vector";
  45269. import { Color3 } from "babylonjs/Maths/math.color";
  45270. import { TransformNode } from "babylonjs/Meshes/transformNode";
  45271. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45272. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  45273. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  45274. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  45275. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  45276. import { Scene } from "babylonjs/scene";
  45277. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  45278. /**
  45279. * Single plane drag gizmo
  45280. */
  45281. export class PlaneDragGizmo extends Gizmo {
  45282. /**
  45283. * Drag behavior responsible for the gizmos dragging interactions
  45284. */
  45285. dragBehavior: PointerDragBehavior;
  45286. private _pointerObserver;
  45287. /**
  45288. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  45289. */
  45290. snapDistance: number;
  45291. /**
  45292. * Event that fires each time the gizmo snaps to a new location.
  45293. * * snapDistance is the the change in distance
  45294. */
  45295. onSnapObservable: Observable<{
  45296. snapDistance: number;
  45297. }>;
  45298. private _plane;
  45299. private _coloredMaterial;
  45300. private _hoverMaterial;
  45301. private _isEnabled;
  45302. private _parent;
  45303. /** @hidden */
  45304. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  45305. /** @hidden */
  45306. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  45307. /**
  45308. * Creates a PlaneDragGizmo
  45309. * @param gizmoLayer The utility layer the gizmo will be added to
  45310. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  45311. * @param color The color of the gizmo
  45312. */
  45313. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  45314. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45315. /**
  45316. * If the gizmo is enabled
  45317. */
  45318. isEnabled: boolean;
  45319. /**
  45320. * Disposes of the gizmo
  45321. */
  45322. dispose(): void;
  45323. }
  45324. }
  45325. declare module "babylonjs/Gizmos/positionGizmo" {
  45326. import { Observable } from "babylonjs/Misc/observable";
  45327. import { Nullable } from "babylonjs/types";
  45328. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45329. import { Mesh } from "babylonjs/Meshes/mesh";
  45330. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  45331. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  45332. import { PlaneDragGizmo } from "babylonjs/Gizmos/planeDragGizmo";
  45333. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  45334. /**
  45335. * Gizmo that enables dragging a mesh along 3 axis
  45336. */
  45337. export class PositionGizmo extends Gizmo {
  45338. /**
  45339. * Internal gizmo used for interactions on the x axis
  45340. */
  45341. xGizmo: AxisDragGizmo;
  45342. /**
  45343. * Internal gizmo used for interactions on the y axis
  45344. */
  45345. yGizmo: AxisDragGizmo;
  45346. /**
  45347. * Internal gizmo used for interactions on the z axis
  45348. */
  45349. zGizmo: AxisDragGizmo;
  45350. /**
  45351. * Internal gizmo used for interactions on the yz plane
  45352. */
  45353. xPlaneGizmo: PlaneDragGizmo;
  45354. /**
  45355. * Internal gizmo used for interactions on the xz plane
  45356. */
  45357. yPlaneGizmo: PlaneDragGizmo;
  45358. /**
  45359. * Internal gizmo used for interactions on the xy plane
  45360. */
  45361. zPlaneGizmo: PlaneDragGizmo;
  45362. /**
  45363. * private variables
  45364. */
  45365. private _meshAttached;
  45366. private _updateGizmoRotationToMatchAttachedMesh;
  45367. private _snapDistance;
  45368. private _scaleRatio;
  45369. /** Fires an event when any of it's sub gizmos are dragged */
  45370. onDragStartObservable: Observable<unknown>;
  45371. /** Fires an event when any of it's sub gizmos are released from dragging */
  45372. onDragEndObservable: Observable<unknown>;
  45373. /**
  45374. * If set to true, planar drag is enabled
  45375. */
  45376. private _planarGizmoEnabled;
  45377. attachedMesh: Nullable<AbstractMesh>;
  45378. /**
  45379. * Creates a PositionGizmo
  45380. * @param gizmoLayer The utility layer the gizmo will be added to
  45381. */
  45382. constructor(gizmoLayer?: UtilityLayerRenderer);
  45383. /**
  45384. * If the planar drag gizmo is enabled
  45385. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  45386. */
  45387. planarGizmoEnabled: boolean;
  45388. updateGizmoRotationToMatchAttachedMesh: boolean;
  45389. /**
  45390. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  45391. */
  45392. snapDistance: number;
  45393. /**
  45394. * Ratio for the scale of the gizmo (Default: 1)
  45395. */
  45396. scaleRatio: number;
  45397. /**
  45398. * Disposes of the gizmo
  45399. */
  45400. dispose(): void;
  45401. /**
  45402. * CustomMeshes are not supported by this gizmo
  45403. * @param mesh The mesh to replace the default mesh of the gizmo
  45404. */
  45405. setCustomMesh(mesh: Mesh): void;
  45406. }
  45407. }
  45408. declare module "babylonjs/Gizmos/axisDragGizmo" {
  45409. import { Observable } from "babylonjs/Misc/observable";
  45410. import { Nullable } from "babylonjs/types";
  45411. import { Vector3 } from "babylonjs/Maths/math.vector";
  45412. import { TransformNode } from "babylonjs/Meshes/transformNode";
  45413. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45414. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  45415. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  45416. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  45417. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  45418. import { Scene } from "babylonjs/scene";
  45419. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  45420. import { Color3 } from "babylonjs/Maths/math.color";
  45421. /**
  45422. * Single axis drag gizmo
  45423. */
  45424. export class AxisDragGizmo extends Gizmo {
  45425. /**
  45426. * Drag behavior responsible for the gizmos dragging interactions
  45427. */
  45428. dragBehavior: PointerDragBehavior;
  45429. private _pointerObserver;
  45430. /**
  45431. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  45432. */
  45433. snapDistance: number;
  45434. /**
  45435. * Event that fires each time the gizmo snaps to a new location.
  45436. * * snapDistance is the the change in distance
  45437. */
  45438. onSnapObservable: Observable<{
  45439. snapDistance: number;
  45440. }>;
  45441. private _isEnabled;
  45442. private _parent;
  45443. private _arrow;
  45444. private _coloredMaterial;
  45445. private _hoverMaterial;
  45446. /** @hidden */
  45447. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  45448. /** @hidden */
  45449. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  45450. /**
  45451. * Creates an AxisDragGizmo
  45452. * @param gizmoLayer The utility layer the gizmo will be added to
  45453. * @param dragAxis The axis which the gizmo will be able to drag on
  45454. * @param color The color of the gizmo
  45455. */
  45456. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  45457. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45458. /**
  45459. * If the gizmo is enabled
  45460. */
  45461. isEnabled: boolean;
  45462. /**
  45463. * Disposes of the gizmo
  45464. */
  45465. dispose(): void;
  45466. }
  45467. }
  45468. declare module "babylonjs/Debug/axesViewer" {
  45469. import { Vector3 } from "babylonjs/Maths/math.vector";
  45470. import { Nullable } from "babylonjs/types";
  45471. import { Scene } from "babylonjs/scene";
  45472. import { TransformNode } from "babylonjs/Meshes/transformNode";
  45473. /**
  45474. * The Axes viewer will show 3 axes in a specific point in space
  45475. */
  45476. export class AxesViewer {
  45477. private _xAxis;
  45478. private _yAxis;
  45479. private _zAxis;
  45480. private _scaleLinesFactor;
  45481. private _instanced;
  45482. /**
  45483. * Gets the hosting scene
  45484. */
  45485. scene: Scene;
  45486. /**
  45487. * Gets or sets a number used to scale line length
  45488. */
  45489. scaleLines: number;
  45490. /** Gets the node hierarchy used to render x-axis */
  45491. readonly xAxis: TransformNode;
  45492. /** Gets the node hierarchy used to render y-axis */
  45493. readonly yAxis: TransformNode;
  45494. /** Gets the node hierarchy used to render z-axis */
  45495. readonly zAxis: TransformNode;
  45496. /**
  45497. * Creates a new AxesViewer
  45498. * @param scene defines the hosting scene
  45499. * @param scaleLines defines a number used to scale line length (1 by default)
  45500. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  45501. * @param xAxis defines the node hierarchy used to render the x-axis
  45502. * @param yAxis defines the node hierarchy used to render the y-axis
  45503. * @param zAxis defines the node hierarchy used to render the z-axis
  45504. */
  45505. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  45506. /**
  45507. * Force the viewer to update
  45508. * @param position defines the position of the viewer
  45509. * @param xaxis defines the x axis of the viewer
  45510. * @param yaxis defines the y axis of the viewer
  45511. * @param zaxis defines the z axis of the viewer
  45512. */
  45513. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  45514. /**
  45515. * Creates an instance of this axes viewer.
  45516. * @returns a new axes viewer with instanced meshes
  45517. */
  45518. createInstance(): AxesViewer;
  45519. /** Releases resources */
  45520. dispose(): void;
  45521. private static _SetRenderingGroupId;
  45522. }
  45523. }
  45524. declare module "babylonjs/Debug/boneAxesViewer" {
  45525. import { Nullable } from "babylonjs/types";
  45526. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  45527. import { Vector3 } from "babylonjs/Maths/math.vector";
  45528. import { Mesh } from "babylonjs/Meshes/mesh";
  45529. import { Bone } from "babylonjs/Bones/bone";
  45530. import { Scene } from "babylonjs/scene";
  45531. /**
  45532. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  45533. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  45534. */
  45535. export class BoneAxesViewer extends AxesViewer {
  45536. /**
  45537. * Gets or sets the target mesh where to display the axes viewer
  45538. */
  45539. mesh: Nullable<Mesh>;
  45540. /**
  45541. * Gets or sets the target bone where to display the axes viewer
  45542. */
  45543. bone: Nullable<Bone>;
  45544. /** Gets current position */
  45545. pos: Vector3;
  45546. /** Gets direction of X axis */
  45547. xaxis: Vector3;
  45548. /** Gets direction of Y axis */
  45549. yaxis: Vector3;
  45550. /** Gets direction of Z axis */
  45551. zaxis: Vector3;
  45552. /**
  45553. * Creates a new BoneAxesViewer
  45554. * @param scene defines the hosting scene
  45555. * @param bone defines the target bone
  45556. * @param mesh defines the target mesh
  45557. * @param scaleLines defines a scaling factor for line length (1 by default)
  45558. */
  45559. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  45560. /**
  45561. * Force the viewer to update
  45562. */
  45563. update(): void;
  45564. /** Releases resources */
  45565. dispose(): void;
  45566. }
  45567. }
  45568. declare module "babylonjs/Debug/debugLayer" {
  45569. import { Scene } from "babylonjs/scene";
  45570. /**
  45571. * Interface used to define scene explorer extensibility option
  45572. */
  45573. export interface IExplorerExtensibilityOption {
  45574. /**
  45575. * Define the option label
  45576. */
  45577. label: string;
  45578. /**
  45579. * Defines the action to execute on click
  45580. */
  45581. action: (entity: any) => void;
  45582. }
  45583. /**
  45584. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  45585. */
  45586. export interface IExplorerExtensibilityGroup {
  45587. /**
  45588. * Defines a predicate to test if a given type mut be extended
  45589. */
  45590. predicate: (entity: any) => boolean;
  45591. /**
  45592. * Gets the list of options added to a type
  45593. */
  45594. entries: IExplorerExtensibilityOption[];
  45595. }
  45596. /**
  45597. * Interface used to define the options to use to create the Inspector
  45598. */
  45599. export interface IInspectorOptions {
  45600. /**
  45601. * Display in overlay mode (default: false)
  45602. */
  45603. overlay?: boolean;
  45604. /**
  45605. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  45606. */
  45607. globalRoot?: HTMLElement;
  45608. /**
  45609. * Display the Scene explorer
  45610. */
  45611. showExplorer?: boolean;
  45612. /**
  45613. * Display the property inspector
  45614. */
  45615. showInspector?: boolean;
  45616. /**
  45617. * Display in embed mode (both panes on the right)
  45618. */
  45619. embedMode?: boolean;
  45620. /**
  45621. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  45622. */
  45623. handleResize?: boolean;
  45624. /**
  45625. * Allow the panes to popup (default: true)
  45626. */
  45627. enablePopup?: boolean;
  45628. /**
  45629. * Allow the panes to be closed by users (default: true)
  45630. */
  45631. enableClose?: boolean;
  45632. /**
  45633. * Optional list of extensibility entries
  45634. */
  45635. explorerExtensibility?: IExplorerExtensibilityGroup[];
  45636. /**
  45637. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  45638. */
  45639. inspectorURL?: string;
  45640. }
  45641. module "babylonjs/scene" {
  45642. interface Scene {
  45643. /**
  45644. * @hidden
  45645. * Backing field
  45646. */
  45647. _debugLayer: DebugLayer;
  45648. /**
  45649. * Gets the debug layer (aka Inspector) associated with the scene
  45650. * @see http://doc.babylonjs.com/features/playground_debuglayer
  45651. */
  45652. debugLayer: DebugLayer;
  45653. }
  45654. }
  45655. /**
  45656. * The debug layer (aka Inspector) is the go to tool in order to better understand
  45657. * what is happening in your scene
  45658. * @see http://doc.babylonjs.com/features/playground_debuglayer
  45659. */
  45660. export class DebugLayer {
  45661. /**
  45662. * Define the url to get the inspector script from.
  45663. * By default it uses the babylonjs CDN.
  45664. * @ignoreNaming
  45665. */
  45666. static InspectorURL: string;
  45667. private _scene;
  45668. private BJSINSPECTOR;
  45669. private _onPropertyChangedObservable?;
  45670. /**
  45671. * Observable triggered when a property is changed through the inspector.
  45672. */
  45673. readonly onPropertyChangedObservable: any;
  45674. /**
  45675. * Instantiates a new debug layer.
  45676. * The debug layer (aka Inspector) is the go to tool in order to better understand
  45677. * what is happening in your scene
  45678. * @see http://doc.babylonjs.com/features/playground_debuglayer
  45679. * @param scene Defines the scene to inspect
  45680. */
  45681. constructor(scene: Scene);
  45682. /** Creates the inspector window. */
  45683. private _createInspector;
  45684. /**
  45685. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  45686. * @param entity defines the entity to select
  45687. * @param lineContainerTitle defines the specific block to highlight
  45688. */
  45689. select(entity: any, lineContainerTitle?: string): void;
  45690. /** Get the inspector from bundle or global */
  45691. private _getGlobalInspector;
  45692. /**
  45693. * Get if the inspector is visible or not.
  45694. * @returns true if visible otherwise, false
  45695. */
  45696. isVisible(): boolean;
  45697. /**
  45698. * Hide the inspector and close its window.
  45699. */
  45700. hide(): void;
  45701. /**
  45702. * Launch the debugLayer.
  45703. * @param config Define the configuration of the inspector
  45704. * @return a promise fulfilled when the debug layer is visible
  45705. */
  45706. show(config?: IInspectorOptions): Promise<DebugLayer>;
  45707. }
  45708. }
  45709. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  45710. import { Nullable } from "babylonjs/types";
  45711. import { Scene } from "babylonjs/scene";
  45712. import { Vector4 } from "babylonjs/Maths/math.vector";
  45713. import { Color4 } from "babylonjs/Maths/math.color";
  45714. import { Mesh } from "babylonjs/Meshes/mesh";
  45715. /**
  45716. * Class containing static functions to help procedurally build meshes
  45717. */
  45718. export class BoxBuilder {
  45719. /**
  45720. * Creates a box mesh
  45721. * * The parameter `size` sets the size (float) of each box side (default 1)
  45722. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  45723. * * 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)
  45724. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  45725. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  45726. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  45727. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45728. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  45729. * @param name defines the name of the mesh
  45730. * @param options defines the options used to create the mesh
  45731. * @param scene defines the hosting scene
  45732. * @returns the box mesh
  45733. */
  45734. static CreateBox(name: string, options: {
  45735. size?: number;
  45736. width?: number;
  45737. height?: number;
  45738. depth?: number;
  45739. faceUV?: Vector4[];
  45740. faceColors?: Color4[];
  45741. sideOrientation?: number;
  45742. frontUVs?: Vector4;
  45743. backUVs?: Vector4;
  45744. wrap?: boolean;
  45745. topBaseAt?: number;
  45746. bottomBaseAt?: number;
  45747. updatable?: boolean;
  45748. }, scene?: Nullable<Scene>): Mesh;
  45749. }
  45750. }
  45751. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  45752. import { Vector4 } from "babylonjs/Maths/math.vector";
  45753. import { Mesh } from "babylonjs/Meshes/mesh";
  45754. import { Scene } from "babylonjs/scene";
  45755. import { Nullable } from "babylonjs/types";
  45756. /**
  45757. * Class containing static functions to help procedurally build meshes
  45758. */
  45759. export class SphereBuilder {
  45760. /**
  45761. * Creates a sphere mesh
  45762. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  45763. * * 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`)
  45764. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  45765. * * 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
  45766. * * 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)
  45767. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  45768. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  45769. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45770. * @param name defines the name of the mesh
  45771. * @param options defines the options used to create the mesh
  45772. * @param scene defines the hosting scene
  45773. * @returns the sphere mesh
  45774. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  45775. */
  45776. static CreateSphere(name: string, options: {
  45777. segments?: number;
  45778. diameter?: number;
  45779. diameterX?: number;
  45780. diameterY?: number;
  45781. diameterZ?: number;
  45782. arc?: number;
  45783. slice?: number;
  45784. sideOrientation?: number;
  45785. frontUVs?: Vector4;
  45786. backUVs?: Vector4;
  45787. updatable?: boolean;
  45788. }, scene?: Nullable<Scene>): Mesh;
  45789. }
  45790. }
  45791. declare module "babylonjs/Debug/physicsViewer" {
  45792. import { Nullable } from "babylonjs/types";
  45793. import { Scene } from "babylonjs/scene";
  45794. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45795. import { Mesh } from "babylonjs/Meshes/mesh";
  45796. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  45797. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  45798. /**
  45799. * Used to show the physics impostor around the specific mesh
  45800. */
  45801. export class PhysicsViewer {
  45802. /** @hidden */
  45803. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  45804. /** @hidden */
  45805. protected _meshes: Array<Nullable<AbstractMesh>>;
  45806. /** @hidden */
  45807. protected _scene: Nullable<Scene>;
  45808. /** @hidden */
  45809. protected _numMeshes: number;
  45810. /** @hidden */
  45811. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  45812. private _renderFunction;
  45813. private _utilityLayer;
  45814. private _debugBoxMesh;
  45815. private _debugSphereMesh;
  45816. private _debugCylinderMesh;
  45817. private _debugMaterial;
  45818. private _debugMeshMeshes;
  45819. /**
  45820. * Creates a new PhysicsViewer
  45821. * @param scene defines the hosting scene
  45822. */
  45823. constructor(scene: Scene);
  45824. /** @hidden */
  45825. protected _updateDebugMeshes(): void;
  45826. /**
  45827. * Renders a specified physic impostor
  45828. * @param impostor defines the impostor to render
  45829. * @param targetMesh defines the mesh represented by the impostor
  45830. * @returns the new debug mesh used to render the impostor
  45831. */
  45832. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  45833. /**
  45834. * Hides a specified physic impostor
  45835. * @param impostor defines the impostor to hide
  45836. */
  45837. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  45838. private _getDebugMaterial;
  45839. private _getDebugBoxMesh;
  45840. private _getDebugSphereMesh;
  45841. private _getDebugCylinderMesh;
  45842. private _getDebugMeshMesh;
  45843. private _getDebugMesh;
  45844. /** Releases all resources */
  45845. dispose(): void;
  45846. }
  45847. }
  45848. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  45849. import { Vector3 } from "babylonjs/Maths/math.vector";
  45850. import { Color4 } from "babylonjs/Maths/math.color";
  45851. import { Nullable } from "babylonjs/types";
  45852. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  45853. import { Scene } from "babylonjs/scene";
  45854. /**
  45855. * Class containing static functions to help procedurally build meshes
  45856. */
  45857. export class LinesBuilder {
  45858. /**
  45859. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  45860. * * 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
  45861. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  45862. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  45863. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  45864. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  45865. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  45866. * * 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
  45867. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  45868. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45869. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  45870. * @param name defines the name of the new line system
  45871. * @param options defines the options used to create the line system
  45872. * @param scene defines the hosting scene
  45873. * @returns a new line system mesh
  45874. */
  45875. static CreateLineSystem(name: string, options: {
  45876. lines: Vector3[][];
  45877. updatable?: boolean;
  45878. instance?: Nullable<LinesMesh>;
  45879. colors?: Nullable<Color4[][]>;
  45880. useVertexAlpha?: boolean;
  45881. }, scene: Nullable<Scene>): LinesMesh;
  45882. /**
  45883. * Creates a line mesh
  45884. * 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
  45885. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  45886. * * The parameter `points` is an array successive Vector3
  45887. * * 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
  45888. * * The optional parameter `colors` is an array of successive Color4, one per line point
  45889. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  45890. * * When updating an instance, remember that only point positions can change, not the number of points
  45891. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45892. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  45893. * @param name defines the name of the new line system
  45894. * @param options defines the options used to create the line system
  45895. * @param scene defines the hosting scene
  45896. * @returns a new line mesh
  45897. */
  45898. static CreateLines(name: string, options: {
  45899. points: Vector3[];
  45900. updatable?: boolean;
  45901. instance?: Nullable<LinesMesh>;
  45902. colors?: Color4[];
  45903. useVertexAlpha?: boolean;
  45904. }, scene?: Nullable<Scene>): LinesMesh;
  45905. /**
  45906. * Creates a dashed line mesh
  45907. * * 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
  45908. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  45909. * * The parameter `points` is an array successive Vector3
  45910. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  45911. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  45912. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  45913. * * 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
  45914. * * When updating an instance, remember that only point positions can change, not the number of points
  45915. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45916. * @param name defines the name of the mesh
  45917. * @param options defines the options used to create the mesh
  45918. * @param scene defines the hosting scene
  45919. * @returns the dashed line mesh
  45920. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  45921. */
  45922. static CreateDashedLines(name: string, options: {
  45923. points: Vector3[];
  45924. dashSize?: number;
  45925. gapSize?: number;
  45926. dashNb?: number;
  45927. updatable?: boolean;
  45928. instance?: LinesMesh;
  45929. }, scene?: Nullable<Scene>): LinesMesh;
  45930. }
  45931. }
  45932. declare module "babylonjs/Debug/rayHelper" {
  45933. import { Nullable } from "babylonjs/types";
  45934. import { Ray } from "babylonjs/Culling/ray";
  45935. import { Vector3 } from "babylonjs/Maths/math.vector";
  45936. import { Color3 } from "babylonjs/Maths/math.color";
  45937. import { Scene } from "babylonjs/scene";
  45938. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45939. import "babylonjs/Meshes/Builders/linesBuilder";
  45940. /**
  45941. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  45942. * in order to better appreciate the issue one might have.
  45943. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  45944. */
  45945. export class RayHelper {
  45946. /**
  45947. * Defines the ray we are currently tryin to visualize.
  45948. */
  45949. ray: Nullable<Ray>;
  45950. private _renderPoints;
  45951. private _renderLine;
  45952. private _renderFunction;
  45953. private _scene;
  45954. private _updateToMeshFunction;
  45955. private _attachedToMesh;
  45956. private _meshSpaceDirection;
  45957. private _meshSpaceOrigin;
  45958. /**
  45959. * Helper function to create a colored helper in a scene in one line.
  45960. * @param ray Defines the ray we are currently tryin to visualize
  45961. * @param scene Defines the scene the ray is used in
  45962. * @param color Defines the color we want to see the ray in
  45963. * @returns The newly created ray helper.
  45964. */
  45965. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  45966. /**
  45967. * Instantiate a new ray helper.
  45968. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  45969. * in order to better appreciate the issue one might have.
  45970. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  45971. * @param ray Defines the ray we are currently tryin to visualize
  45972. */
  45973. constructor(ray: Ray);
  45974. /**
  45975. * Shows the ray we are willing to debug.
  45976. * @param scene Defines the scene the ray needs to be rendered in
  45977. * @param color Defines the color the ray needs to be rendered in
  45978. */
  45979. show(scene: Scene, color?: Color3): void;
  45980. /**
  45981. * Hides the ray we are debugging.
  45982. */
  45983. hide(): void;
  45984. private _render;
  45985. /**
  45986. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  45987. * @param mesh Defines the mesh we want the helper attached to
  45988. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  45989. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  45990. * @param length Defines the length of the ray
  45991. */
  45992. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  45993. /**
  45994. * Detach the ray helper from the mesh it has previously been attached to.
  45995. */
  45996. detachFromMesh(): void;
  45997. private _updateToMesh;
  45998. /**
  45999. * Dispose the helper and release its associated resources.
  46000. */
  46001. dispose(): void;
  46002. }
  46003. }
  46004. declare module "babylonjs/Debug/skeletonViewer" {
  46005. import { Color3 } from "babylonjs/Maths/math.color";
  46006. import { Scene } from "babylonjs/scene";
  46007. import { Nullable } from "babylonjs/types";
  46008. import { Skeleton } from "babylonjs/Bones/skeleton";
  46009. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46010. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  46011. /**
  46012. * Class used to render a debug view of a given skeleton
  46013. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  46014. */
  46015. export class SkeletonViewer {
  46016. /** defines the skeleton to render */
  46017. skeleton: Skeleton;
  46018. /** defines the mesh attached to the skeleton */
  46019. mesh: AbstractMesh;
  46020. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  46021. autoUpdateBonesMatrices: boolean;
  46022. /** defines the rendering group id to use with the viewer */
  46023. renderingGroupId: number;
  46024. /** Gets or sets the color used to render the skeleton */
  46025. color: Color3;
  46026. private _scene;
  46027. private _debugLines;
  46028. private _debugMesh;
  46029. private _isEnabled;
  46030. private _renderFunction;
  46031. private _utilityLayer;
  46032. /**
  46033. * Returns the mesh used to render the bones
  46034. */
  46035. readonly debugMesh: Nullable<LinesMesh>;
  46036. /**
  46037. * Creates a new SkeletonViewer
  46038. * @param skeleton defines the skeleton to render
  46039. * @param mesh defines the mesh attached to the skeleton
  46040. * @param scene defines the hosting scene
  46041. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  46042. * @param renderingGroupId defines the rendering group id to use with the viewer
  46043. */
  46044. constructor(
  46045. /** defines the skeleton to render */
  46046. skeleton: Skeleton,
  46047. /** defines the mesh attached to the skeleton */
  46048. mesh: AbstractMesh, scene: Scene,
  46049. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  46050. autoUpdateBonesMatrices?: boolean,
  46051. /** defines the rendering group id to use with the viewer */
  46052. renderingGroupId?: number);
  46053. /** Gets or sets a boolean indicating if the viewer is enabled */
  46054. isEnabled: boolean;
  46055. private _getBonePosition;
  46056. private _getLinesForBonesWithLength;
  46057. private _getLinesForBonesNoLength;
  46058. /** Update the viewer to sync with current skeleton state */
  46059. update(): void;
  46060. /** Release associated resources */
  46061. dispose(): void;
  46062. }
  46063. }
  46064. declare module "babylonjs/Debug/index" {
  46065. export * from "babylonjs/Debug/axesViewer";
  46066. export * from "babylonjs/Debug/boneAxesViewer";
  46067. export * from "babylonjs/Debug/debugLayer";
  46068. export * from "babylonjs/Debug/physicsViewer";
  46069. export * from "babylonjs/Debug/rayHelper";
  46070. export * from "babylonjs/Debug/skeletonViewer";
  46071. }
  46072. declare module "babylonjs/Engines/nullEngine" {
  46073. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  46074. import { Scene } from "babylonjs/scene";
  46075. import { Engine } from "babylonjs/Engines/engine";
  46076. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  46077. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  46078. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  46079. import { Effect } from "babylonjs/Materials/effect";
  46080. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  46081. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  46082. import { IColor4Like, IViewportLike } from "babylonjs/Maths/math.like";
  46083. /**
  46084. * Options to create the null engine
  46085. */
  46086. export class NullEngineOptions {
  46087. /**
  46088. * Render width (Default: 512)
  46089. */
  46090. renderWidth: number;
  46091. /**
  46092. * Render height (Default: 256)
  46093. */
  46094. renderHeight: number;
  46095. /**
  46096. * Texture size (Default: 512)
  46097. */
  46098. textureSize: number;
  46099. /**
  46100. * If delta time between frames should be constant
  46101. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46102. */
  46103. deterministicLockstep: boolean;
  46104. /**
  46105. * Maximum about of steps between frames (Default: 4)
  46106. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46107. */
  46108. lockstepMaxSteps: number;
  46109. }
  46110. /**
  46111. * The null engine class provides support for headless version of babylon.js.
  46112. * This can be used in server side scenario or for testing purposes
  46113. */
  46114. export class NullEngine extends Engine {
  46115. private _options;
  46116. /**
  46117. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  46118. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46119. * @returns true if engine is in deterministic lock step mode
  46120. */
  46121. isDeterministicLockStep(): boolean;
  46122. /**
  46123. * Gets the max steps when engine is running in deterministic lock step
  46124. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46125. * @returns the max steps
  46126. */
  46127. getLockstepMaxSteps(): number;
  46128. /**
  46129. * Gets the current hardware scaling level.
  46130. * By default the hardware scaling level is computed from the window device ratio.
  46131. * 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.
  46132. * @returns a number indicating the current hardware scaling level
  46133. */
  46134. getHardwareScalingLevel(): number;
  46135. constructor(options?: NullEngineOptions);
  46136. /**
  46137. * Creates a vertex buffer
  46138. * @param vertices the data for the vertex buffer
  46139. * @returns the new WebGL static buffer
  46140. */
  46141. createVertexBuffer(vertices: FloatArray): DataBuffer;
  46142. /**
  46143. * Creates a new index buffer
  46144. * @param indices defines the content of the index buffer
  46145. * @param updatable defines if the index buffer must be updatable
  46146. * @returns a new webGL buffer
  46147. */
  46148. createIndexBuffer(indices: IndicesArray): DataBuffer;
  46149. /**
  46150. * Clear the current render buffer or the current render target (if any is set up)
  46151. * @param color defines the color to use
  46152. * @param backBuffer defines if the back buffer must be cleared
  46153. * @param depth defines if the depth buffer must be cleared
  46154. * @param stencil defines if the stencil buffer must be cleared
  46155. */
  46156. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  46157. /**
  46158. * Gets the current render width
  46159. * @param useScreen defines if screen size must be used (or the current render target if any)
  46160. * @returns a number defining the current render width
  46161. */
  46162. getRenderWidth(useScreen?: boolean): number;
  46163. /**
  46164. * Gets the current render height
  46165. * @param useScreen defines if screen size must be used (or the current render target if any)
  46166. * @returns a number defining the current render height
  46167. */
  46168. getRenderHeight(useScreen?: boolean): number;
  46169. /**
  46170. * Set the WebGL's viewport
  46171. * @param viewport defines the viewport element to be used
  46172. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  46173. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  46174. */
  46175. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  46176. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  46177. /**
  46178. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  46179. * @param pipelineContext defines the pipeline context to use
  46180. * @param uniformsNames defines the list of uniform names
  46181. * @returns an array of webGL uniform locations
  46182. */
  46183. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  46184. /**
  46185. * Gets the lsit of active attributes for a given webGL program
  46186. * @param pipelineContext defines the pipeline context to use
  46187. * @param attributesNames defines the list of attribute names to get
  46188. * @returns an array of indices indicating the offset of each attribute
  46189. */
  46190. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  46191. /**
  46192. * Binds an effect to the webGL context
  46193. * @param effect defines the effect to bind
  46194. */
  46195. bindSamplers(effect: Effect): void;
  46196. /**
  46197. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  46198. * @param effect defines the effect to activate
  46199. */
  46200. enableEffect(effect: Effect): void;
  46201. /**
  46202. * Set various states to the webGL context
  46203. * @param culling defines backface culling state
  46204. * @param zOffset defines the value to apply to zOffset (0 by default)
  46205. * @param force defines if states must be applied even if cache is up to date
  46206. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  46207. */
  46208. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  46209. /**
  46210. * Set the value of an uniform to an array of int32
  46211. * @param uniform defines the webGL uniform location where to store the value
  46212. * @param array defines the array of int32 to store
  46213. */
  46214. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  46215. /**
  46216. * Set the value of an uniform to an array of int32 (stored as vec2)
  46217. * @param uniform defines the webGL uniform location where to store the value
  46218. * @param array defines the array of int32 to store
  46219. */
  46220. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  46221. /**
  46222. * Set the value of an uniform to an array of int32 (stored as vec3)
  46223. * @param uniform defines the webGL uniform location where to store the value
  46224. * @param array defines the array of int32 to store
  46225. */
  46226. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  46227. /**
  46228. * Set the value of an uniform to an array of int32 (stored as vec4)
  46229. * @param uniform defines the webGL uniform location where to store the value
  46230. * @param array defines the array of int32 to store
  46231. */
  46232. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  46233. /**
  46234. * Set the value of an uniform to an array of float32
  46235. * @param uniform defines the webGL uniform location where to store the value
  46236. * @param array defines the array of float32 to store
  46237. */
  46238. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  46239. /**
  46240. * Set the value of an uniform to an array of float32 (stored as vec2)
  46241. * @param uniform defines the webGL uniform location where to store the value
  46242. * @param array defines the array of float32 to store
  46243. */
  46244. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  46245. /**
  46246. * Set the value of an uniform to an array of float32 (stored as vec3)
  46247. * @param uniform defines the webGL uniform location where to store the value
  46248. * @param array defines the array of float32 to store
  46249. */
  46250. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  46251. /**
  46252. * Set the value of an uniform to an array of float32 (stored as vec4)
  46253. * @param uniform defines the webGL uniform location where to store the value
  46254. * @param array defines the array of float32 to store
  46255. */
  46256. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  46257. /**
  46258. * Set the value of an uniform to an array of number
  46259. * @param uniform defines the webGL uniform location where to store the value
  46260. * @param array defines the array of number to store
  46261. */
  46262. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  46263. /**
  46264. * Set the value of an uniform to an array of number (stored as vec2)
  46265. * @param uniform defines the webGL uniform location where to store the value
  46266. * @param array defines the array of number to store
  46267. */
  46268. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  46269. /**
  46270. * Set the value of an uniform to an array of number (stored as vec3)
  46271. * @param uniform defines the webGL uniform location where to store the value
  46272. * @param array defines the array of number to store
  46273. */
  46274. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  46275. /**
  46276. * Set the value of an uniform to an array of number (stored as vec4)
  46277. * @param uniform defines the webGL uniform location where to store the value
  46278. * @param array defines the array of number to store
  46279. */
  46280. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  46281. /**
  46282. * Set the value of an uniform to an array of float32 (stored as matrices)
  46283. * @param uniform defines the webGL uniform location where to store the value
  46284. * @param matrices defines the array of float32 to store
  46285. */
  46286. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  46287. /**
  46288. * Set the value of an uniform to a matrix (3x3)
  46289. * @param uniform defines the webGL uniform location where to store the value
  46290. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  46291. */
  46292. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  46293. /**
  46294. * Set the value of an uniform to a matrix (2x2)
  46295. * @param uniform defines the webGL uniform location where to store the value
  46296. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  46297. */
  46298. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  46299. /**
  46300. * Set the value of an uniform to a number (float)
  46301. * @param uniform defines the webGL uniform location where to store the value
  46302. * @param value defines the float number to store
  46303. */
  46304. setFloat(uniform: WebGLUniformLocation, value: number): void;
  46305. /**
  46306. * Set the value of an uniform to a vec2
  46307. * @param uniform defines the webGL uniform location where to store the value
  46308. * @param x defines the 1st component of the value
  46309. * @param y defines the 2nd component of the value
  46310. */
  46311. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  46312. /**
  46313. * Set the value of an uniform to a vec3
  46314. * @param uniform defines the webGL uniform location where to store the value
  46315. * @param x defines the 1st component of the value
  46316. * @param y defines the 2nd component of the value
  46317. * @param z defines the 3rd component of the value
  46318. */
  46319. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  46320. /**
  46321. * Set the value of an uniform to a boolean
  46322. * @param uniform defines the webGL uniform location where to store the value
  46323. * @param bool defines the boolean to store
  46324. */
  46325. setBool(uniform: WebGLUniformLocation, bool: number): void;
  46326. /**
  46327. * Set the value of an uniform to a vec4
  46328. * @param uniform defines the webGL uniform location where to store the value
  46329. * @param x defines the 1st component of the value
  46330. * @param y defines the 2nd component of the value
  46331. * @param z defines the 3rd component of the value
  46332. * @param w defines the 4th component of the value
  46333. */
  46334. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  46335. /**
  46336. * Sets the current alpha mode
  46337. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  46338. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  46339. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  46340. */
  46341. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  46342. /**
  46343. * Bind webGl buffers directly to the webGL context
  46344. * @param vertexBuffers defines the vertex buffer to bind
  46345. * @param indexBuffer defines the index buffer to bind
  46346. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  46347. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  46348. * @param effect defines the effect associated with the vertex buffer
  46349. */
  46350. bindBuffers(vertexBuffers: {
  46351. [key: string]: VertexBuffer;
  46352. }, indexBuffer: DataBuffer, effect: Effect): void;
  46353. /**
  46354. * Force the entire cache to be cleared
  46355. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  46356. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  46357. */
  46358. wipeCaches(bruteForce?: boolean): void;
  46359. /**
  46360. * Send a draw order
  46361. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  46362. * @param indexStart defines the starting index
  46363. * @param indexCount defines the number of index to draw
  46364. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  46365. */
  46366. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  46367. /**
  46368. * Draw a list of indexed primitives
  46369. * @param fillMode defines the primitive to use
  46370. * @param indexStart defines the starting index
  46371. * @param indexCount defines the number of index to draw
  46372. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  46373. */
  46374. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  46375. /**
  46376. * Draw a list of unindexed primitives
  46377. * @param fillMode defines the primitive to use
  46378. * @param verticesStart defines the index of first vertex to draw
  46379. * @param verticesCount defines the count of vertices to draw
  46380. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  46381. */
  46382. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  46383. /** @hidden */
  46384. _createTexture(): WebGLTexture;
  46385. /** @hidden */
  46386. _releaseTexture(texture: InternalTexture): void;
  46387. /**
  46388. * Usually called from Texture.ts.
  46389. * Passed information to create a WebGLTexture
  46390. * @param urlArg defines a value which contains one of the following:
  46391. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  46392. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  46393. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  46394. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  46395. * @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)
  46396. * @param scene needed for loading to the correct scene
  46397. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  46398. * @param onLoad optional callback to be called upon successful completion
  46399. * @param onError optional callback to be called upon failure
  46400. * @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
  46401. * @param fallBack an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  46402. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  46403. * @param forcedExtension defines the extension to use to pick the right loader
  46404. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  46405. * @returns a InternalTexture for assignment back into BABYLON.Texture
  46406. */
  46407. 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;
  46408. /**
  46409. * Creates a new render target texture
  46410. * @param size defines the size of the texture
  46411. * @param options defines the options used to create the texture
  46412. * @returns a new render target texture stored in an InternalTexture
  46413. */
  46414. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  46415. /**
  46416. * Update the sampling mode of a given texture
  46417. * @param samplingMode defines the required sampling mode
  46418. * @param texture defines the texture to update
  46419. */
  46420. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  46421. /**
  46422. * Binds the frame buffer to the specified texture.
  46423. * @param texture The texture to render to or null for the default canvas
  46424. * @param faceIndex The face of the texture to render to in case of cube texture
  46425. * @param requiredWidth The width of the target to render to
  46426. * @param requiredHeight The height of the target to render to
  46427. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  46428. * @param depthStencilTexture The depth stencil texture to use to render
  46429. * @param lodLevel defines le lod level to bind to the frame buffer
  46430. */
  46431. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  46432. /**
  46433. * Unbind the current render target texture from the webGL context
  46434. * @param texture defines the render target texture to unbind
  46435. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  46436. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  46437. */
  46438. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  46439. /**
  46440. * Creates a dynamic vertex buffer
  46441. * @param vertices the data for the dynamic vertex buffer
  46442. * @returns the new WebGL dynamic buffer
  46443. */
  46444. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  46445. /**
  46446. * Update the content of a dynamic texture
  46447. * @param texture defines the texture to update
  46448. * @param canvas defines the canvas containing the source
  46449. * @param invertY defines if data must be stored with Y axis inverted
  46450. * @param premulAlpha defines if alpha is stored as premultiplied
  46451. * @param format defines the format of the data
  46452. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  46453. */
  46454. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  46455. /**
  46456. * Gets a boolean indicating if all created effects are ready
  46457. * @returns true if all effects are ready
  46458. */
  46459. areAllEffectsReady(): boolean;
  46460. /**
  46461. * @hidden
  46462. * Get the current error code of the webGL context
  46463. * @returns the error code
  46464. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  46465. */
  46466. getError(): number;
  46467. /** @hidden */
  46468. _getUnpackAlignement(): number;
  46469. /** @hidden */
  46470. _unpackFlipY(value: boolean): void;
  46471. /**
  46472. * Update a dynamic index buffer
  46473. * @param indexBuffer defines the target index buffer
  46474. * @param indices defines the data to update
  46475. * @param offset defines the offset in the target index buffer where update should start
  46476. */
  46477. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  46478. /**
  46479. * Updates a dynamic vertex buffer.
  46480. * @param vertexBuffer the vertex buffer to update
  46481. * @param vertices the data used to update the vertex buffer
  46482. * @param byteOffset the byte offset of the data (optional)
  46483. * @param byteLength the byte length of the data (optional)
  46484. */
  46485. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  46486. /** @hidden */
  46487. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  46488. /** @hidden */
  46489. _bindTexture(channel: number, texture: InternalTexture): void;
  46490. protected _deleteBuffer(buffer: WebGLBuffer): void;
  46491. /**
  46492. * 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
  46493. */
  46494. releaseEffects(): void;
  46495. displayLoadingUI(): void;
  46496. hideLoadingUI(): void;
  46497. /** @hidden */
  46498. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46499. /** @hidden */
  46500. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46501. /** @hidden */
  46502. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46503. /** @hidden */
  46504. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  46505. }
  46506. }
  46507. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  46508. import { Nullable, int } from "babylonjs/types";
  46509. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  46510. /** @hidden */
  46511. export class _OcclusionDataStorage {
  46512. /** @hidden */
  46513. occlusionInternalRetryCounter: number;
  46514. /** @hidden */
  46515. isOcclusionQueryInProgress: boolean;
  46516. /** @hidden */
  46517. isOccluded: boolean;
  46518. /** @hidden */
  46519. occlusionRetryCount: number;
  46520. /** @hidden */
  46521. occlusionType: number;
  46522. /** @hidden */
  46523. occlusionQueryAlgorithmType: number;
  46524. }
  46525. module "babylonjs/Engines/engine" {
  46526. interface Engine {
  46527. /**
  46528. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  46529. * @return the new query
  46530. */
  46531. createQuery(): WebGLQuery;
  46532. /**
  46533. * Delete and release a webGL query
  46534. * @param query defines the query to delete
  46535. * @return the current engine
  46536. */
  46537. deleteQuery(query: WebGLQuery): Engine;
  46538. /**
  46539. * Check if a given query has resolved and got its value
  46540. * @param query defines the query to check
  46541. * @returns true if the query got its value
  46542. */
  46543. isQueryResultAvailable(query: WebGLQuery): boolean;
  46544. /**
  46545. * Gets the value of a given query
  46546. * @param query defines the query to check
  46547. * @returns the value of the query
  46548. */
  46549. getQueryResult(query: WebGLQuery): number;
  46550. /**
  46551. * Initiates an occlusion query
  46552. * @param algorithmType defines the algorithm to use
  46553. * @param query defines the query to use
  46554. * @returns the current engine
  46555. * @see http://doc.babylonjs.com/features/occlusionquery
  46556. */
  46557. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  46558. /**
  46559. * Ends an occlusion query
  46560. * @see http://doc.babylonjs.com/features/occlusionquery
  46561. * @param algorithmType defines the algorithm to use
  46562. * @returns the current engine
  46563. */
  46564. endOcclusionQuery(algorithmType: number): Engine;
  46565. /**
  46566. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  46567. * Please note that only one query can be issued at a time
  46568. * @returns a time token used to track the time span
  46569. */
  46570. startTimeQuery(): Nullable<_TimeToken>;
  46571. /**
  46572. * Ends a time query
  46573. * @param token defines the token used to measure the time span
  46574. * @returns the time spent (in ns)
  46575. */
  46576. endTimeQuery(token: _TimeToken): int;
  46577. /** @hidden */
  46578. _currentNonTimestampToken: Nullable<_TimeToken>;
  46579. /** @hidden */
  46580. _createTimeQuery(): WebGLQuery;
  46581. /** @hidden */
  46582. _deleteTimeQuery(query: WebGLQuery): void;
  46583. /** @hidden */
  46584. _getGlAlgorithmType(algorithmType: number): number;
  46585. /** @hidden */
  46586. _getTimeQueryResult(query: WebGLQuery): any;
  46587. /** @hidden */
  46588. _getTimeQueryAvailability(query: WebGLQuery): any;
  46589. }
  46590. }
  46591. module "babylonjs/Meshes/abstractMesh" {
  46592. interface AbstractMesh {
  46593. /**
  46594. * Backing filed
  46595. * @hidden
  46596. */
  46597. __occlusionDataStorage: _OcclusionDataStorage;
  46598. /**
  46599. * Access property
  46600. * @hidden
  46601. */
  46602. _occlusionDataStorage: _OcclusionDataStorage;
  46603. /**
  46604. * 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.
  46605. * The default value is -1 which means don't break the query and wait till the result
  46606. * @see http://doc.babylonjs.com/features/occlusionquery
  46607. */
  46608. occlusionRetryCount: number;
  46609. /**
  46610. * 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:
  46611. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  46612. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  46613. * * 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.
  46614. * @see http://doc.babylonjs.com/features/occlusionquery
  46615. */
  46616. occlusionType: number;
  46617. /**
  46618. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  46619. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  46620. * * 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.
  46621. * @see http://doc.babylonjs.com/features/occlusionquery
  46622. */
  46623. occlusionQueryAlgorithmType: number;
  46624. /**
  46625. * 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
  46626. * @see http://doc.babylonjs.com/features/occlusionquery
  46627. */
  46628. isOccluded: boolean;
  46629. /**
  46630. * Flag to check the progress status of the query
  46631. * @see http://doc.babylonjs.com/features/occlusionquery
  46632. */
  46633. isOcclusionQueryInProgress: boolean;
  46634. }
  46635. }
  46636. }
  46637. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  46638. import { Nullable } from "babylonjs/types";
  46639. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  46640. /** @hidden */
  46641. export var _forceTransformFeedbackToBundle: boolean;
  46642. module "babylonjs/Engines/engine" {
  46643. interface Engine {
  46644. /**
  46645. * Creates a webGL transform feedback object
  46646. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  46647. * @returns the webGL transform feedback object
  46648. */
  46649. createTransformFeedback(): WebGLTransformFeedback;
  46650. /**
  46651. * Delete a webGL transform feedback object
  46652. * @param value defines the webGL transform feedback object to delete
  46653. */
  46654. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  46655. /**
  46656. * Bind a webGL transform feedback object to the webgl context
  46657. * @param value defines the webGL transform feedback object to bind
  46658. */
  46659. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  46660. /**
  46661. * Begins a transform feedback operation
  46662. * @param usePoints defines if points or triangles must be used
  46663. */
  46664. beginTransformFeedback(usePoints: boolean): void;
  46665. /**
  46666. * Ends a transform feedback operation
  46667. */
  46668. endTransformFeedback(): void;
  46669. /**
  46670. * Specify the varyings to use with transform feedback
  46671. * @param program defines the associated webGL program
  46672. * @param value defines the list of strings representing the varying names
  46673. */
  46674. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  46675. /**
  46676. * Bind a webGL buffer for a transform feedback operation
  46677. * @param value defines the webGL buffer to bind
  46678. */
  46679. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  46680. }
  46681. }
  46682. }
  46683. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  46684. import { Scene } from "babylonjs/scene";
  46685. import { Engine } from "babylonjs/Engines/engine";
  46686. import { Texture } from "babylonjs/Materials/Textures/texture";
  46687. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  46688. import "babylonjs/Engines/Extensions/engine.multiRender";
  46689. /**
  46690. * Creation options of the multi render target texture.
  46691. */
  46692. export interface IMultiRenderTargetOptions {
  46693. /**
  46694. * Define if the texture needs to create mip maps after render.
  46695. */
  46696. generateMipMaps?: boolean;
  46697. /**
  46698. * Define the types of all the draw buffers we want to create
  46699. */
  46700. types?: number[];
  46701. /**
  46702. * Define the sampling modes of all the draw buffers we want to create
  46703. */
  46704. samplingModes?: number[];
  46705. /**
  46706. * Define if a depth buffer is required
  46707. */
  46708. generateDepthBuffer?: boolean;
  46709. /**
  46710. * Define if a stencil buffer is required
  46711. */
  46712. generateStencilBuffer?: boolean;
  46713. /**
  46714. * Define if a depth texture is required instead of a depth buffer
  46715. */
  46716. generateDepthTexture?: boolean;
  46717. /**
  46718. * Define the number of desired draw buffers
  46719. */
  46720. textureCount?: number;
  46721. /**
  46722. * Define if aspect ratio should be adapted to the texture or stay the scene one
  46723. */
  46724. doNotChangeAspectRatio?: boolean;
  46725. /**
  46726. * Define the default type of the buffers we are creating
  46727. */
  46728. defaultType?: number;
  46729. }
  46730. /**
  46731. * A multi render target, like a render target provides the ability to render to a texture.
  46732. * Unlike the render target, it can render to several draw buffers in one draw.
  46733. * This is specially interesting in deferred rendering or for any effects requiring more than
  46734. * just one color from a single pass.
  46735. */
  46736. export class MultiRenderTarget extends RenderTargetTexture {
  46737. private _internalTextures;
  46738. private _textures;
  46739. private _multiRenderTargetOptions;
  46740. /**
  46741. * Get if draw buffers are currently supported by the used hardware and browser.
  46742. */
  46743. readonly isSupported: boolean;
  46744. /**
  46745. * Get the list of textures generated by the multi render target.
  46746. */
  46747. readonly textures: Texture[];
  46748. /**
  46749. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  46750. */
  46751. readonly depthTexture: Texture;
  46752. /**
  46753. * Set the wrapping mode on U of all the textures we are rendering to.
  46754. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  46755. */
  46756. wrapU: number;
  46757. /**
  46758. * Set the wrapping mode on V of all the textures we are rendering to.
  46759. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  46760. */
  46761. wrapV: number;
  46762. /**
  46763. * Instantiate a new multi render target texture.
  46764. * A multi render target, like a render target provides the ability to render to a texture.
  46765. * Unlike the render target, it can render to several draw buffers in one draw.
  46766. * This is specially interesting in deferred rendering or for any effects requiring more than
  46767. * just one color from a single pass.
  46768. * @param name Define the name of the texture
  46769. * @param size Define the size of the buffers to render to
  46770. * @param count Define the number of target we are rendering into
  46771. * @param scene Define the scene the texture belongs to
  46772. * @param options Define the options used to create the multi render target
  46773. */
  46774. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  46775. /** @hidden */
  46776. _rebuild(): void;
  46777. private _createInternalTextures;
  46778. private _createTextures;
  46779. /**
  46780. * Define the number of samples used if MSAA is enabled.
  46781. */
  46782. samples: number;
  46783. /**
  46784. * Resize all the textures in the multi render target.
  46785. * Be carrefull as it will recreate all the data in the new texture.
  46786. * @param size Define the new size
  46787. */
  46788. resize(size: any): void;
  46789. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  46790. /**
  46791. * Dispose the render targets and their associated resources
  46792. */
  46793. dispose(): void;
  46794. /**
  46795. * Release all the underlying texture used as draw buffers.
  46796. */
  46797. releaseInternalTextures(): void;
  46798. }
  46799. }
  46800. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  46801. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  46802. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  46803. import { Nullable } from "babylonjs/types";
  46804. module "babylonjs/Engines/thinEngine" {
  46805. interface ThinEngine {
  46806. /**
  46807. * Unbind a list of render target textures from the webGL context
  46808. * This is used only when drawBuffer extension or webGL2 are active
  46809. * @param textures defines the render target textures to unbind
  46810. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  46811. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  46812. */
  46813. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  46814. /**
  46815. * Create a multi render target texture
  46816. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  46817. * @param size defines the size of the texture
  46818. * @param options defines the creation options
  46819. * @returns the cube texture as an InternalTexture
  46820. */
  46821. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  46822. /**
  46823. * Update the sample count for a given multiple render target texture
  46824. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  46825. * @param textures defines the textures to update
  46826. * @param samples defines the sample count to set
  46827. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  46828. */
  46829. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  46830. }
  46831. }
  46832. }
  46833. declare module "babylonjs/Engines/Extensions/engine.views" {
  46834. import { Camera } from "babylonjs/Cameras/camera";
  46835. import { Nullable } from "babylonjs/types";
  46836. /**
  46837. * Class used to define an additional view for the engine
  46838. * @see https://doc.babylonjs.com/how_to/multi_canvases
  46839. */
  46840. export class EngineView {
  46841. /** Defines the canvas where to render the view */
  46842. target: HTMLCanvasElement;
  46843. /** Defines an optional camera used to render the view (will use active camera else) */
  46844. camera?: Camera;
  46845. }
  46846. module "babylonjs/Engines/engine" {
  46847. interface Engine {
  46848. /**
  46849. * Gets or sets the HTML element to use for attaching events
  46850. */
  46851. inputElement: Nullable<HTMLElement>;
  46852. /**
  46853. * Gets the current engine view
  46854. * @see https://doc.babylonjs.com/how_to/multi_canvases
  46855. */
  46856. activeView: Nullable<EngineView>;
  46857. /** Gets or sets the list of views */
  46858. views: EngineView[];
  46859. /**
  46860. * Register a new child canvas
  46861. * @param canvas defines the canvas to register
  46862. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  46863. * @returns the associated view
  46864. */
  46865. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  46866. /**
  46867. * Remove a registered child canvas
  46868. * @param canvas defines the canvas to remove
  46869. * @returns the current engine
  46870. */
  46871. unRegisterView(canvas: HTMLCanvasElement): Engine;
  46872. }
  46873. }
  46874. }
  46875. declare module "babylonjs/Engines/Extensions/index" {
  46876. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  46877. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  46878. export * from "babylonjs/Engines/Extensions/engine.multiview";
  46879. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  46880. export * from "babylonjs/Engines/Extensions/engine.dynamicTexture";
  46881. export * from "babylonjs/Engines/Extensions/engine.videoTexture";
  46882. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  46883. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  46884. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  46885. export * from "babylonjs/Engines/Extensions/engine.renderTargetCube";
  46886. export * from "babylonjs/Engines/Extensions/engine.webVR";
  46887. export * from "babylonjs/Engines/Extensions/engine.uniformBuffer";
  46888. export * from "babylonjs/Engines/Extensions/engine.views";
  46889. }
  46890. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  46891. import { Nullable } from "babylonjs/types";
  46892. /**
  46893. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  46894. */
  46895. export interface CubeMapInfo {
  46896. /**
  46897. * The pixel array for the front face.
  46898. * This is stored in format, left to right, up to down format.
  46899. */
  46900. front: Nullable<ArrayBufferView>;
  46901. /**
  46902. * The pixel array for the back face.
  46903. * This is stored in format, left to right, up to down format.
  46904. */
  46905. back: Nullable<ArrayBufferView>;
  46906. /**
  46907. * The pixel array for the left face.
  46908. * This is stored in format, left to right, up to down format.
  46909. */
  46910. left: Nullable<ArrayBufferView>;
  46911. /**
  46912. * The pixel array for the right face.
  46913. * This is stored in format, left to right, up to down format.
  46914. */
  46915. right: Nullable<ArrayBufferView>;
  46916. /**
  46917. * The pixel array for the up face.
  46918. * This is stored in format, left to right, up to down format.
  46919. */
  46920. up: Nullable<ArrayBufferView>;
  46921. /**
  46922. * The pixel array for the down face.
  46923. * This is stored in format, left to right, up to down format.
  46924. */
  46925. down: Nullable<ArrayBufferView>;
  46926. /**
  46927. * The size of the cubemap stored.
  46928. *
  46929. * Each faces will be size * size pixels.
  46930. */
  46931. size: number;
  46932. /**
  46933. * The format of the texture.
  46934. *
  46935. * RGBA, RGB.
  46936. */
  46937. format: number;
  46938. /**
  46939. * The type of the texture data.
  46940. *
  46941. * UNSIGNED_INT, FLOAT.
  46942. */
  46943. type: number;
  46944. /**
  46945. * Specifies whether the texture is in gamma space.
  46946. */
  46947. gammaSpace: boolean;
  46948. }
  46949. /**
  46950. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  46951. */
  46952. export class PanoramaToCubeMapTools {
  46953. private static FACE_FRONT;
  46954. private static FACE_BACK;
  46955. private static FACE_RIGHT;
  46956. private static FACE_LEFT;
  46957. private static FACE_DOWN;
  46958. private static FACE_UP;
  46959. /**
  46960. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  46961. *
  46962. * @param float32Array The source data.
  46963. * @param inputWidth The width of the input panorama.
  46964. * @param inputHeight The height of the input panorama.
  46965. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  46966. * @return The cubemap data
  46967. */
  46968. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  46969. private static CreateCubemapTexture;
  46970. private static CalcProjectionSpherical;
  46971. }
  46972. }
  46973. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  46974. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  46975. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46976. import { Nullable } from "babylonjs/types";
  46977. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  46978. /**
  46979. * Helper class dealing with the extraction of spherical polynomial dataArray
  46980. * from a cube map.
  46981. */
  46982. export class CubeMapToSphericalPolynomialTools {
  46983. private static FileFaces;
  46984. /**
  46985. * Converts a texture to the according Spherical Polynomial data.
  46986. * This extracts the first 3 orders only as they are the only one used in the lighting.
  46987. *
  46988. * @param texture The texture to extract the information from.
  46989. * @return The Spherical Polynomial data.
  46990. */
  46991. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  46992. /**
  46993. * Converts a cubemap to the according Spherical Polynomial data.
  46994. * This extracts the first 3 orders only as they are the only one used in the lighting.
  46995. *
  46996. * @param cubeInfo The Cube map to extract the information from.
  46997. * @return The Spherical Polynomial data.
  46998. */
  46999. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  47000. }
  47001. }
  47002. declare module "babylonjs/Materials/Textures/baseTexture.polynomial" {
  47003. import { Nullable } from "babylonjs/types";
  47004. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  47005. module "babylonjs/Materials/Textures/baseTexture" {
  47006. interface BaseTexture {
  47007. /**
  47008. * Get the polynomial representation of the texture data.
  47009. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  47010. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  47011. */
  47012. sphericalPolynomial: Nullable<SphericalPolynomial>;
  47013. }
  47014. }
  47015. }
  47016. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  47017. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  47018. /** @hidden */
  47019. export var rgbdEncodePixelShader: {
  47020. name: string;
  47021. shader: string;
  47022. };
  47023. }
  47024. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  47025. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  47026. /** @hidden */
  47027. export var rgbdDecodePixelShader: {
  47028. name: string;
  47029. shader: string;
  47030. };
  47031. }
  47032. declare module "babylonjs/Misc/environmentTextureTools" {
  47033. import { Nullable } from "babylonjs/types";
  47034. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  47035. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  47036. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  47037. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  47038. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  47039. import "babylonjs/Shaders/rgbdEncode.fragment";
  47040. import "babylonjs/Shaders/rgbdDecode.fragment";
  47041. /**
  47042. * Raw texture data and descriptor sufficient for WebGL texture upload
  47043. */
  47044. export interface EnvironmentTextureInfo {
  47045. /**
  47046. * Version of the environment map
  47047. */
  47048. version: number;
  47049. /**
  47050. * Width of image
  47051. */
  47052. width: number;
  47053. /**
  47054. * Irradiance information stored in the file.
  47055. */
  47056. irradiance: any;
  47057. /**
  47058. * Specular information stored in the file.
  47059. */
  47060. specular: any;
  47061. }
  47062. /**
  47063. * Defines One Image in the file. It requires only the position in the file
  47064. * as well as the length.
  47065. */
  47066. interface BufferImageData {
  47067. /**
  47068. * Length of the image data.
  47069. */
  47070. length: number;
  47071. /**
  47072. * Position of the data from the null terminator delimiting the end of the JSON.
  47073. */
  47074. position: number;
  47075. }
  47076. /**
  47077. * Defines the specular data enclosed in the file.
  47078. * This corresponds to the version 1 of the data.
  47079. */
  47080. export interface EnvironmentTextureSpecularInfoV1 {
  47081. /**
  47082. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  47083. */
  47084. specularDataPosition?: number;
  47085. /**
  47086. * This contains all the images data needed to reconstruct the cubemap.
  47087. */
  47088. mipmaps: Array<BufferImageData>;
  47089. /**
  47090. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  47091. */
  47092. lodGenerationScale: number;
  47093. }
  47094. /**
  47095. * Sets of helpers addressing the serialization and deserialization of environment texture
  47096. * stored in a BabylonJS env file.
  47097. * Those files are usually stored as .env files.
  47098. */
  47099. export class EnvironmentTextureTools {
  47100. /**
  47101. * Magic number identifying the env file.
  47102. */
  47103. private static _MagicBytes;
  47104. /**
  47105. * Gets the environment info from an env file.
  47106. * @param data The array buffer containing the .env bytes.
  47107. * @returns the environment file info (the json header) if successfully parsed.
  47108. */
  47109. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  47110. /**
  47111. * Creates an environment texture from a loaded cube texture.
  47112. * @param texture defines the cube texture to convert in env file
  47113. * @return a promise containing the environment data if succesfull.
  47114. */
  47115. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  47116. /**
  47117. * Creates a JSON representation of the spherical data.
  47118. * @param texture defines the texture containing the polynomials
  47119. * @return the JSON representation of the spherical info
  47120. */
  47121. private static _CreateEnvTextureIrradiance;
  47122. /**
  47123. * Creates the ArrayBufferViews used for initializing environment texture image data.
  47124. * @param arrayBuffer the underlying ArrayBuffer to which the views refer
  47125. * @param info parameters that determine what views will be created for accessing the underlying buffer
  47126. * @return the views described by info providing access to the underlying buffer
  47127. */
  47128. static CreateImageDataArrayBufferViews(arrayBuffer: any, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  47129. /**
  47130. * Uploads the texture info contained in the env file to the GPU.
  47131. * @param texture defines the internal texture to upload to
  47132. * @param arrayBuffer defines the buffer cotaining the data to load
  47133. * @param info defines the texture info retrieved through the GetEnvInfo method
  47134. * @returns a promise
  47135. */
  47136. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  47137. private static _OnImageReadyAsync;
  47138. /**
  47139. * Uploads the levels of image data to the GPU.
  47140. * @param texture defines the internal texture to upload to
  47141. * @param imageData defines the array buffer views of image data [mipmap][face]
  47142. * @returns a promise
  47143. */
  47144. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  47145. /**
  47146. * Uploads spherical polynomials information to the texture.
  47147. * @param texture defines the texture we are trying to upload the information to
  47148. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  47149. */
  47150. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  47151. /** @hidden */
  47152. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  47153. }
  47154. }
  47155. declare module "babylonjs/Maths/math.vertexFormat" {
  47156. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  47157. /**
  47158. * Contains position and normal vectors for a vertex
  47159. */
  47160. export class PositionNormalVertex {
  47161. /** the position of the vertex (defaut: 0,0,0) */
  47162. position: Vector3;
  47163. /** the normal of the vertex (defaut: 0,1,0) */
  47164. normal: Vector3;
  47165. /**
  47166. * Creates a PositionNormalVertex
  47167. * @param position the position of the vertex (defaut: 0,0,0)
  47168. * @param normal the normal of the vertex (defaut: 0,1,0)
  47169. */
  47170. constructor(
  47171. /** the position of the vertex (defaut: 0,0,0) */
  47172. position?: Vector3,
  47173. /** the normal of the vertex (defaut: 0,1,0) */
  47174. normal?: Vector3);
  47175. /**
  47176. * Clones the PositionNormalVertex
  47177. * @returns the cloned PositionNormalVertex
  47178. */
  47179. clone(): PositionNormalVertex;
  47180. }
  47181. /**
  47182. * Contains position, normal and uv vectors for a vertex
  47183. */
  47184. export class PositionNormalTextureVertex {
  47185. /** the position of the vertex (defaut: 0,0,0) */
  47186. position: Vector3;
  47187. /** the normal of the vertex (defaut: 0,1,0) */
  47188. normal: Vector3;
  47189. /** the uv of the vertex (default: 0,0) */
  47190. uv: Vector2;
  47191. /**
  47192. * Creates a PositionNormalTextureVertex
  47193. * @param position the position of the vertex (defaut: 0,0,0)
  47194. * @param normal the normal of the vertex (defaut: 0,1,0)
  47195. * @param uv the uv of the vertex (default: 0,0)
  47196. */
  47197. constructor(
  47198. /** the position of the vertex (defaut: 0,0,0) */
  47199. position?: Vector3,
  47200. /** the normal of the vertex (defaut: 0,1,0) */
  47201. normal?: Vector3,
  47202. /** the uv of the vertex (default: 0,0) */
  47203. uv?: Vector2);
  47204. /**
  47205. * Clones the PositionNormalTextureVertex
  47206. * @returns the cloned PositionNormalTextureVertex
  47207. */
  47208. clone(): PositionNormalTextureVertex;
  47209. }
  47210. }
  47211. declare module "babylonjs/Maths/math" {
  47212. export * from "babylonjs/Maths/math.axis";
  47213. export * from "babylonjs/Maths/math.color";
  47214. export * from "babylonjs/Maths/math.constants";
  47215. export * from "babylonjs/Maths/math.frustum";
  47216. export * from "babylonjs/Maths/math.path";
  47217. export * from "babylonjs/Maths/math.plane";
  47218. export * from "babylonjs/Maths/math.size";
  47219. export * from "babylonjs/Maths/math.vector";
  47220. export * from "babylonjs/Maths/math.vertexFormat";
  47221. export * from "babylonjs/Maths/math.viewport";
  47222. }
  47223. declare module "babylonjs/Engines/Native/nativeShaderProcessor" {
  47224. import { WebGL2ShaderProcessor } from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  47225. /** @hidden */
  47226. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  47227. private _genericAttributeLocation;
  47228. private _varyingLocationCount;
  47229. private _varyingLocationMap;
  47230. private _replacements;
  47231. private _textureCount;
  47232. private _uniforms;
  47233. lineProcessor(line: string): string;
  47234. attributeProcessor(attribute: string): string;
  47235. varyingProcessor(varying: string, isFragment: boolean): string;
  47236. uniformProcessor(uniform: string): string;
  47237. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  47238. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  47239. }
  47240. }
  47241. declare module "babylonjs/Engines/nativeEngine" {
  47242. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  47243. import { Engine } from "babylonjs/Engines/engine";
  47244. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  47245. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  47246. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47247. import { Effect } from "babylonjs/Materials/effect";
  47248. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  47249. import { Matrix, Viewport, Color3 } from "babylonjs/Maths/math";
  47250. import { IColor4Like } from "babylonjs/Maths/math.like";
  47251. import { Scene } from "babylonjs/scene";
  47252. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  47253. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  47254. /**
  47255. * Container for accessors for natively-stored mesh data buffers.
  47256. */
  47257. class NativeDataBuffer extends DataBuffer {
  47258. /**
  47259. * Accessor value used to identify/retrieve a natively-stored index buffer.
  47260. */
  47261. nativeIndexBuffer?: any;
  47262. /**
  47263. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  47264. */
  47265. nativeVertexBuffer?: any;
  47266. }
  47267. /** @hidden */
  47268. class NativeTexture extends InternalTexture {
  47269. getInternalTexture(): InternalTexture;
  47270. getViewCount(): number;
  47271. }
  47272. /** @hidden */
  47273. export class NativeEngine extends Engine {
  47274. private readonly _native;
  47275. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  47276. private readonly INVALID_HANDLE;
  47277. getHardwareScalingLevel(): number;
  47278. constructor();
  47279. /**
  47280. * Can be used to override the current requestAnimationFrame requester.
  47281. * @hidden
  47282. */
  47283. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  47284. /**
  47285. * Override default engine behavior.
  47286. * @param color
  47287. * @param backBuffer
  47288. * @param depth
  47289. * @param stencil
  47290. */
  47291. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  47292. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  47293. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  47294. createVertexBuffer(data: DataArray): NativeDataBuffer;
  47295. recordVertexArrayObject(vertexBuffers: {
  47296. [key: string]: VertexBuffer;
  47297. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  47298. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  47299. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  47300. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  47301. /**
  47302. * Draw a list of indexed primitives
  47303. * @param fillMode defines the primitive to use
  47304. * @param indexStart defines the starting index
  47305. * @param indexCount defines the number of index to draw
  47306. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  47307. */
  47308. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  47309. /**
  47310. * Draw a list of unindexed primitives
  47311. * @param fillMode defines the primitive to use
  47312. * @param verticesStart defines the index of first vertex to draw
  47313. * @param verticesCount defines the count of vertices to draw
  47314. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  47315. */
  47316. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  47317. createPipelineContext(): IPipelineContext;
  47318. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  47319. /** @hidden */
  47320. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  47321. /** @hidden */
  47322. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  47323. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  47324. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  47325. protected _setProgram(program: WebGLProgram): void;
  47326. _releaseEffect(effect: Effect): void;
  47327. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  47328. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  47329. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  47330. bindSamplers(effect: Effect): void;
  47331. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  47332. getRenderWidth(useScreen?: boolean): number;
  47333. getRenderHeight(useScreen?: boolean): number;
  47334. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  47335. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  47336. /**
  47337. * Set the z offset to apply to current rendering
  47338. * @param value defines the offset to apply
  47339. */
  47340. setZOffset(value: number): void;
  47341. /**
  47342. * Gets the current value of the zOffset
  47343. * @returns the current zOffset state
  47344. */
  47345. getZOffset(): number;
  47346. /**
  47347. * Enable or disable depth buffering
  47348. * @param enable defines the state to set
  47349. */
  47350. setDepthBuffer(enable: boolean): void;
  47351. /**
  47352. * Gets a boolean indicating if depth writing is enabled
  47353. * @returns the current depth writing state
  47354. */
  47355. getDepthWrite(): boolean;
  47356. /**
  47357. * Enable or disable depth writing
  47358. * @param enable defines the state to set
  47359. */
  47360. setDepthWrite(enable: boolean): void;
  47361. /**
  47362. * Enable or disable color writing
  47363. * @param enable defines the state to set
  47364. */
  47365. setColorWrite(enable: boolean): void;
  47366. /**
  47367. * Gets a boolean indicating if color writing is enabled
  47368. * @returns the current color writing state
  47369. */
  47370. getColorWrite(): boolean;
  47371. /**
  47372. * Sets alpha constants used by some alpha blending modes
  47373. * @param r defines the red component
  47374. * @param g defines the green component
  47375. * @param b defines the blue component
  47376. * @param a defines the alpha component
  47377. */
  47378. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  47379. /**
  47380. * Sets the current alpha mode
  47381. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  47382. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  47383. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  47384. */
  47385. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  47386. /**
  47387. * Gets the current alpha mode
  47388. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  47389. * @returns the current alpha mode
  47390. */
  47391. getAlphaMode(): number;
  47392. setInt(uniform: WebGLUniformLocation, int: number): void;
  47393. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  47394. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  47395. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  47396. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  47397. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  47398. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  47399. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  47400. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  47401. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  47402. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  47403. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  47404. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  47405. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  47406. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  47407. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  47408. setFloat(uniform: WebGLUniformLocation, value: number): void;
  47409. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  47410. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  47411. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  47412. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  47413. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  47414. wipeCaches(bruteForce?: boolean): void;
  47415. _createTexture(): WebGLTexture;
  47416. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  47417. /**
  47418. * Usually called from BABYLON.Texture.ts.
  47419. * Passed information to create a WebGLTexture
  47420. * @param urlArg defines a value which contains one of the following:
  47421. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  47422. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  47423. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  47424. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  47425. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  47426. * @param scene needed for loading to the correct scene
  47427. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  47428. * @param onLoad optional callback to be called upon successful completion
  47429. * @param onError optional callback to be called upon failure
  47430. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  47431. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  47432. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  47433. * @param forcedExtension defines the extension to use to pick the right loader
  47434. * @returns a InternalTexture for assignment back into BABYLON.Texture
  47435. */
  47436. 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;
  47437. /**
  47438. * Creates a cube texture
  47439. * @param rootUrl defines the url where the files to load is located
  47440. * @param scene defines the current scene
  47441. * @param files defines the list of files to load (1 per face)
  47442. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  47443. * @param onLoad defines an optional callback raised when the texture is loaded
  47444. * @param onError defines an optional callback raised if there is an issue to load the texture
  47445. * @param format defines the format of the data
  47446. * @param forcedExtension defines the extension to use to pick the right loader
  47447. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  47448. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  47449. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  47450. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  47451. * @returns the cube texture as an InternalTexture
  47452. */
  47453. 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;
  47454. private _getSamplingFilter;
  47455. private static _GetNativeTextureFormat;
  47456. createRenderTargetTexture(size: number | {
  47457. width: number;
  47458. height: number;
  47459. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  47460. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  47461. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  47462. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  47463. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  47464. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  47465. /**
  47466. * Updates a dynamic vertex buffer.
  47467. * @param vertexBuffer the vertex buffer to update
  47468. * @param data the data used to update the vertex buffer
  47469. * @param byteOffset the byte offset of the data (optional)
  47470. * @param byteLength the byte length of the data (optional)
  47471. */
  47472. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  47473. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  47474. private _updateAnisotropicLevel;
  47475. private _getAddressMode;
  47476. /** @hidden */
  47477. _bindTexture(channel: number, texture: InternalTexture): void;
  47478. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  47479. releaseEffects(): void;
  47480. /** @hidden */
  47481. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47482. /** @hidden */
  47483. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47484. /** @hidden */
  47485. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47486. /** @hidden */
  47487. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  47488. }
  47489. }
  47490. declare module "babylonjs/Engines/index" {
  47491. export * from "babylonjs/Engines/constants";
  47492. export * from "babylonjs/Engines/engineCapabilities";
  47493. export * from "babylonjs/Engines/instancingAttributeInfo";
  47494. export * from "babylonjs/Engines/thinEngine";
  47495. export * from "babylonjs/Engines/engine";
  47496. export * from "babylonjs/Engines/engineStore";
  47497. export * from "babylonjs/Engines/nullEngine";
  47498. export * from "babylonjs/Engines/Extensions/index";
  47499. export * from "babylonjs/Engines/IPipelineContext";
  47500. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  47501. export * from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  47502. export * from "babylonjs/Engines/nativeEngine";
  47503. }
  47504. declare module "babylonjs/Events/clipboardEvents" {
  47505. /**
  47506. * Gather the list of clipboard event types as constants.
  47507. */
  47508. export class ClipboardEventTypes {
  47509. /**
  47510. * The clipboard event is fired when a copy command is active (pressed).
  47511. */
  47512. static readonly COPY: number;
  47513. /**
  47514. * The clipboard event is fired when a cut command is active (pressed).
  47515. */
  47516. static readonly CUT: number;
  47517. /**
  47518. * The clipboard event is fired when a paste command is active (pressed).
  47519. */
  47520. static readonly PASTE: number;
  47521. }
  47522. /**
  47523. * This class is used to store clipboard related info for the onClipboardObservable event.
  47524. */
  47525. export class ClipboardInfo {
  47526. /**
  47527. * Defines the type of event (BABYLON.ClipboardEventTypes)
  47528. */
  47529. type: number;
  47530. /**
  47531. * Defines the related dom event
  47532. */
  47533. event: ClipboardEvent;
  47534. /**
  47535. *Creates an instance of ClipboardInfo.
  47536. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  47537. * @param event Defines the related dom event
  47538. */
  47539. constructor(
  47540. /**
  47541. * Defines the type of event (BABYLON.ClipboardEventTypes)
  47542. */
  47543. type: number,
  47544. /**
  47545. * Defines the related dom event
  47546. */
  47547. event: ClipboardEvent);
  47548. /**
  47549. * Get the clipboard event's type from the keycode.
  47550. * @param keyCode Defines the keyCode for the current keyboard event.
  47551. * @return {number}
  47552. */
  47553. static GetTypeFromCharacter(keyCode: number): number;
  47554. }
  47555. }
  47556. declare module "babylonjs/Events/index" {
  47557. export * from "babylonjs/Events/keyboardEvents";
  47558. export * from "babylonjs/Events/pointerEvents";
  47559. export * from "babylonjs/Events/clipboardEvents";
  47560. }
  47561. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  47562. import { Scene } from "babylonjs/scene";
  47563. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47564. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  47565. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  47566. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  47567. /**
  47568. * Google Daydream controller
  47569. */
  47570. export class DaydreamController extends WebVRController {
  47571. /**
  47572. * Base Url for the controller model.
  47573. */
  47574. static MODEL_BASE_URL: string;
  47575. /**
  47576. * File name for the controller model.
  47577. */
  47578. static MODEL_FILENAME: string;
  47579. /**
  47580. * Gamepad Id prefix used to identify Daydream Controller.
  47581. */
  47582. static readonly GAMEPAD_ID_PREFIX: string;
  47583. /**
  47584. * Creates a new DaydreamController from a gamepad
  47585. * @param vrGamepad the gamepad that the controller should be created from
  47586. */
  47587. constructor(vrGamepad: any);
  47588. /**
  47589. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  47590. * @param scene scene in which to add meshes
  47591. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  47592. */
  47593. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  47594. /**
  47595. * Called once for each button that changed state since the last frame
  47596. * @param buttonIdx Which button index changed
  47597. * @param state New state of the button
  47598. * @param changes Which properties on the state changed since last frame
  47599. */
  47600. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  47601. }
  47602. }
  47603. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  47604. import { Scene } from "babylonjs/scene";
  47605. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47606. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  47607. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  47608. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  47609. /**
  47610. * Gear VR Controller
  47611. */
  47612. export class GearVRController extends WebVRController {
  47613. /**
  47614. * Base Url for the controller model.
  47615. */
  47616. static MODEL_BASE_URL: string;
  47617. /**
  47618. * File name for the controller model.
  47619. */
  47620. static MODEL_FILENAME: string;
  47621. /**
  47622. * Gamepad Id prefix used to identify this controller.
  47623. */
  47624. static readonly GAMEPAD_ID_PREFIX: string;
  47625. private readonly _buttonIndexToObservableNameMap;
  47626. /**
  47627. * Creates a new GearVRController from a gamepad
  47628. * @param vrGamepad the gamepad that the controller should be created from
  47629. */
  47630. constructor(vrGamepad: any);
  47631. /**
  47632. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  47633. * @param scene scene in which to add meshes
  47634. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  47635. */
  47636. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  47637. /**
  47638. * Called once for each button that changed state since the last frame
  47639. * @param buttonIdx Which button index changed
  47640. * @param state New state of the button
  47641. * @param changes Which properties on the state changed since last frame
  47642. */
  47643. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  47644. }
  47645. }
  47646. declare module "babylonjs/Gamepads/Controllers/index" {
  47647. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  47648. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  47649. export * from "babylonjs/Gamepads/Controllers/genericController";
  47650. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  47651. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  47652. export * from "babylonjs/Gamepads/Controllers/viveController";
  47653. export * from "babylonjs/Gamepads/Controllers/webVRController";
  47654. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  47655. }
  47656. declare module "babylonjs/Gamepads/index" {
  47657. export * from "babylonjs/Gamepads/Controllers/index";
  47658. export * from "babylonjs/Gamepads/gamepad";
  47659. export * from "babylonjs/Gamepads/gamepadManager";
  47660. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  47661. export * from "babylonjs/Gamepads/xboxGamepad";
  47662. export * from "babylonjs/Gamepads/dualShockGamepad";
  47663. }
  47664. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  47665. import { Scene } from "babylonjs/scene";
  47666. import { Vector4 } from "babylonjs/Maths/math.vector";
  47667. import { Color4 } from "babylonjs/Maths/math.color";
  47668. import { Mesh } from "babylonjs/Meshes/mesh";
  47669. import { Nullable } from "babylonjs/types";
  47670. /**
  47671. * Class containing static functions to help procedurally build meshes
  47672. */
  47673. export class PolyhedronBuilder {
  47674. /**
  47675. * Creates a polyhedron mesh
  47676. * * 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
  47677. * * The parameter `size` (positive float, default 1) sets the polygon size
  47678. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  47679. * * 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`
  47680. * * 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
  47681. * * 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)`)
  47682. * * 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
  47683. * * 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
  47684. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47685. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  47686. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47687. * @param name defines the name of the mesh
  47688. * @param options defines the options used to create the mesh
  47689. * @param scene defines the hosting scene
  47690. * @returns the polyhedron mesh
  47691. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  47692. */
  47693. static CreatePolyhedron(name: string, options: {
  47694. type?: number;
  47695. size?: number;
  47696. sizeX?: number;
  47697. sizeY?: number;
  47698. sizeZ?: number;
  47699. custom?: any;
  47700. faceUV?: Vector4[];
  47701. faceColors?: Color4[];
  47702. flat?: boolean;
  47703. updatable?: boolean;
  47704. sideOrientation?: number;
  47705. frontUVs?: Vector4;
  47706. backUVs?: Vector4;
  47707. }, scene?: Nullable<Scene>): Mesh;
  47708. }
  47709. }
  47710. declare module "babylonjs/Gizmos/scaleGizmo" {
  47711. import { Observable } from "babylonjs/Misc/observable";
  47712. import { Nullable } from "babylonjs/types";
  47713. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47714. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47715. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  47716. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47717. /**
  47718. * Gizmo that enables scaling a mesh along 3 axis
  47719. */
  47720. export class ScaleGizmo extends Gizmo {
  47721. /**
  47722. * Internal gizmo used for interactions on the x axis
  47723. */
  47724. xGizmo: AxisScaleGizmo;
  47725. /**
  47726. * Internal gizmo used for interactions on the y axis
  47727. */
  47728. yGizmo: AxisScaleGizmo;
  47729. /**
  47730. * Internal gizmo used for interactions on the z axis
  47731. */
  47732. zGizmo: AxisScaleGizmo;
  47733. /**
  47734. * Internal gizmo used to scale all axis equally
  47735. */
  47736. uniformScaleGizmo: AxisScaleGizmo;
  47737. private _meshAttached;
  47738. private _updateGizmoRotationToMatchAttachedMesh;
  47739. private _snapDistance;
  47740. private _scaleRatio;
  47741. private _uniformScalingMesh;
  47742. private _octahedron;
  47743. private _sensitivity;
  47744. /** Fires an event when any of it's sub gizmos are dragged */
  47745. onDragStartObservable: Observable<unknown>;
  47746. /** Fires an event when any of it's sub gizmos are released from dragging */
  47747. onDragEndObservable: Observable<unknown>;
  47748. attachedMesh: Nullable<AbstractMesh>;
  47749. /**
  47750. * Creates a ScaleGizmo
  47751. * @param gizmoLayer The utility layer the gizmo will be added to
  47752. */
  47753. constructor(gizmoLayer?: UtilityLayerRenderer);
  47754. updateGizmoRotationToMatchAttachedMesh: boolean;
  47755. /**
  47756. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  47757. */
  47758. snapDistance: number;
  47759. /**
  47760. * Ratio for the scale of the gizmo (Default: 1)
  47761. */
  47762. scaleRatio: number;
  47763. /**
  47764. * Sensitivity factor for dragging (Default: 1)
  47765. */
  47766. sensitivity: number;
  47767. /**
  47768. * Disposes of the gizmo
  47769. */
  47770. dispose(): void;
  47771. }
  47772. }
  47773. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  47774. import { Observable } from "babylonjs/Misc/observable";
  47775. import { Nullable } from "babylonjs/types";
  47776. import { Vector3 } from "babylonjs/Maths/math.vector";
  47777. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47778. import { Mesh } from "babylonjs/Meshes/mesh";
  47779. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  47780. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47781. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47782. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  47783. import { Color3 } from "babylonjs/Maths/math.color";
  47784. /**
  47785. * Single axis scale gizmo
  47786. */
  47787. export class AxisScaleGizmo extends Gizmo {
  47788. /**
  47789. * Drag behavior responsible for the gizmos dragging interactions
  47790. */
  47791. dragBehavior: PointerDragBehavior;
  47792. private _pointerObserver;
  47793. /**
  47794. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  47795. */
  47796. snapDistance: number;
  47797. /**
  47798. * Event that fires each time the gizmo snaps to a new location.
  47799. * * snapDistance is the the change in distance
  47800. */
  47801. onSnapObservable: Observable<{
  47802. snapDistance: number;
  47803. }>;
  47804. /**
  47805. * If the scaling operation should be done on all axis (default: false)
  47806. */
  47807. uniformScaling: boolean;
  47808. /**
  47809. * Custom sensitivity value for the drag strength
  47810. */
  47811. sensitivity: number;
  47812. private _isEnabled;
  47813. private _parent;
  47814. private _arrow;
  47815. private _coloredMaterial;
  47816. private _hoverMaterial;
  47817. /**
  47818. * Creates an AxisScaleGizmo
  47819. * @param gizmoLayer The utility layer the gizmo will be added to
  47820. * @param dragAxis The axis which the gizmo will be able to scale on
  47821. * @param color The color of the gizmo
  47822. */
  47823. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  47824. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  47825. /**
  47826. * If the gizmo is enabled
  47827. */
  47828. isEnabled: boolean;
  47829. /**
  47830. * Disposes of the gizmo
  47831. */
  47832. dispose(): void;
  47833. /**
  47834. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  47835. * @param mesh The mesh to replace the default mesh of the gizmo
  47836. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  47837. */
  47838. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  47839. }
  47840. }
  47841. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  47842. import { Observable } from "babylonjs/Misc/observable";
  47843. import { Nullable } from "babylonjs/types";
  47844. import { Vector3 } from "babylonjs/Maths/math.vector";
  47845. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47846. import { Mesh } from "babylonjs/Meshes/mesh";
  47847. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47848. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47849. import { Color3 } from "babylonjs/Maths/math.color";
  47850. import "babylonjs/Meshes/Builders/boxBuilder";
  47851. /**
  47852. * Bounding box gizmo
  47853. */
  47854. export class BoundingBoxGizmo extends Gizmo {
  47855. private _lineBoundingBox;
  47856. private _rotateSpheresParent;
  47857. private _scaleBoxesParent;
  47858. private _boundingDimensions;
  47859. private _renderObserver;
  47860. private _pointerObserver;
  47861. private _scaleDragSpeed;
  47862. private _tmpQuaternion;
  47863. private _tmpVector;
  47864. private _tmpRotationMatrix;
  47865. /**
  47866. * 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)
  47867. */
  47868. ignoreChildren: boolean;
  47869. /**
  47870. * 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)
  47871. */
  47872. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  47873. /**
  47874. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  47875. */
  47876. rotationSphereSize: number;
  47877. /**
  47878. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  47879. */
  47880. scaleBoxSize: number;
  47881. /**
  47882. * 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)
  47883. */
  47884. fixedDragMeshScreenSize: boolean;
  47885. /**
  47886. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  47887. */
  47888. fixedDragMeshScreenSizeDistanceFactor: number;
  47889. /**
  47890. * Fired when a rotation sphere or scale box is dragged
  47891. */
  47892. onDragStartObservable: Observable<{}>;
  47893. /**
  47894. * Fired when a scale box is dragged
  47895. */
  47896. onScaleBoxDragObservable: Observable<{}>;
  47897. /**
  47898. * Fired when a scale box drag is ended
  47899. */
  47900. onScaleBoxDragEndObservable: Observable<{}>;
  47901. /**
  47902. * Fired when a rotation sphere is dragged
  47903. */
  47904. onRotationSphereDragObservable: Observable<{}>;
  47905. /**
  47906. * Fired when a rotation sphere drag is ended
  47907. */
  47908. onRotationSphereDragEndObservable: Observable<{}>;
  47909. /**
  47910. * 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)
  47911. */
  47912. scalePivot: Nullable<Vector3>;
  47913. /**
  47914. * Mesh used as a pivot to rotate the attached mesh
  47915. */
  47916. private _anchorMesh;
  47917. private _existingMeshScale;
  47918. private _dragMesh;
  47919. private pointerDragBehavior;
  47920. private coloredMaterial;
  47921. private hoverColoredMaterial;
  47922. /**
  47923. * Sets the color of the bounding box gizmo
  47924. * @param color the color to set
  47925. */
  47926. setColor(color: Color3): void;
  47927. /**
  47928. * Creates an BoundingBoxGizmo
  47929. * @param gizmoLayer The utility layer the gizmo will be added to
  47930. * @param color The color of the gizmo
  47931. */
  47932. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  47933. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  47934. private _selectNode;
  47935. /**
  47936. * Updates the bounding box information for the Gizmo
  47937. */
  47938. updateBoundingBox(): void;
  47939. private _updateRotationSpheres;
  47940. private _updateScaleBoxes;
  47941. /**
  47942. * Enables rotation on the specified axis and disables rotation on the others
  47943. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  47944. */
  47945. setEnabledRotationAxis(axis: string): void;
  47946. /**
  47947. * Enables/disables scaling
  47948. * @param enable if scaling should be enabled
  47949. */
  47950. setEnabledScaling(enable: boolean): void;
  47951. private _updateDummy;
  47952. /**
  47953. * Enables a pointer drag behavior on the bounding box of the gizmo
  47954. */
  47955. enableDragBehavior(): void;
  47956. /**
  47957. * Disposes of the gizmo
  47958. */
  47959. dispose(): void;
  47960. /**
  47961. * 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)
  47962. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  47963. * @returns the bounding box mesh with the passed in mesh as a child
  47964. */
  47965. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  47966. /**
  47967. * CustomMeshes are not supported by this gizmo
  47968. * @param mesh The mesh to replace the default mesh of the gizmo
  47969. */
  47970. setCustomMesh(mesh: Mesh): void;
  47971. }
  47972. }
  47973. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  47974. import { Observable } from "babylonjs/Misc/observable";
  47975. import { Nullable } from "babylonjs/types";
  47976. import { Vector3 } from "babylonjs/Maths/math.vector";
  47977. import { Color3 } from "babylonjs/Maths/math.color";
  47978. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47979. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  47980. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47981. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47982. import "babylonjs/Meshes/Builders/linesBuilder";
  47983. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  47984. /**
  47985. * Single plane rotation gizmo
  47986. */
  47987. export class PlaneRotationGizmo extends Gizmo {
  47988. /**
  47989. * Drag behavior responsible for the gizmos dragging interactions
  47990. */
  47991. dragBehavior: PointerDragBehavior;
  47992. private _pointerObserver;
  47993. /**
  47994. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  47995. */
  47996. snapDistance: number;
  47997. /**
  47998. * Event that fires each time the gizmo snaps to a new location.
  47999. * * snapDistance is the the change in distance
  48000. */
  48001. onSnapObservable: Observable<{
  48002. snapDistance: number;
  48003. }>;
  48004. private _isEnabled;
  48005. private _parent;
  48006. /**
  48007. * Creates a PlaneRotationGizmo
  48008. * @param gizmoLayer The utility layer the gizmo will be added to
  48009. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  48010. * @param color The color of the gizmo
  48011. * @param tessellation Amount of tessellation to be used when creating rotation circles
  48012. * @param useEulerRotation Use and update Euler angle instead of quaternion
  48013. */
  48014. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  48015. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  48016. /**
  48017. * If the gizmo is enabled
  48018. */
  48019. isEnabled: boolean;
  48020. /**
  48021. * Disposes of the gizmo
  48022. */
  48023. dispose(): void;
  48024. }
  48025. }
  48026. declare module "babylonjs/Gizmos/rotationGizmo" {
  48027. import { Observable } from "babylonjs/Misc/observable";
  48028. import { Nullable } from "babylonjs/types";
  48029. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48030. import { Mesh } from "babylonjs/Meshes/mesh";
  48031. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  48032. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  48033. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  48034. /**
  48035. * Gizmo that enables rotating a mesh along 3 axis
  48036. */
  48037. export class RotationGizmo extends Gizmo {
  48038. /**
  48039. * Internal gizmo used for interactions on the x axis
  48040. */
  48041. xGizmo: PlaneRotationGizmo;
  48042. /**
  48043. * Internal gizmo used for interactions on the y axis
  48044. */
  48045. yGizmo: PlaneRotationGizmo;
  48046. /**
  48047. * Internal gizmo used for interactions on the z axis
  48048. */
  48049. zGizmo: PlaneRotationGizmo;
  48050. /** Fires an event when any of it's sub gizmos are dragged */
  48051. onDragStartObservable: Observable<unknown>;
  48052. /** Fires an event when any of it's sub gizmos are released from dragging */
  48053. onDragEndObservable: Observable<unknown>;
  48054. private _meshAttached;
  48055. attachedMesh: Nullable<AbstractMesh>;
  48056. /**
  48057. * Creates a RotationGizmo
  48058. * @param gizmoLayer The utility layer the gizmo will be added to
  48059. * @param tessellation Amount of tessellation to be used when creating rotation circles
  48060. * @param useEulerRotation Use and update Euler angle instead of quaternion
  48061. */
  48062. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  48063. updateGizmoRotationToMatchAttachedMesh: boolean;
  48064. /**
  48065. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  48066. */
  48067. snapDistance: number;
  48068. /**
  48069. * Ratio for the scale of the gizmo (Default: 1)
  48070. */
  48071. scaleRatio: number;
  48072. /**
  48073. * Disposes of the gizmo
  48074. */
  48075. dispose(): void;
  48076. /**
  48077. * CustomMeshes are not supported by this gizmo
  48078. * @param mesh The mesh to replace the default mesh of the gizmo
  48079. */
  48080. setCustomMesh(mesh: Mesh): void;
  48081. }
  48082. }
  48083. declare module "babylonjs/Gizmos/gizmoManager" {
  48084. import { Observable } from "babylonjs/Misc/observable";
  48085. import { Nullable } from "babylonjs/types";
  48086. import { Scene, IDisposable } from "babylonjs/scene";
  48087. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48088. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  48089. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  48090. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  48091. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  48092. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  48093. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  48094. /**
  48095. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  48096. */
  48097. export class GizmoManager implements IDisposable {
  48098. private scene;
  48099. /**
  48100. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  48101. */
  48102. gizmos: {
  48103. positionGizmo: Nullable<PositionGizmo>;
  48104. rotationGizmo: Nullable<RotationGizmo>;
  48105. scaleGizmo: Nullable<ScaleGizmo>;
  48106. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  48107. };
  48108. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  48109. clearGizmoOnEmptyPointerEvent: boolean;
  48110. /** Fires an event when the manager is attached to a mesh */
  48111. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  48112. private _gizmosEnabled;
  48113. private _pointerObserver;
  48114. private _attachedMesh;
  48115. private _boundingBoxColor;
  48116. private _defaultUtilityLayer;
  48117. private _defaultKeepDepthUtilityLayer;
  48118. /**
  48119. * When bounding box gizmo is enabled, this can be used to track drag/end events
  48120. */
  48121. boundingBoxDragBehavior: SixDofDragBehavior;
  48122. /**
  48123. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  48124. */
  48125. attachableMeshes: Nullable<Array<AbstractMesh>>;
  48126. /**
  48127. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  48128. */
  48129. usePointerToAttachGizmos: boolean;
  48130. /**
  48131. * Utility layer that the bounding box gizmo belongs to
  48132. */
  48133. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  48134. /**
  48135. * Utility layer that all gizmos besides bounding box belong to
  48136. */
  48137. readonly utilityLayer: UtilityLayerRenderer;
  48138. /**
  48139. * Instatiates a gizmo manager
  48140. * @param scene the scene to overlay the gizmos on top of
  48141. */
  48142. constructor(scene: Scene);
  48143. /**
  48144. * Attaches a set of gizmos to the specified mesh
  48145. * @param mesh The mesh the gizmo's should be attached to
  48146. */
  48147. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  48148. /**
  48149. * If the position gizmo is enabled
  48150. */
  48151. positionGizmoEnabled: boolean;
  48152. /**
  48153. * If the rotation gizmo is enabled
  48154. */
  48155. rotationGizmoEnabled: boolean;
  48156. /**
  48157. * If the scale gizmo is enabled
  48158. */
  48159. scaleGizmoEnabled: boolean;
  48160. /**
  48161. * If the boundingBox gizmo is enabled
  48162. */
  48163. boundingBoxGizmoEnabled: boolean;
  48164. /**
  48165. * Disposes of the gizmo manager
  48166. */
  48167. dispose(): void;
  48168. }
  48169. }
  48170. declare module "babylonjs/Lights/directionalLight" {
  48171. import { Camera } from "babylonjs/Cameras/camera";
  48172. import { Scene } from "babylonjs/scene";
  48173. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  48174. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48175. import { Light } from "babylonjs/Lights/light";
  48176. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  48177. import { Effect } from "babylonjs/Materials/effect";
  48178. /**
  48179. * A directional light is defined by a direction (what a surprise!).
  48180. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  48181. * 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.
  48182. * Documentation: https://doc.babylonjs.com/babylon101/lights
  48183. */
  48184. export class DirectionalLight extends ShadowLight {
  48185. private _shadowFrustumSize;
  48186. /**
  48187. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  48188. */
  48189. /**
  48190. * Specifies a fix frustum size for the shadow generation.
  48191. */
  48192. shadowFrustumSize: number;
  48193. private _shadowOrthoScale;
  48194. /**
  48195. * Gets the shadow projection scale against the optimal computed one.
  48196. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  48197. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  48198. */
  48199. /**
  48200. * Sets the shadow projection scale against the optimal computed one.
  48201. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  48202. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  48203. */
  48204. shadowOrthoScale: number;
  48205. /**
  48206. * Automatically compute the projection matrix to best fit (including all the casters)
  48207. * on each frame.
  48208. */
  48209. autoUpdateExtends: boolean;
  48210. private _orthoLeft;
  48211. private _orthoRight;
  48212. private _orthoTop;
  48213. private _orthoBottom;
  48214. /**
  48215. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  48216. * The directional light is emitted from everywhere in the given direction.
  48217. * It can cast shadows.
  48218. * Documentation : https://doc.babylonjs.com/babylon101/lights
  48219. * @param name The friendly name of the light
  48220. * @param direction The direction of the light
  48221. * @param scene The scene the light belongs to
  48222. */
  48223. constructor(name: string, direction: Vector3, scene: Scene);
  48224. /**
  48225. * Returns the string "DirectionalLight".
  48226. * @return The class name
  48227. */
  48228. getClassName(): string;
  48229. /**
  48230. * Returns the integer 1.
  48231. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  48232. */
  48233. getTypeID(): number;
  48234. /**
  48235. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  48236. * Returns the DirectionalLight Shadow projection matrix.
  48237. */
  48238. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  48239. /**
  48240. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  48241. * Returns the DirectionalLight Shadow projection matrix.
  48242. */
  48243. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  48244. /**
  48245. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  48246. * Returns the DirectionalLight Shadow projection matrix.
  48247. */
  48248. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  48249. protected _buildUniformLayout(): void;
  48250. /**
  48251. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  48252. * @param effect The effect to update
  48253. * @param lightIndex The index of the light in the effect to update
  48254. * @returns The directional light
  48255. */
  48256. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  48257. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  48258. /**
  48259. * Gets the minZ used for shadow according to both the scene and the light.
  48260. *
  48261. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  48262. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  48263. * @param activeCamera The camera we are returning the min for
  48264. * @returns the depth min z
  48265. */
  48266. getDepthMinZ(activeCamera: Camera): number;
  48267. /**
  48268. * Gets the maxZ used for shadow according to both the scene and the light.
  48269. *
  48270. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  48271. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  48272. * @param activeCamera The camera we are returning the max for
  48273. * @returns the depth max z
  48274. */
  48275. getDepthMaxZ(activeCamera: Camera): number;
  48276. /**
  48277. * Prepares the list of defines specific to the light type.
  48278. * @param defines the list of defines
  48279. * @param lightIndex defines the index of the light for the effect
  48280. */
  48281. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  48282. }
  48283. }
  48284. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  48285. import { Mesh } from "babylonjs/Meshes/mesh";
  48286. /**
  48287. * Class containing static functions to help procedurally build meshes
  48288. */
  48289. export class HemisphereBuilder {
  48290. /**
  48291. * Creates a hemisphere mesh
  48292. * @param name defines the name of the mesh
  48293. * @param options defines the options used to create the mesh
  48294. * @param scene defines the hosting scene
  48295. * @returns the hemisphere mesh
  48296. */
  48297. static CreateHemisphere(name: string, options: {
  48298. segments?: number;
  48299. diameter?: number;
  48300. sideOrientation?: number;
  48301. }, scene: any): Mesh;
  48302. }
  48303. }
  48304. declare module "babylonjs/Lights/spotLight" {
  48305. import { Nullable } from "babylonjs/types";
  48306. import { Scene } from "babylonjs/scene";
  48307. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  48308. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48309. import { Effect } from "babylonjs/Materials/effect";
  48310. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48311. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  48312. /**
  48313. * A spot light is defined by a position, a direction, an angle, and an exponent.
  48314. * These values define a cone of light starting from the position, emitting toward the direction.
  48315. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  48316. * and the exponent defines the speed of the decay of the light with distance (reach).
  48317. * Documentation: https://doc.babylonjs.com/babylon101/lights
  48318. */
  48319. export class SpotLight extends ShadowLight {
  48320. private _angle;
  48321. private _innerAngle;
  48322. private _cosHalfAngle;
  48323. private _lightAngleScale;
  48324. private _lightAngleOffset;
  48325. /**
  48326. * Gets the cone angle of the spot light in Radians.
  48327. */
  48328. /**
  48329. * Sets the cone angle of the spot light in Radians.
  48330. */
  48331. angle: number;
  48332. /**
  48333. * Only used in gltf falloff mode, this defines the angle where
  48334. * the directional falloff will start before cutting at angle which could be seen
  48335. * as outer angle.
  48336. */
  48337. /**
  48338. * Only used in gltf falloff mode, this defines the angle where
  48339. * the directional falloff will start before cutting at angle which could be seen
  48340. * as outer angle.
  48341. */
  48342. innerAngle: number;
  48343. private _shadowAngleScale;
  48344. /**
  48345. * Allows scaling the angle of the light for shadow generation only.
  48346. */
  48347. /**
  48348. * Allows scaling the angle of the light for shadow generation only.
  48349. */
  48350. shadowAngleScale: number;
  48351. /**
  48352. * The light decay speed with the distance from the emission spot.
  48353. */
  48354. exponent: number;
  48355. private _projectionTextureMatrix;
  48356. /**
  48357. * Allows reading the projecton texture
  48358. */
  48359. readonly projectionTextureMatrix: Matrix;
  48360. protected _projectionTextureLightNear: number;
  48361. /**
  48362. * Gets the near clip of the Spotlight for texture projection.
  48363. */
  48364. /**
  48365. * Sets the near clip of the Spotlight for texture projection.
  48366. */
  48367. projectionTextureLightNear: number;
  48368. protected _projectionTextureLightFar: number;
  48369. /**
  48370. * Gets the far clip of the Spotlight for texture projection.
  48371. */
  48372. /**
  48373. * Sets the far clip of the Spotlight for texture projection.
  48374. */
  48375. projectionTextureLightFar: number;
  48376. protected _projectionTextureUpDirection: Vector3;
  48377. /**
  48378. * Gets the Up vector of the Spotlight for texture projection.
  48379. */
  48380. /**
  48381. * Sets the Up vector of the Spotlight for texture projection.
  48382. */
  48383. projectionTextureUpDirection: Vector3;
  48384. private _projectionTexture;
  48385. /**
  48386. * Gets the projection texture of the light.
  48387. */
  48388. /**
  48389. * Sets the projection texture of the light.
  48390. */
  48391. projectionTexture: Nullable<BaseTexture>;
  48392. private _projectionTextureViewLightDirty;
  48393. private _projectionTextureProjectionLightDirty;
  48394. private _projectionTextureDirty;
  48395. private _projectionTextureViewTargetVector;
  48396. private _projectionTextureViewLightMatrix;
  48397. private _projectionTextureProjectionLightMatrix;
  48398. private _projectionTextureScalingMatrix;
  48399. /**
  48400. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  48401. * It can cast shadows.
  48402. * Documentation : https://doc.babylonjs.com/babylon101/lights
  48403. * @param name The light friendly name
  48404. * @param position The position of the spot light in the scene
  48405. * @param direction The direction of the light in the scene
  48406. * @param angle The cone angle of the light in Radians
  48407. * @param exponent The light decay speed with the distance from the emission spot
  48408. * @param scene The scene the lights belongs to
  48409. */
  48410. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  48411. /**
  48412. * Returns the string "SpotLight".
  48413. * @returns the class name
  48414. */
  48415. getClassName(): string;
  48416. /**
  48417. * Returns the integer 2.
  48418. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  48419. */
  48420. getTypeID(): number;
  48421. /**
  48422. * Overrides the direction setter to recompute the projection texture view light Matrix.
  48423. */
  48424. protected _setDirection(value: Vector3): void;
  48425. /**
  48426. * Overrides the position setter to recompute the projection texture view light Matrix.
  48427. */
  48428. protected _setPosition(value: Vector3): void;
  48429. /**
  48430. * 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.
  48431. * Returns the SpotLight.
  48432. */
  48433. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  48434. protected _computeProjectionTextureViewLightMatrix(): void;
  48435. protected _computeProjectionTextureProjectionLightMatrix(): void;
  48436. /**
  48437. * Main function for light texture projection matrix computing.
  48438. */
  48439. protected _computeProjectionTextureMatrix(): void;
  48440. protected _buildUniformLayout(): void;
  48441. private _computeAngleValues;
  48442. /**
  48443. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  48444. * @param effect The effect to update
  48445. * @param lightIndex The index of the light in the effect to update
  48446. * @returns The spot light
  48447. */
  48448. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  48449. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  48450. /**
  48451. * Disposes the light and the associated resources.
  48452. */
  48453. dispose(): void;
  48454. /**
  48455. * Prepares the list of defines specific to the light type.
  48456. * @param defines the list of defines
  48457. * @param lightIndex defines the index of the light for the effect
  48458. */
  48459. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  48460. }
  48461. }
  48462. declare module "babylonjs/Gizmos/lightGizmo" {
  48463. import { Nullable } from "babylonjs/types";
  48464. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  48465. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  48466. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  48467. import { Light } from "babylonjs/Lights/light";
  48468. /**
  48469. * Gizmo that enables viewing a light
  48470. */
  48471. export class LightGizmo extends Gizmo {
  48472. private _lightMesh;
  48473. private _material;
  48474. private _cachedPosition;
  48475. private _cachedForward;
  48476. private _attachedMeshParent;
  48477. /**
  48478. * Creates a LightGizmo
  48479. * @param gizmoLayer The utility layer the gizmo will be added to
  48480. */
  48481. constructor(gizmoLayer?: UtilityLayerRenderer);
  48482. private _light;
  48483. /**
  48484. * The light that the gizmo is attached to
  48485. */
  48486. light: Nullable<Light>;
  48487. /**
  48488. * Gets the material used to render the light gizmo
  48489. */
  48490. readonly material: StandardMaterial;
  48491. /**
  48492. * @hidden
  48493. * Updates the gizmo to match the attached mesh's position/rotation
  48494. */
  48495. protected _update(): void;
  48496. private static _Scale;
  48497. /**
  48498. * Creates the lines for a light mesh
  48499. */
  48500. private static _CreateLightLines;
  48501. /**
  48502. * Disposes of the light gizmo
  48503. */
  48504. dispose(): void;
  48505. private static _CreateHemisphericLightMesh;
  48506. private static _CreatePointLightMesh;
  48507. private static _CreateSpotLightMesh;
  48508. private static _CreateDirectionalLightMesh;
  48509. }
  48510. }
  48511. declare module "babylonjs/Gizmos/index" {
  48512. export * from "babylonjs/Gizmos/axisDragGizmo";
  48513. export * from "babylonjs/Gizmos/axisScaleGizmo";
  48514. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  48515. export * from "babylonjs/Gizmos/gizmo";
  48516. export * from "babylonjs/Gizmos/gizmoManager";
  48517. export * from "babylonjs/Gizmos/planeRotationGizmo";
  48518. export * from "babylonjs/Gizmos/positionGizmo";
  48519. export * from "babylonjs/Gizmos/rotationGizmo";
  48520. export * from "babylonjs/Gizmos/scaleGizmo";
  48521. export * from "babylonjs/Gizmos/lightGizmo";
  48522. export * from "babylonjs/Gizmos/planeDragGizmo";
  48523. }
  48524. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  48525. /** @hidden */
  48526. export var backgroundFragmentDeclaration: {
  48527. name: string;
  48528. shader: string;
  48529. };
  48530. }
  48531. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  48532. /** @hidden */
  48533. export var backgroundUboDeclaration: {
  48534. name: string;
  48535. shader: string;
  48536. };
  48537. }
  48538. declare module "babylonjs/Shaders/background.fragment" {
  48539. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  48540. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  48541. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  48542. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  48543. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  48544. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  48545. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  48546. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  48547. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  48548. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  48549. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  48550. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  48551. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  48552. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  48553. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  48554. /** @hidden */
  48555. export var backgroundPixelShader: {
  48556. name: string;
  48557. shader: string;
  48558. };
  48559. }
  48560. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  48561. /** @hidden */
  48562. export var backgroundVertexDeclaration: {
  48563. name: string;
  48564. shader: string;
  48565. };
  48566. }
  48567. declare module "babylonjs/Shaders/background.vertex" {
  48568. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  48569. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  48570. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  48571. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  48572. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  48573. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  48574. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  48575. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  48576. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  48577. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  48578. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  48579. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  48580. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  48581. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  48582. /** @hidden */
  48583. export var backgroundVertexShader: {
  48584. name: string;
  48585. shader: string;
  48586. };
  48587. }
  48588. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  48589. import { Nullable, int, float } from "babylonjs/types";
  48590. import { Scene } from "babylonjs/scene";
  48591. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  48592. import { SubMesh } from "babylonjs/Meshes/subMesh";
  48593. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48594. import { Mesh } from "babylonjs/Meshes/mesh";
  48595. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  48596. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  48597. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  48598. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48599. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  48600. import { Color3 } from "babylonjs/Maths/math.color";
  48601. import "babylonjs/Shaders/background.fragment";
  48602. import "babylonjs/Shaders/background.vertex";
  48603. /**
  48604. * Background material used to create an efficient environement around your scene.
  48605. */
  48606. export class BackgroundMaterial extends PushMaterial {
  48607. /**
  48608. * Standard reflectance value at parallel view angle.
  48609. */
  48610. static StandardReflectance0: number;
  48611. /**
  48612. * Standard reflectance value at grazing angle.
  48613. */
  48614. static StandardReflectance90: number;
  48615. protected _primaryColor: Color3;
  48616. /**
  48617. * Key light Color (multiply against the environement texture)
  48618. */
  48619. primaryColor: Color3;
  48620. protected __perceptualColor: Nullable<Color3>;
  48621. /**
  48622. * Experimental Internal Use Only.
  48623. *
  48624. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  48625. * This acts as a helper to set the primary color to a more "human friendly" value.
  48626. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  48627. * output color as close as possible from the chosen value.
  48628. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  48629. * part of lighting setup.)
  48630. */
  48631. _perceptualColor: Nullable<Color3>;
  48632. protected _primaryColorShadowLevel: float;
  48633. /**
  48634. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  48635. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  48636. */
  48637. primaryColorShadowLevel: float;
  48638. protected _primaryColorHighlightLevel: float;
  48639. /**
  48640. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  48641. * The primary color is used at the level chosen to define what the white area would look.
  48642. */
  48643. primaryColorHighlightLevel: float;
  48644. protected _reflectionTexture: Nullable<BaseTexture>;
  48645. /**
  48646. * Reflection Texture used in the material.
  48647. * Should be author in a specific way for the best result (refer to the documentation).
  48648. */
  48649. reflectionTexture: Nullable<BaseTexture>;
  48650. protected _reflectionBlur: float;
  48651. /**
  48652. * Reflection Texture level of blur.
  48653. *
  48654. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  48655. * texture twice.
  48656. */
  48657. reflectionBlur: float;
  48658. protected _diffuseTexture: Nullable<BaseTexture>;
  48659. /**
  48660. * Diffuse Texture used in the material.
  48661. * Should be author in a specific way for the best result (refer to the documentation).
  48662. */
  48663. diffuseTexture: Nullable<BaseTexture>;
  48664. protected _shadowLights: Nullable<IShadowLight[]>;
  48665. /**
  48666. * Specify the list of lights casting shadow on the material.
  48667. * All scene shadow lights will be included if null.
  48668. */
  48669. shadowLights: Nullable<IShadowLight[]>;
  48670. protected _shadowLevel: float;
  48671. /**
  48672. * Helps adjusting the shadow to a softer level if required.
  48673. * 0 means black shadows and 1 means no shadows.
  48674. */
  48675. shadowLevel: float;
  48676. protected _sceneCenter: Vector3;
  48677. /**
  48678. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  48679. * It is usually zero but might be interesting to modify according to your setup.
  48680. */
  48681. sceneCenter: Vector3;
  48682. protected _opacityFresnel: boolean;
  48683. /**
  48684. * This helps specifying that the material is falling off to the sky box at grazing angle.
  48685. * This helps ensuring a nice transition when the camera goes under the ground.
  48686. */
  48687. opacityFresnel: boolean;
  48688. protected _reflectionFresnel: boolean;
  48689. /**
  48690. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  48691. * This helps adding a mirror texture on the ground.
  48692. */
  48693. reflectionFresnel: boolean;
  48694. protected _reflectionFalloffDistance: number;
  48695. /**
  48696. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  48697. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  48698. */
  48699. reflectionFalloffDistance: number;
  48700. protected _reflectionAmount: number;
  48701. /**
  48702. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  48703. */
  48704. reflectionAmount: number;
  48705. protected _reflectionReflectance0: number;
  48706. /**
  48707. * This specifies the weight of the reflection at grazing angle.
  48708. */
  48709. reflectionReflectance0: number;
  48710. protected _reflectionReflectance90: number;
  48711. /**
  48712. * This specifies the weight of the reflection at a perpendicular point of view.
  48713. */
  48714. reflectionReflectance90: number;
  48715. /**
  48716. * Sets the reflection reflectance fresnel values according to the default standard
  48717. * empirically know to work well :-)
  48718. */
  48719. reflectionStandardFresnelWeight: number;
  48720. protected _useRGBColor: boolean;
  48721. /**
  48722. * Helps to directly use the maps channels instead of their level.
  48723. */
  48724. useRGBColor: boolean;
  48725. protected _enableNoise: boolean;
  48726. /**
  48727. * This helps reducing the banding effect that could occur on the background.
  48728. */
  48729. enableNoise: boolean;
  48730. /**
  48731. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  48732. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  48733. * Recommended to be keep at 1.0 except for special cases.
  48734. */
  48735. fovMultiplier: number;
  48736. private _fovMultiplier;
  48737. /**
  48738. * Enable the FOV adjustment feature controlled by fovMultiplier.
  48739. */
  48740. useEquirectangularFOV: boolean;
  48741. private _maxSimultaneousLights;
  48742. /**
  48743. * Number of Simultaneous lights allowed on the material.
  48744. */
  48745. maxSimultaneousLights: int;
  48746. /**
  48747. * Default configuration related to image processing available in the Background Material.
  48748. */
  48749. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  48750. /**
  48751. * Keep track of the image processing observer to allow dispose and replace.
  48752. */
  48753. private _imageProcessingObserver;
  48754. /**
  48755. * Attaches a new image processing configuration to the PBR Material.
  48756. * @param configuration (if null the scene configuration will be use)
  48757. */
  48758. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  48759. /**
  48760. * Gets the image processing configuration used either in this material.
  48761. */
  48762. /**
  48763. * Sets the Default image processing configuration used either in the this material.
  48764. *
  48765. * If sets to null, the scene one is in use.
  48766. */
  48767. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  48768. /**
  48769. * Gets wether the color curves effect is enabled.
  48770. */
  48771. /**
  48772. * Sets wether the color curves effect is enabled.
  48773. */
  48774. cameraColorCurvesEnabled: boolean;
  48775. /**
  48776. * Gets wether the color grading effect is enabled.
  48777. */
  48778. /**
  48779. * Gets wether the color grading effect is enabled.
  48780. */
  48781. cameraColorGradingEnabled: boolean;
  48782. /**
  48783. * Gets wether tonemapping is enabled or not.
  48784. */
  48785. /**
  48786. * Sets wether tonemapping is enabled or not
  48787. */
  48788. cameraToneMappingEnabled: boolean;
  48789. /**
  48790. * The camera exposure used on this material.
  48791. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  48792. * This corresponds to a photographic exposure.
  48793. */
  48794. /**
  48795. * The camera exposure used on this material.
  48796. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  48797. * This corresponds to a photographic exposure.
  48798. */
  48799. cameraExposure: float;
  48800. /**
  48801. * Gets The camera contrast used on this material.
  48802. */
  48803. /**
  48804. * Sets The camera contrast used on this material.
  48805. */
  48806. cameraContrast: float;
  48807. /**
  48808. * Gets the Color Grading 2D Lookup Texture.
  48809. */
  48810. /**
  48811. * Sets the Color Grading 2D Lookup Texture.
  48812. */
  48813. cameraColorGradingTexture: Nullable<BaseTexture>;
  48814. /**
  48815. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  48816. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  48817. * 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;
  48818. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  48819. */
  48820. /**
  48821. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  48822. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  48823. * 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;
  48824. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  48825. */
  48826. cameraColorCurves: Nullable<ColorCurves>;
  48827. /**
  48828. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  48829. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  48830. */
  48831. switchToBGR: boolean;
  48832. private _renderTargets;
  48833. private _reflectionControls;
  48834. private _white;
  48835. private _primaryShadowColor;
  48836. private _primaryHighlightColor;
  48837. /**
  48838. * Instantiates a Background Material in the given scene
  48839. * @param name The friendly name of the material
  48840. * @param scene The scene to add the material to
  48841. */
  48842. constructor(name: string, scene: Scene);
  48843. /**
  48844. * Gets a boolean indicating that current material needs to register RTT
  48845. */
  48846. readonly hasRenderTargetTextures: boolean;
  48847. /**
  48848. * The entire material has been created in order to prevent overdraw.
  48849. * @returns false
  48850. */
  48851. needAlphaTesting(): boolean;
  48852. /**
  48853. * The entire material has been created in order to prevent overdraw.
  48854. * @returns true if blending is enable
  48855. */
  48856. needAlphaBlending(): boolean;
  48857. /**
  48858. * Checks wether the material is ready to be rendered for a given mesh.
  48859. * @param mesh The mesh to render
  48860. * @param subMesh The submesh to check against
  48861. * @param useInstances Specify wether or not the material is used with instances
  48862. * @returns true if all the dependencies are ready (Textures, Effects...)
  48863. */
  48864. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  48865. /**
  48866. * Compute the primary color according to the chosen perceptual color.
  48867. */
  48868. private _computePrimaryColorFromPerceptualColor;
  48869. /**
  48870. * Compute the highlights and shadow colors according to their chosen levels.
  48871. */
  48872. private _computePrimaryColors;
  48873. /**
  48874. * Build the uniform buffer used in the material.
  48875. */
  48876. buildUniformLayout(): void;
  48877. /**
  48878. * Unbind the material.
  48879. */
  48880. unbind(): void;
  48881. /**
  48882. * Bind only the world matrix to the material.
  48883. * @param world The world matrix to bind.
  48884. */
  48885. bindOnlyWorldMatrix(world: Matrix): void;
  48886. /**
  48887. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  48888. * @param world The world matrix to bind.
  48889. * @param subMesh The submesh to bind for.
  48890. */
  48891. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  48892. /**
  48893. * Checks to see if a texture is used in the material.
  48894. * @param texture - Base texture to use.
  48895. * @returns - Boolean specifying if a texture is used in the material.
  48896. */
  48897. hasTexture(texture: BaseTexture): boolean;
  48898. /**
  48899. * Dispose the material.
  48900. * @param forceDisposeEffect Force disposal of the associated effect.
  48901. * @param forceDisposeTextures Force disposal of the associated textures.
  48902. */
  48903. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  48904. /**
  48905. * Clones the material.
  48906. * @param name The cloned name.
  48907. * @returns The cloned material.
  48908. */
  48909. clone(name: string): BackgroundMaterial;
  48910. /**
  48911. * Serializes the current material to its JSON representation.
  48912. * @returns The JSON representation.
  48913. */
  48914. serialize(): any;
  48915. /**
  48916. * Gets the class name of the material
  48917. * @returns "BackgroundMaterial"
  48918. */
  48919. getClassName(): string;
  48920. /**
  48921. * Parse a JSON input to create back a background material.
  48922. * @param source The JSON data to parse
  48923. * @param scene The scene to create the parsed material in
  48924. * @param rootUrl The root url of the assets the material depends upon
  48925. * @returns the instantiated BackgroundMaterial.
  48926. */
  48927. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  48928. }
  48929. }
  48930. declare module "babylonjs/Helpers/environmentHelper" {
  48931. import { Observable } from "babylonjs/Misc/observable";
  48932. import { Nullable } from "babylonjs/types";
  48933. import { Scene } from "babylonjs/scene";
  48934. import { Vector3 } from "babylonjs/Maths/math.vector";
  48935. import { Color3 } from "babylonjs/Maths/math.color";
  48936. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48937. import { Mesh } from "babylonjs/Meshes/mesh";
  48938. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48939. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  48940. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  48941. import "babylonjs/Meshes/Builders/planeBuilder";
  48942. import "babylonjs/Meshes/Builders/boxBuilder";
  48943. /**
  48944. * Represents the different options available during the creation of
  48945. * a Environment helper.
  48946. *
  48947. * This can control the default ground, skybox and image processing setup of your scene.
  48948. */
  48949. export interface IEnvironmentHelperOptions {
  48950. /**
  48951. * Specifies wether or not to create a ground.
  48952. * True by default.
  48953. */
  48954. createGround: boolean;
  48955. /**
  48956. * Specifies the ground size.
  48957. * 15 by default.
  48958. */
  48959. groundSize: number;
  48960. /**
  48961. * The texture used on the ground for the main color.
  48962. * Comes from the BabylonJS CDN by default.
  48963. *
  48964. * Remarks: Can be either a texture or a url.
  48965. */
  48966. groundTexture: string | BaseTexture;
  48967. /**
  48968. * The color mixed in the ground texture by default.
  48969. * BabylonJS clearColor by default.
  48970. */
  48971. groundColor: Color3;
  48972. /**
  48973. * Specifies the ground opacity.
  48974. * 1 by default.
  48975. */
  48976. groundOpacity: number;
  48977. /**
  48978. * Enables the ground to receive shadows.
  48979. * True by default.
  48980. */
  48981. enableGroundShadow: boolean;
  48982. /**
  48983. * Helps preventing the shadow to be fully black on the ground.
  48984. * 0.5 by default.
  48985. */
  48986. groundShadowLevel: number;
  48987. /**
  48988. * Creates a mirror texture attach to the ground.
  48989. * false by default.
  48990. */
  48991. enableGroundMirror: boolean;
  48992. /**
  48993. * Specifies the ground mirror size ratio.
  48994. * 0.3 by default as the default kernel is 64.
  48995. */
  48996. groundMirrorSizeRatio: number;
  48997. /**
  48998. * Specifies the ground mirror blur kernel size.
  48999. * 64 by default.
  49000. */
  49001. groundMirrorBlurKernel: number;
  49002. /**
  49003. * Specifies the ground mirror visibility amount.
  49004. * 1 by default
  49005. */
  49006. groundMirrorAmount: number;
  49007. /**
  49008. * Specifies the ground mirror reflectance weight.
  49009. * This uses the standard weight of the background material to setup the fresnel effect
  49010. * of the mirror.
  49011. * 1 by default.
  49012. */
  49013. groundMirrorFresnelWeight: number;
  49014. /**
  49015. * Specifies the ground mirror Falloff distance.
  49016. * This can helps reducing the size of the reflection.
  49017. * 0 by Default.
  49018. */
  49019. groundMirrorFallOffDistance: number;
  49020. /**
  49021. * Specifies the ground mirror texture type.
  49022. * Unsigned Int by Default.
  49023. */
  49024. groundMirrorTextureType: number;
  49025. /**
  49026. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  49027. * the shown objects.
  49028. */
  49029. groundYBias: number;
  49030. /**
  49031. * Specifies wether or not to create a skybox.
  49032. * True by default.
  49033. */
  49034. createSkybox: boolean;
  49035. /**
  49036. * Specifies the skybox size.
  49037. * 20 by default.
  49038. */
  49039. skyboxSize: number;
  49040. /**
  49041. * The texture used on the skybox for the main color.
  49042. * Comes from the BabylonJS CDN by default.
  49043. *
  49044. * Remarks: Can be either a texture or a url.
  49045. */
  49046. skyboxTexture: string | BaseTexture;
  49047. /**
  49048. * The color mixed in the skybox texture by default.
  49049. * BabylonJS clearColor by default.
  49050. */
  49051. skyboxColor: Color3;
  49052. /**
  49053. * The background rotation around the Y axis of the scene.
  49054. * This helps aligning the key lights of your scene with the background.
  49055. * 0 by default.
  49056. */
  49057. backgroundYRotation: number;
  49058. /**
  49059. * Compute automatically the size of the elements to best fit with the scene.
  49060. */
  49061. sizeAuto: boolean;
  49062. /**
  49063. * Default position of the rootMesh if autoSize is not true.
  49064. */
  49065. rootPosition: Vector3;
  49066. /**
  49067. * Sets up the image processing in the scene.
  49068. * true by default.
  49069. */
  49070. setupImageProcessing: boolean;
  49071. /**
  49072. * The texture used as your environment texture in the scene.
  49073. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  49074. *
  49075. * Remarks: Can be either a texture or a url.
  49076. */
  49077. environmentTexture: string | BaseTexture;
  49078. /**
  49079. * The value of the exposure to apply to the scene.
  49080. * 0.6 by default if setupImageProcessing is true.
  49081. */
  49082. cameraExposure: number;
  49083. /**
  49084. * The value of the contrast to apply to the scene.
  49085. * 1.6 by default if setupImageProcessing is true.
  49086. */
  49087. cameraContrast: number;
  49088. /**
  49089. * Specifies wether or not tonemapping should be enabled in the scene.
  49090. * true by default if setupImageProcessing is true.
  49091. */
  49092. toneMappingEnabled: boolean;
  49093. }
  49094. /**
  49095. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  49096. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  49097. * It also helps with the default setup of your imageProcessing configuration.
  49098. */
  49099. export class EnvironmentHelper {
  49100. /**
  49101. * Default ground texture URL.
  49102. */
  49103. private static _groundTextureCDNUrl;
  49104. /**
  49105. * Default skybox texture URL.
  49106. */
  49107. private static _skyboxTextureCDNUrl;
  49108. /**
  49109. * Default environment texture URL.
  49110. */
  49111. private static _environmentTextureCDNUrl;
  49112. /**
  49113. * Creates the default options for the helper.
  49114. */
  49115. private static _getDefaultOptions;
  49116. private _rootMesh;
  49117. /**
  49118. * Gets the root mesh created by the helper.
  49119. */
  49120. readonly rootMesh: Mesh;
  49121. private _skybox;
  49122. /**
  49123. * Gets the skybox created by the helper.
  49124. */
  49125. readonly skybox: Nullable<Mesh>;
  49126. private _skyboxTexture;
  49127. /**
  49128. * Gets the skybox texture created by the helper.
  49129. */
  49130. readonly skyboxTexture: Nullable<BaseTexture>;
  49131. private _skyboxMaterial;
  49132. /**
  49133. * Gets the skybox material created by the helper.
  49134. */
  49135. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  49136. private _ground;
  49137. /**
  49138. * Gets the ground mesh created by the helper.
  49139. */
  49140. readonly ground: Nullable<Mesh>;
  49141. private _groundTexture;
  49142. /**
  49143. * Gets the ground texture created by the helper.
  49144. */
  49145. readonly groundTexture: Nullable<BaseTexture>;
  49146. private _groundMirror;
  49147. /**
  49148. * Gets the ground mirror created by the helper.
  49149. */
  49150. readonly groundMirror: Nullable<MirrorTexture>;
  49151. /**
  49152. * Gets the ground mirror render list to helps pushing the meshes
  49153. * you wish in the ground reflection.
  49154. */
  49155. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  49156. private _groundMaterial;
  49157. /**
  49158. * Gets the ground material created by the helper.
  49159. */
  49160. readonly groundMaterial: Nullable<BackgroundMaterial>;
  49161. /**
  49162. * Stores the creation options.
  49163. */
  49164. private readonly _scene;
  49165. private _options;
  49166. /**
  49167. * This observable will be notified with any error during the creation of the environment,
  49168. * mainly texture creation errors.
  49169. */
  49170. onErrorObservable: Observable<{
  49171. message?: string;
  49172. exception?: any;
  49173. }>;
  49174. /**
  49175. * constructor
  49176. * @param options Defines the options we want to customize the helper
  49177. * @param scene The scene to add the material to
  49178. */
  49179. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  49180. /**
  49181. * Updates the background according to the new options
  49182. * @param options
  49183. */
  49184. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  49185. /**
  49186. * Sets the primary color of all the available elements.
  49187. * @param color the main color to affect to the ground and the background
  49188. */
  49189. setMainColor(color: Color3): void;
  49190. /**
  49191. * Setup the image processing according to the specified options.
  49192. */
  49193. private _setupImageProcessing;
  49194. /**
  49195. * Setup the environment texture according to the specified options.
  49196. */
  49197. private _setupEnvironmentTexture;
  49198. /**
  49199. * Setup the background according to the specified options.
  49200. */
  49201. private _setupBackground;
  49202. /**
  49203. * Get the scene sizes according to the setup.
  49204. */
  49205. private _getSceneSize;
  49206. /**
  49207. * Setup the ground according to the specified options.
  49208. */
  49209. private _setupGround;
  49210. /**
  49211. * Setup the ground material according to the specified options.
  49212. */
  49213. private _setupGroundMaterial;
  49214. /**
  49215. * Setup the ground diffuse texture according to the specified options.
  49216. */
  49217. private _setupGroundDiffuseTexture;
  49218. /**
  49219. * Setup the ground mirror texture according to the specified options.
  49220. */
  49221. private _setupGroundMirrorTexture;
  49222. /**
  49223. * Setup the ground to receive the mirror texture.
  49224. */
  49225. private _setupMirrorInGroundMaterial;
  49226. /**
  49227. * Setup the skybox according to the specified options.
  49228. */
  49229. private _setupSkybox;
  49230. /**
  49231. * Setup the skybox material according to the specified options.
  49232. */
  49233. private _setupSkyboxMaterial;
  49234. /**
  49235. * Setup the skybox reflection texture according to the specified options.
  49236. */
  49237. private _setupSkyboxReflectionTexture;
  49238. private _errorHandler;
  49239. /**
  49240. * Dispose all the elements created by the Helper.
  49241. */
  49242. dispose(): void;
  49243. }
  49244. }
  49245. declare module "babylonjs/Helpers/photoDome" {
  49246. import { Observable } from "babylonjs/Misc/observable";
  49247. import { Nullable } from "babylonjs/types";
  49248. import { Scene } from "babylonjs/scene";
  49249. import { TransformNode } from "babylonjs/Meshes/transformNode";
  49250. import { Mesh } from "babylonjs/Meshes/mesh";
  49251. import { Texture } from "babylonjs/Materials/Textures/texture";
  49252. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  49253. import "babylonjs/Meshes/Builders/sphereBuilder";
  49254. /**
  49255. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  49256. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  49257. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  49258. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  49259. */
  49260. export class PhotoDome extends TransformNode {
  49261. /**
  49262. * Define the image as a Monoscopic panoramic 360 image.
  49263. */
  49264. static readonly MODE_MONOSCOPIC: number;
  49265. /**
  49266. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  49267. */
  49268. static readonly MODE_TOPBOTTOM: number;
  49269. /**
  49270. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  49271. */
  49272. static readonly MODE_SIDEBYSIDE: number;
  49273. private _useDirectMapping;
  49274. /**
  49275. * The texture being displayed on the sphere
  49276. */
  49277. protected _photoTexture: Texture;
  49278. /**
  49279. * Gets or sets the texture being displayed on the sphere
  49280. */
  49281. photoTexture: Texture;
  49282. /**
  49283. * Observable raised when an error occured while loading the 360 image
  49284. */
  49285. onLoadErrorObservable: Observable<string>;
  49286. /**
  49287. * The skybox material
  49288. */
  49289. protected _material: BackgroundMaterial;
  49290. /**
  49291. * The surface used for the skybox
  49292. */
  49293. protected _mesh: Mesh;
  49294. /**
  49295. * Gets the mesh used for the skybox.
  49296. */
  49297. readonly mesh: Mesh;
  49298. /**
  49299. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  49300. * Also see the options.resolution property.
  49301. */
  49302. fovMultiplier: number;
  49303. private _imageMode;
  49304. /**
  49305. * Gets or set the current video mode for the video. It can be:
  49306. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  49307. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  49308. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  49309. */
  49310. imageMode: number;
  49311. /**
  49312. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  49313. * @param name Element's name, child elements will append suffixes for their own names.
  49314. * @param urlsOfPhoto defines the url of the photo to display
  49315. * @param options defines an object containing optional or exposed sub element properties
  49316. * @param onError defines a callback called when an error occured while loading the texture
  49317. */
  49318. constructor(name: string, urlOfPhoto: string, options: {
  49319. resolution?: number;
  49320. size?: number;
  49321. useDirectMapping?: boolean;
  49322. faceForward?: boolean;
  49323. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  49324. private _onBeforeCameraRenderObserver;
  49325. private _changeImageMode;
  49326. /**
  49327. * Releases resources associated with this node.
  49328. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  49329. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  49330. */
  49331. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  49332. }
  49333. }
  49334. declare module "babylonjs/Misc/rgbdTextureTools" {
  49335. import "babylonjs/Shaders/rgbdDecode.fragment";
  49336. import "babylonjs/Engines/Extensions/engine.renderTarget";
  49337. import { Texture } from "babylonjs/Materials/Textures/texture";
  49338. /**
  49339. * Class used to host RGBD texture specific utilities
  49340. */
  49341. export class RGBDTextureTools {
  49342. /**
  49343. * Expand the RGBD Texture from RGBD to Half Float if possible.
  49344. * @param texture the texture to expand.
  49345. */
  49346. static ExpandRGBDTexture(texture: Texture): void;
  49347. }
  49348. }
  49349. declare module "babylonjs/Misc/brdfTextureTools" {
  49350. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49351. import { Scene } from "babylonjs/scene";
  49352. /**
  49353. * Class used to host texture specific utilities
  49354. */
  49355. export class BRDFTextureTools {
  49356. /**
  49357. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  49358. * @param scene defines the hosting scene
  49359. * @returns the environment BRDF texture
  49360. */
  49361. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  49362. private static _environmentBRDFBase64Texture;
  49363. }
  49364. }
  49365. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  49366. import { Nullable } from "babylonjs/types";
  49367. import { Color3 } from "babylonjs/Maths/math.color";
  49368. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49369. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  49370. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  49371. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  49372. import { Engine } from "babylonjs/Engines/engine";
  49373. import { Scene } from "babylonjs/scene";
  49374. /**
  49375. * @hidden
  49376. */
  49377. export interface IMaterialClearCoatDefines {
  49378. CLEARCOAT: boolean;
  49379. CLEARCOAT_DEFAULTIOR: boolean;
  49380. CLEARCOAT_TEXTURE: boolean;
  49381. CLEARCOAT_TEXTUREDIRECTUV: number;
  49382. CLEARCOAT_BUMP: boolean;
  49383. CLEARCOAT_BUMPDIRECTUV: number;
  49384. CLEARCOAT_TINT: boolean;
  49385. CLEARCOAT_TINT_TEXTURE: boolean;
  49386. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  49387. /** @hidden */
  49388. _areTexturesDirty: boolean;
  49389. }
  49390. /**
  49391. * Define the code related to the clear coat parameters of the pbr material.
  49392. */
  49393. export class PBRClearCoatConfiguration {
  49394. /**
  49395. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  49396. * The default fits with a polyurethane material.
  49397. */
  49398. private static readonly _DefaultIndexOfRefraction;
  49399. private _isEnabled;
  49400. /**
  49401. * Defines if the clear coat is enabled in the material.
  49402. */
  49403. isEnabled: boolean;
  49404. /**
  49405. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  49406. */
  49407. intensity: number;
  49408. /**
  49409. * Defines the clear coat layer roughness.
  49410. */
  49411. roughness: number;
  49412. private _indexOfRefraction;
  49413. /**
  49414. * Defines the index of refraction of the clear coat.
  49415. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  49416. * The default fits with a polyurethane material.
  49417. * Changing the default value is more performance intensive.
  49418. */
  49419. indexOfRefraction: number;
  49420. private _texture;
  49421. /**
  49422. * Stores the clear coat values in a texture.
  49423. */
  49424. texture: Nullable<BaseTexture>;
  49425. private _bumpTexture;
  49426. /**
  49427. * Define the clear coat specific bump texture.
  49428. */
  49429. bumpTexture: Nullable<BaseTexture>;
  49430. private _isTintEnabled;
  49431. /**
  49432. * Defines if the clear coat tint is enabled in the material.
  49433. */
  49434. isTintEnabled: boolean;
  49435. /**
  49436. * Defines the clear coat tint of the material.
  49437. * This is only use if tint is enabled
  49438. */
  49439. tintColor: Color3;
  49440. /**
  49441. * Defines the distance at which the tint color should be found in the
  49442. * clear coat media.
  49443. * This is only use if tint is enabled
  49444. */
  49445. tintColorAtDistance: number;
  49446. /**
  49447. * Defines the clear coat layer thickness.
  49448. * This is only use if tint is enabled
  49449. */
  49450. tintThickness: number;
  49451. private _tintTexture;
  49452. /**
  49453. * Stores the clear tint values in a texture.
  49454. * rgb is tint
  49455. * a is a thickness factor
  49456. */
  49457. tintTexture: Nullable<BaseTexture>;
  49458. /** @hidden */
  49459. private _internalMarkAllSubMeshesAsTexturesDirty;
  49460. /** @hidden */
  49461. _markAllSubMeshesAsTexturesDirty(): void;
  49462. /**
  49463. * Instantiate a new istance of clear coat configuration.
  49464. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  49465. */
  49466. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  49467. /**
  49468. * Gets wehter the submesh is ready to be used or not.
  49469. * @param defines the list of "defines" to update.
  49470. * @param scene defines the scene the material belongs to.
  49471. * @param engine defines the engine the material belongs to.
  49472. * @param disableBumpMap defines wether the material disables bump or not.
  49473. * @returns - boolean indicating that the submesh is ready or not.
  49474. */
  49475. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  49476. /**
  49477. * Checks to see if a texture is used in the material.
  49478. * @param defines the list of "defines" to update.
  49479. * @param scene defines the scene to the material belongs to.
  49480. */
  49481. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  49482. /**
  49483. * Binds the material data.
  49484. * @param uniformBuffer defines the Uniform buffer to fill in.
  49485. * @param scene defines the scene the material belongs to.
  49486. * @param engine defines the engine the material belongs to.
  49487. * @param disableBumpMap defines wether the material disables bump or not.
  49488. * @param isFrozen defines wether the material is frozen or not.
  49489. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  49490. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  49491. */
  49492. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  49493. /**
  49494. * Checks to see if a texture is used in the material.
  49495. * @param texture - Base texture to use.
  49496. * @returns - Boolean specifying if a texture is used in the material.
  49497. */
  49498. hasTexture(texture: BaseTexture): boolean;
  49499. /**
  49500. * Returns an array of the actively used textures.
  49501. * @param activeTextures Array of BaseTextures
  49502. */
  49503. getActiveTextures(activeTextures: BaseTexture[]): void;
  49504. /**
  49505. * Returns the animatable textures.
  49506. * @param animatables Array of animatable textures.
  49507. */
  49508. getAnimatables(animatables: IAnimatable[]): void;
  49509. /**
  49510. * Disposes the resources of the material.
  49511. * @param forceDisposeTextures - Forces the disposal of all textures.
  49512. */
  49513. dispose(forceDisposeTextures?: boolean): void;
  49514. /**
  49515. * Get the current class name of the texture useful for serialization or dynamic coding.
  49516. * @returns "PBRClearCoatConfiguration"
  49517. */
  49518. getClassName(): string;
  49519. /**
  49520. * Add fallbacks to the effect fallbacks list.
  49521. * @param defines defines the Base texture to use.
  49522. * @param fallbacks defines the current fallback list.
  49523. * @param currentRank defines the current fallback rank.
  49524. * @returns the new fallback rank.
  49525. */
  49526. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  49527. /**
  49528. * Add the required uniforms to the current list.
  49529. * @param uniforms defines the current uniform list.
  49530. */
  49531. static AddUniforms(uniforms: string[]): void;
  49532. /**
  49533. * Add the required samplers to the current list.
  49534. * @param samplers defines the current sampler list.
  49535. */
  49536. static AddSamplers(samplers: string[]): void;
  49537. /**
  49538. * Add the required uniforms to the current buffer.
  49539. * @param uniformBuffer defines the current uniform buffer.
  49540. */
  49541. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  49542. /**
  49543. * Makes a duplicate of the current configuration into another one.
  49544. * @param clearCoatConfiguration define the config where to copy the info
  49545. */
  49546. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  49547. /**
  49548. * Serializes this clear coat configuration.
  49549. * @returns - An object with the serialized config.
  49550. */
  49551. serialize(): any;
  49552. /**
  49553. * Parses a anisotropy Configuration from a serialized object.
  49554. * @param source - Serialized object.
  49555. * @param scene Defines the scene we are parsing for
  49556. * @param rootUrl Defines the rootUrl to load from
  49557. */
  49558. parse(source: any, scene: Scene, rootUrl: string): void;
  49559. }
  49560. }
  49561. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  49562. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  49563. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49564. import { Vector2 } from "babylonjs/Maths/math.vector";
  49565. import { Scene } from "babylonjs/scene";
  49566. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49567. import { Nullable } from "babylonjs/types";
  49568. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  49569. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  49570. /**
  49571. * @hidden
  49572. */
  49573. export interface IMaterialAnisotropicDefines {
  49574. ANISOTROPIC: boolean;
  49575. ANISOTROPIC_TEXTURE: boolean;
  49576. ANISOTROPIC_TEXTUREDIRECTUV: number;
  49577. MAINUV1: boolean;
  49578. _areTexturesDirty: boolean;
  49579. _needUVs: boolean;
  49580. }
  49581. /**
  49582. * Define the code related to the anisotropic parameters of the pbr material.
  49583. */
  49584. export class PBRAnisotropicConfiguration {
  49585. private _isEnabled;
  49586. /**
  49587. * Defines if the anisotropy is enabled in the material.
  49588. */
  49589. isEnabled: boolean;
  49590. /**
  49591. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  49592. */
  49593. intensity: number;
  49594. /**
  49595. * Defines if the effect is along the tangents, bitangents or in between.
  49596. * By default, the effect is "strectching" the highlights along the tangents.
  49597. */
  49598. direction: Vector2;
  49599. private _texture;
  49600. /**
  49601. * Stores the anisotropy values in a texture.
  49602. * rg is direction (like normal from -1 to 1)
  49603. * b is a intensity
  49604. */
  49605. texture: Nullable<BaseTexture>;
  49606. /** @hidden */
  49607. private _internalMarkAllSubMeshesAsTexturesDirty;
  49608. /** @hidden */
  49609. _markAllSubMeshesAsTexturesDirty(): void;
  49610. /**
  49611. * Instantiate a new istance of anisotropy configuration.
  49612. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  49613. */
  49614. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  49615. /**
  49616. * Specifies that the submesh is ready to be used.
  49617. * @param defines the list of "defines" to update.
  49618. * @param scene defines the scene the material belongs to.
  49619. * @returns - boolean indicating that the submesh is ready or not.
  49620. */
  49621. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  49622. /**
  49623. * Checks to see if a texture is used in the material.
  49624. * @param defines the list of "defines" to update.
  49625. * @param mesh the mesh we are preparing the defines for.
  49626. * @param scene defines the scene the material belongs to.
  49627. */
  49628. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  49629. /**
  49630. * Binds the material data.
  49631. * @param uniformBuffer defines the Uniform buffer to fill in.
  49632. * @param scene defines the scene the material belongs to.
  49633. * @param isFrozen defines wether the material is frozen or not.
  49634. */
  49635. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  49636. /**
  49637. * Checks to see if a texture is used in the material.
  49638. * @param texture - Base texture to use.
  49639. * @returns - Boolean specifying if a texture is used in the material.
  49640. */
  49641. hasTexture(texture: BaseTexture): boolean;
  49642. /**
  49643. * Returns an array of the actively used textures.
  49644. * @param activeTextures Array of BaseTextures
  49645. */
  49646. getActiveTextures(activeTextures: BaseTexture[]): void;
  49647. /**
  49648. * Returns the animatable textures.
  49649. * @param animatables Array of animatable textures.
  49650. */
  49651. getAnimatables(animatables: IAnimatable[]): void;
  49652. /**
  49653. * Disposes the resources of the material.
  49654. * @param forceDisposeTextures - Forces the disposal of all textures.
  49655. */
  49656. dispose(forceDisposeTextures?: boolean): void;
  49657. /**
  49658. * Get the current class name of the texture useful for serialization or dynamic coding.
  49659. * @returns "PBRAnisotropicConfiguration"
  49660. */
  49661. getClassName(): string;
  49662. /**
  49663. * Add fallbacks to the effect fallbacks list.
  49664. * @param defines defines the Base texture to use.
  49665. * @param fallbacks defines the current fallback list.
  49666. * @param currentRank defines the current fallback rank.
  49667. * @returns the new fallback rank.
  49668. */
  49669. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  49670. /**
  49671. * Add the required uniforms to the current list.
  49672. * @param uniforms defines the current uniform list.
  49673. */
  49674. static AddUniforms(uniforms: string[]): void;
  49675. /**
  49676. * Add the required uniforms to the current buffer.
  49677. * @param uniformBuffer defines the current uniform buffer.
  49678. */
  49679. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  49680. /**
  49681. * Add the required samplers to the current list.
  49682. * @param samplers defines the current sampler list.
  49683. */
  49684. static AddSamplers(samplers: string[]): void;
  49685. /**
  49686. * Makes a duplicate of the current configuration into another one.
  49687. * @param anisotropicConfiguration define the config where to copy the info
  49688. */
  49689. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  49690. /**
  49691. * Serializes this anisotropy configuration.
  49692. * @returns - An object with the serialized config.
  49693. */
  49694. serialize(): any;
  49695. /**
  49696. * Parses a anisotropy Configuration from a serialized object.
  49697. * @param source - Serialized object.
  49698. * @param scene Defines the scene we are parsing for
  49699. * @param rootUrl Defines the rootUrl to load from
  49700. */
  49701. parse(source: any, scene: Scene, rootUrl: string): void;
  49702. }
  49703. }
  49704. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  49705. import { Scene } from "babylonjs/scene";
  49706. /**
  49707. * @hidden
  49708. */
  49709. export interface IMaterialBRDFDefines {
  49710. BRDF_V_HEIGHT_CORRELATED: boolean;
  49711. MS_BRDF_ENERGY_CONSERVATION: boolean;
  49712. SPHERICAL_HARMONICS: boolean;
  49713. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  49714. /** @hidden */
  49715. _areMiscDirty: boolean;
  49716. }
  49717. /**
  49718. * Define the code related to the BRDF parameters of the pbr material.
  49719. */
  49720. export class PBRBRDFConfiguration {
  49721. /**
  49722. * Default value used for the energy conservation.
  49723. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  49724. */
  49725. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  49726. /**
  49727. * Default value used for the Smith Visibility Height Correlated mode.
  49728. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  49729. */
  49730. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  49731. /**
  49732. * Default value used for the IBL diffuse part.
  49733. * This can help switching back to the polynomials mode globally which is a tiny bit
  49734. * less GPU intensive at the drawback of a lower quality.
  49735. */
  49736. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  49737. /**
  49738. * Default value used for activating energy conservation for the specular workflow.
  49739. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  49740. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  49741. */
  49742. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  49743. private _useEnergyConservation;
  49744. /**
  49745. * Defines if the material uses energy conservation.
  49746. */
  49747. useEnergyConservation: boolean;
  49748. private _useSmithVisibilityHeightCorrelated;
  49749. /**
  49750. * LEGACY Mode set to false
  49751. * Defines if the material uses height smith correlated visibility term.
  49752. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  49753. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  49754. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  49755. * Not relying on height correlated will also disable energy conservation.
  49756. */
  49757. useSmithVisibilityHeightCorrelated: boolean;
  49758. private _useSphericalHarmonics;
  49759. /**
  49760. * LEGACY Mode set to false
  49761. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  49762. * diffuse part of the IBL.
  49763. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  49764. * to the ground truth.
  49765. */
  49766. useSphericalHarmonics: boolean;
  49767. private _useSpecularGlossinessInputEnergyConservation;
  49768. /**
  49769. * Defines if the material uses energy conservation, when the specular workflow is active.
  49770. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  49771. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  49772. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  49773. */
  49774. useSpecularGlossinessInputEnergyConservation: boolean;
  49775. /** @hidden */
  49776. private _internalMarkAllSubMeshesAsMiscDirty;
  49777. /** @hidden */
  49778. _markAllSubMeshesAsMiscDirty(): void;
  49779. /**
  49780. * Instantiate a new istance of clear coat configuration.
  49781. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  49782. */
  49783. constructor(markAllSubMeshesAsMiscDirty: () => void);
  49784. /**
  49785. * Checks to see if a texture is used in the material.
  49786. * @param defines the list of "defines" to update.
  49787. */
  49788. prepareDefines(defines: IMaterialBRDFDefines): void;
  49789. /**
  49790. * Get the current class name of the texture useful for serialization or dynamic coding.
  49791. * @returns "PBRClearCoatConfiguration"
  49792. */
  49793. getClassName(): string;
  49794. /**
  49795. * Makes a duplicate of the current configuration into another one.
  49796. * @param brdfConfiguration define the config where to copy the info
  49797. */
  49798. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  49799. /**
  49800. * Serializes this BRDF configuration.
  49801. * @returns - An object with the serialized config.
  49802. */
  49803. serialize(): any;
  49804. /**
  49805. * Parses a anisotropy Configuration from a serialized object.
  49806. * @param source - Serialized object.
  49807. * @param scene Defines the scene we are parsing for
  49808. * @param rootUrl Defines the rootUrl to load from
  49809. */
  49810. parse(source: any, scene: Scene, rootUrl: string): void;
  49811. }
  49812. }
  49813. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  49814. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  49815. import { Color3 } from "babylonjs/Maths/math.color";
  49816. import { Scene } from "babylonjs/scene";
  49817. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49818. import { Nullable } from "babylonjs/types";
  49819. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  49820. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  49821. /**
  49822. * @hidden
  49823. */
  49824. export interface IMaterialSheenDefines {
  49825. SHEEN: boolean;
  49826. SHEEN_TEXTURE: boolean;
  49827. SHEEN_TEXTUREDIRECTUV: number;
  49828. SHEEN_LINKWITHALBEDO: boolean;
  49829. /** @hidden */
  49830. _areTexturesDirty: boolean;
  49831. }
  49832. /**
  49833. * Define the code related to the Sheen parameters of the pbr material.
  49834. */
  49835. export class PBRSheenConfiguration {
  49836. private _isEnabled;
  49837. /**
  49838. * Defines if the material uses sheen.
  49839. */
  49840. isEnabled: boolean;
  49841. private _linkSheenWithAlbedo;
  49842. /**
  49843. * Defines if the sheen is linked to the sheen color.
  49844. */
  49845. linkSheenWithAlbedo: boolean;
  49846. /**
  49847. * Defines the sheen intensity.
  49848. */
  49849. intensity: number;
  49850. /**
  49851. * Defines the sheen color.
  49852. */
  49853. color: Color3;
  49854. private _texture;
  49855. /**
  49856. * Stores the sheen tint values in a texture.
  49857. * rgb is tint
  49858. * a is a intensity
  49859. */
  49860. texture: Nullable<BaseTexture>;
  49861. /** @hidden */
  49862. private _internalMarkAllSubMeshesAsTexturesDirty;
  49863. /** @hidden */
  49864. _markAllSubMeshesAsTexturesDirty(): void;
  49865. /**
  49866. * Instantiate a new istance of clear coat configuration.
  49867. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  49868. */
  49869. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  49870. /**
  49871. * Specifies that the submesh is ready to be used.
  49872. * @param defines the list of "defines" to update.
  49873. * @param scene defines the scene the material belongs to.
  49874. * @returns - boolean indicating that the submesh is ready or not.
  49875. */
  49876. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  49877. /**
  49878. * Checks to see if a texture is used in the material.
  49879. * @param defines the list of "defines" to update.
  49880. * @param scene defines the scene the material belongs to.
  49881. */
  49882. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  49883. /**
  49884. * Binds the material data.
  49885. * @param uniformBuffer defines the Uniform buffer to fill in.
  49886. * @param scene defines the scene the material belongs to.
  49887. * @param isFrozen defines wether the material is frozen or not.
  49888. */
  49889. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  49890. /**
  49891. * Checks to see if a texture is used in the material.
  49892. * @param texture - Base texture to use.
  49893. * @returns - Boolean specifying if a texture is used in the material.
  49894. */
  49895. hasTexture(texture: BaseTexture): boolean;
  49896. /**
  49897. * Returns an array of the actively used textures.
  49898. * @param activeTextures Array of BaseTextures
  49899. */
  49900. getActiveTextures(activeTextures: BaseTexture[]): void;
  49901. /**
  49902. * Returns the animatable textures.
  49903. * @param animatables Array of animatable textures.
  49904. */
  49905. getAnimatables(animatables: IAnimatable[]): void;
  49906. /**
  49907. * Disposes the resources of the material.
  49908. * @param forceDisposeTextures - Forces the disposal of all textures.
  49909. */
  49910. dispose(forceDisposeTextures?: boolean): void;
  49911. /**
  49912. * Get the current class name of the texture useful for serialization or dynamic coding.
  49913. * @returns "PBRSheenConfiguration"
  49914. */
  49915. getClassName(): string;
  49916. /**
  49917. * Add fallbacks to the effect fallbacks list.
  49918. * @param defines defines the Base texture to use.
  49919. * @param fallbacks defines the current fallback list.
  49920. * @param currentRank defines the current fallback rank.
  49921. * @returns the new fallback rank.
  49922. */
  49923. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  49924. /**
  49925. * Add the required uniforms to the current list.
  49926. * @param uniforms defines the current uniform list.
  49927. */
  49928. static AddUniforms(uniforms: string[]): void;
  49929. /**
  49930. * Add the required uniforms to the current buffer.
  49931. * @param uniformBuffer defines the current uniform buffer.
  49932. */
  49933. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  49934. /**
  49935. * Add the required samplers to the current list.
  49936. * @param samplers defines the current sampler list.
  49937. */
  49938. static AddSamplers(samplers: string[]): void;
  49939. /**
  49940. * Makes a duplicate of the current configuration into another one.
  49941. * @param sheenConfiguration define the config where to copy the info
  49942. */
  49943. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  49944. /**
  49945. * Serializes this BRDF configuration.
  49946. * @returns - An object with the serialized config.
  49947. */
  49948. serialize(): any;
  49949. /**
  49950. * Parses a anisotropy Configuration from a serialized object.
  49951. * @param source - Serialized object.
  49952. * @param scene Defines the scene we are parsing for
  49953. * @param rootUrl Defines the rootUrl to load from
  49954. */
  49955. parse(source: any, scene: Scene, rootUrl: string): void;
  49956. }
  49957. }
  49958. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  49959. import { Nullable } from "babylonjs/types";
  49960. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  49961. import { Color3 } from "babylonjs/Maths/math.color";
  49962. import { SmartArray } from "babylonjs/Misc/smartArray";
  49963. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49964. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  49965. import { Effect } from "babylonjs/Materials/effect";
  49966. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  49967. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  49968. import { Engine } from "babylonjs/Engines/engine";
  49969. import { Scene } from "babylonjs/scene";
  49970. /**
  49971. * @hidden
  49972. */
  49973. export interface IMaterialSubSurfaceDefines {
  49974. SUBSURFACE: boolean;
  49975. SS_REFRACTION: boolean;
  49976. SS_TRANSLUCENCY: boolean;
  49977. SS_SCATERRING: boolean;
  49978. SS_THICKNESSANDMASK_TEXTURE: boolean;
  49979. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  49980. SS_REFRACTIONMAP_3D: boolean;
  49981. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  49982. SS_LODINREFRACTIONALPHA: boolean;
  49983. SS_GAMMAREFRACTION: boolean;
  49984. SS_RGBDREFRACTION: boolean;
  49985. SS_LINEARSPECULARREFRACTION: boolean;
  49986. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  49987. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  49988. /** @hidden */
  49989. _areTexturesDirty: boolean;
  49990. }
  49991. /**
  49992. * Define the code related to the sub surface parameters of the pbr material.
  49993. */
  49994. export class PBRSubSurfaceConfiguration {
  49995. private _isRefractionEnabled;
  49996. /**
  49997. * Defines if the refraction is enabled in the material.
  49998. */
  49999. isRefractionEnabled: boolean;
  50000. private _isTranslucencyEnabled;
  50001. /**
  50002. * Defines if the translucency is enabled in the material.
  50003. */
  50004. isTranslucencyEnabled: boolean;
  50005. private _isScatteringEnabled;
  50006. /**
  50007. * Defines the refraction intensity of the material.
  50008. * The refraction when enabled replaces the Diffuse part of the material.
  50009. * The intensity helps transitionning between diffuse and refraction.
  50010. */
  50011. refractionIntensity: number;
  50012. /**
  50013. * Defines the translucency intensity of the material.
  50014. * When translucency has been enabled, this defines how much of the "translucency"
  50015. * is addded to the diffuse part of the material.
  50016. */
  50017. translucencyIntensity: number;
  50018. /**
  50019. * Defines the scattering intensity of the material.
  50020. * When scattering has been enabled, this defines how much of the "scattered light"
  50021. * is addded to the diffuse part of the material.
  50022. */
  50023. scatteringIntensity: number;
  50024. private _thicknessTexture;
  50025. /**
  50026. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  50027. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  50028. * 0 would mean minimumThickness
  50029. * 1 would mean maximumThickness
  50030. * The other channels might be use as a mask to vary the different effects intensity.
  50031. */
  50032. thicknessTexture: Nullable<BaseTexture>;
  50033. private _refractionTexture;
  50034. /**
  50035. * Defines the texture to use for refraction.
  50036. */
  50037. refractionTexture: Nullable<BaseTexture>;
  50038. private _indexOfRefraction;
  50039. /**
  50040. * Defines the index of refraction used in the material.
  50041. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  50042. */
  50043. indexOfRefraction: number;
  50044. private _invertRefractionY;
  50045. /**
  50046. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  50047. */
  50048. invertRefractionY: boolean;
  50049. private _linkRefractionWithTransparency;
  50050. /**
  50051. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  50052. * Materials half opaque for instance using refraction could benefit from this control.
  50053. */
  50054. linkRefractionWithTransparency: boolean;
  50055. /**
  50056. * Defines the minimum thickness stored in the thickness map.
  50057. * If no thickness map is defined, this value will be used to simulate thickness.
  50058. */
  50059. minimumThickness: number;
  50060. /**
  50061. * Defines the maximum thickness stored in the thickness map.
  50062. */
  50063. maximumThickness: number;
  50064. /**
  50065. * Defines the volume tint of the material.
  50066. * This is used for both translucency and scattering.
  50067. */
  50068. tintColor: Color3;
  50069. /**
  50070. * Defines the distance at which the tint color should be found in the media.
  50071. * This is used for refraction only.
  50072. */
  50073. tintColorAtDistance: number;
  50074. /**
  50075. * Defines how far each channel transmit through the media.
  50076. * It is defined as a color to simplify it selection.
  50077. */
  50078. diffusionDistance: Color3;
  50079. private _useMaskFromThicknessTexture;
  50080. /**
  50081. * Stores the intensity of the different subsurface effects in the thickness texture.
  50082. * * the green channel is the translucency intensity.
  50083. * * the blue channel is the scattering intensity.
  50084. * * the alpha channel is the refraction intensity.
  50085. */
  50086. useMaskFromThicknessTexture: boolean;
  50087. /** @hidden */
  50088. private _internalMarkAllSubMeshesAsTexturesDirty;
  50089. /** @hidden */
  50090. _markAllSubMeshesAsTexturesDirty(): void;
  50091. /**
  50092. * Instantiate a new istance of sub surface configuration.
  50093. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  50094. */
  50095. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  50096. /**
  50097. * Gets wehter the submesh is ready to be used or not.
  50098. * @param defines the list of "defines" to update.
  50099. * @param scene defines the scene the material belongs to.
  50100. * @returns - boolean indicating that the submesh is ready or not.
  50101. */
  50102. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  50103. /**
  50104. * Checks to see if a texture is used in the material.
  50105. * @param defines the list of "defines" to update.
  50106. * @param scene defines the scene to the material belongs to.
  50107. */
  50108. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  50109. /**
  50110. * Binds the material data.
  50111. * @param uniformBuffer defines the Uniform buffer to fill in.
  50112. * @param scene defines the scene the material belongs to.
  50113. * @param engine defines the engine the material belongs to.
  50114. * @param isFrozen defines wether the material is frozen or not.
  50115. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  50116. */
  50117. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  50118. /**
  50119. * Unbinds the material from the mesh.
  50120. * @param activeEffect defines the effect that should be unbound from.
  50121. * @returns true if unbound, otherwise false
  50122. */
  50123. unbind(activeEffect: Effect): boolean;
  50124. /**
  50125. * Returns the texture used for refraction or null if none is used.
  50126. * @param scene defines the scene the material belongs to.
  50127. * @returns - Refraction texture if present. If no refraction texture and refraction
  50128. * is linked with transparency, returns environment texture. Otherwise, returns null.
  50129. */
  50130. private _getRefractionTexture;
  50131. /**
  50132. * Returns true if alpha blending should be disabled.
  50133. */
  50134. readonly disableAlphaBlending: boolean;
  50135. /**
  50136. * Fills the list of render target textures.
  50137. * @param renderTargets the list of render targets to update
  50138. */
  50139. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  50140. /**
  50141. * Checks to see if a texture is used in the material.
  50142. * @param texture - Base texture to use.
  50143. * @returns - Boolean specifying if a texture is used in the material.
  50144. */
  50145. hasTexture(texture: BaseTexture): boolean;
  50146. /**
  50147. * Gets a boolean indicating that current material needs to register RTT
  50148. * @returns true if this uses a render target otherwise false.
  50149. */
  50150. hasRenderTargetTextures(): boolean;
  50151. /**
  50152. * Returns an array of the actively used textures.
  50153. * @param activeTextures Array of BaseTextures
  50154. */
  50155. getActiveTextures(activeTextures: BaseTexture[]): void;
  50156. /**
  50157. * Returns the animatable textures.
  50158. * @param animatables Array of animatable textures.
  50159. */
  50160. getAnimatables(animatables: IAnimatable[]): void;
  50161. /**
  50162. * Disposes the resources of the material.
  50163. * @param forceDisposeTextures - Forces the disposal of all textures.
  50164. */
  50165. dispose(forceDisposeTextures?: boolean): void;
  50166. /**
  50167. * Get the current class name of the texture useful for serialization or dynamic coding.
  50168. * @returns "PBRSubSurfaceConfiguration"
  50169. */
  50170. getClassName(): string;
  50171. /**
  50172. * Add fallbacks to the effect fallbacks list.
  50173. * @param defines defines the Base texture to use.
  50174. * @param fallbacks defines the current fallback list.
  50175. * @param currentRank defines the current fallback rank.
  50176. * @returns the new fallback rank.
  50177. */
  50178. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  50179. /**
  50180. * Add the required uniforms to the current list.
  50181. * @param uniforms defines the current uniform list.
  50182. */
  50183. static AddUniforms(uniforms: string[]): void;
  50184. /**
  50185. * Add the required samplers to the current list.
  50186. * @param samplers defines the current sampler list.
  50187. */
  50188. static AddSamplers(samplers: string[]): void;
  50189. /**
  50190. * Add the required uniforms to the current buffer.
  50191. * @param uniformBuffer defines the current uniform buffer.
  50192. */
  50193. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  50194. /**
  50195. * Makes a duplicate of the current configuration into another one.
  50196. * @param configuration define the config where to copy the info
  50197. */
  50198. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  50199. /**
  50200. * Serializes this Sub Surface configuration.
  50201. * @returns - An object with the serialized config.
  50202. */
  50203. serialize(): any;
  50204. /**
  50205. * Parses a anisotropy Configuration from a serialized object.
  50206. * @param source - Serialized object.
  50207. * @param scene Defines the scene we are parsing for
  50208. * @param rootUrl Defines the rootUrl to load from
  50209. */
  50210. parse(source: any, scene: Scene, rootUrl: string): void;
  50211. }
  50212. }
  50213. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  50214. /** @hidden */
  50215. export var pbrFragmentDeclaration: {
  50216. name: string;
  50217. shader: string;
  50218. };
  50219. }
  50220. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  50221. /** @hidden */
  50222. export var pbrUboDeclaration: {
  50223. name: string;
  50224. shader: string;
  50225. };
  50226. }
  50227. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  50228. /** @hidden */
  50229. export var pbrFragmentExtraDeclaration: {
  50230. name: string;
  50231. shader: string;
  50232. };
  50233. }
  50234. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  50235. /** @hidden */
  50236. export var pbrFragmentSamplersDeclaration: {
  50237. name: string;
  50238. shader: string;
  50239. };
  50240. }
  50241. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  50242. /** @hidden */
  50243. export var pbrHelperFunctions: {
  50244. name: string;
  50245. shader: string;
  50246. };
  50247. }
  50248. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  50249. /** @hidden */
  50250. export var harmonicsFunctions: {
  50251. name: string;
  50252. shader: string;
  50253. };
  50254. }
  50255. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  50256. /** @hidden */
  50257. export var pbrDirectLightingSetupFunctions: {
  50258. name: string;
  50259. shader: string;
  50260. };
  50261. }
  50262. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  50263. /** @hidden */
  50264. export var pbrDirectLightingFalloffFunctions: {
  50265. name: string;
  50266. shader: string;
  50267. };
  50268. }
  50269. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  50270. /** @hidden */
  50271. export var pbrBRDFFunctions: {
  50272. name: string;
  50273. shader: string;
  50274. };
  50275. }
  50276. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  50277. /** @hidden */
  50278. export var pbrDirectLightingFunctions: {
  50279. name: string;
  50280. shader: string;
  50281. };
  50282. }
  50283. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  50284. /** @hidden */
  50285. export var pbrIBLFunctions: {
  50286. name: string;
  50287. shader: string;
  50288. };
  50289. }
  50290. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  50291. /** @hidden */
  50292. export var pbrDebug: {
  50293. name: string;
  50294. shader: string;
  50295. };
  50296. }
  50297. declare module "babylonjs/Shaders/pbr.fragment" {
  50298. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  50299. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  50300. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  50301. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  50302. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  50303. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  50304. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  50305. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  50306. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  50307. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  50308. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  50309. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  50310. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  50311. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  50312. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  50313. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  50314. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  50315. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  50316. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  50317. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  50318. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  50319. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  50320. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  50321. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  50322. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  50323. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  50324. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  50325. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  50326. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  50327. /** @hidden */
  50328. export var pbrPixelShader: {
  50329. name: string;
  50330. shader: string;
  50331. };
  50332. }
  50333. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  50334. /** @hidden */
  50335. export var pbrVertexDeclaration: {
  50336. name: string;
  50337. shader: string;
  50338. };
  50339. }
  50340. declare module "babylonjs/Shaders/pbr.vertex" {
  50341. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  50342. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  50343. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  50344. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  50345. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  50346. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  50347. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  50348. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  50349. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  50350. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  50351. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  50352. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  50353. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  50354. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  50355. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  50356. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  50357. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  50358. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  50359. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  50360. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  50361. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  50362. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  50363. /** @hidden */
  50364. export var pbrVertexShader: {
  50365. name: string;
  50366. shader: string;
  50367. };
  50368. }
  50369. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  50370. import { Nullable } from "babylonjs/types";
  50371. import { Scene } from "babylonjs/scene";
  50372. import { Matrix } from "babylonjs/Maths/math.vector";
  50373. import { SubMesh } from "babylonjs/Meshes/subMesh";
  50374. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50375. import { Mesh } from "babylonjs/Meshes/mesh";
  50376. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  50377. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  50378. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  50379. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  50380. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  50381. import { Color3 } from "babylonjs/Maths/math.color";
  50382. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  50383. import { Material, IMaterialCompilationOptions } from "babylonjs/Materials/material";
  50384. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  50385. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  50386. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50387. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  50388. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  50389. import "babylonjs/Shaders/pbr.fragment";
  50390. import "babylonjs/Shaders/pbr.vertex";
  50391. /**
  50392. * Manages the defines for the PBR Material.
  50393. * @hidden
  50394. */
  50395. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  50396. PBR: boolean;
  50397. MAINUV1: boolean;
  50398. MAINUV2: boolean;
  50399. UV1: boolean;
  50400. UV2: boolean;
  50401. ALBEDO: boolean;
  50402. ALBEDODIRECTUV: number;
  50403. VERTEXCOLOR: boolean;
  50404. AMBIENT: boolean;
  50405. AMBIENTDIRECTUV: number;
  50406. AMBIENTINGRAYSCALE: boolean;
  50407. OPACITY: boolean;
  50408. VERTEXALPHA: boolean;
  50409. OPACITYDIRECTUV: number;
  50410. OPACITYRGB: boolean;
  50411. ALPHATEST: boolean;
  50412. DEPTHPREPASS: boolean;
  50413. ALPHABLEND: boolean;
  50414. ALPHAFROMALBEDO: boolean;
  50415. ALPHATESTVALUE: string;
  50416. SPECULAROVERALPHA: boolean;
  50417. RADIANCEOVERALPHA: boolean;
  50418. ALPHAFRESNEL: boolean;
  50419. LINEARALPHAFRESNEL: boolean;
  50420. PREMULTIPLYALPHA: boolean;
  50421. EMISSIVE: boolean;
  50422. EMISSIVEDIRECTUV: number;
  50423. REFLECTIVITY: boolean;
  50424. REFLECTIVITYDIRECTUV: number;
  50425. SPECULARTERM: boolean;
  50426. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  50427. MICROSURFACEAUTOMATIC: boolean;
  50428. LODBASEDMICROSFURACE: boolean;
  50429. MICROSURFACEMAP: boolean;
  50430. MICROSURFACEMAPDIRECTUV: number;
  50431. METALLICWORKFLOW: boolean;
  50432. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  50433. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  50434. METALLNESSSTOREINMETALMAPBLUE: boolean;
  50435. AOSTOREINMETALMAPRED: boolean;
  50436. METALLICF0FACTORFROMMETALLICMAP: boolean;
  50437. ENVIRONMENTBRDF: boolean;
  50438. ENVIRONMENTBRDF_RGBD: boolean;
  50439. NORMAL: boolean;
  50440. TANGENT: boolean;
  50441. BUMP: boolean;
  50442. BUMPDIRECTUV: number;
  50443. OBJECTSPACE_NORMALMAP: boolean;
  50444. PARALLAX: boolean;
  50445. PARALLAXOCCLUSION: boolean;
  50446. NORMALXYSCALE: boolean;
  50447. LIGHTMAP: boolean;
  50448. LIGHTMAPDIRECTUV: number;
  50449. USELIGHTMAPASSHADOWMAP: boolean;
  50450. GAMMALIGHTMAP: boolean;
  50451. RGBDLIGHTMAP: boolean;
  50452. REFLECTION: boolean;
  50453. REFLECTIONMAP_3D: boolean;
  50454. REFLECTIONMAP_SPHERICAL: boolean;
  50455. REFLECTIONMAP_PLANAR: boolean;
  50456. REFLECTIONMAP_CUBIC: boolean;
  50457. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  50458. REFLECTIONMAP_PROJECTION: boolean;
  50459. REFLECTIONMAP_SKYBOX: boolean;
  50460. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  50461. REFLECTIONMAP_EXPLICIT: boolean;
  50462. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  50463. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  50464. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  50465. INVERTCUBICMAP: boolean;
  50466. USESPHERICALFROMREFLECTIONMAP: boolean;
  50467. USEIRRADIANCEMAP: boolean;
  50468. SPHERICAL_HARMONICS: boolean;
  50469. USESPHERICALINVERTEX: boolean;
  50470. REFLECTIONMAP_OPPOSITEZ: boolean;
  50471. LODINREFLECTIONALPHA: boolean;
  50472. GAMMAREFLECTION: boolean;
  50473. RGBDREFLECTION: boolean;
  50474. LINEARSPECULARREFLECTION: boolean;
  50475. RADIANCEOCCLUSION: boolean;
  50476. HORIZONOCCLUSION: boolean;
  50477. INSTANCES: boolean;
  50478. NUM_BONE_INFLUENCERS: number;
  50479. BonesPerMesh: number;
  50480. BONETEXTURE: boolean;
  50481. NONUNIFORMSCALING: boolean;
  50482. MORPHTARGETS: boolean;
  50483. MORPHTARGETS_NORMAL: boolean;
  50484. MORPHTARGETS_TANGENT: boolean;
  50485. MORPHTARGETS_UV: boolean;
  50486. NUM_MORPH_INFLUENCERS: number;
  50487. IMAGEPROCESSING: boolean;
  50488. VIGNETTE: boolean;
  50489. VIGNETTEBLENDMODEMULTIPLY: boolean;
  50490. VIGNETTEBLENDMODEOPAQUE: boolean;
  50491. TONEMAPPING: boolean;
  50492. TONEMAPPING_ACES: boolean;
  50493. CONTRAST: boolean;
  50494. COLORCURVES: boolean;
  50495. COLORGRADING: boolean;
  50496. COLORGRADING3D: boolean;
  50497. SAMPLER3DGREENDEPTH: boolean;
  50498. SAMPLER3DBGRMAP: boolean;
  50499. IMAGEPROCESSINGPOSTPROCESS: boolean;
  50500. EXPOSURE: boolean;
  50501. MULTIVIEW: boolean;
  50502. USEPHYSICALLIGHTFALLOFF: boolean;
  50503. USEGLTFLIGHTFALLOFF: boolean;
  50504. TWOSIDEDLIGHTING: boolean;
  50505. SHADOWFLOAT: boolean;
  50506. CLIPPLANE: boolean;
  50507. CLIPPLANE2: boolean;
  50508. CLIPPLANE3: boolean;
  50509. CLIPPLANE4: boolean;
  50510. POINTSIZE: boolean;
  50511. FOG: boolean;
  50512. LOGARITHMICDEPTH: boolean;
  50513. FORCENORMALFORWARD: boolean;
  50514. SPECULARAA: boolean;
  50515. CLEARCOAT: boolean;
  50516. CLEARCOAT_DEFAULTIOR: boolean;
  50517. CLEARCOAT_TEXTURE: boolean;
  50518. CLEARCOAT_TEXTUREDIRECTUV: number;
  50519. CLEARCOAT_BUMP: boolean;
  50520. CLEARCOAT_BUMPDIRECTUV: number;
  50521. CLEARCOAT_TINT: boolean;
  50522. CLEARCOAT_TINT_TEXTURE: boolean;
  50523. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  50524. ANISOTROPIC: boolean;
  50525. ANISOTROPIC_TEXTURE: boolean;
  50526. ANISOTROPIC_TEXTUREDIRECTUV: number;
  50527. BRDF_V_HEIGHT_CORRELATED: boolean;
  50528. MS_BRDF_ENERGY_CONSERVATION: boolean;
  50529. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  50530. SHEEN: boolean;
  50531. SHEEN_TEXTURE: boolean;
  50532. SHEEN_TEXTUREDIRECTUV: number;
  50533. SHEEN_LINKWITHALBEDO: boolean;
  50534. SUBSURFACE: boolean;
  50535. SS_REFRACTION: boolean;
  50536. SS_TRANSLUCENCY: boolean;
  50537. SS_SCATERRING: boolean;
  50538. SS_THICKNESSANDMASK_TEXTURE: boolean;
  50539. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  50540. SS_REFRACTIONMAP_3D: boolean;
  50541. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  50542. SS_LODINREFRACTIONALPHA: boolean;
  50543. SS_GAMMAREFRACTION: boolean;
  50544. SS_RGBDREFRACTION: boolean;
  50545. SS_LINEARSPECULARREFRACTION: boolean;
  50546. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  50547. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  50548. UNLIT: boolean;
  50549. DEBUGMODE: number;
  50550. /**
  50551. * Initializes the PBR Material defines.
  50552. */
  50553. constructor();
  50554. /**
  50555. * Resets the PBR Material defines.
  50556. */
  50557. reset(): void;
  50558. }
  50559. /**
  50560. * The Physically based material base class of BJS.
  50561. *
  50562. * This offers the main features of a standard PBR material.
  50563. * For more information, please refer to the documentation :
  50564. * https://doc.babylonjs.com/how_to/physically_based_rendering
  50565. */
  50566. export abstract class PBRBaseMaterial extends PushMaterial {
  50567. /**
  50568. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  50569. */
  50570. static readonly PBRMATERIAL_OPAQUE: number;
  50571. /**
  50572. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  50573. */
  50574. static readonly PBRMATERIAL_ALPHATEST: number;
  50575. /**
  50576. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  50577. */
  50578. static readonly PBRMATERIAL_ALPHABLEND: number;
  50579. /**
  50580. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  50581. * They are also discarded below the alpha cutoff threshold to improve performances.
  50582. */
  50583. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  50584. /**
  50585. * Defines the default value of how much AO map is occluding the analytical lights
  50586. * (point spot...).
  50587. */
  50588. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  50589. /**
  50590. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  50591. */
  50592. static readonly LIGHTFALLOFF_PHYSICAL: number;
  50593. /**
  50594. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  50595. * to enhance interoperability with other engines.
  50596. */
  50597. static readonly LIGHTFALLOFF_GLTF: number;
  50598. /**
  50599. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  50600. * to enhance interoperability with other materials.
  50601. */
  50602. static readonly LIGHTFALLOFF_STANDARD: number;
  50603. /**
  50604. * Intensity of the direct lights e.g. the four lights available in your scene.
  50605. * This impacts both the direct diffuse and specular highlights.
  50606. */
  50607. protected _directIntensity: number;
  50608. /**
  50609. * Intensity of the emissive part of the material.
  50610. * This helps controlling the emissive effect without modifying the emissive color.
  50611. */
  50612. protected _emissiveIntensity: number;
  50613. /**
  50614. * Intensity of the environment e.g. how much the environment will light the object
  50615. * either through harmonics for rough material or through the refelction for shiny ones.
  50616. */
  50617. protected _environmentIntensity: number;
  50618. /**
  50619. * This is a special control allowing the reduction of the specular highlights coming from the
  50620. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  50621. */
  50622. protected _specularIntensity: number;
  50623. /**
  50624. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  50625. */
  50626. private _lightingInfos;
  50627. /**
  50628. * Debug Control allowing disabling the bump map on this material.
  50629. */
  50630. protected _disableBumpMap: boolean;
  50631. /**
  50632. * AKA Diffuse Texture in standard nomenclature.
  50633. */
  50634. protected _albedoTexture: Nullable<BaseTexture>;
  50635. /**
  50636. * AKA Occlusion Texture in other nomenclature.
  50637. */
  50638. protected _ambientTexture: Nullable<BaseTexture>;
  50639. /**
  50640. * AKA Occlusion Texture Intensity in other nomenclature.
  50641. */
  50642. protected _ambientTextureStrength: number;
  50643. /**
  50644. * Defines how much the AO map is occluding the analytical lights (point spot...).
  50645. * 1 means it completely occludes it
  50646. * 0 mean it has no impact
  50647. */
  50648. protected _ambientTextureImpactOnAnalyticalLights: number;
  50649. /**
  50650. * Stores the alpha values in a texture.
  50651. */
  50652. protected _opacityTexture: Nullable<BaseTexture>;
  50653. /**
  50654. * Stores the reflection values in a texture.
  50655. */
  50656. protected _reflectionTexture: Nullable<BaseTexture>;
  50657. /**
  50658. * Stores the emissive values in a texture.
  50659. */
  50660. protected _emissiveTexture: Nullable<BaseTexture>;
  50661. /**
  50662. * AKA Specular texture in other nomenclature.
  50663. */
  50664. protected _reflectivityTexture: Nullable<BaseTexture>;
  50665. /**
  50666. * Used to switch from specular/glossiness to metallic/roughness workflow.
  50667. */
  50668. protected _metallicTexture: Nullable<BaseTexture>;
  50669. /**
  50670. * Specifies the metallic scalar of the metallic/roughness workflow.
  50671. * Can also be used to scale the metalness values of the metallic texture.
  50672. */
  50673. protected _metallic: Nullable<number>;
  50674. /**
  50675. * Specifies the roughness scalar of the metallic/roughness workflow.
  50676. * Can also be used to scale the roughness values of the metallic texture.
  50677. */
  50678. protected _roughness: Nullable<number>;
  50679. /**
  50680. * Specifies the an F0 factor to help configuring the material F0.
  50681. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  50682. * to 0.5 the previously hard coded value stays the same.
  50683. * Can also be used to scale the F0 values of the metallic texture.
  50684. */
  50685. protected _metallicF0Factor: number;
  50686. /**
  50687. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  50688. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  50689. * your expectation as it multiplies with the texture data.
  50690. */
  50691. protected _useMetallicF0FactorFromMetallicTexture: boolean;
  50692. /**
  50693. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  50694. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  50695. */
  50696. protected _microSurfaceTexture: Nullable<BaseTexture>;
  50697. /**
  50698. * Stores surface normal data used to displace a mesh in a texture.
  50699. */
  50700. protected _bumpTexture: Nullable<BaseTexture>;
  50701. /**
  50702. * Stores the pre-calculated light information of a mesh in a texture.
  50703. */
  50704. protected _lightmapTexture: Nullable<BaseTexture>;
  50705. /**
  50706. * The color of a material in ambient lighting.
  50707. */
  50708. protected _ambientColor: Color3;
  50709. /**
  50710. * AKA Diffuse Color in other nomenclature.
  50711. */
  50712. protected _albedoColor: Color3;
  50713. /**
  50714. * AKA Specular Color in other nomenclature.
  50715. */
  50716. protected _reflectivityColor: Color3;
  50717. /**
  50718. * The color applied when light is reflected from a material.
  50719. */
  50720. protected _reflectionColor: Color3;
  50721. /**
  50722. * The color applied when light is emitted from a material.
  50723. */
  50724. protected _emissiveColor: Color3;
  50725. /**
  50726. * AKA Glossiness in other nomenclature.
  50727. */
  50728. protected _microSurface: number;
  50729. /**
  50730. * Specifies that the material will use the light map as a show map.
  50731. */
  50732. protected _useLightmapAsShadowmap: boolean;
  50733. /**
  50734. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  50735. * makes the reflect vector face the model (under horizon).
  50736. */
  50737. protected _useHorizonOcclusion: boolean;
  50738. /**
  50739. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  50740. * too much the area relying on ambient texture to define their ambient occlusion.
  50741. */
  50742. protected _useRadianceOcclusion: boolean;
  50743. /**
  50744. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  50745. */
  50746. protected _useAlphaFromAlbedoTexture: boolean;
  50747. /**
  50748. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  50749. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  50750. */
  50751. protected _useSpecularOverAlpha: boolean;
  50752. /**
  50753. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  50754. */
  50755. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  50756. /**
  50757. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  50758. */
  50759. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  50760. /**
  50761. * Specifies if the metallic texture contains the roughness information in its green channel.
  50762. */
  50763. protected _useRoughnessFromMetallicTextureGreen: boolean;
  50764. /**
  50765. * Specifies if the metallic texture contains the metallness information in its blue channel.
  50766. */
  50767. protected _useMetallnessFromMetallicTextureBlue: boolean;
  50768. /**
  50769. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  50770. */
  50771. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  50772. /**
  50773. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  50774. */
  50775. protected _useAmbientInGrayScale: boolean;
  50776. /**
  50777. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  50778. * The material will try to infer what glossiness each pixel should be.
  50779. */
  50780. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  50781. /**
  50782. * Defines the falloff type used in this material.
  50783. * It by default is Physical.
  50784. */
  50785. protected _lightFalloff: number;
  50786. /**
  50787. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  50788. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  50789. */
  50790. protected _useRadianceOverAlpha: boolean;
  50791. /**
  50792. * Allows using an object space normal map (instead of tangent space).
  50793. */
  50794. protected _useObjectSpaceNormalMap: boolean;
  50795. /**
  50796. * Allows using the bump map in parallax mode.
  50797. */
  50798. protected _useParallax: boolean;
  50799. /**
  50800. * Allows using the bump map in parallax occlusion mode.
  50801. */
  50802. protected _useParallaxOcclusion: boolean;
  50803. /**
  50804. * Controls the scale bias of the parallax mode.
  50805. */
  50806. protected _parallaxScaleBias: number;
  50807. /**
  50808. * If sets to true, disables all the lights affecting the material.
  50809. */
  50810. protected _disableLighting: boolean;
  50811. /**
  50812. * Number of Simultaneous lights allowed on the material.
  50813. */
  50814. protected _maxSimultaneousLights: number;
  50815. /**
  50816. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  50817. */
  50818. protected _invertNormalMapX: boolean;
  50819. /**
  50820. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  50821. */
  50822. protected _invertNormalMapY: boolean;
  50823. /**
  50824. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  50825. */
  50826. protected _twoSidedLighting: boolean;
  50827. /**
  50828. * Defines the alpha limits in alpha test mode.
  50829. */
  50830. protected _alphaCutOff: number;
  50831. /**
  50832. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  50833. */
  50834. protected _forceAlphaTest: boolean;
  50835. /**
  50836. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  50837. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  50838. */
  50839. protected _useAlphaFresnel: boolean;
  50840. /**
  50841. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  50842. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  50843. */
  50844. protected _useLinearAlphaFresnel: boolean;
  50845. /**
  50846. * The transparency mode of the material.
  50847. */
  50848. protected _transparencyMode: Nullable<number>;
  50849. /**
  50850. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  50851. * from cos thetav and roughness:
  50852. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  50853. */
  50854. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  50855. /**
  50856. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  50857. */
  50858. protected _forceIrradianceInFragment: boolean;
  50859. /**
  50860. * Force normal to face away from face.
  50861. */
  50862. protected _forceNormalForward: boolean;
  50863. /**
  50864. * Enables specular anti aliasing in the PBR shader.
  50865. * It will both interacts on the Geometry for analytical and IBL lighting.
  50866. * It also prefilter the roughness map based on the bump values.
  50867. */
  50868. protected _enableSpecularAntiAliasing: boolean;
  50869. /**
  50870. * Default configuration related to image processing available in the PBR Material.
  50871. */
  50872. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  50873. /**
  50874. * Keep track of the image processing observer to allow dispose and replace.
  50875. */
  50876. private _imageProcessingObserver;
  50877. /**
  50878. * Attaches a new image processing configuration to the PBR Material.
  50879. * @param configuration
  50880. */
  50881. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  50882. /**
  50883. * Stores the available render targets.
  50884. */
  50885. private _renderTargets;
  50886. /**
  50887. * Sets the global ambient color for the material used in lighting calculations.
  50888. */
  50889. private _globalAmbientColor;
  50890. /**
  50891. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  50892. */
  50893. private _useLogarithmicDepth;
  50894. /**
  50895. * If set to true, no lighting calculations will be applied.
  50896. */
  50897. private _unlit;
  50898. private _debugMode;
  50899. /**
  50900. * @hidden
  50901. * This is reserved for the inspector.
  50902. * Defines the material debug mode.
  50903. * It helps seeing only some components of the material while troubleshooting.
  50904. */
  50905. debugMode: number;
  50906. /**
  50907. * @hidden
  50908. * This is reserved for the inspector.
  50909. * Specify from where on screen the debug mode should start.
  50910. * The value goes from -1 (full screen) to 1 (not visible)
  50911. * It helps with side by side comparison against the final render
  50912. * This defaults to -1
  50913. */
  50914. private debugLimit;
  50915. /**
  50916. * @hidden
  50917. * This is reserved for the inspector.
  50918. * As the default viewing range might not be enough (if the ambient is really small for instance)
  50919. * You can use the factor to better multiply the final value.
  50920. */
  50921. private debugFactor;
  50922. /**
  50923. * Defines the clear coat layer parameters for the material.
  50924. */
  50925. readonly clearCoat: PBRClearCoatConfiguration;
  50926. /**
  50927. * Defines the anisotropic parameters for the material.
  50928. */
  50929. readonly anisotropy: PBRAnisotropicConfiguration;
  50930. /**
  50931. * Defines the BRDF parameters for the material.
  50932. */
  50933. readonly brdf: PBRBRDFConfiguration;
  50934. /**
  50935. * Defines the Sheen parameters for the material.
  50936. */
  50937. readonly sheen: PBRSheenConfiguration;
  50938. /**
  50939. * Defines the SubSurface parameters for the material.
  50940. */
  50941. readonly subSurface: PBRSubSurfaceConfiguration;
  50942. /**
  50943. * Custom callback helping to override the default shader used in the material.
  50944. */
  50945. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  50946. protected _rebuildInParallel: boolean;
  50947. /**
  50948. * Instantiates a new PBRMaterial instance.
  50949. *
  50950. * @param name The material name
  50951. * @param scene The scene the material will be use in.
  50952. */
  50953. constructor(name: string, scene: Scene);
  50954. /**
  50955. * Gets a boolean indicating that current material needs to register RTT
  50956. */
  50957. readonly hasRenderTargetTextures: boolean;
  50958. /**
  50959. * Gets the name of the material class.
  50960. */
  50961. getClassName(): string;
  50962. /**
  50963. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  50964. */
  50965. /**
  50966. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  50967. */
  50968. useLogarithmicDepth: boolean;
  50969. /**
  50970. * Gets the current transparency mode.
  50971. */
  50972. /**
  50973. * Sets the transparency mode of the material.
  50974. *
  50975. * | Value | Type | Description |
  50976. * | ----- | ----------------------------------- | ----------- |
  50977. * | 0 | OPAQUE | |
  50978. * | 1 | ALPHATEST | |
  50979. * | 2 | ALPHABLEND | |
  50980. * | 3 | ALPHATESTANDBLEND | |
  50981. *
  50982. */
  50983. transparencyMode: Nullable<number>;
  50984. /**
  50985. * Returns true if alpha blending should be disabled.
  50986. */
  50987. private readonly _disableAlphaBlending;
  50988. /**
  50989. * Specifies whether or not this material should be rendered in alpha blend mode.
  50990. */
  50991. needAlphaBlending(): boolean;
  50992. /**
  50993. * Specifies if the mesh will require alpha blending.
  50994. * @param mesh - BJS mesh.
  50995. */
  50996. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  50997. /**
  50998. * Specifies whether or not this material should be rendered in alpha test mode.
  50999. */
  51000. needAlphaTesting(): boolean;
  51001. /**
  51002. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  51003. */
  51004. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  51005. /**
  51006. * Gets the texture used for the alpha test.
  51007. */
  51008. getAlphaTestTexture(): Nullable<BaseTexture>;
  51009. /**
  51010. * Specifies that the submesh is ready to be used.
  51011. * @param mesh - BJS mesh.
  51012. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  51013. * @param useInstances - Specifies that instances should be used.
  51014. * @returns - boolean indicating that the submesh is ready or not.
  51015. */
  51016. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  51017. /**
  51018. * Specifies if the material uses metallic roughness workflow.
  51019. * @returns boolean specifiying if the material uses metallic roughness workflow.
  51020. */
  51021. isMetallicWorkflow(): boolean;
  51022. private _prepareEffect;
  51023. private _prepareDefines;
  51024. /**
  51025. * Force shader compilation
  51026. */
  51027. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  51028. /**
  51029. * Initializes the uniform buffer layout for the shader.
  51030. */
  51031. buildUniformLayout(): void;
  51032. /**
  51033. * Unbinds the material from the mesh
  51034. */
  51035. unbind(): void;
  51036. /**
  51037. * Binds the submesh data.
  51038. * @param world - The world matrix.
  51039. * @param mesh - The BJS mesh.
  51040. * @param subMesh - A submesh of the BJS mesh.
  51041. */
  51042. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  51043. /**
  51044. * Returns the animatable textures.
  51045. * @returns - Array of animatable textures.
  51046. */
  51047. getAnimatables(): IAnimatable[];
  51048. /**
  51049. * Returns the texture used for reflections.
  51050. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  51051. */
  51052. private _getReflectionTexture;
  51053. /**
  51054. * Returns an array of the actively used textures.
  51055. * @returns - Array of BaseTextures
  51056. */
  51057. getActiveTextures(): BaseTexture[];
  51058. /**
  51059. * Checks to see if a texture is used in the material.
  51060. * @param texture - Base texture to use.
  51061. * @returns - Boolean specifying if a texture is used in the material.
  51062. */
  51063. hasTexture(texture: BaseTexture): boolean;
  51064. /**
  51065. * Disposes the resources of the material.
  51066. * @param forceDisposeEffect - Forces the disposal of effects.
  51067. * @param forceDisposeTextures - Forces the disposal of all textures.
  51068. */
  51069. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  51070. }
  51071. }
  51072. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  51073. import { Nullable } from "babylonjs/types";
  51074. import { Scene } from "babylonjs/scene";
  51075. import { Color3 } from "babylonjs/Maths/math.color";
  51076. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  51077. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  51078. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51079. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  51080. /**
  51081. * The Physically based material of BJS.
  51082. *
  51083. * This offers the main features of a standard PBR material.
  51084. * For more information, please refer to the documentation :
  51085. * https://doc.babylonjs.com/how_to/physically_based_rendering
  51086. */
  51087. export class PBRMaterial extends PBRBaseMaterial {
  51088. /**
  51089. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  51090. */
  51091. static readonly PBRMATERIAL_OPAQUE: number;
  51092. /**
  51093. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  51094. */
  51095. static readonly PBRMATERIAL_ALPHATEST: number;
  51096. /**
  51097. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  51098. */
  51099. static readonly PBRMATERIAL_ALPHABLEND: number;
  51100. /**
  51101. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  51102. * They are also discarded below the alpha cutoff threshold to improve performances.
  51103. */
  51104. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  51105. /**
  51106. * Defines the default value of how much AO map is occluding the analytical lights
  51107. * (point spot...).
  51108. */
  51109. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  51110. /**
  51111. * Intensity of the direct lights e.g. the four lights available in your scene.
  51112. * This impacts both the direct diffuse and specular highlights.
  51113. */
  51114. directIntensity: number;
  51115. /**
  51116. * Intensity of the emissive part of the material.
  51117. * This helps controlling the emissive effect without modifying the emissive color.
  51118. */
  51119. emissiveIntensity: number;
  51120. /**
  51121. * Intensity of the environment e.g. how much the environment will light the object
  51122. * either through harmonics for rough material or through the refelction for shiny ones.
  51123. */
  51124. environmentIntensity: number;
  51125. /**
  51126. * This is a special control allowing the reduction of the specular highlights coming from the
  51127. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  51128. */
  51129. specularIntensity: number;
  51130. /**
  51131. * Debug Control allowing disabling the bump map on this material.
  51132. */
  51133. disableBumpMap: boolean;
  51134. /**
  51135. * AKA Diffuse Texture in standard nomenclature.
  51136. */
  51137. albedoTexture: BaseTexture;
  51138. /**
  51139. * AKA Occlusion Texture in other nomenclature.
  51140. */
  51141. ambientTexture: BaseTexture;
  51142. /**
  51143. * AKA Occlusion Texture Intensity in other nomenclature.
  51144. */
  51145. ambientTextureStrength: number;
  51146. /**
  51147. * Defines how much the AO map is occluding the analytical lights (point spot...).
  51148. * 1 means it completely occludes it
  51149. * 0 mean it has no impact
  51150. */
  51151. ambientTextureImpactOnAnalyticalLights: number;
  51152. /**
  51153. * Stores the alpha values in a texture.
  51154. */
  51155. opacityTexture: BaseTexture;
  51156. /**
  51157. * Stores the reflection values in a texture.
  51158. */
  51159. reflectionTexture: Nullable<BaseTexture>;
  51160. /**
  51161. * Stores the emissive values in a texture.
  51162. */
  51163. emissiveTexture: BaseTexture;
  51164. /**
  51165. * AKA Specular texture in other nomenclature.
  51166. */
  51167. reflectivityTexture: BaseTexture;
  51168. /**
  51169. * Used to switch from specular/glossiness to metallic/roughness workflow.
  51170. */
  51171. metallicTexture: BaseTexture;
  51172. /**
  51173. * Specifies the metallic scalar of the metallic/roughness workflow.
  51174. * Can also be used to scale the metalness values of the metallic texture.
  51175. */
  51176. metallic: Nullable<number>;
  51177. /**
  51178. * Specifies the roughness scalar of the metallic/roughness workflow.
  51179. * Can also be used to scale the roughness values of the metallic texture.
  51180. */
  51181. roughness: Nullable<number>;
  51182. /**
  51183. * Specifies the an F0 factor to help configuring the material F0.
  51184. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  51185. * to 0.5 the previously hard coded value stays the same.
  51186. * Can also be used to scale the F0 values of the metallic texture.
  51187. */
  51188. metallicF0Factor: number;
  51189. /**
  51190. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  51191. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  51192. * your expectation as it multiplies with the texture data.
  51193. */
  51194. useMetallicF0FactorFromMetallicTexture: boolean;
  51195. /**
  51196. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  51197. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  51198. */
  51199. microSurfaceTexture: BaseTexture;
  51200. /**
  51201. * Stores surface normal data used to displace a mesh in a texture.
  51202. */
  51203. bumpTexture: BaseTexture;
  51204. /**
  51205. * Stores the pre-calculated light information of a mesh in a texture.
  51206. */
  51207. lightmapTexture: BaseTexture;
  51208. /**
  51209. * Stores the refracted light information in a texture.
  51210. */
  51211. refractionTexture: Nullable<BaseTexture>;
  51212. /**
  51213. * The color of a material in ambient lighting.
  51214. */
  51215. ambientColor: Color3;
  51216. /**
  51217. * AKA Diffuse Color in other nomenclature.
  51218. */
  51219. albedoColor: Color3;
  51220. /**
  51221. * AKA Specular Color in other nomenclature.
  51222. */
  51223. reflectivityColor: Color3;
  51224. /**
  51225. * The color reflected from the material.
  51226. */
  51227. reflectionColor: Color3;
  51228. /**
  51229. * The color emitted from the material.
  51230. */
  51231. emissiveColor: Color3;
  51232. /**
  51233. * AKA Glossiness in other nomenclature.
  51234. */
  51235. microSurface: number;
  51236. /**
  51237. * source material index of refraction (IOR)' / 'destination material IOR.
  51238. */
  51239. indexOfRefraction: number;
  51240. /**
  51241. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  51242. */
  51243. invertRefractionY: boolean;
  51244. /**
  51245. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  51246. * Materials half opaque for instance using refraction could benefit from this control.
  51247. */
  51248. linkRefractionWithTransparency: boolean;
  51249. /**
  51250. * If true, the light map contains occlusion information instead of lighting info.
  51251. */
  51252. useLightmapAsShadowmap: boolean;
  51253. /**
  51254. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  51255. */
  51256. useAlphaFromAlbedoTexture: boolean;
  51257. /**
  51258. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  51259. */
  51260. forceAlphaTest: boolean;
  51261. /**
  51262. * Defines the alpha limits in alpha test mode.
  51263. */
  51264. alphaCutOff: number;
  51265. /**
  51266. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  51267. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  51268. */
  51269. useSpecularOverAlpha: boolean;
  51270. /**
  51271. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  51272. */
  51273. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  51274. /**
  51275. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  51276. */
  51277. useRoughnessFromMetallicTextureAlpha: boolean;
  51278. /**
  51279. * Specifies if the metallic texture contains the roughness information in its green channel.
  51280. */
  51281. useRoughnessFromMetallicTextureGreen: boolean;
  51282. /**
  51283. * Specifies if the metallic texture contains the metallness information in its blue channel.
  51284. */
  51285. useMetallnessFromMetallicTextureBlue: boolean;
  51286. /**
  51287. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  51288. */
  51289. useAmbientOcclusionFromMetallicTextureRed: boolean;
  51290. /**
  51291. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  51292. */
  51293. useAmbientInGrayScale: boolean;
  51294. /**
  51295. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  51296. * The material will try to infer what glossiness each pixel should be.
  51297. */
  51298. useAutoMicroSurfaceFromReflectivityMap: boolean;
  51299. /**
  51300. * BJS is using an harcoded light falloff based on a manually sets up range.
  51301. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  51302. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  51303. */
  51304. /**
  51305. * BJS is using an harcoded light falloff based on a manually sets up range.
  51306. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  51307. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  51308. */
  51309. usePhysicalLightFalloff: boolean;
  51310. /**
  51311. * In order to support the falloff compatibility with gltf, a special mode has been added
  51312. * to reproduce the gltf light falloff.
  51313. */
  51314. /**
  51315. * In order to support the falloff compatibility with gltf, a special mode has been added
  51316. * to reproduce the gltf light falloff.
  51317. */
  51318. useGLTFLightFalloff: boolean;
  51319. /**
  51320. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  51321. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  51322. */
  51323. useRadianceOverAlpha: boolean;
  51324. /**
  51325. * Allows using an object space normal map (instead of tangent space).
  51326. */
  51327. useObjectSpaceNormalMap: boolean;
  51328. /**
  51329. * Allows using the bump map in parallax mode.
  51330. */
  51331. useParallax: boolean;
  51332. /**
  51333. * Allows using the bump map in parallax occlusion mode.
  51334. */
  51335. useParallaxOcclusion: boolean;
  51336. /**
  51337. * Controls the scale bias of the parallax mode.
  51338. */
  51339. parallaxScaleBias: number;
  51340. /**
  51341. * If sets to true, disables all the lights affecting the material.
  51342. */
  51343. disableLighting: boolean;
  51344. /**
  51345. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  51346. */
  51347. forceIrradianceInFragment: boolean;
  51348. /**
  51349. * Number of Simultaneous lights allowed on the material.
  51350. */
  51351. maxSimultaneousLights: number;
  51352. /**
  51353. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  51354. */
  51355. invertNormalMapX: boolean;
  51356. /**
  51357. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  51358. */
  51359. invertNormalMapY: boolean;
  51360. /**
  51361. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  51362. */
  51363. twoSidedLighting: boolean;
  51364. /**
  51365. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  51366. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  51367. */
  51368. useAlphaFresnel: boolean;
  51369. /**
  51370. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  51371. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  51372. */
  51373. useLinearAlphaFresnel: boolean;
  51374. /**
  51375. * Let user defines the brdf lookup texture used for IBL.
  51376. * A default 8bit version is embedded but you could point at :
  51377. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  51378. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  51379. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  51380. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  51381. */
  51382. environmentBRDFTexture: Nullable<BaseTexture>;
  51383. /**
  51384. * Force normal to face away from face.
  51385. */
  51386. forceNormalForward: boolean;
  51387. /**
  51388. * Enables specular anti aliasing in the PBR shader.
  51389. * It will both interacts on the Geometry for analytical and IBL lighting.
  51390. * It also prefilter the roughness map based on the bump values.
  51391. */
  51392. enableSpecularAntiAliasing: boolean;
  51393. /**
  51394. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  51395. * makes the reflect vector face the model (under horizon).
  51396. */
  51397. useHorizonOcclusion: boolean;
  51398. /**
  51399. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  51400. * too much the area relying on ambient texture to define their ambient occlusion.
  51401. */
  51402. useRadianceOcclusion: boolean;
  51403. /**
  51404. * If set to true, no lighting calculations will be applied.
  51405. */
  51406. unlit: boolean;
  51407. /**
  51408. * Gets the image processing configuration used either in this material.
  51409. */
  51410. /**
  51411. * Sets the Default image processing configuration used either in the this material.
  51412. *
  51413. * If sets to null, the scene one is in use.
  51414. */
  51415. imageProcessingConfiguration: ImageProcessingConfiguration;
  51416. /**
  51417. * Gets wether the color curves effect is enabled.
  51418. */
  51419. /**
  51420. * Sets wether the color curves effect is enabled.
  51421. */
  51422. cameraColorCurvesEnabled: boolean;
  51423. /**
  51424. * Gets wether the color grading effect is enabled.
  51425. */
  51426. /**
  51427. * Gets wether the color grading effect is enabled.
  51428. */
  51429. cameraColorGradingEnabled: boolean;
  51430. /**
  51431. * Gets wether tonemapping is enabled or not.
  51432. */
  51433. /**
  51434. * Sets wether tonemapping is enabled or not
  51435. */
  51436. cameraToneMappingEnabled: boolean;
  51437. /**
  51438. * The camera exposure used on this material.
  51439. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  51440. * This corresponds to a photographic exposure.
  51441. */
  51442. /**
  51443. * The camera exposure used on this material.
  51444. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  51445. * This corresponds to a photographic exposure.
  51446. */
  51447. cameraExposure: number;
  51448. /**
  51449. * Gets The camera contrast used on this material.
  51450. */
  51451. /**
  51452. * Sets The camera contrast used on this material.
  51453. */
  51454. cameraContrast: number;
  51455. /**
  51456. * Gets the Color Grading 2D Lookup Texture.
  51457. */
  51458. /**
  51459. * Sets the Color Grading 2D Lookup Texture.
  51460. */
  51461. cameraColorGradingTexture: Nullable<BaseTexture>;
  51462. /**
  51463. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  51464. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  51465. * 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;
  51466. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  51467. */
  51468. /**
  51469. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  51470. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  51471. * 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;
  51472. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  51473. */
  51474. cameraColorCurves: Nullable<ColorCurves>;
  51475. /**
  51476. * Instantiates a new PBRMaterial instance.
  51477. *
  51478. * @param name The material name
  51479. * @param scene The scene the material will be use in.
  51480. */
  51481. constructor(name: string, scene: Scene);
  51482. /**
  51483. * Returns the name of this material class.
  51484. */
  51485. getClassName(): string;
  51486. /**
  51487. * Makes a duplicate of the current material.
  51488. * @param name - name to use for the new material.
  51489. */
  51490. clone(name: string): PBRMaterial;
  51491. /**
  51492. * Serializes this PBR Material.
  51493. * @returns - An object with the serialized material.
  51494. */
  51495. serialize(): any;
  51496. /**
  51497. * Parses a PBR Material from a serialized object.
  51498. * @param source - Serialized object.
  51499. * @param scene - BJS scene instance.
  51500. * @param rootUrl - url for the scene object
  51501. * @returns - PBRMaterial
  51502. */
  51503. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  51504. }
  51505. }
  51506. declare module "babylonjs/Misc/dds" {
  51507. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  51508. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  51509. import { Nullable } from "babylonjs/types";
  51510. import { Scene } from "babylonjs/scene";
  51511. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  51512. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  51513. /**
  51514. * Direct draw surface info
  51515. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  51516. */
  51517. export interface DDSInfo {
  51518. /**
  51519. * Width of the texture
  51520. */
  51521. width: number;
  51522. /**
  51523. * Width of the texture
  51524. */
  51525. height: number;
  51526. /**
  51527. * Number of Mipmaps for the texture
  51528. * @see https://en.wikipedia.org/wiki/Mipmap
  51529. */
  51530. mipmapCount: number;
  51531. /**
  51532. * If the textures format is a known fourCC format
  51533. * @see https://www.fourcc.org/
  51534. */
  51535. isFourCC: boolean;
  51536. /**
  51537. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  51538. */
  51539. isRGB: boolean;
  51540. /**
  51541. * If the texture is a lumincance format
  51542. */
  51543. isLuminance: boolean;
  51544. /**
  51545. * If this is a cube texture
  51546. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  51547. */
  51548. isCube: boolean;
  51549. /**
  51550. * If the texture is a compressed format eg. FOURCC_DXT1
  51551. */
  51552. isCompressed: boolean;
  51553. /**
  51554. * The dxgiFormat of the texture
  51555. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  51556. */
  51557. dxgiFormat: number;
  51558. /**
  51559. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  51560. */
  51561. textureType: number;
  51562. /**
  51563. * Sphericle polynomial created for the dds texture
  51564. */
  51565. sphericalPolynomial?: SphericalPolynomial;
  51566. }
  51567. /**
  51568. * Class used to provide DDS decompression tools
  51569. */
  51570. export class DDSTools {
  51571. /**
  51572. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  51573. */
  51574. static StoreLODInAlphaChannel: boolean;
  51575. /**
  51576. * Gets DDS information from an array buffer
  51577. * @param arrayBuffer defines the array buffer to read data from
  51578. * @returns the DDS information
  51579. */
  51580. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  51581. private static _FloatView;
  51582. private static _Int32View;
  51583. private static _ToHalfFloat;
  51584. private static _FromHalfFloat;
  51585. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  51586. private static _GetHalfFloatRGBAArrayBuffer;
  51587. private static _GetFloatRGBAArrayBuffer;
  51588. private static _GetFloatAsUIntRGBAArrayBuffer;
  51589. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  51590. private static _GetRGBAArrayBuffer;
  51591. private static _ExtractLongWordOrder;
  51592. private static _GetRGBArrayBuffer;
  51593. private static _GetLuminanceArrayBuffer;
  51594. /**
  51595. * Uploads DDS Levels to a Babylon Texture
  51596. * @hidden
  51597. */
  51598. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  51599. }
  51600. module "babylonjs/Engines/thinEngine" {
  51601. interface ThinEngine {
  51602. /**
  51603. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  51604. * @param rootUrl defines the url where the file to load is located
  51605. * @param scene defines the current scene
  51606. * @param lodScale defines scale to apply to the mip map selection
  51607. * @param lodOffset defines offset to apply to the mip map selection
  51608. * @param onLoad defines an optional callback raised when the texture is loaded
  51609. * @param onError defines an optional callback raised if there is an issue to load the texture
  51610. * @param format defines the format of the data
  51611. * @param forcedExtension defines the extension to use to pick the right loader
  51612. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  51613. * @returns the cube texture as an InternalTexture
  51614. */
  51615. 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;
  51616. }
  51617. }
  51618. }
  51619. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  51620. import { Nullable } from "babylonjs/types";
  51621. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  51622. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  51623. /**
  51624. * Implementation of the DDS Texture Loader.
  51625. * @hidden
  51626. */
  51627. export class _DDSTextureLoader implements IInternalTextureLoader {
  51628. /**
  51629. * Defines wether the loader supports cascade loading the different faces.
  51630. */
  51631. readonly supportCascades: boolean;
  51632. /**
  51633. * This returns if the loader support the current file information.
  51634. * @param extension defines the file extension of the file being loaded
  51635. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51636. * @param fallback defines the fallback internal texture if any
  51637. * @param isBase64 defines whether the texture is encoded as a base64
  51638. * @param isBuffer defines whether the texture data are stored as a buffer
  51639. * @returns true if the loader can load the specified file
  51640. */
  51641. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  51642. /**
  51643. * Transform the url before loading if required.
  51644. * @param rootUrl the url of the texture
  51645. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51646. * @returns the transformed texture
  51647. */
  51648. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  51649. /**
  51650. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  51651. * @param rootUrl the url of the texture
  51652. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51653. * @returns the fallback texture
  51654. */
  51655. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  51656. /**
  51657. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  51658. * @param data contains the texture data
  51659. * @param texture defines the BabylonJS internal texture
  51660. * @param createPolynomials will be true if polynomials have been requested
  51661. * @param onLoad defines the callback to trigger once the texture is ready
  51662. * @param onError defines the callback to trigger in case of error
  51663. */
  51664. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  51665. /**
  51666. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  51667. * @param data contains the texture data
  51668. * @param texture defines the BabylonJS internal texture
  51669. * @param callback defines the method to call once ready to upload
  51670. */
  51671. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  51672. }
  51673. }
  51674. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  51675. import { Nullable } from "babylonjs/types";
  51676. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  51677. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  51678. /**
  51679. * Implementation of the ENV Texture Loader.
  51680. * @hidden
  51681. */
  51682. export class _ENVTextureLoader implements IInternalTextureLoader {
  51683. /**
  51684. * Defines wether the loader supports cascade loading the different faces.
  51685. */
  51686. readonly supportCascades: boolean;
  51687. /**
  51688. * This returns if the loader support the current file information.
  51689. * @param extension defines the file extension of the file being loaded
  51690. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51691. * @param fallback defines the fallback internal texture if any
  51692. * @param isBase64 defines whether the texture is encoded as a base64
  51693. * @param isBuffer defines whether the texture data are stored as a buffer
  51694. * @returns true if the loader can load the specified file
  51695. */
  51696. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  51697. /**
  51698. * Transform the url before loading if required.
  51699. * @param rootUrl the url of the texture
  51700. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51701. * @returns the transformed texture
  51702. */
  51703. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  51704. /**
  51705. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  51706. * @param rootUrl the url of the texture
  51707. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51708. * @returns the fallback texture
  51709. */
  51710. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  51711. /**
  51712. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  51713. * @param data contains the texture data
  51714. * @param texture defines the BabylonJS internal texture
  51715. * @param createPolynomials will be true if polynomials have been requested
  51716. * @param onLoad defines the callback to trigger once the texture is ready
  51717. * @param onError defines the callback to trigger in case of error
  51718. */
  51719. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  51720. /**
  51721. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  51722. * @param data contains the texture data
  51723. * @param texture defines the BabylonJS internal texture
  51724. * @param callback defines the method to call once ready to upload
  51725. */
  51726. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  51727. }
  51728. }
  51729. declare module "babylonjs/Misc/khronosTextureContainer" {
  51730. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  51731. /**
  51732. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  51733. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  51734. */
  51735. export class KhronosTextureContainer {
  51736. /** contents of the KTX container file */
  51737. arrayBuffer: any;
  51738. private static HEADER_LEN;
  51739. private static COMPRESSED_2D;
  51740. private static COMPRESSED_3D;
  51741. private static TEX_2D;
  51742. private static TEX_3D;
  51743. /**
  51744. * Gets the openGL type
  51745. */
  51746. glType: number;
  51747. /**
  51748. * Gets the openGL type size
  51749. */
  51750. glTypeSize: number;
  51751. /**
  51752. * Gets the openGL format
  51753. */
  51754. glFormat: number;
  51755. /**
  51756. * Gets the openGL internal format
  51757. */
  51758. glInternalFormat: number;
  51759. /**
  51760. * Gets the base internal format
  51761. */
  51762. glBaseInternalFormat: number;
  51763. /**
  51764. * Gets image width in pixel
  51765. */
  51766. pixelWidth: number;
  51767. /**
  51768. * Gets image height in pixel
  51769. */
  51770. pixelHeight: number;
  51771. /**
  51772. * Gets image depth in pixels
  51773. */
  51774. pixelDepth: number;
  51775. /**
  51776. * Gets the number of array elements
  51777. */
  51778. numberOfArrayElements: number;
  51779. /**
  51780. * Gets the number of faces
  51781. */
  51782. numberOfFaces: number;
  51783. /**
  51784. * Gets the number of mipmap levels
  51785. */
  51786. numberOfMipmapLevels: number;
  51787. /**
  51788. * Gets the bytes of key value data
  51789. */
  51790. bytesOfKeyValueData: number;
  51791. /**
  51792. * Gets the load type
  51793. */
  51794. loadType: number;
  51795. /**
  51796. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  51797. */
  51798. isInvalid: boolean;
  51799. /**
  51800. * Creates a new KhronosTextureContainer
  51801. * @param arrayBuffer contents of the KTX container file
  51802. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  51803. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  51804. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  51805. */
  51806. constructor(
  51807. /** contents of the KTX container file */
  51808. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  51809. /**
  51810. * Uploads KTX content to a Babylon Texture.
  51811. * It is assumed that the texture has already been created & is currently bound
  51812. * @hidden
  51813. */
  51814. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  51815. private _upload2DCompressedLevels;
  51816. }
  51817. }
  51818. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  51819. import { Nullable } from "babylonjs/types";
  51820. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  51821. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  51822. /**
  51823. * Implementation of the KTX Texture Loader.
  51824. * @hidden
  51825. */
  51826. export class _KTXTextureLoader implements IInternalTextureLoader {
  51827. /**
  51828. * Defines wether the loader supports cascade loading the different faces.
  51829. */
  51830. readonly supportCascades: boolean;
  51831. /**
  51832. * This returns if the loader support the current file information.
  51833. * @param extension defines the file extension of the file being loaded
  51834. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51835. * @param fallback defines the fallback internal texture if any
  51836. * @param isBase64 defines whether the texture is encoded as a base64
  51837. * @param isBuffer defines whether the texture data are stored as a buffer
  51838. * @returns true if the loader can load the specified file
  51839. */
  51840. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  51841. /**
  51842. * Transform the url before loading if required.
  51843. * @param rootUrl the url of the texture
  51844. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51845. * @returns the transformed texture
  51846. */
  51847. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  51848. /**
  51849. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  51850. * @param rootUrl the url of the texture
  51851. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51852. * @returns the fallback texture
  51853. */
  51854. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  51855. /**
  51856. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  51857. * @param data contains the texture data
  51858. * @param texture defines the BabylonJS internal texture
  51859. * @param createPolynomials will be true if polynomials have been requested
  51860. * @param onLoad defines the callback to trigger once the texture is ready
  51861. * @param onError defines the callback to trigger in case of error
  51862. */
  51863. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  51864. /**
  51865. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  51866. * @param data contains the texture data
  51867. * @param texture defines the BabylonJS internal texture
  51868. * @param callback defines the method to call once ready to upload
  51869. */
  51870. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  51871. }
  51872. }
  51873. declare module "babylonjs/Helpers/sceneHelpers" {
  51874. import { Nullable } from "babylonjs/types";
  51875. import { Mesh } from "babylonjs/Meshes/mesh";
  51876. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51877. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  51878. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  51879. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  51880. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  51881. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  51882. import "babylonjs/Meshes/Builders/boxBuilder";
  51883. import { WebXRDefaultExperience, WebXRDefaultExperienceOptions } from "babylonjs/Cameras/XR/webXRDefaultExperience";
  51884. /** @hidden */
  51885. export var _forceSceneHelpersToBundle: boolean;
  51886. module "babylonjs/scene" {
  51887. interface Scene {
  51888. /**
  51889. * Creates a default light for the scene.
  51890. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  51891. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  51892. */
  51893. createDefaultLight(replace?: boolean): void;
  51894. /**
  51895. * Creates a default camera for the scene.
  51896. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  51897. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  51898. * @param replace has default false, when true replaces the active camera in the scene
  51899. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  51900. */
  51901. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  51902. /**
  51903. * Creates a default camera and a default light.
  51904. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  51905. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  51906. * @param replace has the default false, when true replaces the active camera/light in the scene
  51907. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  51908. */
  51909. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  51910. /**
  51911. * Creates a new sky box
  51912. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  51913. * @param environmentTexture defines the texture to use as environment texture
  51914. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  51915. * @param scale defines the overall scale of the skybox
  51916. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  51917. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  51918. * @returns a new mesh holding the sky box
  51919. */
  51920. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  51921. /**
  51922. * Creates a new environment
  51923. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  51924. * @param options defines the options you can use to configure the environment
  51925. * @returns the new EnvironmentHelper
  51926. */
  51927. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  51928. /**
  51929. * Creates a new VREXperienceHelper
  51930. * @see http://doc.babylonjs.com/how_to/webvr_helper
  51931. * @param webVROptions defines the options used to create the new VREXperienceHelper
  51932. * @returns a new VREXperienceHelper
  51933. */
  51934. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  51935. /**
  51936. * Creates a new WebXRDefaultExperience
  51937. * @see http://doc.babylonjs.com/how_to/webxr
  51938. * @param options experience options
  51939. * @returns a promise for a new WebXRDefaultExperience
  51940. */
  51941. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  51942. }
  51943. }
  51944. }
  51945. declare module "babylonjs/Helpers/videoDome" {
  51946. import { Scene } from "babylonjs/scene";
  51947. import { TransformNode } from "babylonjs/Meshes/transformNode";
  51948. import { Mesh } from "babylonjs/Meshes/mesh";
  51949. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  51950. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  51951. import "babylonjs/Meshes/Builders/sphereBuilder";
  51952. /**
  51953. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  51954. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  51955. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  51956. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  51957. */
  51958. export class VideoDome extends TransformNode {
  51959. /**
  51960. * Define the video source as a Monoscopic panoramic 360 video.
  51961. */
  51962. static readonly MODE_MONOSCOPIC: number;
  51963. /**
  51964. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  51965. */
  51966. static readonly MODE_TOPBOTTOM: number;
  51967. /**
  51968. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  51969. */
  51970. static readonly MODE_SIDEBYSIDE: number;
  51971. private _halfDome;
  51972. private _useDirectMapping;
  51973. /**
  51974. * The video texture being displayed on the sphere
  51975. */
  51976. protected _videoTexture: VideoTexture;
  51977. /**
  51978. * Gets the video texture being displayed on the sphere
  51979. */
  51980. readonly videoTexture: VideoTexture;
  51981. /**
  51982. * The skybox material
  51983. */
  51984. protected _material: BackgroundMaterial;
  51985. /**
  51986. * The surface used for the skybox
  51987. */
  51988. protected _mesh: Mesh;
  51989. /**
  51990. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  51991. */
  51992. private _halfDomeMask;
  51993. /**
  51994. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  51995. * Also see the options.resolution property.
  51996. */
  51997. fovMultiplier: number;
  51998. private _videoMode;
  51999. /**
  52000. * Gets or set the current video mode for the video. It can be:
  52001. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  52002. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  52003. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  52004. */
  52005. videoMode: number;
  52006. /**
  52007. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  52008. *
  52009. */
  52010. /**
  52011. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  52012. */
  52013. halfDome: boolean;
  52014. /**
  52015. * Oberserver used in Stereoscopic VR Mode.
  52016. */
  52017. private _onBeforeCameraRenderObserver;
  52018. /**
  52019. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  52020. * @param name Element's name, child elements will append suffixes for their own names.
  52021. * @param urlsOrVideo defines the url(s) or the video element to use
  52022. * @param options An object containing optional or exposed sub element properties
  52023. */
  52024. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  52025. resolution?: number;
  52026. clickToPlay?: boolean;
  52027. autoPlay?: boolean;
  52028. loop?: boolean;
  52029. size?: number;
  52030. poster?: string;
  52031. faceForward?: boolean;
  52032. useDirectMapping?: boolean;
  52033. halfDomeMode?: boolean;
  52034. }, scene: Scene);
  52035. private _changeVideoMode;
  52036. /**
  52037. * Releases resources associated with this node.
  52038. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  52039. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  52040. */
  52041. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  52042. }
  52043. }
  52044. declare module "babylonjs/Helpers/index" {
  52045. export * from "babylonjs/Helpers/environmentHelper";
  52046. export * from "babylonjs/Helpers/photoDome";
  52047. export * from "babylonjs/Helpers/sceneHelpers";
  52048. export * from "babylonjs/Helpers/videoDome";
  52049. }
  52050. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  52051. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  52052. import { IDisposable } from "babylonjs/scene";
  52053. import { Engine } from "babylonjs/Engines/engine";
  52054. /**
  52055. * This class can be used to get instrumentation data from a Babylon engine
  52056. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  52057. */
  52058. export class EngineInstrumentation implements IDisposable {
  52059. /**
  52060. * Define the instrumented engine.
  52061. */
  52062. engine: Engine;
  52063. private _captureGPUFrameTime;
  52064. private _gpuFrameTimeToken;
  52065. private _gpuFrameTime;
  52066. private _captureShaderCompilationTime;
  52067. private _shaderCompilationTime;
  52068. private _onBeginFrameObserver;
  52069. private _onEndFrameObserver;
  52070. private _onBeforeShaderCompilationObserver;
  52071. private _onAfterShaderCompilationObserver;
  52072. /**
  52073. * Gets the perf counter used for GPU frame time
  52074. */
  52075. readonly gpuFrameTimeCounter: PerfCounter;
  52076. /**
  52077. * Gets the GPU frame time capture status
  52078. */
  52079. /**
  52080. * Enable or disable the GPU frame time capture
  52081. */
  52082. captureGPUFrameTime: boolean;
  52083. /**
  52084. * Gets the perf counter used for shader compilation time
  52085. */
  52086. readonly shaderCompilationTimeCounter: PerfCounter;
  52087. /**
  52088. * Gets the shader compilation time capture status
  52089. */
  52090. /**
  52091. * Enable or disable the shader compilation time capture
  52092. */
  52093. captureShaderCompilationTime: boolean;
  52094. /**
  52095. * Instantiates a new engine instrumentation.
  52096. * This class can be used to get instrumentation data from a Babylon engine
  52097. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  52098. * @param engine Defines the engine to instrument
  52099. */
  52100. constructor(
  52101. /**
  52102. * Define the instrumented engine.
  52103. */
  52104. engine: Engine);
  52105. /**
  52106. * Dispose and release associated resources.
  52107. */
  52108. dispose(): void;
  52109. }
  52110. }
  52111. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  52112. import { Scene, IDisposable } from "babylonjs/scene";
  52113. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  52114. /**
  52115. * This class can be used to get instrumentation data from a Babylon engine
  52116. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  52117. */
  52118. export class SceneInstrumentation implements IDisposable {
  52119. /**
  52120. * Defines the scene to instrument
  52121. */
  52122. scene: Scene;
  52123. private _captureActiveMeshesEvaluationTime;
  52124. private _activeMeshesEvaluationTime;
  52125. private _captureRenderTargetsRenderTime;
  52126. private _renderTargetsRenderTime;
  52127. private _captureFrameTime;
  52128. private _frameTime;
  52129. private _captureRenderTime;
  52130. private _renderTime;
  52131. private _captureInterFrameTime;
  52132. private _interFrameTime;
  52133. private _captureParticlesRenderTime;
  52134. private _particlesRenderTime;
  52135. private _captureSpritesRenderTime;
  52136. private _spritesRenderTime;
  52137. private _capturePhysicsTime;
  52138. private _physicsTime;
  52139. private _captureAnimationsTime;
  52140. private _animationsTime;
  52141. private _captureCameraRenderTime;
  52142. private _cameraRenderTime;
  52143. private _onBeforeActiveMeshesEvaluationObserver;
  52144. private _onAfterActiveMeshesEvaluationObserver;
  52145. private _onBeforeRenderTargetsRenderObserver;
  52146. private _onAfterRenderTargetsRenderObserver;
  52147. private _onAfterRenderObserver;
  52148. private _onBeforeDrawPhaseObserver;
  52149. private _onAfterDrawPhaseObserver;
  52150. private _onBeforeAnimationsObserver;
  52151. private _onBeforeParticlesRenderingObserver;
  52152. private _onAfterParticlesRenderingObserver;
  52153. private _onBeforeSpritesRenderingObserver;
  52154. private _onAfterSpritesRenderingObserver;
  52155. private _onBeforePhysicsObserver;
  52156. private _onAfterPhysicsObserver;
  52157. private _onAfterAnimationsObserver;
  52158. private _onBeforeCameraRenderObserver;
  52159. private _onAfterCameraRenderObserver;
  52160. /**
  52161. * Gets the perf counter used for active meshes evaluation time
  52162. */
  52163. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  52164. /**
  52165. * Gets the active meshes evaluation time capture status
  52166. */
  52167. /**
  52168. * Enable or disable the active meshes evaluation time capture
  52169. */
  52170. captureActiveMeshesEvaluationTime: boolean;
  52171. /**
  52172. * Gets the perf counter used for render targets render time
  52173. */
  52174. readonly renderTargetsRenderTimeCounter: PerfCounter;
  52175. /**
  52176. * Gets the render targets render time capture status
  52177. */
  52178. /**
  52179. * Enable or disable the render targets render time capture
  52180. */
  52181. captureRenderTargetsRenderTime: boolean;
  52182. /**
  52183. * Gets the perf counter used for particles render time
  52184. */
  52185. readonly particlesRenderTimeCounter: PerfCounter;
  52186. /**
  52187. * Gets the particles render time capture status
  52188. */
  52189. /**
  52190. * Enable or disable the particles render time capture
  52191. */
  52192. captureParticlesRenderTime: boolean;
  52193. /**
  52194. * Gets the perf counter used for sprites render time
  52195. */
  52196. readonly spritesRenderTimeCounter: PerfCounter;
  52197. /**
  52198. * Gets the sprites render time capture status
  52199. */
  52200. /**
  52201. * Enable or disable the sprites render time capture
  52202. */
  52203. captureSpritesRenderTime: boolean;
  52204. /**
  52205. * Gets the perf counter used for physics time
  52206. */
  52207. readonly physicsTimeCounter: PerfCounter;
  52208. /**
  52209. * Gets the physics time capture status
  52210. */
  52211. /**
  52212. * Enable or disable the physics time capture
  52213. */
  52214. capturePhysicsTime: boolean;
  52215. /**
  52216. * Gets the perf counter used for animations time
  52217. */
  52218. readonly animationsTimeCounter: PerfCounter;
  52219. /**
  52220. * Gets the animations time capture status
  52221. */
  52222. /**
  52223. * Enable or disable the animations time capture
  52224. */
  52225. captureAnimationsTime: boolean;
  52226. /**
  52227. * Gets the perf counter used for frame time capture
  52228. */
  52229. readonly frameTimeCounter: PerfCounter;
  52230. /**
  52231. * Gets the frame time capture status
  52232. */
  52233. /**
  52234. * Enable or disable the frame time capture
  52235. */
  52236. captureFrameTime: boolean;
  52237. /**
  52238. * Gets the perf counter used for inter-frames time capture
  52239. */
  52240. readonly interFrameTimeCounter: PerfCounter;
  52241. /**
  52242. * Gets the inter-frames time capture status
  52243. */
  52244. /**
  52245. * Enable or disable the inter-frames time capture
  52246. */
  52247. captureInterFrameTime: boolean;
  52248. /**
  52249. * Gets the perf counter used for render time capture
  52250. */
  52251. readonly renderTimeCounter: PerfCounter;
  52252. /**
  52253. * Gets the render time capture status
  52254. */
  52255. /**
  52256. * Enable or disable the render time capture
  52257. */
  52258. captureRenderTime: boolean;
  52259. /**
  52260. * Gets the perf counter used for camera render time capture
  52261. */
  52262. readonly cameraRenderTimeCounter: PerfCounter;
  52263. /**
  52264. * Gets the camera render time capture status
  52265. */
  52266. /**
  52267. * Enable or disable the camera render time capture
  52268. */
  52269. captureCameraRenderTime: boolean;
  52270. /**
  52271. * Gets the perf counter used for draw calls
  52272. */
  52273. readonly drawCallsCounter: PerfCounter;
  52274. /**
  52275. * Instantiates a new scene instrumentation.
  52276. * This class can be used to get instrumentation data from a Babylon engine
  52277. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  52278. * @param scene Defines the scene to instrument
  52279. */
  52280. constructor(
  52281. /**
  52282. * Defines the scene to instrument
  52283. */
  52284. scene: Scene);
  52285. /**
  52286. * Dispose and release associated resources.
  52287. */
  52288. dispose(): void;
  52289. }
  52290. }
  52291. declare module "babylonjs/Instrumentation/index" {
  52292. export * from "babylonjs/Instrumentation/engineInstrumentation";
  52293. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  52294. export * from "babylonjs/Instrumentation/timeToken";
  52295. }
  52296. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  52297. /** @hidden */
  52298. export var glowMapGenerationPixelShader: {
  52299. name: string;
  52300. shader: string;
  52301. };
  52302. }
  52303. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  52304. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  52305. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  52306. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  52307. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  52308. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  52309. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  52310. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  52311. /** @hidden */
  52312. export var glowMapGenerationVertexShader: {
  52313. name: string;
  52314. shader: string;
  52315. };
  52316. }
  52317. declare module "babylonjs/Layers/effectLayer" {
  52318. import { Observable } from "babylonjs/Misc/observable";
  52319. import { Nullable } from "babylonjs/types";
  52320. import { Camera } from "babylonjs/Cameras/camera";
  52321. import { Scene } from "babylonjs/scene";
  52322. import { ISize } from "babylonjs/Maths/math.size";
  52323. import { Color4 } from "babylonjs/Maths/math.color";
  52324. import { Engine } from "babylonjs/Engines/engine";
  52325. import { SubMesh } from "babylonjs/Meshes/subMesh";
  52326. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52327. import { Mesh } from "babylonjs/Meshes/mesh";
  52328. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  52329. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52330. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  52331. import { Effect } from "babylonjs/Materials/effect";
  52332. import { Material } from "babylonjs/Materials/material";
  52333. import "babylonjs/Shaders/glowMapGeneration.fragment";
  52334. import "babylonjs/Shaders/glowMapGeneration.vertex";
  52335. /**
  52336. * Effect layer options. This helps customizing the behaviour
  52337. * of the effect layer.
  52338. */
  52339. export interface IEffectLayerOptions {
  52340. /**
  52341. * Multiplication factor apply to the canvas size to compute the render target size
  52342. * used to generated the objects (the smaller the faster).
  52343. */
  52344. mainTextureRatio: number;
  52345. /**
  52346. * Enforces a fixed size texture to ensure effect stability across devices.
  52347. */
  52348. mainTextureFixedSize?: number;
  52349. /**
  52350. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  52351. */
  52352. alphaBlendingMode: number;
  52353. /**
  52354. * The camera attached to the layer.
  52355. */
  52356. camera: Nullable<Camera>;
  52357. /**
  52358. * The rendering group to draw the layer in.
  52359. */
  52360. renderingGroupId: number;
  52361. }
  52362. /**
  52363. * The effect layer Helps adding post process effect blended with the main pass.
  52364. *
  52365. * This can be for instance use to generate glow or higlight effects on the scene.
  52366. *
  52367. * The effect layer class can not be used directly and is intented to inherited from to be
  52368. * customized per effects.
  52369. */
  52370. export abstract class EffectLayer {
  52371. private _vertexBuffers;
  52372. private _indexBuffer;
  52373. private _cachedDefines;
  52374. private _effectLayerMapGenerationEffect;
  52375. private _effectLayerOptions;
  52376. private _mergeEffect;
  52377. protected _scene: Scene;
  52378. protected _engine: Engine;
  52379. protected _maxSize: number;
  52380. protected _mainTextureDesiredSize: ISize;
  52381. protected _mainTexture: RenderTargetTexture;
  52382. protected _shouldRender: boolean;
  52383. protected _postProcesses: PostProcess[];
  52384. protected _textures: BaseTexture[];
  52385. protected _emissiveTextureAndColor: {
  52386. texture: Nullable<BaseTexture>;
  52387. color: Color4;
  52388. };
  52389. /**
  52390. * The name of the layer
  52391. */
  52392. name: string;
  52393. /**
  52394. * The clear color of the texture used to generate the glow map.
  52395. */
  52396. neutralColor: Color4;
  52397. /**
  52398. * Specifies wether the highlight layer is enabled or not.
  52399. */
  52400. isEnabled: boolean;
  52401. /**
  52402. * Gets the camera attached to the layer.
  52403. */
  52404. readonly camera: Nullable<Camera>;
  52405. /**
  52406. * Gets the rendering group id the layer should render in.
  52407. */
  52408. renderingGroupId: number;
  52409. /**
  52410. * An event triggered when the effect layer has been disposed.
  52411. */
  52412. onDisposeObservable: Observable<EffectLayer>;
  52413. /**
  52414. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  52415. */
  52416. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  52417. /**
  52418. * An event triggered when the generated texture is being merged in the scene.
  52419. */
  52420. onBeforeComposeObservable: Observable<EffectLayer>;
  52421. /**
  52422. * An event triggered when the mesh is rendered into the effect render target.
  52423. */
  52424. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  52425. /**
  52426. * An event triggered after the mesh has been rendered into the effect render target.
  52427. */
  52428. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  52429. /**
  52430. * An event triggered when the generated texture has been merged in the scene.
  52431. */
  52432. onAfterComposeObservable: Observable<EffectLayer>;
  52433. /**
  52434. * An event triggered when the efffect layer changes its size.
  52435. */
  52436. onSizeChangedObservable: Observable<EffectLayer>;
  52437. /** @hidden */
  52438. static _SceneComponentInitialization: (scene: Scene) => void;
  52439. /**
  52440. * Instantiates a new effect Layer and references it in the scene.
  52441. * @param name The name of the layer
  52442. * @param scene The scene to use the layer in
  52443. */
  52444. constructor(
  52445. /** The Friendly of the effect in the scene */
  52446. name: string, scene: Scene);
  52447. /**
  52448. * Get the effect name of the layer.
  52449. * @return The effect name
  52450. */
  52451. abstract getEffectName(): string;
  52452. /**
  52453. * Checks for the readiness of the element composing the layer.
  52454. * @param subMesh the mesh to check for
  52455. * @param useInstances specify wether or not to use instances to render the mesh
  52456. * @return true if ready otherwise, false
  52457. */
  52458. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  52459. /**
  52460. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  52461. * @returns true if the effect requires stencil during the main canvas render pass.
  52462. */
  52463. abstract needStencil(): boolean;
  52464. /**
  52465. * Create the merge effect. This is the shader use to blit the information back
  52466. * to the main canvas at the end of the scene rendering.
  52467. * @returns The effect containing the shader used to merge the effect on the main canvas
  52468. */
  52469. protected abstract _createMergeEffect(): Effect;
  52470. /**
  52471. * Creates the render target textures and post processes used in the effect layer.
  52472. */
  52473. protected abstract _createTextureAndPostProcesses(): void;
  52474. /**
  52475. * Implementation specific of rendering the generating effect on the main canvas.
  52476. * @param effect The effect used to render through
  52477. */
  52478. protected abstract _internalRender(effect: Effect): void;
  52479. /**
  52480. * Sets the required values for both the emissive texture and and the main color.
  52481. */
  52482. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  52483. /**
  52484. * Free any resources and references associated to a mesh.
  52485. * Internal use
  52486. * @param mesh The mesh to free.
  52487. */
  52488. abstract _disposeMesh(mesh: Mesh): void;
  52489. /**
  52490. * Serializes this layer (Glow or Highlight for example)
  52491. * @returns a serialized layer object
  52492. */
  52493. abstract serialize?(): any;
  52494. /**
  52495. * Initializes the effect layer with the required options.
  52496. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  52497. */
  52498. protected _init(options: Partial<IEffectLayerOptions>): void;
  52499. /**
  52500. * Generates the index buffer of the full screen quad blending to the main canvas.
  52501. */
  52502. private _generateIndexBuffer;
  52503. /**
  52504. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  52505. */
  52506. private _generateVertexBuffer;
  52507. /**
  52508. * Sets the main texture desired size which is the closest power of two
  52509. * of the engine canvas size.
  52510. */
  52511. private _setMainTextureSize;
  52512. /**
  52513. * Creates the main texture for the effect layer.
  52514. */
  52515. protected _createMainTexture(): void;
  52516. /**
  52517. * Adds specific effects defines.
  52518. * @param defines The defines to add specifics to.
  52519. */
  52520. protected _addCustomEffectDefines(defines: string[]): void;
  52521. /**
  52522. * Checks for the readiness of the element composing the layer.
  52523. * @param subMesh the mesh to check for
  52524. * @param useInstances specify wether or not to use instances to render the mesh
  52525. * @param emissiveTexture the associated emissive texture used to generate the glow
  52526. * @return true if ready otherwise, false
  52527. */
  52528. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  52529. /**
  52530. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  52531. */
  52532. render(): void;
  52533. /**
  52534. * Determine if a given mesh will be used in the current effect.
  52535. * @param mesh mesh to test
  52536. * @returns true if the mesh will be used
  52537. */
  52538. hasMesh(mesh: AbstractMesh): boolean;
  52539. /**
  52540. * Returns true if the layer contains information to display, otherwise false.
  52541. * @returns true if the glow layer should be rendered
  52542. */
  52543. shouldRender(): boolean;
  52544. /**
  52545. * Returns true if the mesh should render, otherwise false.
  52546. * @param mesh The mesh to render
  52547. * @returns true if it should render otherwise false
  52548. */
  52549. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  52550. /**
  52551. * Returns true if the mesh can be rendered, otherwise false.
  52552. * @param mesh The mesh to render
  52553. * @param material The material used on the mesh
  52554. * @returns true if it can be rendered otherwise false
  52555. */
  52556. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  52557. /**
  52558. * Returns true if the mesh should render, otherwise false.
  52559. * @param mesh The mesh to render
  52560. * @returns true if it should render otherwise false
  52561. */
  52562. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  52563. /**
  52564. * Renders the submesh passed in parameter to the generation map.
  52565. */
  52566. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  52567. /**
  52568. * Defines wether the current material of the mesh should be use to render the effect.
  52569. * @param mesh defines the current mesh to render
  52570. */
  52571. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  52572. /**
  52573. * Rebuild the required buffers.
  52574. * @hidden Internal use only.
  52575. */
  52576. _rebuild(): void;
  52577. /**
  52578. * Dispose only the render target textures and post process.
  52579. */
  52580. private _disposeTextureAndPostProcesses;
  52581. /**
  52582. * Dispose the highlight layer and free resources.
  52583. */
  52584. dispose(): void;
  52585. /**
  52586. * Gets the class name of the effect layer
  52587. * @returns the string with the class name of the effect layer
  52588. */
  52589. getClassName(): string;
  52590. /**
  52591. * Creates an effect layer from parsed effect layer data
  52592. * @param parsedEffectLayer defines effect layer data
  52593. * @param scene defines the current scene
  52594. * @param rootUrl defines the root URL containing the effect layer information
  52595. * @returns a parsed effect Layer
  52596. */
  52597. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  52598. }
  52599. }
  52600. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  52601. import { Scene } from "babylonjs/scene";
  52602. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  52603. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  52604. import { AbstractScene } from "babylonjs/abstractScene";
  52605. module "babylonjs/abstractScene" {
  52606. interface AbstractScene {
  52607. /**
  52608. * The list of effect layers (highlights/glow) added to the scene
  52609. * @see http://doc.babylonjs.com/how_to/highlight_layer
  52610. * @see http://doc.babylonjs.com/how_to/glow_layer
  52611. */
  52612. effectLayers: Array<EffectLayer>;
  52613. /**
  52614. * Removes the given effect layer from this scene.
  52615. * @param toRemove defines the effect layer to remove
  52616. * @returns the index of the removed effect layer
  52617. */
  52618. removeEffectLayer(toRemove: EffectLayer): number;
  52619. /**
  52620. * Adds the given effect layer to this scene
  52621. * @param newEffectLayer defines the effect layer to add
  52622. */
  52623. addEffectLayer(newEffectLayer: EffectLayer): void;
  52624. }
  52625. }
  52626. /**
  52627. * Defines the layer scene component responsible to manage any effect layers
  52628. * in a given scene.
  52629. */
  52630. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  52631. /**
  52632. * The component name helpfull to identify the component in the list of scene components.
  52633. */
  52634. readonly name: string;
  52635. /**
  52636. * The scene the component belongs to.
  52637. */
  52638. scene: Scene;
  52639. private _engine;
  52640. private _renderEffects;
  52641. private _needStencil;
  52642. private _previousStencilState;
  52643. /**
  52644. * Creates a new instance of the component for the given scene
  52645. * @param scene Defines the scene to register the component in
  52646. */
  52647. constructor(scene: Scene);
  52648. /**
  52649. * Registers the component in a given scene
  52650. */
  52651. register(): void;
  52652. /**
  52653. * Rebuilds the elements related to this component in case of
  52654. * context lost for instance.
  52655. */
  52656. rebuild(): void;
  52657. /**
  52658. * Serializes the component data to the specified json object
  52659. * @param serializationObject The object to serialize to
  52660. */
  52661. serialize(serializationObject: any): void;
  52662. /**
  52663. * Adds all the elements from the container to the scene
  52664. * @param container the container holding the elements
  52665. */
  52666. addFromContainer(container: AbstractScene): void;
  52667. /**
  52668. * Removes all the elements in the container from the scene
  52669. * @param container contains the elements to remove
  52670. * @param dispose if the removed element should be disposed (default: false)
  52671. */
  52672. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  52673. /**
  52674. * Disposes the component and the associated ressources.
  52675. */
  52676. dispose(): void;
  52677. private _isReadyForMesh;
  52678. private _renderMainTexture;
  52679. private _setStencil;
  52680. private _setStencilBack;
  52681. private _draw;
  52682. private _drawCamera;
  52683. private _drawRenderingGroup;
  52684. }
  52685. }
  52686. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  52687. /** @hidden */
  52688. export var glowMapMergePixelShader: {
  52689. name: string;
  52690. shader: string;
  52691. };
  52692. }
  52693. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  52694. /** @hidden */
  52695. export var glowMapMergeVertexShader: {
  52696. name: string;
  52697. shader: string;
  52698. };
  52699. }
  52700. declare module "babylonjs/Layers/glowLayer" {
  52701. import { Nullable } from "babylonjs/types";
  52702. import { Camera } from "babylonjs/Cameras/camera";
  52703. import { Scene } from "babylonjs/scene";
  52704. import { SubMesh } from "babylonjs/Meshes/subMesh";
  52705. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52706. import { Mesh } from "babylonjs/Meshes/mesh";
  52707. import { Texture } from "babylonjs/Materials/Textures/texture";
  52708. import { Effect } from "babylonjs/Materials/effect";
  52709. import { Material } from "babylonjs/Materials/material";
  52710. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  52711. import { Color4 } from "babylonjs/Maths/math.color";
  52712. import "babylonjs/Shaders/glowMapMerge.fragment";
  52713. import "babylonjs/Shaders/glowMapMerge.vertex";
  52714. import "babylonjs/Layers/effectLayerSceneComponent";
  52715. module "babylonjs/abstractScene" {
  52716. interface AbstractScene {
  52717. /**
  52718. * Return a the first highlight layer of the scene with a given name.
  52719. * @param name The name of the highlight layer to look for.
  52720. * @return The highlight layer if found otherwise null.
  52721. */
  52722. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  52723. }
  52724. }
  52725. /**
  52726. * Glow layer options. This helps customizing the behaviour
  52727. * of the glow layer.
  52728. */
  52729. export interface IGlowLayerOptions {
  52730. /**
  52731. * Multiplication factor apply to the canvas size to compute the render target size
  52732. * used to generated the glowing objects (the smaller the faster).
  52733. */
  52734. mainTextureRatio: number;
  52735. /**
  52736. * Enforces a fixed size texture to ensure resize independant blur.
  52737. */
  52738. mainTextureFixedSize?: number;
  52739. /**
  52740. * How big is the kernel of the blur texture.
  52741. */
  52742. blurKernelSize: number;
  52743. /**
  52744. * The camera attached to the layer.
  52745. */
  52746. camera: Nullable<Camera>;
  52747. /**
  52748. * Enable MSAA by chosing the number of samples.
  52749. */
  52750. mainTextureSamples?: number;
  52751. /**
  52752. * The rendering group to draw the layer in.
  52753. */
  52754. renderingGroupId: number;
  52755. }
  52756. /**
  52757. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  52758. *
  52759. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  52760. *
  52761. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  52762. */
  52763. export class GlowLayer extends EffectLayer {
  52764. /**
  52765. * Effect Name of the layer.
  52766. */
  52767. static readonly EffectName: string;
  52768. /**
  52769. * The default blur kernel size used for the glow.
  52770. */
  52771. static DefaultBlurKernelSize: number;
  52772. /**
  52773. * The default texture size ratio used for the glow.
  52774. */
  52775. static DefaultTextureRatio: number;
  52776. /**
  52777. * Sets the kernel size of the blur.
  52778. */
  52779. /**
  52780. * Gets the kernel size of the blur.
  52781. */
  52782. blurKernelSize: number;
  52783. /**
  52784. * Sets the glow intensity.
  52785. */
  52786. /**
  52787. * Gets the glow intensity.
  52788. */
  52789. intensity: number;
  52790. private _options;
  52791. private _intensity;
  52792. private _horizontalBlurPostprocess1;
  52793. private _verticalBlurPostprocess1;
  52794. private _horizontalBlurPostprocess2;
  52795. private _verticalBlurPostprocess2;
  52796. private _blurTexture1;
  52797. private _blurTexture2;
  52798. private _postProcesses1;
  52799. private _postProcesses2;
  52800. private _includedOnlyMeshes;
  52801. private _excludedMeshes;
  52802. private _meshesUsingTheirOwnMaterials;
  52803. /**
  52804. * Callback used to let the user override the color selection on a per mesh basis
  52805. */
  52806. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  52807. /**
  52808. * Callback used to let the user override the texture selection on a per mesh basis
  52809. */
  52810. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  52811. /**
  52812. * Instantiates a new glow Layer and references it to the scene.
  52813. * @param name The name of the layer
  52814. * @param scene The scene to use the layer in
  52815. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  52816. */
  52817. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  52818. /**
  52819. * Get the effect name of the layer.
  52820. * @return The effect name
  52821. */
  52822. getEffectName(): string;
  52823. /**
  52824. * Create the merge effect. This is the shader use to blit the information back
  52825. * to the main canvas at the end of the scene rendering.
  52826. */
  52827. protected _createMergeEffect(): Effect;
  52828. /**
  52829. * Creates the render target textures and post processes used in the glow layer.
  52830. */
  52831. protected _createTextureAndPostProcesses(): void;
  52832. /**
  52833. * Checks for the readiness of the element composing the layer.
  52834. * @param subMesh the mesh to check for
  52835. * @param useInstances specify wether or not to use instances to render the mesh
  52836. * @param emissiveTexture the associated emissive texture used to generate the glow
  52837. * @return true if ready otherwise, false
  52838. */
  52839. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  52840. /**
  52841. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  52842. */
  52843. needStencil(): boolean;
  52844. /**
  52845. * Returns true if the mesh can be rendered, otherwise false.
  52846. * @param mesh The mesh to render
  52847. * @param material The material used on the mesh
  52848. * @returns true if it can be rendered otherwise false
  52849. */
  52850. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  52851. /**
  52852. * Implementation specific of rendering the generating effect on the main canvas.
  52853. * @param effect The effect used to render through
  52854. */
  52855. protected _internalRender(effect: Effect): void;
  52856. /**
  52857. * Sets the required values for both the emissive texture and and the main color.
  52858. */
  52859. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  52860. /**
  52861. * Returns true if the mesh should render, otherwise false.
  52862. * @param mesh The mesh to render
  52863. * @returns true if it should render otherwise false
  52864. */
  52865. protected _shouldRenderMesh(mesh: Mesh): boolean;
  52866. /**
  52867. * Adds specific effects defines.
  52868. * @param defines The defines to add specifics to.
  52869. */
  52870. protected _addCustomEffectDefines(defines: string[]): void;
  52871. /**
  52872. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  52873. * @param mesh The mesh to exclude from the glow layer
  52874. */
  52875. addExcludedMesh(mesh: Mesh): void;
  52876. /**
  52877. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  52878. * @param mesh The mesh to remove
  52879. */
  52880. removeExcludedMesh(mesh: Mesh): void;
  52881. /**
  52882. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  52883. * @param mesh The mesh to include in the glow layer
  52884. */
  52885. addIncludedOnlyMesh(mesh: Mesh): void;
  52886. /**
  52887. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  52888. * @param mesh The mesh to remove
  52889. */
  52890. removeIncludedOnlyMesh(mesh: Mesh): void;
  52891. /**
  52892. * Determine if a given mesh will be used in the glow layer
  52893. * @param mesh The mesh to test
  52894. * @returns true if the mesh will be highlighted by the current glow layer
  52895. */
  52896. hasMesh(mesh: AbstractMesh): boolean;
  52897. /**
  52898. * Defines wether the current material of the mesh should be use to render the effect.
  52899. * @param mesh defines the current mesh to render
  52900. */
  52901. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  52902. /**
  52903. * Add a mesh to be rendered through its own material and not with emissive only.
  52904. * @param mesh The mesh for which we need to use its material
  52905. */
  52906. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  52907. /**
  52908. * Remove a mesh from being rendered through its own material and not with emissive only.
  52909. * @param mesh The mesh for which we need to not use its material
  52910. */
  52911. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  52912. /**
  52913. * Free any resources and references associated to a mesh.
  52914. * Internal use
  52915. * @param mesh The mesh to free.
  52916. * @hidden
  52917. */
  52918. _disposeMesh(mesh: Mesh): void;
  52919. /**
  52920. * Gets the class name of the effect layer
  52921. * @returns the string with the class name of the effect layer
  52922. */
  52923. getClassName(): string;
  52924. /**
  52925. * Serializes this glow layer
  52926. * @returns a serialized glow layer object
  52927. */
  52928. serialize(): any;
  52929. /**
  52930. * Creates a Glow Layer from parsed glow layer data
  52931. * @param parsedGlowLayer defines glow layer data
  52932. * @param scene defines the current scene
  52933. * @param rootUrl defines the root URL containing the glow layer information
  52934. * @returns a parsed Glow Layer
  52935. */
  52936. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  52937. }
  52938. }
  52939. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  52940. /** @hidden */
  52941. export var glowBlurPostProcessPixelShader: {
  52942. name: string;
  52943. shader: string;
  52944. };
  52945. }
  52946. declare module "babylonjs/Layers/highlightLayer" {
  52947. import { Observable } from "babylonjs/Misc/observable";
  52948. import { Nullable } from "babylonjs/types";
  52949. import { Camera } from "babylonjs/Cameras/camera";
  52950. import { Scene } from "babylonjs/scene";
  52951. import { SubMesh } from "babylonjs/Meshes/subMesh";
  52952. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52953. import { Mesh } from "babylonjs/Meshes/mesh";
  52954. import { Effect } from "babylonjs/Materials/effect";
  52955. import { Material } from "babylonjs/Materials/material";
  52956. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  52957. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  52958. import "babylonjs/Shaders/glowMapMerge.fragment";
  52959. import "babylonjs/Shaders/glowMapMerge.vertex";
  52960. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  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. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  52969. }
  52970. }
  52971. /**
  52972. * Highlight layer options. This helps customizing the behaviour
  52973. * of the highlight layer.
  52974. */
  52975. export interface IHighlightLayerOptions {
  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. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  52987. * of the picture to blur (the smaller the faster).
  52988. */
  52989. blurTextureSizeRatio: number;
  52990. /**
  52991. * How big in texel of the blur texture is the vertical blur.
  52992. */
  52993. blurVerticalSize: number;
  52994. /**
  52995. * How big in texel of the blur texture is the horizontal blur.
  52996. */
  52997. blurHorizontalSize: number;
  52998. /**
  52999. * Alpha blending mode used to apply the blur. Default is combine.
  53000. */
  53001. alphaBlendingMode: number;
  53002. /**
  53003. * The camera attached to the layer.
  53004. */
  53005. camera: Nullable<Camera>;
  53006. /**
  53007. * Should we display highlight as a solid stroke?
  53008. */
  53009. isStroke?: boolean;
  53010. /**
  53011. * The rendering group to draw the layer in.
  53012. */
  53013. renderingGroupId: number;
  53014. }
  53015. /**
  53016. * The highlight layer Helps adding a glow effect around a mesh.
  53017. *
  53018. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  53019. * glowy meshes to your scene.
  53020. *
  53021. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  53022. */
  53023. export class HighlightLayer extends EffectLayer {
  53024. name: string;
  53025. /**
  53026. * Effect Name of the highlight layer.
  53027. */
  53028. static readonly EffectName: string;
  53029. /**
  53030. * The neutral color used during the preparation of the glow effect.
  53031. * This is black by default as the blend operation is a blend operation.
  53032. */
  53033. static NeutralColor: Color4;
  53034. /**
  53035. * Stencil value used for glowing meshes.
  53036. */
  53037. static GlowingMeshStencilReference: number;
  53038. /**
  53039. * Stencil value used for the other meshes in the scene.
  53040. */
  53041. static NormalMeshStencilReference: number;
  53042. /**
  53043. * Specifies whether or not the inner glow is ACTIVE in the layer.
  53044. */
  53045. innerGlow: boolean;
  53046. /**
  53047. * Specifies whether or not the outer glow is ACTIVE in the layer.
  53048. */
  53049. outerGlow: boolean;
  53050. /**
  53051. * Specifies the horizontal size of the blur.
  53052. */
  53053. /**
  53054. * Gets the horizontal size of the blur.
  53055. */
  53056. blurHorizontalSize: number;
  53057. /**
  53058. * Specifies the vertical size of the blur.
  53059. */
  53060. /**
  53061. * Gets the vertical size of the blur.
  53062. */
  53063. blurVerticalSize: number;
  53064. /**
  53065. * An event triggered when the highlight layer is being blurred.
  53066. */
  53067. onBeforeBlurObservable: Observable<HighlightLayer>;
  53068. /**
  53069. * An event triggered when the highlight layer has been blurred.
  53070. */
  53071. onAfterBlurObservable: Observable<HighlightLayer>;
  53072. private _instanceGlowingMeshStencilReference;
  53073. private _options;
  53074. private _downSamplePostprocess;
  53075. private _horizontalBlurPostprocess;
  53076. private _verticalBlurPostprocess;
  53077. private _blurTexture;
  53078. private _meshes;
  53079. private _excludedMeshes;
  53080. /**
  53081. * Instantiates a new highlight Layer and references it to the scene..
  53082. * @param name The name of the layer
  53083. * @param scene The scene to use the layer in
  53084. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  53085. */
  53086. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  53087. /**
  53088. * Get the effect name of the layer.
  53089. * @return The effect name
  53090. */
  53091. getEffectName(): string;
  53092. /**
  53093. * Create the merge effect. This is the shader use to blit the information back
  53094. * to the main canvas at the end of the scene rendering.
  53095. */
  53096. protected _createMergeEffect(): Effect;
  53097. /**
  53098. * Creates the render target textures and post processes used in the highlight layer.
  53099. */
  53100. protected _createTextureAndPostProcesses(): void;
  53101. /**
  53102. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  53103. */
  53104. needStencil(): boolean;
  53105. /**
  53106. * Checks for the readiness of the element composing the layer.
  53107. * @param subMesh the mesh to check for
  53108. * @param useInstances specify wether or not to use instances to render the mesh
  53109. * @param emissiveTexture the associated emissive texture used to generate the glow
  53110. * @return true if ready otherwise, false
  53111. */
  53112. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  53113. /**
  53114. * Implementation specific of rendering the generating effect on the main canvas.
  53115. * @param effect The effect used to render through
  53116. */
  53117. protected _internalRender(effect: Effect): void;
  53118. /**
  53119. * Returns true if the layer contains information to display, otherwise false.
  53120. */
  53121. shouldRender(): boolean;
  53122. /**
  53123. * Returns true if the mesh should render, otherwise false.
  53124. * @param mesh The mesh to render
  53125. * @returns true if it should render otherwise false
  53126. */
  53127. protected _shouldRenderMesh(mesh: Mesh): boolean;
  53128. /**
  53129. * Sets the required values for both the emissive texture and and the main color.
  53130. */
  53131. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  53132. /**
  53133. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  53134. * @param mesh The mesh to exclude from the highlight layer
  53135. */
  53136. addExcludedMesh(mesh: Mesh): void;
  53137. /**
  53138. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  53139. * @param mesh The mesh to highlight
  53140. */
  53141. removeExcludedMesh(mesh: Mesh): void;
  53142. /**
  53143. * Determine if a given mesh will be highlighted by the current HighlightLayer
  53144. * @param mesh mesh to test
  53145. * @returns true if the mesh will be highlighted by the current HighlightLayer
  53146. */
  53147. hasMesh(mesh: AbstractMesh): boolean;
  53148. /**
  53149. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  53150. * @param mesh The mesh to highlight
  53151. * @param color The color of the highlight
  53152. * @param glowEmissiveOnly Extract the glow from the emissive texture
  53153. */
  53154. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  53155. /**
  53156. * Remove a mesh from the highlight layer in order to make it stop glowing.
  53157. * @param mesh The mesh to highlight
  53158. */
  53159. removeMesh(mesh: Mesh): void;
  53160. /**
  53161. * Force the stencil to the normal expected value for none glowing parts
  53162. */
  53163. private _defaultStencilReference;
  53164. /**
  53165. * Free any resources and references associated to a mesh.
  53166. * Internal use
  53167. * @param mesh The mesh to free.
  53168. * @hidden
  53169. */
  53170. _disposeMesh(mesh: Mesh): void;
  53171. /**
  53172. * Dispose the highlight layer and free resources.
  53173. */
  53174. dispose(): void;
  53175. /**
  53176. * Gets the class name of the effect layer
  53177. * @returns the string with the class name of the effect layer
  53178. */
  53179. getClassName(): string;
  53180. /**
  53181. * Serializes this Highlight layer
  53182. * @returns a serialized Highlight layer object
  53183. */
  53184. serialize(): any;
  53185. /**
  53186. * Creates a Highlight layer from parsed Highlight layer data
  53187. * @param parsedHightlightLayer defines the Highlight layer data
  53188. * @param scene defines the current scene
  53189. * @param rootUrl defines the root URL containing the Highlight layer information
  53190. * @returns a parsed Highlight layer
  53191. */
  53192. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  53193. }
  53194. }
  53195. declare module "babylonjs/Layers/layerSceneComponent" {
  53196. import { Scene } from "babylonjs/scene";
  53197. import { ISceneComponent } from "babylonjs/sceneComponent";
  53198. import { Layer } from "babylonjs/Layers/layer";
  53199. import { AbstractScene } from "babylonjs/abstractScene";
  53200. module "babylonjs/abstractScene" {
  53201. interface AbstractScene {
  53202. /**
  53203. * The list of layers (background and foreground) of the scene
  53204. */
  53205. layers: Array<Layer>;
  53206. }
  53207. }
  53208. /**
  53209. * Defines the layer scene component responsible to manage any layers
  53210. * in a given scene.
  53211. */
  53212. export class LayerSceneComponent implements ISceneComponent {
  53213. /**
  53214. * The component name helpfull to identify the component in the list of scene components.
  53215. */
  53216. readonly name: string;
  53217. /**
  53218. * The scene the component belongs to.
  53219. */
  53220. scene: Scene;
  53221. private _engine;
  53222. /**
  53223. * Creates a new instance of the component for the given scene
  53224. * @param scene Defines the scene to register the component in
  53225. */
  53226. constructor(scene: Scene);
  53227. /**
  53228. * Registers the component in a given scene
  53229. */
  53230. register(): void;
  53231. /**
  53232. * Rebuilds the elements related to this component in case of
  53233. * context lost for instance.
  53234. */
  53235. rebuild(): void;
  53236. /**
  53237. * Disposes the component and the associated ressources.
  53238. */
  53239. dispose(): void;
  53240. private _draw;
  53241. private _drawCameraPredicate;
  53242. private _drawCameraBackground;
  53243. private _drawCameraForeground;
  53244. private _drawRenderTargetPredicate;
  53245. private _drawRenderTargetBackground;
  53246. private _drawRenderTargetForeground;
  53247. /**
  53248. * Adds all the elements from the container to the scene
  53249. * @param container the container holding the elements
  53250. */
  53251. addFromContainer(container: AbstractScene): void;
  53252. /**
  53253. * Removes all the elements in the container from the scene
  53254. * @param container contains the elements to remove
  53255. * @param dispose if the removed element should be disposed (default: false)
  53256. */
  53257. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  53258. }
  53259. }
  53260. declare module "babylonjs/Shaders/layer.fragment" {
  53261. /** @hidden */
  53262. export var layerPixelShader: {
  53263. name: string;
  53264. shader: string;
  53265. };
  53266. }
  53267. declare module "babylonjs/Shaders/layer.vertex" {
  53268. /** @hidden */
  53269. export var layerVertexShader: {
  53270. name: string;
  53271. shader: string;
  53272. };
  53273. }
  53274. declare module "babylonjs/Layers/layer" {
  53275. import { Observable } from "babylonjs/Misc/observable";
  53276. import { Nullable } from "babylonjs/types";
  53277. import { Scene } from "babylonjs/scene";
  53278. import { Vector2 } from "babylonjs/Maths/math.vector";
  53279. import { Color4 } from "babylonjs/Maths/math.color";
  53280. import { Texture } from "babylonjs/Materials/Textures/texture";
  53281. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  53282. import "babylonjs/Shaders/layer.fragment";
  53283. import "babylonjs/Shaders/layer.vertex";
  53284. /**
  53285. * This represents a full screen 2d layer.
  53286. * This can be useful to display a picture in the background of your scene for instance.
  53287. * @see https://www.babylonjs-playground.com/#08A2BS#1
  53288. */
  53289. export class Layer {
  53290. /**
  53291. * Define the name of the layer.
  53292. */
  53293. name: string;
  53294. /**
  53295. * Define the texture the layer should display.
  53296. */
  53297. texture: Nullable<Texture>;
  53298. /**
  53299. * Is the layer in background or foreground.
  53300. */
  53301. isBackground: boolean;
  53302. /**
  53303. * Define the color of the layer (instead of texture).
  53304. */
  53305. color: Color4;
  53306. /**
  53307. * Define the scale of the layer in order to zoom in out of the texture.
  53308. */
  53309. scale: Vector2;
  53310. /**
  53311. * Define an offset for the layer in order to shift the texture.
  53312. */
  53313. offset: Vector2;
  53314. /**
  53315. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  53316. */
  53317. alphaBlendingMode: number;
  53318. /**
  53319. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  53320. * Alpha test will not mix with the background color in case of transparency.
  53321. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  53322. */
  53323. alphaTest: boolean;
  53324. /**
  53325. * Define a mask to restrict the layer to only some of the scene cameras.
  53326. */
  53327. layerMask: number;
  53328. /**
  53329. * Define the list of render target the layer is visible into.
  53330. */
  53331. renderTargetTextures: RenderTargetTexture[];
  53332. /**
  53333. * Define if the layer is only used in renderTarget or if it also
  53334. * renders in the main frame buffer of the canvas.
  53335. */
  53336. renderOnlyInRenderTargetTextures: boolean;
  53337. private _scene;
  53338. private _vertexBuffers;
  53339. private _indexBuffer;
  53340. private _effect;
  53341. private _alphaTestEffect;
  53342. /**
  53343. * An event triggered when the layer is disposed.
  53344. */
  53345. onDisposeObservable: Observable<Layer>;
  53346. private _onDisposeObserver;
  53347. /**
  53348. * Back compatibility with callback before the onDisposeObservable existed.
  53349. * The set callback will be triggered when the layer has been disposed.
  53350. */
  53351. onDispose: () => void;
  53352. /**
  53353. * An event triggered before rendering the scene
  53354. */
  53355. onBeforeRenderObservable: Observable<Layer>;
  53356. private _onBeforeRenderObserver;
  53357. /**
  53358. * Back compatibility with callback before the onBeforeRenderObservable existed.
  53359. * The set callback will be triggered just before rendering the layer.
  53360. */
  53361. onBeforeRender: () => void;
  53362. /**
  53363. * An event triggered after rendering the scene
  53364. */
  53365. onAfterRenderObservable: Observable<Layer>;
  53366. private _onAfterRenderObserver;
  53367. /**
  53368. * Back compatibility with callback before the onAfterRenderObservable existed.
  53369. * The set callback will be triggered just after rendering the layer.
  53370. */
  53371. onAfterRender: () => void;
  53372. /**
  53373. * Instantiates a new layer.
  53374. * This represents a full screen 2d layer.
  53375. * This can be useful to display a picture in the background of your scene for instance.
  53376. * @see https://www.babylonjs-playground.com/#08A2BS#1
  53377. * @param name Define the name of the layer in the scene
  53378. * @param imgUrl Define the url of the texture to display in the layer
  53379. * @param scene Define the scene the layer belongs to
  53380. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  53381. * @param color Defines a color for the layer
  53382. */
  53383. constructor(
  53384. /**
  53385. * Define the name of the layer.
  53386. */
  53387. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  53388. private _createIndexBuffer;
  53389. /** @hidden */
  53390. _rebuild(): void;
  53391. /**
  53392. * Renders the layer in the scene.
  53393. */
  53394. render(): void;
  53395. /**
  53396. * Disposes and releases the associated ressources.
  53397. */
  53398. dispose(): void;
  53399. }
  53400. }
  53401. declare module "babylonjs/Layers/index" {
  53402. export * from "babylonjs/Layers/effectLayer";
  53403. export * from "babylonjs/Layers/effectLayerSceneComponent";
  53404. export * from "babylonjs/Layers/glowLayer";
  53405. export * from "babylonjs/Layers/highlightLayer";
  53406. export * from "babylonjs/Layers/layer";
  53407. export * from "babylonjs/Layers/layerSceneComponent";
  53408. }
  53409. declare module "babylonjs/Shaders/lensFlare.fragment" {
  53410. /** @hidden */
  53411. export var lensFlarePixelShader: {
  53412. name: string;
  53413. shader: string;
  53414. };
  53415. }
  53416. declare module "babylonjs/Shaders/lensFlare.vertex" {
  53417. /** @hidden */
  53418. export var lensFlareVertexShader: {
  53419. name: string;
  53420. shader: string;
  53421. };
  53422. }
  53423. declare module "babylonjs/LensFlares/lensFlareSystem" {
  53424. import { Scene } from "babylonjs/scene";
  53425. import { Vector3 } from "babylonjs/Maths/math.vector";
  53426. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53427. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  53428. import "babylonjs/Shaders/lensFlare.fragment";
  53429. import "babylonjs/Shaders/lensFlare.vertex";
  53430. import { Viewport } from "babylonjs/Maths/math.viewport";
  53431. /**
  53432. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  53433. * It is usually composed of several `lensFlare`.
  53434. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53435. */
  53436. export class LensFlareSystem {
  53437. /**
  53438. * Define the name of the lens flare system
  53439. */
  53440. name: string;
  53441. /**
  53442. * List of lens flares used in this system.
  53443. */
  53444. lensFlares: LensFlare[];
  53445. /**
  53446. * Define a limit from the border the lens flare can be visible.
  53447. */
  53448. borderLimit: number;
  53449. /**
  53450. * Define a viewport border we do not want to see the lens flare in.
  53451. */
  53452. viewportBorder: number;
  53453. /**
  53454. * Define a predicate which could limit the list of meshes able to occlude the effect.
  53455. */
  53456. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  53457. /**
  53458. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  53459. */
  53460. layerMask: number;
  53461. /**
  53462. * Define the id of the lens flare system in the scene.
  53463. * (equal to name by default)
  53464. */
  53465. id: string;
  53466. private _scene;
  53467. private _emitter;
  53468. private _vertexBuffers;
  53469. private _indexBuffer;
  53470. private _effect;
  53471. private _positionX;
  53472. private _positionY;
  53473. private _isEnabled;
  53474. /** @hidden */
  53475. static _SceneComponentInitialization: (scene: Scene) => void;
  53476. /**
  53477. * Instantiates a lens flare system.
  53478. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  53479. * It is usually composed of several `lensFlare`.
  53480. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53481. * @param name Define the name of the lens flare system in the scene
  53482. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  53483. * @param scene Define the scene the lens flare system belongs to
  53484. */
  53485. constructor(
  53486. /**
  53487. * Define the name of the lens flare system
  53488. */
  53489. name: string, emitter: any, scene: Scene);
  53490. /**
  53491. * Define if the lens flare system is enabled.
  53492. */
  53493. isEnabled: boolean;
  53494. /**
  53495. * Get the scene the effects belongs to.
  53496. * @returns the scene holding the lens flare system
  53497. */
  53498. getScene(): Scene;
  53499. /**
  53500. * Get the emitter of the lens flare system.
  53501. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  53502. * @returns the emitter of the lens flare system
  53503. */
  53504. getEmitter(): any;
  53505. /**
  53506. * Set the emitter of the lens flare system.
  53507. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  53508. * @param newEmitter Define the new emitter of the system
  53509. */
  53510. setEmitter(newEmitter: any): void;
  53511. /**
  53512. * Get the lens flare system emitter position.
  53513. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  53514. * @returns the position
  53515. */
  53516. getEmitterPosition(): Vector3;
  53517. /**
  53518. * @hidden
  53519. */
  53520. computeEffectivePosition(globalViewport: Viewport): boolean;
  53521. /** @hidden */
  53522. _isVisible(): boolean;
  53523. /**
  53524. * @hidden
  53525. */
  53526. render(): boolean;
  53527. /**
  53528. * Dispose and release the lens flare with its associated resources.
  53529. */
  53530. dispose(): void;
  53531. /**
  53532. * Parse a lens flare system from a JSON repressentation
  53533. * @param parsedLensFlareSystem Define the JSON to parse
  53534. * @param scene Define the scene the parsed system should be instantiated in
  53535. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  53536. * @returns the parsed system
  53537. */
  53538. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  53539. /**
  53540. * Serialize the current Lens Flare System into a JSON representation.
  53541. * @returns the serialized JSON
  53542. */
  53543. serialize(): any;
  53544. }
  53545. }
  53546. declare module "babylonjs/LensFlares/lensFlare" {
  53547. import { Nullable } from "babylonjs/types";
  53548. import { Color3 } from "babylonjs/Maths/math.color";
  53549. import { Texture } from "babylonjs/Materials/Textures/texture";
  53550. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  53551. /**
  53552. * This represents one of the lens effect in a `lensFlareSystem`.
  53553. * It controls one of the indiviual texture used in the effect.
  53554. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53555. */
  53556. export class LensFlare {
  53557. /**
  53558. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  53559. */
  53560. size: number;
  53561. /**
  53562. * 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.
  53563. */
  53564. position: number;
  53565. /**
  53566. * Define the lens color.
  53567. */
  53568. color: Color3;
  53569. /**
  53570. * Define the lens texture.
  53571. */
  53572. texture: Nullable<Texture>;
  53573. /**
  53574. * Define the alpha mode to render this particular lens.
  53575. */
  53576. alphaMode: number;
  53577. private _system;
  53578. /**
  53579. * Creates a new Lens Flare.
  53580. * This represents one of the lens effect in a `lensFlareSystem`.
  53581. * It controls one of the indiviual texture used in the effect.
  53582. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53583. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  53584. * @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.
  53585. * @param color Define the lens color
  53586. * @param imgUrl Define the lens texture url
  53587. * @param system Define the `lensFlareSystem` this flare is part of
  53588. * @returns The newly created Lens Flare
  53589. */
  53590. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  53591. /**
  53592. * Instantiates a new Lens Flare.
  53593. * This represents one of the lens effect in a `lensFlareSystem`.
  53594. * It controls one of the indiviual texture used in the effect.
  53595. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53596. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  53597. * @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.
  53598. * @param color Define the lens color
  53599. * @param imgUrl Define the lens texture url
  53600. * @param system Define the `lensFlareSystem` this flare is part of
  53601. */
  53602. constructor(
  53603. /**
  53604. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  53605. */
  53606. size: number,
  53607. /**
  53608. * 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.
  53609. */
  53610. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  53611. /**
  53612. * Dispose and release the lens flare with its associated resources.
  53613. */
  53614. dispose(): void;
  53615. }
  53616. }
  53617. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  53618. import { Nullable } from "babylonjs/types";
  53619. import { Scene } from "babylonjs/scene";
  53620. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  53621. import { AbstractScene } from "babylonjs/abstractScene";
  53622. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  53623. module "babylonjs/abstractScene" {
  53624. interface AbstractScene {
  53625. /**
  53626. * The list of lens flare system added to the scene
  53627. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53628. */
  53629. lensFlareSystems: Array<LensFlareSystem>;
  53630. /**
  53631. * Removes the given lens flare system from this scene.
  53632. * @param toRemove The lens flare system to remove
  53633. * @returns The index of the removed lens flare system
  53634. */
  53635. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  53636. /**
  53637. * Adds the given lens flare system to this scene
  53638. * @param newLensFlareSystem The lens flare system to add
  53639. */
  53640. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  53641. /**
  53642. * Gets a lens flare system using its name
  53643. * @param name defines the name to look for
  53644. * @returns the lens flare system or null if not found
  53645. */
  53646. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  53647. /**
  53648. * Gets a lens flare system using its id
  53649. * @param id defines the id to look for
  53650. * @returns the lens flare system or null if not found
  53651. */
  53652. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  53653. }
  53654. }
  53655. /**
  53656. * Defines the lens flare scene component responsible to manage any lens flares
  53657. * in a given scene.
  53658. */
  53659. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  53660. /**
  53661. * The component name helpfull to identify the component in the list of scene components.
  53662. */
  53663. readonly name: string;
  53664. /**
  53665. * The scene the component belongs to.
  53666. */
  53667. scene: Scene;
  53668. /**
  53669. * Creates a new instance of the component for the given scene
  53670. * @param scene Defines the scene to register the component in
  53671. */
  53672. constructor(scene: Scene);
  53673. /**
  53674. * Registers the component in a given scene
  53675. */
  53676. register(): void;
  53677. /**
  53678. * Rebuilds the elements related to this component in case of
  53679. * context lost for instance.
  53680. */
  53681. rebuild(): void;
  53682. /**
  53683. * Adds all the elements from the container to the scene
  53684. * @param container the container holding the elements
  53685. */
  53686. addFromContainer(container: AbstractScene): void;
  53687. /**
  53688. * Removes all the elements in the container from the scene
  53689. * @param container contains the elements to remove
  53690. * @param dispose if the removed element should be disposed (default: false)
  53691. */
  53692. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  53693. /**
  53694. * Serializes the component data to the specified json object
  53695. * @param serializationObject The object to serialize to
  53696. */
  53697. serialize(serializationObject: any): void;
  53698. /**
  53699. * Disposes the component and the associated ressources.
  53700. */
  53701. dispose(): void;
  53702. private _draw;
  53703. }
  53704. }
  53705. declare module "babylonjs/LensFlares/index" {
  53706. export * from "babylonjs/LensFlares/lensFlare";
  53707. export * from "babylonjs/LensFlares/lensFlareSystem";
  53708. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  53709. }
  53710. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  53711. import { Scene } from "babylonjs/scene";
  53712. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  53713. import { AbstractScene } from "babylonjs/abstractScene";
  53714. /**
  53715. * Defines the shadow generator component responsible to manage any shadow generators
  53716. * in a given scene.
  53717. */
  53718. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  53719. /**
  53720. * The component name helpfull to identify the component in the list of scene components.
  53721. */
  53722. readonly name: string;
  53723. /**
  53724. * The scene the component belongs to.
  53725. */
  53726. scene: Scene;
  53727. /**
  53728. * Creates a new instance of the component for the given scene
  53729. * @param scene Defines the scene to register the component in
  53730. */
  53731. constructor(scene: Scene);
  53732. /**
  53733. * Registers the component in a given scene
  53734. */
  53735. register(): void;
  53736. /**
  53737. * Rebuilds the elements related to this component in case of
  53738. * context lost for instance.
  53739. */
  53740. rebuild(): void;
  53741. /**
  53742. * Serializes the component data to the specified json object
  53743. * @param serializationObject The object to serialize to
  53744. */
  53745. serialize(serializationObject: any): void;
  53746. /**
  53747. * Adds all the elements from the container to the scene
  53748. * @param container the container holding the elements
  53749. */
  53750. addFromContainer(container: AbstractScene): void;
  53751. /**
  53752. * Removes all the elements in the container from the scene
  53753. * @param container contains the elements to remove
  53754. * @param dispose if the removed element should be disposed (default: false)
  53755. */
  53756. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  53757. /**
  53758. * Rebuilds the elements related to this component in case of
  53759. * context lost for instance.
  53760. */
  53761. dispose(): void;
  53762. private _gatherRenderTargets;
  53763. }
  53764. }
  53765. declare module "babylonjs/Lights/Shadows/index" {
  53766. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  53767. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  53768. }
  53769. declare module "babylonjs/Lights/pointLight" {
  53770. import { Scene } from "babylonjs/scene";
  53771. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  53772. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53773. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  53774. import { Effect } from "babylonjs/Materials/effect";
  53775. /**
  53776. * A point light is a light defined by an unique point in world space.
  53777. * The light is emitted in every direction from this point.
  53778. * A good example of a point light is a standard light bulb.
  53779. * Documentation: https://doc.babylonjs.com/babylon101/lights
  53780. */
  53781. export class PointLight extends ShadowLight {
  53782. private _shadowAngle;
  53783. /**
  53784. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  53785. * This specifies what angle the shadow will use to be created.
  53786. *
  53787. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  53788. */
  53789. /**
  53790. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  53791. * This specifies what angle the shadow will use to be created.
  53792. *
  53793. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  53794. */
  53795. shadowAngle: number;
  53796. /**
  53797. * Gets the direction if it has been set.
  53798. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  53799. */
  53800. /**
  53801. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  53802. */
  53803. direction: Vector3;
  53804. /**
  53805. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  53806. * A PointLight emits the light in every direction.
  53807. * It can cast shadows.
  53808. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  53809. * ```javascript
  53810. * var pointLight = new PointLight("pl", camera.position, scene);
  53811. * ```
  53812. * Documentation : https://doc.babylonjs.com/babylon101/lights
  53813. * @param name The light friendly name
  53814. * @param position The position of the point light in the scene
  53815. * @param scene The scene the lights belongs to
  53816. */
  53817. constructor(name: string, position: Vector3, scene: Scene);
  53818. /**
  53819. * Returns the string "PointLight"
  53820. * @returns the class name
  53821. */
  53822. getClassName(): string;
  53823. /**
  53824. * Returns the integer 0.
  53825. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  53826. */
  53827. getTypeID(): number;
  53828. /**
  53829. * Specifies wether or not the shadowmap should be a cube texture.
  53830. * @returns true if the shadowmap needs to be a cube texture.
  53831. */
  53832. needCube(): boolean;
  53833. /**
  53834. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  53835. * @param faceIndex The index of the face we are computed the direction to generate shadow
  53836. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  53837. */
  53838. getShadowDirection(faceIndex?: number): Vector3;
  53839. /**
  53840. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  53841. * - fov = PI / 2
  53842. * - aspect ratio : 1.0
  53843. * - z-near and far equal to the active camera minZ and maxZ.
  53844. * Returns the PointLight.
  53845. */
  53846. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  53847. protected _buildUniformLayout(): void;
  53848. /**
  53849. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  53850. * @param effect The effect to update
  53851. * @param lightIndex The index of the light in the effect to update
  53852. * @returns The point light
  53853. */
  53854. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  53855. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  53856. /**
  53857. * Prepares the list of defines specific to the light type.
  53858. * @param defines the list of defines
  53859. * @param lightIndex defines the index of the light for the effect
  53860. */
  53861. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  53862. }
  53863. }
  53864. declare module "babylonjs/Lights/index" {
  53865. export * from "babylonjs/Lights/light";
  53866. export * from "babylonjs/Lights/shadowLight";
  53867. export * from "babylonjs/Lights/Shadows/index";
  53868. export * from "babylonjs/Lights/directionalLight";
  53869. export * from "babylonjs/Lights/hemisphericLight";
  53870. export * from "babylonjs/Lights/pointLight";
  53871. export * from "babylonjs/Lights/spotLight";
  53872. }
  53873. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  53874. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  53875. /**
  53876. * Header information of HDR texture files.
  53877. */
  53878. export interface HDRInfo {
  53879. /**
  53880. * The height of the texture in pixels.
  53881. */
  53882. height: number;
  53883. /**
  53884. * The width of the texture in pixels.
  53885. */
  53886. width: number;
  53887. /**
  53888. * The index of the beginning of the data in the binary file.
  53889. */
  53890. dataPosition: number;
  53891. }
  53892. /**
  53893. * This groups tools to convert HDR texture to native colors array.
  53894. */
  53895. export class HDRTools {
  53896. private static Ldexp;
  53897. private static Rgbe2float;
  53898. private static readStringLine;
  53899. /**
  53900. * Reads header information from an RGBE texture stored in a native array.
  53901. * More information on this format are available here:
  53902. * https://en.wikipedia.org/wiki/RGBE_image_format
  53903. *
  53904. * @param uint8array The binary file stored in native array.
  53905. * @return The header information.
  53906. */
  53907. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  53908. /**
  53909. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  53910. * This RGBE texture needs to store the information as a panorama.
  53911. *
  53912. * More information on this format are available here:
  53913. * https://en.wikipedia.org/wiki/RGBE_image_format
  53914. *
  53915. * @param buffer The binary file stored in an array buffer.
  53916. * @param size The expected size of the extracted cubemap.
  53917. * @return The Cube Map information.
  53918. */
  53919. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  53920. /**
  53921. * Returns the pixels data extracted from an RGBE texture.
  53922. * This pixels will be stored left to right up to down in the R G B order in one array.
  53923. *
  53924. * More information on this format are available here:
  53925. * https://en.wikipedia.org/wiki/RGBE_image_format
  53926. *
  53927. * @param uint8array The binary file stored in an array buffer.
  53928. * @param hdrInfo The header information of the file.
  53929. * @return The pixels data in RGB right to left up to down order.
  53930. */
  53931. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  53932. private static RGBE_ReadPixels_RLE;
  53933. }
  53934. }
  53935. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  53936. import { Nullable } from "babylonjs/types";
  53937. import { Scene } from "babylonjs/scene";
  53938. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  53939. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53940. import "babylonjs/Engines/Extensions/engine.rawTexture";
  53941. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  53942. /**
  53943. * This represents a texture coming from an HDR input.
  53944. *
  53945. * The only supported format is currently panorama picture stored in RGBE format.
  53946. * Example of such files can be found on HDRLib: http://hdrlib.com/
  53947. */
  53948. export class HDRCubeTexture extends BaseTexture {
  53949. private static _facesMapping;
  53950. private _generateHarmonics;
  53951. private _noMipmap;
  53952. private _textureMatrix;
  53953. private _size;
  53954. private _onLoad;
  53955. private _onError;
  53956. /**
  53957. * The texture URL.
  53958. */
  53959. url: string;
  53960. /**
  53961. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  53962. */
  53963. coordinatesMode: number;
  53964. protected _isBlocking: boolean;
  53965. /**
  53966. * Sets wether or not the texture is blocking during loading.
  53967. */
  53968. /**
  53969. * Gets wether or not the texture is blocking during loading.
  53970. */
  53971. isBlocking: boolean;
  53972. protected _rotationY: number;
  53973. /**
  53974. * Sets texture matrix rotation angle around Y axis in radians.
  53975. */
  53976. /**
  53977. * Gets texture matrix rotation angle around Y axis radians.
  53978. */
  53979. rotationY: number;
  53980. /**
  53981. * Gets or sets the center of the bounding box associated with the cube texture
  53982. * It must define where the camera used to render the texture was set
  53983. */
  53984. boundingBoxPosition: Vector3;
  53985. private _boundingBoxSize;
  53986. /**
  53987. * Gets or sets the size of the bounding box associated with the cube texture
  53988. * When defined, the cubemap will switch to local mode
  53989. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  53990. * @example https://www.babylonjs-playground.com/#RNASML
  53991. */
  53992. boundingBoxSize: Vector3;
  53993. /**
  53994. * Instantiates an HDRTexture from the following parameters.
  53995. *
  53996. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  53997. * @param scene The scene the texture will be used in
  53998. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  53999. * @param noMipmap Forces to not generate the mipmap if true
  54000. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  54001. * @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)
  54002. * @param reserved Reserved flag for internal use.
  54003. */
  54004. 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>);
  54005. /**
  54006. * Get the current class name of the texture useful for serialization or dynamic coding.
  54007. * @returns "HDRCubeTexture"
  54008. */
  54009. getClassName(): string;
  54010. /**
  54011. * Occurs when the file is raw .hdr file.
  54012. */
  54013. private loadTexture;
  54014. clone(): HDRCubeTexture;
  54015. delayLoad(): void;
  54016. /**
  54017. * Get the texture reflection matrix used to rotate/transform the reflection.
  54018. * @returns the reflection matrix
  54019. */
  54020. getReflectionTextureMatrix(): Matrix;
  54021. /**
  54022. * Set the texture reflection matrix used to rotate/transform the reflection.
  54023. * @param value Define the reflection matrix to set
  54024. */
  54025. setReflectionTextureMatrix(value: Matrix): void;
  54026. /**
  54027. * Parses a JSON representation of an HDR Texture in order to create the texture
  54028. * @param parsedTexture Define the JSON representation
  54029. * @param scene Define the scene the texture should be created in
  54030. * @param rootUrl Define the root url in case we need to load relative dependencies
  54031. * @returns the newly created texture after parsing
  54032. */
  54033. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  54034. serialize(): any;
  54035. }
  54036. }
  54037. declare module "babylonjs/Physics/physicsEngine" {
  54038. import { Nullable } from "babylonjs/types";
  54039. import { Vector3 } from "babylonjs/Maths/math.vector";
  54040. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  54041. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  54042. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  54043. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  54044. /**
  54045. * Class used to control physics engine
  54046. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  54047. */
  54048. export class PhysicsEngine implements IPhysicsEngine {
  54049. private _physicsPlugin;
  54050. /**
  54051. * Global value used to control the smallest number supported by the simulation
  54052. */
  54053. static Epsilon: number;
  54054. private _impostors;
  54055. private _joints;
  54056. /**
  54057. * Gets the gravity vector used by the simulation
  54058. */
  54059. gravity: Vector3;
  54060. /**
  54061. * Factory used to create the default physics plugin.
  54062. * @returns The default physics plugin
  54063. */
  54064. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  54065. /**
  54066. * Creates a new Physics Engine
  54067. * @param gravity defines the gravity vector used by the simulation
  54068. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  54069. */
  54070. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  54071. /**
  54072. * Sets the gravity vector used by the simulation
  54073. * @param gravity defines the gravity vector to use
  54074. */
  54075. setGravity(gravity: Vector3): void;
  54076. /**
  54077. * Set the time step of the physics engine.
  54078. * Default is 1/60.
  54079. * To slow it down, enter 1/600 for example.
  54080. * To speed it up, 1/30
  54081. * @param newTimeStep defines the new timestep to apply to this world.
  54082. */
  54083. setTimeStep(newTimeStep?: number): void;
  54084. /**
  54085. * Get the time step of the physics engine.
  54086. * @returns the current time step
  54087. */
  54088. getTimeStep(): number;
  54089. /**
  54090. * Release all resources
  54091. */
  54092. dispose(): void;
  54093. /**
  54094. * Gets the name of the current physics plugin
  54095. * @returns the name of the plugin
  54096. */
  54097. getPhysicsPluginName(): string;
  54098. /**
  54099. * Adding a new impostor for the impostor tracking.
  54100. * This will be done by the impostor itself.
  54101. * @param impostor the impostor to add
  54102. */
  54103. addImpostor(impostor: PhysicsImpostor): void;
  54104. /**
  54105. * Remove an impostor from the engine.
  54106. * This impostor and its mesh will not longer be updated by the physics engine.
  54107. * @param impostor the impostor to remove
  54108. */
  54109. removeImpostor(impostor: PhysicsImpostor): void;
  54110. /**
  54111. * Add a joint to the physics engine
  54112. * @param mainImpostor defines the main impostor to which the joint is added.
  54113. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  54114. * @param joint defines the joint that will connect both impostors.
  54115. */
  54116. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  54117. /**
  54118. * Removes a joint from the simulation
  54119. * @param mainImpostor defines the impostor used with the joint
  54120. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  54121. * @param joint defines the joint to remove
  54122. */
  54123. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  54124. /**
  54125. * Called by the scene. No need to call it.
  54126. * @param delta defines the timespam between frames
  54127. */
  54128. _step(delta: number): void;
  54129. /**
  54130. * Gets the current plugin used to run the simulation
  54131. * @returns current plugin
  54132. */
  54133. getPhysicsPlugin(): IPhysicsEnginePlugin;
  54134. /**
  54135. * Gets the list of physic impostors
  54136. * @returns an array of PhysicsImpostor
  54137. */
  54138. getImpostors(): Array<PhysicsImpostor>;
  54139. /**
  54140. * Gets the impostor for a physics enabled object
  54141. * @param object defines the object impersonated by the impostor
  54142. * @returns the PhysicsImpostor or null if not found
  54143. */
  54144. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  54145. /**
  54146. * Gets the impostor for a physics body object
  54147. * @param body defines physics body used by the impostor
  54148. * @returns the PhysicsImpostor or null if not found
  54149. */
  54150. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  54151. /**
  54152. * Does a raycast in the physics world
  54153. * @param from when should the ray start?
  54154. * @param to when should the ray end?
  54155. * @returns PhysicsRaycastResult
  54156. */
  54157. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  54158. }
  54159. }
  54160. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  54161. import { Nullable } from "babylonjs/types";
  54162. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  54163. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54164. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  54165. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  54166. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  54167. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  54168. /** @hidden */
  54169. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  54170. private _useDeltaForWorldStep;
  54171. world: any;
  54172. name: string;
  54173. private _physicsMaterials;
  54174. private _fixedTimeStep;
  54175. private _cannonRaycastResult;
  54176. private _raycastResult;
  54177. private _physicsBodysToRemoveAfterStep;
  54178. BJSCANNON: any;
  54179. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  54180. setGravity(gravity: Vector3): void;
  54181. setTimeStep(timeStep: number): void;
  54182. getTimeStep(): number;
  54183. executeStep(delta: number): void;
  54184. private _removeMarkedPhysicsBodiesFromWorld;
  54185. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  54186. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  54187. generatePhysicsBody(impostor: PhysicsImpostor): void;
  54188. private _processChildMeshes;
  54189. removePhysicsBody(impostor: PhysicsImpostor): void;
  54190. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  54191. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  54192. private _addMaterial;
  54193. private _checkWithEpsilon;
  54194. private _createShape;
  54195. private _createHeightmap;
  54196. private _minus90X;
  54197. private _plus90X;
  54198. private _tmpPosition;
  54199. private _tmpDeltaPosition;
  54200. private _tmpUnityRotation;
  54201. private _updatePhysicsBodyTransformation;
  54202. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  54203. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  54204. isSupported(): boolean;
  54205. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  54206. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  54207. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  54208. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  54209. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  54210. getBodyMass(impostor: PhysicsImpostor): number;
  54211. getBodyFriction(impostor: PhysicsImpostor): number;
  54212. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  54213. getBodyRestitution(impostor: PhysicsImpostor): number;
  54214. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  54215. sleepBody(impostor: PhysicsImpostor): void;
  54216. wakeUpBody(impostor: PhysicsImpostor): void;
  54217. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  54218. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  54219. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  54220. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  54221. getRadius(impostor: PhysicsImpostor): number;
  54222. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  54223. dispose(): void;
  54224. private _extendNamespace;
  54225. /**
  54226. * Does a raycast in the physics world
  54227. * @param from when should the ray start?
  54228. * @param to when should the ray end?
  54229. * @returns PhysicsRaycastResult
  54230. */
  54231. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  54232. }
  54233. }
  54234. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  54235. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  54236. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  54237. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  54238. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54239. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  54240. import { Nullable } from "babylonjs/types";
  54241. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  54242. /** @hidden */
  54243. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  54244. world: any;
  54245. name: string;
  54246. BJSOIMO: any;
  54247. private _raycastResult;
  54248. constructor(iterations?: number, oimoInjection?: any);
  54249. setGravity(gravity: Vector3): void;
  54250. setTimeStep(timeStep: number): void;
  54251. getTimeStep(): number;
  54252. private _tmpImpostorsArray;
  54253. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  54254. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  54255. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  54256. generatePhysicsBody(impostor: PhysicsImpostor): void;
  54257. private _tmpPositionVector;
  54258. removePhysicsBody(impostor: PhysicsImpostor): void;
  54259. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  54260. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  54261. isSupported(): boolean;
  54262. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  54263. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  54264. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  54265. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  54266. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  54267. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  54268. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  54269. getBodyMass(impostor: PhysicsImpostor): number;
  54270. getBodyFriction(impostor: PhysicsImpostor): number;
  54271. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  54272. getBodyRestitution(impostor: PhysicsImpostor): number;
  54273. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  54274. sleepBody(impostor: PhysicsImpostor): void;
  54275. wakeUpBody(impostor: PhysicsImpostor): void;
  54276. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  54277. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  54278. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  54279. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  54280. getRadius(impostor: PhysicsImpostor): number;
  54281. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  54282. dispose(): void;
  54283. /**
  54284. * Does a raycast in the physics world
  54285. * @param from when should the ray start?
  54286. * @param to when should the ray end?
  54287. * @returns PhysicsRaycastResult
  54288. */
  54289. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  54290. }
  54291. }
  54292. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  54293. import { Nullable } from "babylonjs/types";
  54294. import { Scene } from "babylonjs/scene";
  54295. import { Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  54296. import { Color4 } from "babylonjs/Maths/math.color";
  54297. import { Mesh } from "babylonjs/Meshes/mesh";
  54298. /**
  54299. * Class containing static functions to help procedurally build meshes
  54300. */
  54301. export class RibbonBuilder {
  54302. /**
  54303. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  54304. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  54305. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  54306. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  54307. * * 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
  54308. * * 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
  54309. * * 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
  54310. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54311. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  54312. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  54313. * * 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
  54314. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  54315. * * 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
  54316. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  54317. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54318. * @param name defines the name of the mesh
  54319. * @param options defines the options used to create the mesh
  54320. * @param scene defines the hosting scene
  54321. * @returns the ribbon mesh
  54322. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  54323. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  54324. */
  54325. static CreateRibbon(name: string, options: {
  54326. pathArray: Vector3[][];
  54327. closeArray?: boolean;
  54328. closePath?: boolean;
  54329. offset?: number;
  54330. updatable?: boolean;
  54331. sideOrientation?: number;
  54332. frontUVs?: Vector4;
  54333. backUVs?: Vector4;
  54334. instance?: Mesh;
  54335. invertUV?: boolean;
  54336. uvs?: Vector2[];
  54337. colors?: Color4[];
  54338. }, scene?: Nullable<Scene>): Mesh;
  54339. }
  54340. }
  54341. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  54342. import { Nullable } from "babylonjs/types";
  54343. import { Scene } from "babylonjs/scene";
  54344. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  54345. import { Mesh } from "babylonjs/Meshes/mesh";
  54346. /**
  54347. * Class containing static functions to help procedurally build meshes
  54348. */
  54349. export class ShapeBuilder {
  54350. /**
  54351. * 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.
  54352. * * 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.
  54353. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  54354. * * 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.
  54355. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  54356. * * 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
  54357. * * 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
  54358. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  54359. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54360. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  54361. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  54362. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  54363. * @param name defines the name of the mesh
  54364. * @param options defines the options used to create the mesh
  54365. * @param scene defines the hosting scene
  54366. * @returns the extruded shape mesh
  54367. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  54368. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  54369. */
  54370. static ExtrudeShape(name: string, options: {
  54371. shape: Vector3[];
  54372. path: Vector3[];
  54373. scale?: number;
  54374. rotation?: number;
  54375. cap?: number;
  54376. updatable?: boolean;
  54377. sideOrientation?: number;
  54378. frontUVs?: Vector4;
  54379. backUVs?: Vector4;
  54380. instance?: Mesh;
  54381. invertUV?: boolean;
  54382. }, scene?: Nullable<Scene>): Mesh;
  54383. /**
  54384. * Creates an custom extruded shape mesh.
  54385. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  54386. * * 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.
  54387. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  54388. * * 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
  54389. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  54390. * * 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
  54391. * * It must returns a float value that will be the scale value applied to the shape on each path point
  54392. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  54393. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  54394. * * 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
  54395. * * 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
  54396. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  54397. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54398. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  54399. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  54400. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54401. * @param name defines the name of the mesh
  54402. * @param options defines the options used to create the mesh
  54403. * @param scene defines the hosting scene
  54404. * @returns the custom extruded shape mesh
  54405. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  54406. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  54407. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  54408. */
  54409. static ExtrudeShapeCustom(name: string, options: {
  54410. shape: Vector3[];
  54411. path: Vector3[];
  54412. scaleFunction?: any;
  54413. rotationFunction?: any;
  54414. ribbonCloseArray?: boolean;
  54415. ribbonClosePath?: boolean;
  54416. cap?: number;
  54417. updatable?: boolean;
  54418. sideOrientation?: number;
  54419. frontUVs?: Vector4;
  54420. backUVs?: Vector4;
  54421. instance?: Mesh;
  54422. invertUV?: boolean;
  54423. }, scene?: Nullable<Scene>): Mesh;
  54424. private static _ExtrudeShapeGeneric;
  54425. }
  54426. }
  54427. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  54428. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  54429. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  54430. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  54431. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  54432. import { Nullable } from "babylonjs/types";
  54433. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54434. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  54435. /**
  54436. * AmmoJS Physics plugin
  54437. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  54438. * @see https://github.com/kripken/ammo.js/
  54439. */
  54440. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  54441. private _useDeltaForWorldStep;
  54442. /**
  54443. * Reference to the Ammo library
  54444. */
  54445. bjsAMMO: any;
  54446. /**
  54447. * Created ammoJS world which physics bodies are added to
  54448. */
  54449. world: any;
  54450. /**
  54451. * Name of the plugin
  54452. */
  54453. name: string;
  54454. private _timeStep;
  54455. private _fixedTimeStep;
  54456. private _maxSteps;
  54457. private _tmpQuaternion;
  54458. private _tmpAmmoTransform;
  54459. private _tmpAmmoQuaternion;
  54460. private _tmpAmmoConcreteContactResultCallback;
  54461. private _collisionConfiguration;
  54462. private _dispatcher;
  54463. private _overlappingPairCache;
  54464. private _solver;
  54465. private _softBodySolver;
  54466. private _tmpAmmoVectorA;
  54467. private _tmpAmmoVectorB;
  54468. private _tmpAmmoVectorC;
  54469. private _tmpAmmoVectorD;
  54470. private _tmpContactCallbackResult;
  54471. private _tmpAmmoVectorRCA;
  54472. private _tmpAmmoVectorRCB;
  54473. private _raycastResult;
  54474. private static readonly DISABLE_COLLISION_FLAG;
  54475. private static readonly KINEMATIC_FLAG;
  54476. private static readonly DISABLE_DEACTIVATION_FLAG;
  54477. /**
  54478. * Initializes the ammoJS plugin
  54479. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  54480. * @param ammoInjection can be used to inject your own ammo reference
  54481. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  54482. */
  54483. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  54484. /**
  54485. * Sets the gravity of the physics world (m/(s^2))
  54486. * @param gravity Gravity to set
  54487. */
  54488. setGravity(gravity: Vector3): void;
  54489. /**
  54490. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  54491. * @param timeStep timestep to use in seconds
  54492. */
  54493. setTimeStep(timeStep: number): void;
  54494. /**
  54495. * 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)
  54496. * @param fixedTimeStep fixedTimeStep to use in seconds
  54497. */
  54498. setFixedTimeStep(fixedTimeStep: number): void;
  54499. /**
  54500. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  54501. * @param maxSteps the maximum number of steps by the physics engine per frame
  54502. */
  54503. setMaxSteps(maxSteps: number): void;
  54504. /**
  54505. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  54506. * @returns the current timestep in seconds
  54507. */
  54508. getTimeStep(): number;
  54509. private _isImpostorInContact;
  54510. private _isImpostorPairInContact;
  54511. private _stepSimulation;
  54512. /**
  54513. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  54514. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  54515. * After the step the babylon meshes are set to the position of the physics imposters
  54516. * @param delta amount of time to step forward
  54517. * @param impostors array of imposters to update before/after the step
  54518. */
  54519. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  54520. /**
  54521. * Update babylon mesh to match physics world object
  54522. * @param impostor imposter to match
  54523. */
  54524. private _afterSoftStep;
  54525. /**
  54526. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  54527. * @param impostor imposter to match
  54528. */
  54529. private _ropeStep;
  54530. /**
  54531. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  54532. * @param impostor imposter to match
  54533. */
  54534. private _softbodyOrClothStep;
  54535. private _tmpVector;
  54536. private _tmpMatrix;
  54537. /**
  54538. * Applies an impulse on the imposter
  54539. * @param impostor imposter to apply impulse to
  54540. * @param force amount of force to be applied to the imposter
  54541. * @param contactPoint the location to apply the impulse on the imposter
  54542. */
  54543. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  54544. /**
  54545. * Applies a force on the imposter
  54546. * @param impostor imposter to apply force
  54547. * @param force amount of force to be applied to the imposter
  54548. * @param contactPoint the location to apply the force on the imposter
  54549. */
  54550. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  54551. /**
  54552. * Creates a physics body using the plugin
  54553. * @param impostor the imposter to create the physics body on
  54554. */
  54555. generatePhysicsBody(impostor: PhysicsImpostor): void;
  54556. /**
  54557. * Removes the physics body from the imposter and disposes of the body's memory
  54558. * @param impostor imposter to remove the physics body from
  54559. */
  54560. removePhysicsBody(impostor: PhysicsImpostor): void;
  54561. /**
  54562. * Generates a joint
  54563. * @param impostorJoint the imposter joint to create the joint with
  54564. */
  54565. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  54566. /**
  54567. * Removes a joint
  54568. * @param impostorJoint the imposter joint to remove the joint from
  54569. */
  54570. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  54571. private _addMeshVerts;
  54572. /**
  54573. * Initialise the soft body vertices to match its object's (mesh) vertices
  54574. * Softbody vertices (nodes) are in world space and to match this
  54575. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  54576. * @param impostor to create the softbody for
  54577. */
  54578. private _softVertexData;
  54579. /**
  54580. * Create an impostor's soft body
  54581. * @param impostor to create the softbody for
  54582. */
  54583. private _createSoftbody;
  54584. /**
  54585. * Create cloth for an impostor
  54586. * @param impostor to create the softbody for
  54587. */
  54588. private _createCloth;
  54589. /**
  54590. * Create rope for an impostor
  54591. * @param impostor to create the softbody for
  54592. */
  54593. private _createRope;
  54594. private _addHullVerts;
  54595. private _createShape;
  54596. /**
  54597. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  54598. * @param impostor imposter containing the physics body and babylon object
  54599. */
  54600. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  54601. /**
  54602. * Sets the babylon object's position/rotation from the physics body's position/rotation
  54603. * @param impostor imposter containing the physics body and babylon object
  54604. * @param newPosition new position
  54605. * @param newRotation new rotation
  54606. */
  54607. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  54608. /**
  54609. * If this plugin is supported
  54610. * @returns true if its supported
  54611. */
  54612. isSupported(): boolean;
  54613. /**
  54614. * Sets the linear velocity of the physics body
  54615. * @param impostor imposter to set the velocity on
  54616. * @param velocity velocity to set
  54617. */
  54618. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  54619. /**
  54620. * Sets the angular velocity of the physics body
  54621. * @param impostor imposter to set the velocity on
  54622. * @param velocity velocity to set
  54623. */
  54624. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  54625. /**
  54626. * gets the linear velocity
  54627. * @param impostor imposter to get linear velocity from
  54628. * @returns linear velocity
  54629. */
  54630. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  54631. /**
  54632. * gets the angular velocity
  54633. * @param impostor imposter to get angular velocity from
  54634. * @returns angular velocity
  54635. */
  54636. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  54637. /**
  54638. * Sets the mass of physics body
  54639. * @param impostor imposter to set the mass on
  54640. * @param mass mass to set
  54641. */
  54642. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  54643. /**
  54644. * Gets the mass of the physics body
  54645. * @param impostor imposter to get the mass from
  54646. * @returns mass
  54647. */
  54648. getBodyMass(impostor: PhysicsImpostor): number;
  54649. /**
  54650. * Gets friction of the impostor
  54651. * @param impostor impostor to get friction from
  54652. * @returns friction value
  54653. */
  54654. getBodyFriction(impostor: PhysicsImpostor): number;
  54655. /**
  54656. * Sets friction of the impostor
  54657. * @param impostor impostor to set friction on
  54658. * @param friction friction value
  54659. */
  54660. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  54661. /**
  54662. * Gets restitution of the impostor
  54663. * @param impostor impostor to get restitution from
  54664. * @returns restitution value
  54665. */
  54666. getBodyRestitution(impostor: PhysicsImpostor): number;
  54667. /**
  54668. * Sets resitution of the impostor
  54669. * @param impostor impostor to set resitution on
  54670. * @param restitution resitution value
  54671. */
  54672. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  54673. /**
  54674. * Gets pressure inside the impostor
  54675. * @param impostor impostor to get pressure from
  54676. * @returns pressure value
  54677. */
  54678. getBodyPressure(impostor: PhysicsImpostor): number;
  54679. /**
  54680. * Sets pressure inside a soft body impostor
  54681. * Cloth and rope must remain 0 pressure
  54682. * @param impostor impostor to set pressure on
  54683. * @param pressure pressure value
  54684. */
  54685. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  54686. /**
  54687. * Gets stiffness of the impostor
  54688. * @param impostor impostor to get stiffness from
  54689. * @returns pressure value
  54690. */
  54691. getBodyStiffness(impostor: PhysicsImpostor): number;
  54692. /**
  54693. * Sets stiffness of the impostor
  54694. * @param impostor impostor to set stiffness on
  54695. * @param stiffness stiffness value from 0 to 1
  54696. */
  54697. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  54698. /**
  54699. * Gets velocityIterations of the impostor
  54700. * @param impostor impostor to get velocity iterations from
  54701. * @returns velocityIterations value
  54702. */
  54703. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  54704. /**
  54705. * Sets velocityIterations of the impostor
  54706. * @param impostor impostor to set velocity iterations on
  54707. * @param velocityIterations velocityIterations value
  54708. */
  54709. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  54710. /**
  54711. * Gets positionIterations of the impostor
  54712. * @param impostor impostor to get position iterations from
  54713. * @returns positionIterations value
  54714. */
  54715. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  54716. /**
  54717. * Sets positionIterations of the impostor
  54718. * @param impostor impostor to set position on
  54719. * @param positionIterations positionIterations value
  54720. */
  54721. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  54722. /**
  54723. * Append an anchor to a cloth object
  54724. * @param impostor is the cloth impostor to add anchor to
  54725. * @param otherImpostor is the rigid impostor to anchor to
  54726. * @param width ratio across width from 0 to 1
  54727. * @param height ratio up height from 0 to 1
  54728. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  54729. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  54730. */
  54731. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  54732. /**
  54733. * Append an hook to a rope object
  54734. * @param impostor is the rope impostor to add hook to
  54735. * @param otherImpostor is the rigid impostor to hook to
  54736. * @param length ratio along the rope from 0 to 1
  54737. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  54738. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  54739. */
  54740. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  54741. /**
  54742. * Sleeps the physics body and stops it from being active
  54743. * @param impostor impostor to sleep
  54744. */
  54745. sleepBody(impostor: PhysicsImpostor): void;
  54746. /**
  54747. * Activates the physics body
  54748. * @param impostor impostor to activate
  54749. */
  54750. wakeUpBody(impostor: PhysicsImpostor): void;
  54751. /**
  54752. * Updates the distance parameters of the joint
  54753. * @param joint joint to update
  54754. * @param maxDistance maximum distance of the joint
  54755. * @param minDistance minimum distance of the joint
  54756. */
  54757. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  54758. /**
  54759. * Sets a motor on the joint
  54760. * @param joint joint to set motor on
  54761. * @param speed speed of the motor
  54762. * @param maxForce maximum force of the motor
  54763. * @param motorIndex index of the motor
  54764. */
  54765. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  54766. /**
  54767. * Sets the motors limit
  54768. * @param joint joint to set limit on
  54769. * @param upperLimit upper limit
  54770. * @param lowerLimit lower limit
  54771. */
  54772. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  54773. /**
  54774. * Syncs the position and rotation of a mesh with the impostor
  54775. * @param mesh mesh to sync
  54776. * @param impostor impostor to update the mesh with
  54777. */
  54778. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  54779. /**
  54780. * Gets the radius of the impostor
  54781. * @param impostor impostor to get radius from
  54782. * @returns the radius
  54783. */
  54784. getRadius(impostor: PhysicsImpostor): number;
  54785. /**
  54786. * Gets the box size of the impostor
  54787. * @param impostor impostor to get box size from
  54788. * @param result the resulting box size
  54789. */
  54790. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  54791. /**
  54792. * Disposes of the impostor
  54793. */
  54794. dispose(): void;
  54795. /**
  54796. * Does a raycast in the physics world
  54797. * @param from when should the ray start?
  54798. * @param to when should the ray end?
  54799. * @returns PhysicsRaycastResult
  54800. */
  54801. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  54802. }
  54803. }
  54804. declare module "babylonjs/Probes/reflectionProbe" {
  54805. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  54806. import { Vector3 } from "babylonjs/Maths/math.vector";
  54807. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54808. import { Nullable } from "babylonjs/types";
  54809. import { Scene } from "babylonjs/scene";
  54810. module "babylonjs/abstractScene" {
  54811. interface AbstractScene {
  54812. /**
  54813. * The list of reflection probes added to the scene
  54814. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  54815. */
  54816. reflectionProbes: Array<ReflectionProbe>;
  54817. /**
  54818. * Removes the given reflection probe from this scene.
  54819. * @param toRemove The reflection probe to remove
  54820. * @returns The index of the removed reflection probe
  54821. */
  54822. removeReflectionProbe(toRemove: ReflectionProbe): number;
  54823. /**
  54824. * Adds the given reflection probe to this scene.
  54825. * @param newReflectionProbe The reflection probe to add
  54826. */
  54827. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  54828. }
  54829. }
  54830. /**
  54831. * Class used to generate realtime reflection / refraction cube textures
  54832. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  54833. */
  54834. export class ReflectionProbe {
  54835. /** defines the name of the probe */
  54836. name: string;
  54837. private _scene;
  54838. private _renderTargetTexture;
  54839. private _projectionMatrix;
  54840. private _viewMatrix;
  54841. private _target;
  54842. private _add;
  54843. private _attachedMesh;
  54844. private _invertYAxis;
  54845. /** Gets or sets probe position (center of the cube map) */
  54846. position: Vector3;
  54847. /**
  54848. * Creates a new reflection probe
  54849. * @param name defines the name of the probe
  54850. * @param size defines the texture resolution (for each face)
  54851. * @param scene defines the hosting scene
  54852. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  54853. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  54854. */
  54855. constructor(
  54856. /** defines the name of the probe */
  54857. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  54858. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  54859. samples: number;
  54860. /** Gets or sets the refresh rate to use (on every frame by default) */
  54861. refreshRate: number;
  54862. /**
  54863. * Gets the hosting scene
  54864. * @returns a Scene
  54865. */
  54866. getScene(): Scene;
  54867. /** Gets the internal CubeTexture used to render to */
  54868. readonly cubeTexture: RenderTargetTexture;
  54869. /** Gets the list of meshes to render */
  54870. readonly renderList: Nullable<AbstractMesh[]>;
  54871. /**
  54872. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  54873. * @param mesh defines the mesh to attach to
  54874. */
  54875. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  54876. /**
  54877. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  54878. * @param renderingGroupId The rendering group id corresponding to its index
  54879. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  54880. */
  54881. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  54882. /**
  54883. * Clean all associated resources
  54884. */
  54885. dispose(): void;
  54886. /**
  54887. * Converts the reflection probe information to a readable string for debug purpose.
  54888. * @param fullDetails Supports for multiple levels of logging within scene loading
  54889. * @returns the human readable reflection probe info
  54890. */
  54891. toString(fullDetails?: boolean): string;
  54892. /**
  54893. * Get the class name of the relfection probe.
  54894. * @returns "ReflectionProbe"
  54895. */
  54896. getClassName(): string;
  54897. /**
  54898. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  54899. * @returns The JSON representation of the texture
  54900. */
  54901. serialize(): any;
  54902. /**
  54903. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  54904. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  54905. * @param scene Define the scene the parsed reflection probe should be instantiated in
  54906. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  54907. * @returns The parsed reflection probe if successful
  54908. */
  54909. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  54910. }
  54911. }
  54912. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  54913. /** @hidden */
  54914. export var _BabylonLoaderRegistered: boolean;
  54915. /**
  54916. * Helps setting up some configuration for the babylon file loader.
  54917. */
  54918. export class BabylonFileLoaderConfiguration {
  54919. /**
  54920. * The loader does not allow injecting custom physix engine into the plugins.
  54921. * Unfortunately in ES6, we need to manually inject them into the plugin.
  54922. * So you could set this variable to your engine import to make it work.
  54923. */
  54924. static LoaderInjectedPhysicsEngine: any;
  54925. }
  54926. }
  54927. declare module "babylonjs/Loading/Plugins/index" {
  54928. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  54929. }
  54930. declare module "babylonjs/Loading/index" {
  54931. export * from "babylonjs/Loading/loadingScreen";
  54932. export * from "babylonjs/Loading/Plugins/index";
  54933. export * from "babylonjs/Loading/sceneLoader";
  54934. export * from "babylonjs/Loading/sceneLoaderFlags";
  54935. }
  54936. declare module "babylonjs/Materials/Background/index" {
  54937. export * from "babylonjs/Materials/Background/backgroundMaterial";
  54938. }
  54939. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  54940. import { Scene } from "babylonjs/scene";
  54941. import { Color3 } from "babylonjs/Maths/math.color";
  54942. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  54943. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54944. /**
  54945. * The Physically based simple base material of BJS.
  54946. *
  54947. * This enables better naming and convention enforcements on top of the pbrMaterial.
  54948. * It is used as the base class for both the specGloss and metalRough conventions.
  54949. */
  54950. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  54951. /**
  54952. * Number of Simultaneous lights allowed on the material.
  54953. */
  54954. maxSimultaneousLights: number;
  54955. /**
  54956. * If sets to true, disables all the lights affecting the material.
  54957. */
  54958. disableLighting: boolean;
  54959. /**
  54960. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  54961. */
  54962. environmentTexture: BaseTexture;
  54963. /**
  54964. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  54965. */
  54966. invertNormalMapX: boolean;
  54967. /**
  54968. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  54969. */
  54970. invertNormalMapY: boolean;
  54971. /**
  54972. * Normal map used in the model.
  54973. */
  54974. normalTexture: BaseTexture;
  54975. /**
  54976. * Emissivie color used to self-illuminate the model.
  54977. */
  54978. emissiveColor: Color3;
  54979. /**
  54980. * Emissivie texture used to self-illuminate the model.
  54981. */
  54982. emissiveTexture: BaseTexture;
  54983. /**
  54984. * Occlusion Channel Strenght.
  54985. */
  54986. occlusionStrength: number;
  54987. /**
  54988. * Occlusion Texture of the material (adding extra occlusion effects).
  54989. */
  54990. occlusionTexture: BaseTexture;
  54991. /**
  54992. * Defines the alpha limits in alpha test mode.
  54993. */
  54994. alphaCutOff: number;
  54995. /**
  54996. * Gets the current double sided mode.
  54997. */
  54998. /**
  54999. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  55000. */
  55001. doubleSided: boolean;
  55002. /**
  55003. * Stores the pre-calculated light information of a mesh in a texture.
  55004. */
  55005. lightmapTexture: BaseTexture;
  55006. /**
  55007. * If true, the light map contains occlusion information instead of lighting info.
  55008. */
  55009. useLightmapAsShadowmap: boolean;
  55010. /**
  55011. * Instantiates a new PBRMaterial instance.
  55012. *
  55013. * @param name The material name
  55014. * @param scene The scene the material will be use in.
  55015. */
  55016. constructor(name: string, scene: Scene);
  55017. getClassName(): string;
  55018. }
  55019. }
  55020. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  55021. import { Scene } from "babylonjs/scene";
  55022. import { Color3 } from "babylonjs/Maths/math.color";
  55023. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55024. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  55025. /**
  55026. * The PBR material of BJS following the metal roughness convention.
  55027. *
  55028. * This fits to the PBR convention in the GLTF definition:
  55029. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  55030. */
  55031. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  55032. /**
  55033. * The base color has two different interpretations depending on the value of metalness.
  55034. * When the material is a metal, the base color is the specific measured reflectance value
  55035. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  55036. * of the material.
  55037. */
  55038. baseColor: Color3;
  55039. /**
  55040. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  55041. * well as opacity information in the alpha channel.
  55042. */
  55043. baseTexture: BaseTexture;
  55044. /**
  55045. * Specifies the metallic scalar value of the material.
  55046. * Can also be used to scale the metalness values of the metallic texture.
  55047. */
  55048. metallic: number;
  55049. /**
  55050. * Specifies the roughness scalar value of the material.
  55051. * Can also be used to scale the roughness values of the metallic texture.
  55052. */
  55053. roughness: number;
  55054. /**
  55055. * Texture containing both the metallic value in the B channel and the
  55056. * roughness value in the G channel to keep better precision.
  55057. */
  55058. metallicRoughnessTexture: BaseTexture;
  55059. /**
  55060. * Instantiates a new PBRMetalRoughnessMaterial instance.
  55061. *
  55062. * @param name The material name
  55063. * @param scene The scene the material will be use in.
  55064. */
  55065. constructor(name: string, scene: Scene);
  55066. /**
  55067. * Return the currrent class name of the material.
  55068. */
  55069. getClassName(): string;
  55070. /**
  55071. * Makes a duplicate of the current material.
  55072. * @param name - name to use for the new material.
  55073. */
  55074. clone(name: string): PBRMetallicRoughnessMaterial;
  55075. /**
  55076. * Serialize the material to a parsable JSON object.
  55077. */
  55078. serialize(): any;
  55079. /**
  55080. * Parses a JSON object correponding to the serialize function.
  55081. */
  55082. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  55083. }
  55084. }
  55085. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  55086. import { Scene } from "babylonjs/scene";
  55087. import { Color3 } from "babylonjs/Maths/math.color";
  55088. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55089. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  55090. /**
  55091. * The PBR material of BJS following the specular glossiness convention.
  55092. *
  55093. * This fits to the PBR convention in the GLTF definition:
  55094. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  55095. */
  55096. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  55097. /**
  55098. * Specifies the diffuse color of the material.
  55099. */
  55100. diffuseColor: Color3;
  55101. /**
  55102. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  55103. * channel.
  55104. */
  55105. diffuseTexture: BaseTexture;
  55106. /**
  55107. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  55108. */
  55109. specularColor: Color3;
  55110. /**
  55111. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  55112. */
  55113. glossiness: number;
  55114. /**
  55115. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  55116. */
  55117. specularGlossinessTexture: BaseTexture;
  55118. /**
  55119. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  55120. *
  55121. * @param name The material name
  55122. * @param scene The scene the material will be use in.
  55123. */
  55124. constructor(name: string, scene: Scene);
  55125. /**
  55126. * Return the currrent class name of the material.
  55127. */
  55128. getClassName(): string;
  55129. /**
  55130. * Makes a duplicate of the current material.
  55131. * @param name - name to use for the new material.
  55132. */
  55133. clone(name: string): PBRSpecularGlossinessMaterial;
  55134. /**
  55135. * Serialize the material to a parsable JSON object.
  55136. */
  55137. serialize(): any;
  55138. /**
  55139. * Parses a JSON object correponding to the serialize function.
  55140. */
  55141. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  55142. }
  55143. }
  55144. declare module "babylonjs/Materials/PBR/index" {
  55145. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  55146. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  55147. export * from "babylonjs/Materials/PBR/pbrMaterial";
  55148. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  55149. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  55150. }
  55151. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  55152. import { Nullable } from "babylonjs/types";
  55153. import { Scene } from "babylonjs/scene";
  55154. import { Matrix } from "babylonjs/Maths/math.vector";
  55155. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55156. /**
  55157. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  55158. * It can help converting any input color in a desired output one. This can then be used to create effects
  55159. * from sepia, black and white to sixties or futuristic rendering...
  55160. *
  55161. * The only supported format is currently 3dl.
  55162. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  55163. */
  55164. export class ColorGradingTexture extends BaseTexture {
  55165. /**
  55166. * The current texture matrix. (will always be identity in color grading texture)
  55167. */
  55168. private _textureMatrix;
  55169. /**
  55170. * The texture URL.
  55171. */
  55172. url: string;
  55173. /**
  55174. * Empty line regex stored for GC.
  55175. */
  55176. private static _noneEmptyLineRegex;
  55177. private _engine;
  55178. /**
  55179. * Instantiates a ColorGradingTexture from the following parameters.
  55180. *
  55181. * @param url The location of the color gradind data (currently only supporting 3dl)
  55182. * @param scene The scene the texture will be used in
  55183. */
  55184. constructor(url: string, scene: Scene);
  55185. /**
  55186. * Returns the texture matrix used in most of the material.
  55187. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  55188. */
  55189. getTextureMatrix(): Matrix;
  55190. /**
  55191. * Occurs when the file being loaded is a .3dl LUT file.
  55192. */
  55193. private load3dlTexture;
  55194. /**
  55195. * Starts the loading process of the texture.
  55196. */
  55197. private loadTexture;
  55198. /**
  55199. * Clones the color gradind texture.
  55200. */
  55201. clone(): ColorGradingTexture;
  55202. /**
  55203. * Called during delayed load for textures.
  55204. */
  55205. delayLoad(): void;
  55206. /**
  55207. * Parses a color grading texture serialized by Babylon.
  55208. * @param parsedTexture The texture information being parsedTexture
  55209. * @param scene The scene to load the texture in
  55210. * @param rootUrl The root url of the data assets to load
  55211. * @return A color gradind texture
  55212. */
  55213. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  55214. /**
  55215. * Serializes the LUT texture to json format.
  55216. */
  55217. serialize(): any;
  55218. }
  55219. }
  55220. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  55221. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55222. import { Scene } from "babylonjs/scene";
  55223. import { Nullable } from "babylonjs/types";
  55224. import "babylonjs/Engines/Extensions/engine.rawTexture";
  55225. /**
  55226. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  55227. */
  55228. export class EquiRectangularCubeTexture extends BaseTexture {
  55229. /** The six faces of the cube. */
  55230. private static _FacesMapping;
  55231. private _noMipmap;
  55232. private _onLoad;
  55233. private _onError;
  55234. /** The size of the cubemap. */
  55235. private _size;
  55236. /** The buffer of the image. */
  55237. private _buffer;
  55238. /** The width of the input image. */
  55239. private _width;
  55240. /** The height of the input image. */
  55241. private _height;
  55242. /** The URL to the image. */
  55243. url: string;
  55244. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  55245. coordinatesMode: number;
  55246. /**
  55247. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  55248. * @param url The location of the image
  55249. * @param scene The scene the texture will be used in
  55250. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  55251. * @param noMipmap Forces to not generate the mipmap if true
  55252. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  55253. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  55254. * @param onLoad — defines a callback called when texture is loaded
  55255. * @param onError — defines a callback called if there is an error
  55256. */
  55257. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  55258. /**
  55259. * Load the image data, by putting the image on a canvas and extracting its buffer.
  55260. */
  55261. private loadImage;
  55262. /**
  55263. * Convert the image buffer into a cubemap and create a CubeTexture.
  55264. */
  55265. private loadTexture;
  55266. /**
  55267. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  55268. * @param buffer The ArrayBuffer that should be converted.
  55269. * @returns The buffer as Float32Array.
  55270. */
  55271. private getFloat32ArrayFromArrayBuffer;
  55272. /**
  55273. * Get the current class name of the texture useful for serialization or dynamic coding.
  55274. * @returns "EquiRectangularCubeTexture"
  55275. */
  55276. getClassName(): string;
  55277. /**
  55278. * Create a clone of the current EquiRectangularCubeTexture and return it.
  55279. * @returns A clone of the current EquiRectangularCubeTexture.
  55280. */
  55281. clone(): EquiRectangularCubeTexture;
  55282. }
  55283. }
  55284. declare module "babylonjs/Misc/tga" {
  55285. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  55286. /**
  55287. * Based on jsTGALoader - Javascript loader for TGA file
  55288. * By Vincent Thibault
  55289. * @see http://blog.robrowser.com/javascript-tga-loader.html
  55290. */
  55291. export class TGATools {
  55292. private static _TYPE_INDEXED;
  55293. private static _TYPE_RGB;
  55294. private static _TYPE_GREY;
  55295. private static _TYPE_RLE_INDEXED;
  55296. private static _TYPE_RLE_RGB;
  55297. private static _TYPE_RLE_GREY;
  55298. private static _ORIGIN_MASK;
  55299. private static _ORIGIN_SHIFT;
  55300. private static _ORIGIN_BL;
  55301. private static _ORIGIN_BR;
  55302. private static _ORIGIN_UL;
  55303. private static _ORIGIN_UR;
  55304. /**
  55305. * Gets the header of a TGA file
  55306. * @param data defines the TGA data
  55307. * @returns the header
  55308. */
  55309. static GetTGAHeader(data: Uint8Array): any;
  55310. /**
  55311. * Uploads TGA content to a Babylon Texture
  55312. * @hidden
  55313. */
  55314. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  55315. /** @hidden */
  55316. 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;
  55317. /** @hidden */
  55318. 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;
  55319. /** @hidden */
  55320. 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;
  55321. /** @hidden */
  55322. 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;
  55323. /** @hidden */
  55324. 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;
  55325. /** @hidden */
  55326. 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;
  55327. }
  55328. }
  55329. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  55330. import { Nullable } from "babylonjs/types";
  55331. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  55332. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  55333. /**
  55334. * Implementation of the TGA Texture Loader.
  55335. * @hidden
  55336. */
  55337. export class _TGATextureLoader implements IInternalTextureLoader {
  55338. /**
  55339. * Defines wether the loader supports cascade loading the different faces.
  55340. */
  55341. readonly supportCascades: boolean;
  55342. /**
  55343. * This returns if the loader support the current file information.
  55344. * @param extension defines the file extension of the file being loaded
  55345. * @param textureFormatInUse defines the current compressed format in use iun the engine
  55346. * @param fallback defines the fallback internal texture if any
  55347. * @param isBase64 defines whether the texture is encoded as a base64
  55348. * @param isBuffer defines whether the texture data are stored as a buffer
  55349. * @returns true if the loader can load the specified file
  55350. */
  55351. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  55352. /**
  55353. * Transform the url before loading if required.
  55354. * @param rootUrl the url of the texture
  55355. * @param textureFormatInUse defines the current compressed format in use iun the engine
  55356. * @returns the transformed texture
  55357. */
  55358. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  55359. /**
  55360. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  55361. * @param rootUrl the url of the texture
  55362. * @param textureFormatInUse defines the current compressed format in use iun the engine
  55363. * @returns the fallback texture
  55364. */
  55365. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  55366. /**
  55367. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  55368. * @param data contains the texture data
  55369. * @param texture defines the BabylonJS internal texture
  55370. * @param createPolynomials will be true if polynomials have been requested
  55371. * @param onLoad defines the callback to trigger once the texture is ready
  55372. * @param onError defines the callback to trigger in case of error
  55373. */
  55374. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  55375. /**
  55376. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  55377. * @param data contains the texture data
  55378. * @param texture defines the BabylonJS internal texture
  55379. * @param callback defines the method to call once ready to upload
  55380. */
  55381. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  55382. }
  55383. }
  55384. declare module "babylonjs/Misc/basis" {
  55385. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  55386. /**
  55387. * Info about the .basis files
  55388. */
  55389. class BasisFileInfo {
  55390. /**
  55391. * If the file has alpha
  55392. */
  55393. hasAlpha: boolean;
  55394. /**
  55395. * Info about each image of the basis file
  55396. */
  55397. images: Array<{
  55398. levels: Array<{
  55399. width: number;
  55400. height: number;
  55401. transcodedPixels: ArrayBufferView;
  55402. }>;
  55403. }>;
  55404. }
  55405. /**
  55406. * Result of transcoding a basis file
  55407. */
  55408. class TranscodeResult {
  55409. /**
  55410. * Info about the .basis file
  55411. */
  55412. fileInfo: BasisFileInfo;
  55413. /**
  55414. * Format to use when loading the file
  55415. */
  55416. format: number;
  55417. }
  55418. /**
  55419. * Configuration options for the Basis transcoder
  55420. */
  55421. export class BasisTranscodeConfiguration {
  55422. /**
  55423. * Supported compression formats used to determine the supported output format of the transcoder
  55424. */
  55425. supportedCompressionFormats?: {
  55426. /**
  55427. * etc1 compression format
  55428. */
  55429. etc1?: boolean;
  55430. /**
  55431. * s3tc compression format
  55432. */
  55433. s3tc?: boolean;
  55434. /**
  55435. * pvrtc compression format
  55436. */
  55437. pvrtc?: boolean;
  55438. /**
  55439. * etc2 compression format
  55440. */
  55441. etc2?: boolean;
  55442. };
  55443. /**
  55444. * If mipmap levels should be loaded for transcoded images (Default: true)
  55445. */
  55446. loadMipmapLevels?: boolean;
  55447. /**
  55448. * Index of a single image to load (Default: all images)
  55449. */
  55450. loadSingleImage?: number;
  55451. }
  55452. /**
  55453. * Used to load .Basis files
  55454. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  55455. */
  55456. export class BasisTools {
  55457. private static _IgnoreSupportedFormats;
  55458. /**
  55459. * URL to use when loading the basis transcoder
  55460. */
  55461. static JSModuleURL: string;
  55462. /**
  55463. * URL to use when loading the wasm module for the transcoder
  55464. */
  55465. static WasmModuleURL: string;
  55466. /**
  55467. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  55468. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  55469. * @returns internal format corresponding to the Basis format
  55470. */
  55471. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  55472. private static _WorkerPromise;
  55473. private static _Worker;
  55474. private static _actionId;
  55475. private static _CreateWorkerAsync;
  55476. /**
  55477. * Transcodes a loaded image file to compressed pixel data
  55478. * @param imageData image data to transcode
  55479. * @param config configuration options for the transcoding
  55480. * @returns a promise resulting in the transcoded image
  55481. */
  55482. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  55483. /**
  55484. * Loads a texture from the transcode result
  55485. * @param texture texture load to
  55486. * @param transcodeResult the result of transcoding the basis file to load from
  55487. */
  55488. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  55489. }
  55490. }
  55491. declare module "babylonjs/Materials/Textures/Loaders/basisTextureLoader" {
  55492. import { Nullable } from "babylonjs/types";
  55493. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  55494. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  55495. /**
  55496. * Loader for .basis file format
  55497. */
  55498. export class _BasisTextureLoader implements IInternalTextureLoader {
  55499. /**
  55500. * Defines whether the loader supports cascade loading the different faces.
  55501. */
  55502. readonly supportCascades: boolean;
  55503. /**
  55504. * This returns if the loader support the current file information.
  55505. * @param extension defines the file extension of the file being loaded
  55506. * @param textureFormatInUse defines the current compressed format in use iun the engine
  55507. * @param fallback defines the fallback internal texture if any
  55508. * @param isBase64 defines whether the texture is encoded as a base64
  55509. * @param isBuffer defines whether the texture data are stored as a buffer
  55510. * @returns true if the loader can load the specified file
  55511. */
  55512. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  55513. /**
  55514. * Transform the url before loading if required.
  55515. * @param rootUrl the url of the texture
  55516. * @param textureFormatInUse defines the current compressed format in use iun the engine
  55517. * @returns the transformed texture
  55518. */
  55519. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  55520. /**
  55521. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  55522. * @param rootUrl the url of the texture
  55523. * @param textureFormatInUse defines the current compressed format in use iun the engine
  55524. * @returns the fallback texture
  55525. */
  55526. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  55527. /**
  55528. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  55529. * @param data contains the texture data
  55530. * @param texture defines the BabylonJS internal texture
  55531. * @param createPolynomials will be true if polynomials have been requested
  55532. * @param onLoad defines the callback to trigger once the texture is ready
  55533. * @param onError defines the callback to trigger in case of error
  55534. */
  55535. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  55536. /**
  55537. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  55538. * @param data contains the texture data
  55539. * @param texture defines the BabylonJS internal texture
  55540. * @param callback defines the method to call once ready to upload
  55541. */
  55542. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  55543. }
  55544. }
  55545. declare module "babylonjs/Materials/Textures/Loaders/index" {
  55546. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  55547. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  55548. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  55549. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  55550. export * from "babylonjs/Materials/Textures/Loaders/basisTextureLoader";
  55551. }
  55552. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  55553. import { Scene } from "babylonjs/scene";
  55554. import { Texture } from "babylonjs/Materials/Textures/texture";
  55555. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  55556. /**
  55557. * 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.
  55558. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  55559. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  55560. */
  55561. export class CustomProceduralTexture extends ProceduralTexture {
  55562. private _animate;
  55563. private _time;
  55564. private _config;
  55565. private _texturePath;
  55566. /**
  55567. * Instantiates a new Custom Procedural Texture.
  55568. * 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.
  55569. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  55570. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  55571. * @param name Define the name of the texture
  55572. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  55573. * @param size Define the size of the texture to create
  55574. * @param scene Define the scene the texture belongs to
  55575. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  55576. * @param generateMipMaps Define if the texture should creates mip maps or not
  55577. */
  55578. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  55579. private _loadJson;
  55580. /**
  55581. * Is the texture ready to be used ? (rendered at least once)
  55582. * @returns true if ready, otherwise, false.
  55583. */
  55584. isReady(): boolean;
  55585. /**
  55586. * Render the texture to its associated render target.
  55587. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  55588. */
  55589. render(useCameraPostProcess?: boolean): void;
  55590. /**
  55591. * Update the list of dependant textures samplers in the shader.
  55592. */
  55593. updateTextures(): void;
  55594. /**
  55595. * Update the uniform values of the procedural texture in the shader.
  55596. */
  55597. updateShaderUniforms(): void;
  55598. /**
  55599. * Define if the texture animates or not.
  55600. */
  55601. animate: boolean;
  55602. }
  55603. }
  55604. declare module "babylonjs/Shaders/noise.fragment" {
  55605. /** @hidden */
  55606. export var noisePixelShader: {
  55607. name: string;
  55608. shader: string;
  55609. };
  55610. }
  55611. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  55612. import { Nullable } from "babylonjs/types";
  55613. import { Scene } from "babylonjs/scene";
  55614. import { Texture } from "babylonjs/Materials/Textures/texture";
  55615. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  55616. import "babylonjs/Shaders/noise.fragment";
  55617. /**
  55618. * Class used to generate noise procedural textures
  55619. */
  55620. export class NoiseProceduralTexture extends ProceduralTexture {
  55621. private _time;
  55622. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  55623. brightness: number;
  55624. /** Defines the number of octaves to process */
  55625. octaves: number;
  55626. /** Defines the level of persistence (0.8 by default) */
  55627. persistence: number;
  55628. /** Gets or sets animation speed factor (default is 1) */
  55629. animationSpeedFactor: number;
  55630. /**
  55631. * Creates a new NoiseProceduralTexture
  55632. * @param name defines the name fo the texture
  55633. * @param size defines the size of the texture (default is 256)
  55634. * @param scene defines the hosting scene
  55635. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  55636. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  55637. */
  55638. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  55639. private _updateShaderUniforms;
  55640. protected _getDefines(): string;
  55641. /** Generate the current state of the procedural texture */
  55642. render(useCameraPostProcess?: boolean): void;
  55643. /**
  55644. * Serializes this noise procedural texture
  55645. * @returns a serialized noise procedural texture object
  55646. */
  55647. serialize(): any;
  55648. /**
  55649. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  55650. * @param parsedTexture defines parsed texture data
  55651. * @param scene defines the current scene
  55652. * @param rootUrl defines the root URL containing noise procedural texture information
  55653. * @returns a parsed NoiseProceduralTexture
  55654. */
  55655. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  55656. }
  55657. }
  55658. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  55659. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  55660. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  55661. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  55662. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  55663. }
  55664. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  55665. import { Nullable } from "babylonjs/types";
  55666. import { Scene } from "babylonjs/scene";
  55667. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  55668. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  55669. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  55670. import "babylonjs/Engines/Extensions/engine.rawTexture";
  55671. /**
  55672. * Raw cube texture where the raw buffers are passed in
  55673. */
  55674. export class RawCubeTexture extends CubeTexture {
  55675. /**
  55676. * Creates a cube texture where the raw buffers are passed in.
  55677. * @param scene defines the scene the texture is attached to
  55678. * @param data defines the array of data to use to create each face
  55679. * @param size defines the size of the textures
  55680. * @param format defines the format of the data
  55681. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  55682. * @param generateMipMaps defines if the engine should generate the mip levels
  55683. * @param invertY defines if data must be stored with Y axis inverted
  55684. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  55685. * @param compression defines the compression used (null by default)
  55686. */
  55687. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  55688. /**
  55689. * Updates the raw cube texture.
  55690. * @param data defines the data to store
  55691. * @param format defines the data format
  55692. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  55693. * @param invertY defines if data must be stored with Y axis inverted
  55694. * @param compression defines the compression used (null by default)
  55695. * @param level defines which level of the texture to update
  55696. */
  55697. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  55698. /**
  55699. * Updates a raw cube texture with RGBD encoded data.
  55700. * @param data defines the array of data [mipmap][face] to use to create each face
  55701. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  55702. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  55703. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  55704. * @returns a promsie that resolves when the operation is complete
  55705. */
  55706. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  55707. /**
  55708. * Clones the raw cube texture.
  55709. * @return a new cube texture
  55710. */
  55711. clone(): CubeTexture;
  55712. /** @hidden */
  55713. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  55714. }
  55715. }
  55716. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  55717. import { Scene } from "babylonjs/scene";
  55718. import { Texture } from "babylonjs/Materials/Textures/texture";
  55719. import "babylonjs/Engines/Extensions/engine.rawTexture";
  55720. /**
  55721. * Class used to store 3D textures containing user data
  55722. */
  55723. export class RawTexture3D extends Texture {
  55724. /** Gets or sets the texture format to use */
  55725. format: number;
  55726. private _engine;
  55727. /**
  55728. * Create a new RawTexture3D
  55729. * @param data defines the data of the texture
  55730. * @param width defines the width of the texture
  55731. * @param height defines the height of the texture
  55732. * @param depth defines the depth of the texture
  55733. * @param format defines the texture format to use
  55734. * @param scene defines the hosting scene
  55735. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  55736. * @param invertY defines if texture must be stored with Y axis inverted
  55737. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  55738. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  55739. */
  55740. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  55741. /** Gets or sets the texture format to use */
  55742. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  55743. /**
  55744. * Update the texture with new data
  55745. * @param data defines the data to store in the texture
  55746. */
  55747. update(data: ArrayBufferView): void;
  55748. }
  55749. }
  55750. declare module "babylonjs/Materials/Textures/rawTexture2DArray" {
  55751. import { Scene } from "babylonjs/scene";
  55752. import { Texture } from "babylonjs/Materials/Textures/texture";
  55753. import "babylonjs/Engines/Extensions/engine.rawTexture";
  55754. /**
  55755. * Class used to store 2D array textures containing user data
  55756. */
  55757. export class RawTexture2DArray extends Texture {
  55758. /** Gets or sets the texture format to use */
  55759. format: number;
  55760. private _engine;
  55761. /**
  55762. * Create a new RawTexture2DArray
  55763. * @param data defines the data of the texture
  55764. * @param width defines the width of the texture
  55765. * @param height defines the height of the texture
  55766. * @param depth defines the number of layers of the texture
  55767. * @param format defines the texture format to use
  55768. * @param scene defines the hosting scene
  55769. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  55770. * @param invertY defines if texture must be stored with Y axis inverted
  55771. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  55772. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  55773. */
  55774. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  55775. /** Gets or sets the texture format to use */
  55776. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  55777. /**
  55778. * Update the texture with new data
  55779. * @param data defines the data to store in the texture
  55780. */
  55781. update(data: ArrayBufferView): void;
  55782. }
  55783. }
  55784. declare module "babylonjs/Materials/Textures/refractionTexture" {
  55785. import { Scene } from "babylonjs/scene";
  55786. import { Plane } from "babylonjs/Maths/math.plane";
  55787. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  55788. /**
  55789. * Creates a refraction texture used by refraction channel of the standard material.
  55790. * It is like a mirror but to see through a material.
  55791. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  55792. */
  55793. export class RefractionTexture extends RenderTargetTexture {
  55794. /**
  55795. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  55796. * 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.
  55797. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  55798. */
  55799. refractionPlane: Plane;
  55800. /**
  55801. * Define how deep under the surface we should see.
  55802. */
  55803. depth: number;
  55804. /**
  55805. * Creates a refraction texture used by refraction channel of the standard material.
  55806. * It is like a mirror but to see through a material.
  55807. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  55808. * @param name Define the texture name
  55809. * @param size Define the size of the underlying texture
  55810. * @param scene Define the scene the refraction belongs to
  55811. * @param generateMipMaps Define if we need to generate mips level for the refraction
  55812. */
  55813. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  55814. /**
  55815. * Clone the refraction texture.
  55816. * @returns the cloned texture
  55817. */
  55818. clone(): RefractionTexture;
  55819. /**
  55820. * Serialize the texture to a JSON representation you could use in Parse later on
  55821. * @returns the serialized JSON representation
  55822. */
  55823. serialize(): any;
  55824. }
  55825. }
  55826. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  55827. import { Nullable } from "babylonjs/types";
  55828. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55829. import { Matrix } from "babylonjs/Maths/math.vector";
  55830. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  55831. import "babylonjs/Engines/Extensions/engine.videoTexture";
  55832. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  55833. import { Scene } from "babylonjs/scene";
  55834. /**
  55835. * Defines the options related to the creation of an HtmlElementTexture
  55836. */
  55837. export interface IHtmlElementTextureOptions {
  55838. /**
  55839. * Defines wether mip maps should be created or not.
  55840. */
  55841. generateMipMaps?: boolean;
  55842. /**
  55843. * Defines the sampling mode of the texture.
  55844. */
  55845. samplingMode?: number;
  55846. /**
  55847. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  55848. */
  55849. engine: Nullable<ThinEngine>;
  55850. /**
  55851. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  55852. */
  55853. scene: Nullable<Scene>;
  55854. }
  55855. /**
  55856. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  55857. * To be as efficient as possible depending on your constraints nothing aside the first upload
  55858. * is automatically managed.
  55859. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  55860. * in your application.
  55861. *
  55862. * As the update is not automatic, you need to call them manually.
  55863. */
  55864. export class HtmlElementTexture extends BaseTexture {
  55865. /**
  55866. * The texture URL.
  55867. */
  55868. element: HTMLVideoElement | HTMLCanvasElement;
  55869. private static readonly DefaultOptions;
  55870. private _textureMatrix;
  55871. private _engine;
  55872. private _isVideo;
  55873. private _generateMipMaps;
  55874. private _samplingMode;
  55875. /**
  55876. * Instantiates a HtmlElementTexture from the following parameters.
  55877. *
  55878. * @param name Defines the name of the texture
  55879. * @param element Defines the video or canvas the texture is filled with
  55880. * @param options Defines the other none mandatory texture creation options
  55881. */
  55882. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  55883. private _createInternalTexture;
  55884. /**
  55885. * Returns the texture matrix used in most of the material.
  55886. */
  55887. getTextureMatrix(): Matrix;
  55888. /**
  55889. * Updates the content of the texture.
  55890. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  55891. */
  55892. update(invertY?: Nullable<boolean>): void;
  55893. }
  55894. }
  55895. declare module "babylonjs/Materials/Textures/index" {
  55896. export * from "babylonjs/Materials/Textures/baseTexture";
  55897. export * from "babylonjs/Materials/Textures/baseTexture.polynomial";
  55898. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  55899. export * from "babylonjs/Materials/Textures/cubeTexture";
  55900. export * from "babylonjs/Materials/Textures/dynamicTexture";
  55901. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  55902. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  55903. export * from "babylonjs/Materials/Textures/internalTexture";
  55904. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  55905. export * from "babylonjs/Materials/Textures/Loaders/index";
  55906. export * from "babylonjs/Materials/Textures/mirrorTexture";
  55907. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  55908. export * from "babylonjs/Materials/Textures/Procedurals/index";
  55909. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  55910. export * from "babylonjs/Materials/Textures/rawTexture";
  55911. export * from "babylonjs/Materials/Textures/rawTexture3D";
  55912. export * from "babylonjs/Materials/Textures/rawTexture2DArray";
  55913. export * from "babylonjs/Materials/Textures/refractionTexture";
  55914. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  55915. export * from "babylonjs/Materials/Textures/texture";
  55916. export * from "babylonjs/Materials/Textures/videoTexture";
  55917. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  55918. }
  55919. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets" {
  55920. /**
  55921. * Enum used to define the target of a block
  55922. */
  55923. export enum NodeMaterialBlockTargets {
  55924. /** Vertex shader */
  55925. Vertex = 1,
  55926. /** Fragment shader */
  55927. Fragment = 2,
  55928. /** Neutral */
  55929. Neutral = 4,
  55930. /** Vertex and Fragment */
  55931. VertexAndFragment = 3
  55932. }
  55933. }
  55934. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes" {
  55935. /**
  55936. * Defines the kind of connection point for node based material
  55937. */
  55938. export enum NodeMaterialBlockConnectionPointTypes {
  55939. /** Float */
  55940. Float = 1,
  55941. /** Int */
  55942. Int = 2,
  55943. /** Vector2 */
  55944. Vector2 = 4,
  55945. /** Vector3 */
  55946. Vector3 = 8,
  55947. /** Vector4 */
  55948. Vector4 = 16,
  55949. /** Color3 */
  55950. Color3 = 32,
  55951. /** Color4 */
  55952. Color4 = 64,
  55953. /** Matrix */
  55954. Matrix = 128,
  55955. /** Detect type based on connection */
  55956. AutoDetect = 1024,
  55957. /** Output type that will be defined by input type */
  55958. BasedOnInput = 2048
  55959. }
  55960. }
  55961. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode" {
  55962. /**
  55963. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  55964. */
  55965. export enum NodeMaterialBlockConnectionPointMode {
  55966. /** Value is an uniform */
  55967. Uniform = 0,
  55968. /** Value is a mesh attribute */
  55969. Attribute = 1,
  55970. /** Value is a varying between vertex and fragment shaders */
  55971. Varying = 2,
  55972. /** Mode is undefined */
  55973. Undefined = 3
  55974. }
  55975. }
  55976. declare module "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues" {
  55977. /**
  55978. * Enum used to define system values e.g. values automatically provided by the system
  55979. */
  55980. export enum NodeMaterialSystemValues {
  55981. /** World */
  55982. World = 1,
  55983. /** View */
  55984. View = 2,
  55985. /** Projection */
  55986. Projection = 3,
  55987. /** ViewProjection */
  55988. ViewProjection = 4,
  55989. /** WorldView */
  55990. WorldView = 5,
  55991. /** WorldViewProjection */
  55992. WorldViewProjection = 6,
  55993. /** CameraPosition */
  55994. CameraPosition = 7,
  55995. /** Fog Color */
  55996. FogColor = 8,
  55997. /** Delta time */
  55998. DeltaTime = 9
  55999. }
  56000. }
  56001. declare module "babylonjs/Materials/Node/Enums/index" {
  56002. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  56003. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  56004. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode";
  56005. export * from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  56006. }
  56007. declare module "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer" {
  56008. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56009. /**
  56010. * Root class for all node material optimizers
  56011. */
  56012. export class NodeMaterialOptimizer {
  56013. /**
  56014. * Function used to optimize a NodeMaterial graph
  56015. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  56016. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  56017. */
  56018. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  56019. }
  56020. }
  56021. declare module "babylonjs/Materials/Node/Blocks/transformBlock" {
  56022. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56023. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56024. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56025. import { Scene } from "babylonjs/scene";
  56026. /**
  56027. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  56028. */
  56029. export class TransformBlock extends NodeMaterialBlock {
  56030. /**
  56031. * Defines the value to use to complement W value to transform it to a Vector4
  56032. */
  56033. complementW: number;
  56034. /**
  56035. * Defines the value to use to complement z value to transform it to a Vector4
  56036. */
  56037. complementZ: number;
  56038. /**
  56039. * Creates a new TransformBlock
  56040. * @param name defines the block name
  56041. */
  56042. constructor(name: string);
  56043. /**
  56044. * Gets the current class name
  56045. * @returns the class name
  56046. */
  56047. getClassName(): string;
  56048. /**
  56049. * Gets the vector input
  56050. */
  56051. readonly vector: NodeMaterialConnectionPoint;
  56052. /**
  56053. * Gets the output component
  56054. */
  56055. readonly output: NodeMaterialConnectionPoint;
  56056. /**
  56057. * Gets the matrix transform input
  56058. */
  56059. readonly transform: NodeMaterialConnectionPoint;
  56060. protected _buildBlock(state: NodeMaterialBuildState): this;
  56061. serialize(): any;
  56062. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56063. protected _dumpPropertiesCode(): string;
  56064. }
  56065. }
  56066. declare module "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock" {
  56067. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56068. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56069. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56070. /**
  56071. * Block used to output the vertex position
  56072. */
  56073. export class VertexOutputBlock extends NodeMaterialBlock {
  56074. /**
  56075. * Creates a new VertexOutputBlock
  56076. * @param name defines the block name
  56077. */
  56078. constructor(name: string);
  56079. /**
  56080. * Gets the current class name
  56081. * @returns the class name
  56082. */
  56083. getClassName(): string;
  56084. /**
  56085. * Gets the vector input component
  56086. */
  56087. readonly vector: NodeMaterialConnectionPoint;
  56088. protected _buildBlock(state: NodeMaterialBuildState): this;
  56089. }
  56090. }
  56091. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock" {
  56092. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56093. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56094. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56095. /**
  56096. * Block used to output the final color
  56097. */
  56098. export class FragmentOutputBlock extends NodeMaterialBlock {
  56099. /**
  56100. * Create a new FragmentOutputBlock
  56101. * @param name defines the block name
  56102. */
  56103. constructor(name: string);
  56104. /**
  56105. * Gets the current class name
  56106. * @returns the class name
  56107. */
  56108. getClassName(): string;
  56109. /**
  56110. * Gets the rgba input component
  56111. */
  56112. readonly rgba: NodeMaterialConnectionPoint;
  56113. /**
  56114. * Gets the rgb input component
  56115. */
  56116. readonly rgb: NodeMaterialConnectionPoint;
  56117. /**
  56118. * Gets the a input component
  56119. */
  56120. readonly a: NodeMaterialConnectionPoint;
  56121. protected _buildBlock(state: NodeMaterialBuildState): this;
  56122. }
  56123. }
  56124. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock" {
  56125. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56126. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56127. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56128. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56129. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56130. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56131. import { Effect } from "babylonjs/Materials/effect";
  56132. import { Mesh } from "babylonjs/Meshes/mesh";
  56133. import { Nullable } from "babylonjs/types";
  56134. import { Scene } from "babylonjs/scene";
  56135. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  56136. /**
  56137. * Block used to read a reflection texture from a sampler
  56138. */
  56139. export class ReflectionTextureBlock extends NodeMaterialBlock {
  56140. private _define3DName;
  56141. private _defineCubicName;
  56142. private _defineExplicitName;
  56143. private _defineProjectionName;
  56144. private _defineLocalCubicName;
  56145. private _defineSphericalName;
  56146. private _definePlanarName;
  56147. private _defineEquirectangularName;
  56148. private _defineMirroredEquirectangularFixedName;
  56149. private _defineEquirectangularFixedName;
  56150. private _defineSkyboxName;
  56151. private _cubeSamplerName;
  56152. private _2DSamplerName;
  56153. private _positionUVWName;
  56154. private _directionWName;
  56155. private _reflectionCoordsName;
  56156. private _reflection2DCoordsName;
  56157. private _reflectionColorName;
  56158. private _reflectionMatrixName;
  56159. /**
  56160. * Gets or sets the texture associated with the node
  56161. */
  56162. texture: Nullable<BaseTexture>;
  56163. /**
  56164. * Create a new TextureBlock
  56165. * @param name defines the block name
  56166. */
  56167. constructor(name: string);
  56168. /**
  56169. * Gets the current class name
  56170. * @returns the class name
  56171. */
  56172. getClassName(): string;
  56173. /**
  56174. * Gets the world position input component
  56175. */
  56176. readonly position: NodeMaterialConnectionPoint;
  56177. /**
  56178. * Gets the world position input component
  56179. */
  56180. readonly worldPosition: NodeMaterialConnectionPoint;
  56181. /**
  56182. * Gets the world normal input component
  56183. */
  56184. readonly worldNormal: NodeMaterialConnectionPoint;
  56185. /**
  56186. * Gets the world input component
  56187. */
  56188. readonly world: NodeMaterialConnectionPoint;
  56189. /**
  56190. * Gets the camera (or eye) position component
  56191. */
  56192. readonly cameraPosition: NodeMaterialConnectionPoint;
  56193. /**
  56194. * Gets the view input component
  56195. */
  56196. readonly view: NodeMaterialConnectionPoint;
  56197. /**
  56198. * Gets the rgb output component
  56199. */
  56200. readonly rgb: NodeMaterialConnectionPoint;
  56201. /**
  56202. * Gets the r output component
  56203. */
  56204. readonly r: NodeMaterialConnectionPoint;
  56205. /**
  56206. * Gets the g output component
  56207. */
  56208. readonly g: NodeMaterialConnectionPoint;
  56209. /**
  56210. * Gets the b output component
  56211. */
  56212. readonly b: NodeMaterialConnectionPoint;
  56213. autoConfigure(material: NodeMaterial): void;
  56214. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56215. isReady(): boolean;
  56216. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56217. private _injectVertexCode;
  56218. private _writeOutput;
  56219. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  56220. protected _dumpPropertiesCode(): string;
  56221. serialize(): any;
  56222. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56223. }
  56224. }
  56225. declare module "babylonjs/Materials/Node/nodeMaterial" {
  56226. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56227. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  56228. import { Scene } from "babylonjs/scene";
  56229. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56230. import { Matrix } from "babylonjs/Maths/math.vector";
  56231. import { Mesh } from "babylonjs/Meshes/mesh";
  56232. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56233. import { Observable } from "babylonjs/Misc/observable";
  56234. import { SubMesh } from "babylonjs/Meshes/subMesh";
  56235. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  56236. import { NodeMaterialOptimizer } from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  56237. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  56238. import { Nullable } from "babylonjs/types";
  56239. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  56240. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  56241. import { ReflectionTextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  56242. /**
  56243. * Interface used to configure the node material editor
  56244. */
  56245. export interface INodeMaterialEditorOptions {
  56246. /** Define the URl to load node editor script */
  56247. editorURL?: string;
  56248. }
  56249. /** @hidden */
  56250. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  56251. /** BONES */
  56252. NUM_BONE_INFLUENCERS: number;
  56253. BonesPerMesh: number;
  56254. BONETEXTURE: boolean;
  56255. /** MORPH TARGETS */
  56256. MORPHTARGETS: boolean;
  56257. MORPHTARGETS_NORMAL: boolean;
  56258. MORPHTARGETS_TANGENT: boolean;
  56259. MORPHTARGETS_UV: boolean;
  56260. NUM_MORPH_INFLUENCERS: number;
  56261. /** IMAGE PROCESSING */
  56262. IMAGEPROCESSING: boolean;
  56263. VIGNETTE: boolean;
  56264. VIGNETTEBLENDMODEMULTIPLY: boolean;
  56265. VIGNETTEBLENDMODEOPAQUE: boolean;
  56266. TONEMAPPING: boolean;
  56267. TONEMAPPING_ACES: boolean;
  56268. CONTRAST: boolean;
  56269. EXPOSURE: boolean;
  56270. COLORCURVES: boolean;
  56271. COLORGRADING: boolean;
  56272. COLORGRADING3D: boolean;
  56273. SAMPLER3DGREENDEPTH: boolean;
  56274. SAMPLER3DBGRMAP: boolean;
  56275. IMAGEPROCESSINGPOSTPROCESS: boolean;
  56276. /** MISC. */
  56277. BUMPDIRECTUV: number;
  56278. constructor();
  56279. setValue(name: string, value: boolean): void;
  56280. }
  56281. /**
  56282. * Class used to configure NodeMaterial
  56283. */
  56284. export interface INodeMaterialOptions {
  56285. /**
  56286. * Defines if blocks should emit comments
  56287. */
  56288. emitComments: boolean;
  56289. }
  56290. /**
  56291. * Class used to create a node based material built by assembling shader blocks
  56292. */
  56293. export class NodeMaterial extends PushMaterial {
  56294. private static _BuildIdGenerator;
  56295. private _options;
  56296. private _vertexCompilationState;
  56297. private _fragmentCompilationState;
  56298. private _sharedData;
  56299. private _buildId;
  56300. private _buildWasSuccessful;
  56301. private _cachedWorldViewMatrix;
  56302. private _cachedWorldViewProjectionMatrix;
  56303. private _optimizers;
  56304. private _animationFrame;
  56305. /** Define the URl to load node editor script */
  56306. static EditorURL: string;
  56307. private BJSNODEMATERIALEDITOR;
  56308. /** Get the inspector from bundle or global */
  56309. private _getGlobalNodeMaterialEditor;
  56310. /**
  56311. * Gets or sets data used by visual editor
  56312. * @see https://nme.babylonjs.com
  56313. */
  56314. editorData: any;
  56315. /**
  56316. * 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)
  56317. */
  56318. ignoreAlpha: boolean;
  56319. /**
  56320. * Defines the maximum number of lights that can be used in the material
  56321. */
  56322. maxSimultaneousLights: number;
  56323. /**
  56324. * Observable raised when the material is built
  56325. */
  56326. onBuildObservable: Observable<NodeMaterial>;
  56327. /**
  56328. * Gets or sets the root nodes of the material vertex shader
  56329. */
  56330. _vertexOutputNodes: NodeMaterialBlock[];
  56331. /**
  56332. * Gets or sets the root nodes of the material fragment (pixel) shader
  56333. */
  56334. _fragmentOutputNodes: NodeMaterialBlock[];
  56335. /** Gets or sets options to control the node material overall behavior */
  56336. options: INodeMaterialOptions;
  56337. /**
  56338. * Default configuration related to image processing available in the standard Material.
  56339. */
  56340. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  56341. /**
  56342. * Gets the image processing configuration used either in this material.
  56343. */
  56344. /**
  56345. * Sets the Default image processing configuration used either in the this material.
  56346. *
  56347. * If sets to null, the scene one is in use.
  56348. */
  56349. imageProcessingConfiguration: ImageProcessingConfiguration;
  56350. /**
  56351. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  56352. */
  56353. attachedBlocks: NodeMaterialBlock[];
  56354. /**
  56355. * Create a new node based material
  56356. * @param name defines the material name
  56357. * @param scene defines the hosting scene
  56358. * @param options defines creation option
  56359. */
  56360. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  56361. /**
  56362. * Gets the current class name of the material e.g. "NodeMaterial"
  56363. * @returns the class name
  56364. */
  56365. getClassName(): string;
  56366. /**
  56367. * Keep track of the image processing observer to allow dispose and replace.
  56368. */
  56369. private _imageProcessingObserver;
  56370. /**
  56371. * Attaches a new image processing configuration to the Standard Material.
  56372. * @param configuration
  56373. */
  56374. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  56375. /**
  56376. * Get a block by its name
  56377. * @param name defines the name of the block to retrieve
  56378. * @returns the required block or null if not found
  56379. */
  56380. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  56381. /**
  56382. * Get a block by its name
  56383. * @param predicate defines the predicate used to find the good candidate
  56384. * @returns the required block or null if not found
  56385. */
  56386. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  56387. /**
  56388. * Get an input block by its name
  56389. * @param predicate defines the predicate used to find the good candidate
  56390. * @returns the required input block or null if not found
  56391. */
  56392. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  56393. /**
  56394. * Gets the list of input blocks attached to this material
  56395. * @returns an array of InputBlocks
  56396. */
  56397. getInputBlocks(): InputBlock[];
  56398. /**
  56399. * Adds a new optimizer to the list of optimizers
  56400. * @param optimizer defines the optimizers to add
  56401. * @returns the current material
  56402. */
  56403. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  56404. /**
  56405. * Remove an optimizer from the list of optimizers
  56406. * @param optimizer defines the optimizers to remove
  56407. * @returns the current material
  56408. */
  56409. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  56410. /**
  56411. * Add a new block to the list of output nodes
  56412. * @param node defines the node to add
  56413. * @returns the current material
  56414. */
  56415. addOutputNode(node: NodeMaterialBlock): this;
  56416. /**
  56417. * Remove a block from the list of root nodes
  56418. * @param node defines the node to remove
  56419. * @returns the current material
  56420. */
  56421. removeOutputNode(node: NodeMaterialBlock): this;
  56422. private _addVertexOutputNode;
  56423. private _removeVertexOutputNode;
  56424. private _addFragmentOutputNode;
  56425. private _removeFragmentOutputNode;
  56426. /**
  56427. * Specifies if the material will require alpha blending
  56428. * @returns a boolean specifying if alpha blending is needed
  56429. */
  56430. needAlphaBlending(): boolean;
  56431. /**
  56432. * Specifies if this material should be rendered in alpha test mode
  56433. * @returns a boolean specifying if an alpha test is needed.
  56434. */
  56435. needAlphaTesting(): boolean;
  56436. private _initializeBlock;
  56437. private _resetDualBlocks;
  56438. /**
  56439. * Build the material and generates the inner effect
  56440. * @param verbose defines if the build should log activity
  56441. */
  56442. build(verbose?: boolean): void;
  56443. /**
  56444. * Runs an otpimization phase to try to improve the shader code
  56445. */
  56446. optimize(): void;
  56447. private _prepareDefinesForAttributes;
  56448. /**
  56449. * Get if the submesh is ready to be used and all its information available.
  56450. * Child classes can use it to update shaders
  56451. * @param mesh defines the mesh to check
  56452. * @param subMesh defines which submesh to check
  56453. * @param useInstances specifies that instances should be used
  56454. * @returns a boolean indicating that the submesh is ready or not
  56455. */
  56456. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  56457. /**
  56458. * Get a string representing the shaders built by the current node graph
  56459. */
  56460. readonly compiledShaders: string;
  56461. /**
  56462. * Binds the world matrix to the material
  56463. * @param world defines the world transformation matrix
  56464. */
  56465. bindOnlyWorldMatrix(world: Matrix): void;
  56466. /**
  56467. * Binds the submesh to this material by preparing the effect and shader to draw
  56468. * @param world defines the world transformation matrix
  56469. * @param mesh defines the mesh containing the submesh
  56470. * @param subMesh defines the submesh to bind the material to
  56471. */
  56472. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  56473. /**
  56474. * Gets the active textures from the material
  56475. * @returns an array of textures
  56476. */
  56477. getActiveTextures(): BaseTexture[];
  56478. /**
  56479. * Gets the list of texture blocks
  56480. * @returns an array of texture blocks
  56481. */
  56482. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  56483. /**
  56484. * Specifies if the material uses a texture
  56485. * @param texture defines the texture to check against the material
  56486. * @returns a boolean specifying if the material uses the texture
  56487. */
  56488. hasTexture(texture: BaseTexture): boolean;
  56489. /**
  56490. * Disposes the material
  56491. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  56492. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  56493. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  56494. */
  56495. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  56496. /** Creates the node editor window. */
  56497. private _createNodeEditor;
  56498. /**
  56499. * Launch the node material editor
  56500. * @param config Define the configuration of the editor
  56501. * @return a promise fulfilled when the node editor is visible
  56502. */
  56503. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  56504. /**
  56505. * Clear the current material
  56506. */
  56507. clear(): void;
  56508. /**
  56509. * Clear the current material and set it to a default state
  56510. */
  56511. setToDefault(): void;
  56512. /**
  56513. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  56514. * @param url defines the url to load from
  56515. * @returns a promise that will fullfil when the material is fully loaded
  56516. */
  56517. loadAsync(url: string): Promise<void>;
  56518. private _gatherBlocks;
  56519. /**
  56520. * Generate a string containing the code declaration required to create an equivalent of this material
  56521. * @returns a string
  56522. */
  56523. generateCode(): string;
  56524. /**
  56525. * Serializes this material in a JSON representation
  56526. * @returns the serialized material object
  56527. */
  56528. serialize(): any;
  56529. private _restoreConnections;
  56530. /**
  56531. * Clear the current graph and load a new one from a serialization object
  56532. * @param source defines the JSON representation of the material
  56533. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  56534. */
  56535. loadFromSerialization(source: any, rootUrl?: string): void;
  56536. /**
  56537. * Creates a node material from parsed material data
  56538. * @param source defines the JSON representation of the material
  56539. * @param scene defines the hosting scene
  56540. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  56541. * @returns a new node material
  56542. */
  56543. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  56544. /**
  56545. * Creates a new node material set to default basic configuration
  56546. * @param name defines the name of the material
  56547. * @param scene defines the hosting scene
  56548. * @returns a new NodeMaterial
  56549. */
  56550. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  56551. }
  56552. }
  56553. declare module "babylonjs/Materials/Node/Blocks/Dual/textureBlock" {
  56554. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56555. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56556. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  56557. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56558. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56559. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56560. import { Effect } from "babylonjs/Materials/effect";
  56561. import { Mesh } from "babylonjs/Meshes/mesh";
  56562. import { Nullable } from "babylonjs/types";
  56563. import { Texture } from "babylonjs/Materials/Textures/texture";
  56564. import { Scene } from "babylonjs/scene";
  56565. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  56566. /**
  56567. * Block used to read a texture from a sampler
  56568. */
  56569. export class TextureBlock extends NodeMaterialBlock {
  56570. private _defineName;
  56571. private _linearDefineName;
  56572. private _tempTextureRead;
  56573. private _samplerName;
  56574. private _transformedUVName;
  56575. private _textureTransformName;
  56576. private _textureInfoName;
  56577. private _mainUVName;
  56578. private _mainUVDefineName;
  56579. /**
  56580. * Gets or sets the texture associated with the node
  56581. */
  56582. texture: Nullable<Texture>;
  56583. /**
  56584. * Create a new TextureBlock
  56585. * @param name defines the block name
  56586. */
  56587. constructor(name: string);
  56588. /**
  56589. * Gets the current class name
  56590. * @returns the class name
  56591. */
  56592. getClassName(): string;
  56593. /**
  56594. * Gets the uv input component
  56595. */
  56596. readonly uv: NodeMaterialConnectionPoint;
  56597. /**
  56598. * Gets the rgba output component
  56599. */
  56600. readonly rgba: NodeMaterialConnectionPoint;
  56601. /**
  56602. * Gets the rgb output component
  56603. */
  56604. readonly rgb: NodeMaterialConnectionPoint;
  56605. /**
  56606. * Gets the r output component
  56607. */
  56608. readonly r: NodeMaterialConnectionPoint;
  56609. /**
  56610. * Gets the g output component
  56611. */
  56612. readonly g: NodeMaterialConnectionPoint;
  56613. /**
  56614. * Gets the b output component
  56615. */
  56616. readonly b: NodeMaterialConnectionPoint;
  56617. /**
  56618. * Gets the a output component
  56619. */
  56620. readonly a: NodeMaterialConnectionPoint;
  56621. readonly target: NodeMaterialBlockTargets;
  56622. autoConfigure(material: NodeMaterial): void;
  56623. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  56624. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56625. private _getTextureBase;
  56626. isReady(): boolean;
  56627. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56628. private readonly _isMixed;
  56629. private _injectVertexCode;
  56630. private _writeTextureRead;
  56631. private _writeOutput;
  56632. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  56633. protected _dumpPropertiesCode(): string;
  56634. serialize(): any;
  56635. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56636. }
  56637. }
  56638. declare module "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData" {
  56639. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56640. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56641. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  56642. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  56643. import { ReflectionTextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  56644. import { Scene } from "babylonjs/scene";
  56645. /**
  56646. * Class used to store shared data between 2 NodeMaterialBuildState
  56647. */
  56648. export class NodeMaterialBuildStateSharedData {
  56649. /**
  56650. * Gets the list of emitted varyings
  56651. */
  56652. temps: string[];
  56653. /**
  56654. * Gets the list of emitted varyings
  56655. */
  56656. varyings: string[];
  56657. /**
  56658. * Gets the varying declaration string
  56659. */
  56660. varyingDeclaration: string;
  56661. /**
  56662. * Input blocks
  56663. */
  56664. inputBlocks: InputBlock[];
  56665. /**
  56666. * Input blocks
  56667. */
  56668. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  56669. /**
  56670. * Bindable blocks (Blocks that need to set data to the effect)
  56671. */
  56672. bindableBlocks: NodeMaterialBlock[];
  56673. /**
  56674. * List of blocks that can provide a compilation fallback
  56675. */
  56676. blocksWithFallbacks: NodeMaterialBlock[];
  56677. /**
  56678. * List of blocks that can provide a define update
  56679. */
  56680. blocksWithDefines: NodeMaterialBlock[];
  56681. /**
  56682. * List of blocks that can provide a repeatable content
  56683. */
  56684. repeatableContentBlocks: NodeMaterialBlock[];
  56685. /**
  56686. * List of blocks that can provide a dynamic list of uniforms
  56687. */
  56688. dynamicUniformBlocks: NodeMaterialBlock[];
  56689. /**
  56690. * List of blocks that can block the isReady function for the material
  56691. */
  56692. blockingBlocks: NodeMaterialBlock[];
  56693. /**
  56694. * Gets the list of animated inputs
  56695. */
  56696. animatedInputs: InputBlock[];
  56697. /**
  56698. * Build Id used to avoid multiple recompilations
  56699. */
  56700. buildId: number;
  56701. /** List of emitted variables */
  56702. variableNames: {
  56703. [key: string]: number;
  56704. };
  56705. /** List of emitted defines */
  56706. defineNames: {
  56707. [key: string]: number;
  56708. };
  56709. /** Should emit comments? */
  56710. emitComments: boolean;
  56711. /** Emit build activity */
  56712. verbose: boolean;
  56713. /** Gets or sets the hosting scene */
  56714. scene: Scene;
  56715. /**
  56716. * Gets the compilation hints emitted at compilation time
  56717. */
  56718. hints: {
  56719. needWorldViewMatrix: boolean;
  56720. needWorldViewProjectionMatrix: boolean;
  56721. needAlphaBlending: boolean;
  56722. needAlphaTesting: boolean;
  56723. };
  56724. /**
  56725. * List of compilation checks
  56726. */
  56727. checks: {
  56728. emitVertex: boolean;
  56729. emitFragment: boolean;
  56730. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  56731. };
  56732. /** Creates a new shared data */
  56733. constructor();
  56734. /**
  56735. * Emits console errors and exceptions if there is a failing check
  56736. */
  56737. emitErrors(): void;
  56738. }
  56739. }
  56740. declare module "babylonjs/Materials/Node/nodeMaterialBuildState" {
  56741. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  56742. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  56743. import { NodeMaterialBuildStateSharedData } from "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData";
  56744. /**
  56745. * Class used to store node based material build state
  56746. */
  56747. export class NodeMaterialBuildState {
  56748. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  56749. supportUniformBuffers: boolean;
  56750. /**
  56751. * Gets the list of emitted attributes
  56752. */
  56753. attributes: string[];
  56754. /**
  56755. * Gets the list of emitted uniforms
  56756. */
  56757. uniforms: string[];
  56758. /**
  56759. * Gets the list of emitted constants
  56760. */
  56761. constants: string[];
  56762. /**
  56763. * Gets the list of emitted samplers
  56764. */
  56765. samplers: string[];
  56766. /**
  56767. * Gets the list of emitted functions
  56768. */
  56769. functions: {
  56770. [key: string]: string;
  56771. };
  56772. /**
  56773. * Gets the list of emitted extensions
  56774. */
  56775. extensions: {
  56776. [key: string]: string;
  56777. };
  56778. /**
  56779. * Gets the target of the compilation state
  56780. */
  56781. target: NodeMaterialBlockTargets;
  56782. /**
  56783. * Gets the list of emitted counters
  56784. */
  56785. counters: {
  56786. [key: string]: number;
  56787. };
  56788. /**
  56789. * Shared data between multiple NodeMaterialBuildState instances
  56790. */
  56791. sharedData: NodeMaterialBuildStateSharedData;
  56792. /** @hidden */
  56793. _vertexState: NodeMaterialBuildState;
  56794. /** @hidden */
  56795. _attributeDeclaration: string;
  56796. /** @hidden */
  56797. _uniformDeclaration: string;
  56798. /** @hidden */
  56799. _constantDeclaration: string;
  56800. /** @hidden */
  56801. _samplerDeclaration: string;
  56802. /** @hidden */
  56803. _varyingTransfer: string;
  56804. private _repeatableContentAnchorIndex;
  56805. /** @hidden */
  56806. _builtCompilationString: string;
  56807. /**
  56808. * Gets the emitted compilation strings
  56809. */
  56810. compilationString: string;
  56811. /**
  56812. * Finalize the compilation strings
  56813. * @param state defines the current compilation state
  56814. */
  56815. finalize(state: NodeMaterialBuildState): void;
  56816. /** @hidden */
  56817. readonly _repeatableContentAnchor: string;
  56818. /** @hidden */
  56819. _getFreeVariableName(prefix: string): string;
  56820. /** @hidden */
  56821. _getFreeDefineName(prefix: string): string;
  56822. /** @hidden */
  56823. _excludeVariableName(name: string): void;
  56824. /** @hidden */
  56825. _emit2DSampler(name: string): void;
  56826. /** @hidden */
  56827. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  56828. /** @hidden */
  56829. _emitExtension(name: string, extension: string): void;
  56830. /** @hidden */
  56831. _emitFunction(name: string, code: string, comments: string): void;
  56832. /** @hidden */
  56833. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  56834. replaceStrings?: {
  56835. search: RegExp;
  56836. replace: string;
  56837. }[];
  56838. repeatKey?: string;
  56839. }): string;
  56840. /** @hidden */
  56841. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  56842. repeatKey?: string;
  56843. removeAttributes?: boolean;
  56844. removeUniforms?: boolean;
  56845. removeVaryings?: boolean;
  56846. removeIfDef?: boolean;
  56847. replaceStrings?: {
  56848. search: RegExp;
  56849. replace: string;
  56850. }[];
  56851. }, storeKey?: string): void;
  56852. /** @hidden */
  56853. _registerTempVariable(name: string): boolean;
  56854. /** @hidden */
  56855. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  56856. /** @hidden */
  56857. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  56858. /** @hidden */
  56859. _emitFloat(value: number): string;
  56860. }
  56861. }
  56862. declare module "babylonjs/Materials/Node/nodeMaterialBlock" {
  56863. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  56864. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56865. import { Nullable } from "babylonjs/types";
  56866. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56867. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  56868. import { Effect } from "babylonjs/Materials/effect";
  56869. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56870. import { Mesh } from "babylonjs/Meshes/mesh";
  56871. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56872. import { Scene } from "babylonjs/scene";
  56873. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  56874. /**
  56875. * Defines a block that can be used inside a node based material
  56876. */
  56877. export class NodeMaterialBlock {
  56878. private _buildId;
  56879. private _buildTarget;
  56880. private _target;
  56881. private _isFinalMerger;
  56882. private _isInput;
  56883. protected _isUnique: boolean;
  56884. /** @hidden */
  56885. _codeVariableName: string;
  56886. /** @hidden */
  56887. _inputs: NodeMaterialConnectionPoint[];
  56888. /** @hidden */
  56889. _outputs: NodeMaterialConnectionPoint[];
  56890. /** @hidden */
  56891. _preparationId: number;
  56892. /**
  56893. * Gets or sets the name of the block
  56894. */
  56895. name: string;
  56896. /**
  56897. * Gets or sets the unique id of the node
  56898. */
  56899. uniqueId: number;
  56900. /**
  56901. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  56902. */
  56903. readonly isUnique: boolean;
  56904. /**
  56905. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  56906. */
  56907. readonly isFinalMerger: boolean;
  56908. /**
  56909. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  56910. */
  56911. readonly isInput: boolean;
  56912. /**
  56913. * Gets or sets the build Id
  56914. */
  56915. buildId: number;
  56916. /**
  56917. * Gets or sets the target of the block
  56918. */
  56919. target: NodeMaterialBlockTargets;
  56920. /**
  56921. * Gets the list of input points
  56922. */
  56923. readonly inputs: NodeMaterialConnectionPoint[];
  56924. /** Gets the list of output points */
  56925. readonly outputs: NodeMaterialConnectionPoint[];
  56926. /**
  56927. * Find an input by its name
  56928. * @param name defines the name of the input to look for
  56929. * @returns the input or null if not found
  56930. */
  56931. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  56932. /**
  56933. * Find an output by its name
  56934. * @param name defines the name of the outputto look for
  56935. * @returns the output or null if not found
  56936. */
  56937. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  56938. /**
  56939. * Creates a new NodeMaterialBlock
  56940. * @param name defines the block name
  56941. * @param target defines the target of that block (Vertex by default)
  56942. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  56943. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  56944. */
  56945. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  56946. /**
  56947. * Initialize the block and prepare the context for build
  56948. * @param state defines the state that will be used for the build
  56949. */
  56950. initialize(state: NodeMaterialBuildState): void;
  56951. /**
  56952. * Bind data to effect. Will only be called for blocks with isBindable === true
  56953. * @param effect defines the effect to bind data to
  56954. * @param nodeMaterial defines the hosting NodeMaterial
  56955. * @param mesh defines the mesh that will be rendered
  56956. */
  56957. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56958. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  56959. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  56960. protected _writeFloat(value: number): string;
  56961. /**
  56962. * Gets the current class name e.g. "NodeMaterialBlock"
  56963. * @returns the class name
  56964. */
  56965. getClassName(): string;
  56966. /**
  56967. * Register a new input. Must be called inside a block constructor
  56968. * @param name defines the connection point name
  56969. * @param type defines the connection point type
  56970. * @param isOptional defines a boolean indicating that this input can be omitted
  56971. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  56972. * @returns the current block
  56973. */
  56974. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  56975. /**
  56976. * Register a new output. Must be called inside a block constructor
  56977. * @param name defines the connection point name
  56978. * @param type defines the connection point type
  56979. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  56980. * @returns the current block
  56981. */
  56982. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  56983. /**
  56984. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  56985. * @param forOutput defines an optional connection point to check compatibility with
  56986. * @returns the first available input or null
  56987. */
  56988. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  56989. /**
  56990. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  56991. * @param forBlock defines an optional block to check compatibility with
  56992. * @returns the first available input or null
  56993. */
  56994. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  56995. /**
  56996. * Gets the sibling of the given output
  56997. * @param current defines the current output
  56998. * @returns the next output in the list or null
  56999. */
  57000. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  57001. /**
  57002. * Connect current block with another block
  57003. * @param other defines the block to connect with
  57004. * @param options define the various options to help pick the right connections
  57005. * @returns the current block
  57006. */
  57007. connectTo(other: NodeMaterialBlock, options?: {
  57008. input?: string;
  57009. output?: string;
  57010. outputSwizzle?: string;
  57011. }): this | undefined;
  57012. protected _buildBlock(state: NodeMaterialBuildState): void;
  57013. /**
  57014. * Add uniforms, samplers and uniform buffers at compilation time
  57015. * @param state defines the state to update
  57016. * @param nodeMaterial defines the node material requesting the update
  57017. * @param defines defines the material defines to update
  57018. * @param uniformBuffers defines the list of uniform buffer names
  57019. */
  57020. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  57021. /**
  57022. * Add potential fallbacks if shader compilation fails
  57023. * @param mesh defines the mesh to be rendered
  57024. * @param fallbacks defines the current prioritized list of fallbacks
  57025. */
  57026. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  57027. /**
  57028. * Initialize defines for shader compilation
  57029. * @param mesh defines the mesh to be rendered
  57030. * @param nodeMaterial defines the node material requesting the update
  57031. * @param defines defines the material defines to update
  57032. * @param useInstances specifies that instances should be used
  57033. */
  57034. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  57035. /**
  57036. * Update defines for shader compilation
  57037. * @param mesh defines the mesh to be rendered
  57038. * @param nodeMaterial defines the node material requesting the update
  57039. * @param defines defines the material defines to update
  57040. * @param useInstances specifies that instances should be used
  57041. */
  57042. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  57043. /**
  57044. * Lets the block try to connect some inputs automatically
  57045. * @param material defines the hosting NodeMaterial
  57046. */
  57047. autoConfigure(material: NodeMaterial): void;
  57048. /**
  57049. * Function called when a block is declared as repeatable content generator
  57050. * @param vertexShaderState defines the current compilation state for the vertex shader
  57051. * @param fragmentShaderState defines the current compilation state for the fragment shader
  57052. * @param mesh defines the mesh to be rendered
  57053. * @param defines defines the material defines to update
  57054. */
  57055. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  57056. /**
  57057. * Checks if the block is ready
  57058. * @param mesh defines the mesh to be rendered
  57059. * @param nodeMaterial defines the node material requesting the update
  57060. * @param defines defines the material defines to update
  57061. * @param useInstances specifies that instances should be used
  57062. * @returns true if the block is ready
  57063. */
  57064. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  57065. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  57066. private _processBuild;
  57067. /**
  57068. * Compile the current node and generate the shader code
  57069. * @param state defines the current compilation state (uniforms, samplers, current string)
  57070. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  57071. * @returns true if already built
  57072. */
  57073. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  57074. protected _inputRename(name: string): string;
  57075. protected _outputRename(name: string): string;
  57076. protected _dumpPropertiesCode(): string;
  57077. /** @hidden */
  57078. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  57079. /** @hidden */
  57080. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  57081. /**
  57082. * Clone the current block to a new identical block
  57083. * @param scene defines the hosting scene
  57084. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  57085. * @returns a copy of the current block
  57086. */
  57087. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  57088. /**
  57089. * Serializes this block in a JSON representation
  57090. * @returns the serialized block object
  57091. */
  57092. serialize(): any;
  57093. /** @hidden */
  57094. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57095. /**
  57096. * Release resources
  57097. */
  57098. dispose(): void;
  57099. }
  57100. }
  57101. declare module "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes" {
  57102. /**
  57103. * Enum defining the type of animations supported by InputBlock
  57104. */
  57105. export enum AnimatedInputBlockTypes {
  57106. /** No animation */
  57107. None = 0,
  57108. /** Time based animation. Will only work for floats */
  57109. Time = 1
  57110. }
  57111. }
  57112. declare module "babylonjs/Materials/Node/Blocks/Input/inputBlock" {
  57113. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57114. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  57115. import { NodeMaterialSystemValues } from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  57116. import { Nullable } from "babylonjs/types";
  57117. import { Effect } from "babylonjs/Materials/effect";
  57118. import { Matrix } from "babylonjs/Maths/math.vector";
  57119. import { Scene } from "babylonjs/scene";
  57120. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57121. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57122. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  57123. import { AnimatedInputBlockTypes } from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  57124. /**
  57125. * Block used to expose an input value
  57126. */
  57127. export class InputBlock extends NodeMaterialBlock {
  57128. private _mode;
  57129. private _associatedVariableName;
  57130. private _storedValue;
  57131. private _valueCallback;
  57132. private _type;
  57133. private _animationType;
  57134. /** Gets or set a value used to limit the range of float values */
  57135. min: number;
  57136. /** Gets or set a value used to limit the range of float values */
  57137. max: number;
  57138. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  57139. matrixMode: number;
  57140. /** @hidden */
  57141. _systemValue: Nullable<NodeMaterialSystemValues>;
  57142. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  57143. visibleInInspector: boolean;
  57144. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  57145. isConstant: boolean;
  57146. /**
  57147. * Gets or sets the connection point type (default is float)
  57148. */
  57149. readonly type: NodeMaterialBlockConnectionPointTypes;
  57150. /**
  57151. * Creates a new InputBlock
  57152. * @param name defines the block name
  57153. * @param target defines the target of that block (Vertex by default)
  57154. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  57155. */
  57156. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  57157. /**
  57158. * Gets the output component
  57159. */
  57160. readonly output: NodeMaterialConnectionPoint;
  57161. /**
  57162. * Set the source of this connection point to a vertex attribute
  57163. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  57164. * @returns the current connection point
  57165. */
  57166. setAsAttribute(attributeName?: string): InputBlock;
  57167. /**
  57168. * Set the source of this connection point to a system value
  57169. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  57170. * @returns the current connection point
  57171. */
  57172. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  57173. /**
  57174. * Gets or sets the value of that point.
  57175. * Please note that this value will be ignored if valueCallback is defined
  57176. */
  57177. value: any;
  57178. /**
  57179. * Gets or sets a callback used to get the value of that point.
  57180. * Please note that setting this value will force the connection point to ignore the value property
  57181. */
  57182. valueCallback: () => any;
  57183. /**
  57184. * Gets or sets the associated variable name in the shader
  57185. */
  57186. associatedVariableName: string;
  57187. /** Gets or sets the type of animation applied to the input */
  57188. animationType: AnimatedInputBlockTypes;
  57189. /**
  57190. * Gets a boolean indicating that this connection point not defined yet
  57191. */
  57192. readonly isUndefined: boolean;
  57193. /**
  57194. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  57195. * In this case the connection point name must be the name of the uniform to use.
  57196. * Can only be set on inputs
  57197. */
  57198. isUniform: boolean;
  57199. /**
  57200. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  57201. * In this case the connection point name must be the name of the attribute to use
  57202. * Can only be set on inputs
  57203. */
  57204. isAttribute: boolean;
  57205. /**
  57206. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  57207. * Can only be set on exit points
  57208. */
  57209. isVarying: boolean;
  57210. /**
  57211. * Gets a boolean indicating that the current connection point is a system value
  57212. */
  57213. readonly isSystemValue: boolean;
  57214. /**
  57215. * Gets or sets the current well known value or null if not defined as a system value
  57216. */
  57217. systemValue: Nullable<NodeMaterialSystemValues>;
  57218. /**
  57219. * Gets the current class name
  57220. * @returns the class name
  57221. */
  57222. getClassName(): string;
  57223. /**
  57224. * Animate the input if animationType !== None
  57225. * @param scene defines the rendering scene
  57226. */
  57227. animate(scene: Scene): void;
  57228. private _emitDefine;
  57229. initialize(state: NodeMaterialBuildState): void;
  57230. /**
  57231. * Set the input block to its default value (based on its type)
  57232. */
  57233. setDefaultValue(): void;
  57234. private _emitConstant;
  57235. private _emit;
  57236. /** @hidden */
  57237. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  57238. /** @hidden */
  57239. _transmit(effect: Effect, scene: Scene): void;
  57240. protected _buildBlock(state: NodeMaterialBuildState): void;
  57241. protected _dumpPropertiesCode(): string;
  57242. serialize(): any;
  57243. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57244. }
  57245. }
  57246. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint" {
  57247. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  57248. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  57249. import { Nullable } from "babylonjs/types";
  57250. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  57251. import { Observable } from "babylonjs/Misc/observable";
  57252. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57253. /**
  57254. * Enum used to define the compatibility state between two connection points
  57255. */
  57256. export enum NodeMaterialConnectionPointCompatibilityStates {
  57257. /** Points are compatibles */
  57258. Compatible = 0,
  57259. /** Points are incompatible because of their types */
  57260. TypeIncompatible = 1,
  57261. /** Points are incompatible because of their targets (vertex vs fragment) */
  57262. TargetIncompatible = 2
  57263. }
  57264. /**
  57265. * Defines a connection point for a block
  57266. */
  57267. export class NodeMaterialConnectionPoint {
  57268. /** @hidden */
  57269. _ownerBlock: NodeMaterialBlock;
  57270. /** @hidden */
  57271. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  57272. private _endpoints;
  57273. private _associatedVariableName;
  57274. /** @hidden */
  57275. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  57276. /** @hidden */
  57277. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  57278. private _type;
  57279. /** @hidden */
  57280. _enforceAssociatedVariableName: boolean;
  57281. /**
  57282. * Gets or sets the additional types supported by this connection point
  57283. */
  57284. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  57285. /**
  57286. * Gets or sets the additional types excluded by this connection point
  57287. */
  57288. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  57289. /**
  57290. * Observable triggered when this point is connected
  57291. */
  57292. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  57293. /**
  57294. * Gets or sets the associated variable name in the shader
  57295. */
  57296. associatedVariableName: string;
  57297. /**
  57298. * Gets or sets the connection point type (default is float)
  57299. */
  57300. type: NodeMaterialBlockConnectionPointTypes;
  57301. /**
  57302. * Gets or sets the connection point name
  57303. */
  57304. name: string;
  57305. /**
  57306. * Gets or sets a boolean indicating that this connection point can be omitted
  57307. */
  57308. isOptional: boolean;
  57309. /**
  57310. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  57311. */
  57312. define: string;
  57313. /** @hidden */
  57314. _prioritizeVertex: boolean;
  57315. private _target;
  57316. /** Gets or sets the target of that connection point */
  57317. target: NodeMaterialBlockTargets;
  57318. /**
  57319. * Gets a boolean indicating that the current point is connected
  57320. */
  57321. readonly isConnected: boolean;
  57322. /**
  57323. * Gets a boolean indicating that the current point is connected to an input block
  57324. */
  57325. readonly isConnectedToInputBlock: boolean;
  57326. /**
  57327. * Gets a the connected input block (if any)
  57328. */
  57329. readonly connectInputBlock: Nullable<InputBlock>;
  57330. /** Get the other side of the connection (if any) */
  57331. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  57332. /** Get the block that owns this connection point */
  57333. readonly ownerBlock: NodeMaterialBlock;
  57334. /** Get the block connected on the other side of this connection (if any) */
  57335. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  57336. /** Get the block connected on the endpoints of this connection (if any) */
  57337. readonly connectedBlocks: Array<NodeMaterialBlock>;
  57338. /** Gets the list of connected endpoints */
  57339. readonly endpoints: NodeMaterialConnectionPoint[];
  57340. /** Gets a boolean indicating if that output point is connected to at least one input */
  57341. readonly hasEndpoints: boolean;
  57342. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  57343. readonly isConnectedInVertexShader: boolean;
  57344. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  57345. readonly isConnectedInFragmentShader: boolean;
  57346. /**
  57347. * Creates a new connection point
  57348. * @param name defines the connection point name
  57349. * @param ownerBlock defines the block hosting this connection point
  57350. */
  57351. constructor(name: string, ownerBlock: NodeMaterialBlock);
  57352. /**
  57353. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  57354. * @returns the class name
  57355. */
  57356. getClassName(): string;
  57357. /**
  57358. * Gets a boolean indicating if the current point can be connected to another point
  57359. * @param connectionPoint defines the other connection point
  57360. * @returns a boolean
  57361. */
  57362. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  57363. /**
  57364. * Gets a number indicating if the current point can be connected to another point
  57365. * @param connectionPoint defines the other connection point
  57366. * @returns a number defining the compatibility state
  57367. */
  57368. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  57369. /**
  57370. * Connect this point to another connection point
  57371. * @param connectionPoint defines the other connection point
  57372. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  57373. * @returns the current connection point
  57374. */
  57375. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  57376. /**
  57377. * Disconnect this point from one of his endpoint
  57378. * @param endpoint defines the other connection point
  57379. * @returns the current connection point
  57380. */
  57381. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  57382. /**
  57383. * Serializes this point in a JSON representation
  57384. * @returns the serialized point object
  57385. */
  57386. serialize(): any;
  57387. /**
  57388. * Release resources
  57389. */
  57390. dispose(): void;
  57391. }
  57392. }
  57393. declare module "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock" {
  57394. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57395. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57396. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57397. import { Mesh } from "babylonjs/Meshes/mesh";
  57398. import { Effect } from "babylonjs/Materials/effect";
  57399. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57400. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  57401. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  57402. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  57403. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  57404. /**
  57405. * Block used to add support for vertex skinning (bones)
  57406. */
  57407. export class BonesBlock extends NodeMaterialBlock {
  57408. /**
  57409. * Creates a new BonesBlock
  57410. * @param name defines the block name
  57411. */
  57412. constructor(name: string);
  57413. /**
  57414. * Initialize the block and prepare the context for build
  57415. * @param state defines the state that will be used for the build
  57416. */
  57417. initialize(state: NodeMaterialBuildState): void;
  57418. /**
  57419. * Gets the current class name
  57420. * @returns the class name
  57421. */
  57422. getClassName(): string;
  57423. /**
  57424. * Gets the matrix indices input component
  57425. */
  57426. readonly matricesIndices: NodeMaterialConnectionPoint;
  57427. /**
  57428. * Gets the matrix weights input component
  57429. */
  57430. readonly matricesWeights: NodeMaterialConnectionPoint;
  57431. /**
  57432. * Gets the extra matrix indices input component
  57433. */
  57434. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  57435. /**
  57436. * Gets the extra matrix weights input component
  57437. */
  57438. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  57439. /**
  57440. * Gets the world input component
  57441. */
  57442. readonly world: NodeMaterialConnectionPoint;
  57443. /**
  57444. * Gets the output component
  57445. */
  57446. readonly output: NodeMaterialConnectionPoint;
  57447. autoConfigure(material: NodeMaterial): void;
  57448. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  57449. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57450. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  57451. protected _buildBlock(state: NodeMaterialBuildState): this;
  57452. }
  57453. }
  57454. declare module "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock" {
  57455. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57456. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57457. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57458. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57459. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  57460. /**
  57461. * Block used to add support for instances
  57462. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  57463. */
  57464. export class InstancesBlock extends NodeMaterialBlock {
  57465. /**
  57466. * Creates a new InstancesBlock
  57467. * @param name defines the block name
  57468. */
  57469. constructor(name: string);
  57470. /**
  57471. * Gets the current class name
  57472. * @returns the class name
  57473. */
  57474. getClassName(): string;
  57475. /**
  57476. * Gets the first world row input component
  57477. */
  57478. readonly world0: NodeMaterialConnectionPoint;
  57479. /**
  57480. * Gets the second world row input component
  57481. */
  57482. readonly world1: NodeMaterialConnectionPoint;
  57483. /**
  57484. * Gets the third world row input component
  57485. */
  57486. readonly world2: NodeMaterialConnectionPoint;
  57487. /**
  57488. * Gets the forth world row input component
  57489. */
  57490. readonly world3: NodeMaterialConnectionPoint;
  57491. /**
  57492. * Gets the world input component
  57493. */
  57494. readonly world: NodeMaterialConnectionPoint;
  57495. /**
  57496. * Gets the output component
  57497. */
  57498. readonly output: NodeMaterialConnectionPoint;
  57499. autoConfigure(material: NodeMaterial): void;
  57500. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  57501. protected _buildBlock(state: NodeMaterialBuildState): this;
  57502. }
  57503. }
  57504. declare module "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock" {
  57505. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57506. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57507. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57508. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57509. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  57510. import { Effect } from "babylonjs/Materials/effect";
  57511. import { Mesh } from "babylonjs/Meshes/mesh";
  57512. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  57513. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  57514. /**
  57515. * Block used to add morph targets support to vertex shader
  57516. */
  57517. export class MorphTargetsBlock extends NodeMaterialBlock {
  57518. private _repeatableContentAnchor;
  57519. private _repeatebleContentGenerated;
  57520. /**
  57521. * Create a new MorphTargetsBlock
  57522. * @param name defines the block name
  57523. */
  57524. constructor(name: string);
  57525. /**
  57526. * Gets the current class name
  57527. * @returns the class name
  57528. */
  57529. getClassName(): string;
  57530. /**
  57531. * Gets the position input component
  57532. */
  57533. readonly position: NodeMaterialConnectionPoint;
  57534. /**
  57535. * Gets the normal input component
  57536. */
  57537. readonly normal: NodeMaterialConnectionPoint;
  57538. /**
  57539. * Gets the tangent input component
  57540. */
  57541. readonly tangent: NodeMaterialConnectionPoint;
  57542. /**
  57543. * Gets the tangent input component
  57544. */
  57545. readonly uv: NodeMaterialConnectionPoint;
  57546. /**
  57547. * Gets the position output component
  57548. */
  57549. readonly positionOutput: NodeMaterialConnectionPoint;
  57550. /**
  57551. * Gets the normal output component
  57552. */
  57553. readonly normalOutput: NodeMaterialConnectionPoint;
  57554. /**
  57555. * Gets the tangent output component
  57556. */
  57557. readonly tangentOutput: NodeMaterialConnectionPoint;
  57558. /**
  57559. * Gets the tangent output component
  57560. */
  57561. readonly uvOutput: NodeMaterialConnectionPoint;
  57562. initialize(state: NodeMaterialBuildState): void;
  57563. autoConfigure(material: NodeMaterial): void;
  57564. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  57565. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57566. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  57567. protected _buildBlock(state: NodeMaterialBuildState): this;
  57568. }
  57569. }
  57570. declare module "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock" {
  57571. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57572. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57573. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57574. import { Nullable } from "babylonjs/types";
  57575. import { Scene } from "babylonjs/scene";
  57576. import { Effect } from "babylonjs/Materials/effect";
  57577. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  57578. import { Mesh } from "babylonjs/Meshes/mesh";
  57579. import { Light } from "babylonjs/Lights/light";
  57580. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57581. /**
  57582. * Block used to get data information from a light
  57583. */
  57584. export class LightInformationBlock extends NodeMaterialBlock {
  57585. private _lightDataUniformName;
  57586. private _lightColorUniformName;
  57587. private _lightTypeDefineName;
  57588. /**
  57589. * Gets or sets the light associated with this block
  57590. */
  57591. light: Nullable<Light>;
  57592. /**
  57593. * Creates a new LightInformationBlock
  57594. * @param name defines the block name
  57595. */
  57596. constructor(name: string);
  57597. /**
  57598. * Gets the current class name
  57599. * @returns the class name
  57600. */
  57601. getClassName(): string;
  57602. /**
  57603. * Gets the world position input component
  57604. */
  57605. readonly worldPosition: NodeMaterialConnectionPoint;
  57606. /**
  57607. * Gets the direction output component
  57608. */
  57609. readonly direction: NodeMaterialConnectionPoint;
  57610. /**
  57611. * Gets the direction output component
  57612. */
  57613. readonly color: NodeMaterialConnectionPoint;
  57614. /**
  57615. * Gets the direction output component
  57616. */
  57617. readonly intensity: NodeMaterialConnectionPoint;
  57618. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57619. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  57620. protected _buildBlock(state: NodeMaterialBuildState): this;
  57621. serialize(): any;
  57622. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57623. }
  57624. }
  57625. declare module "babylonjs/Materials/Node/Blocks/Vertex/index" {
  57626. export * from "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock";
  57627. export * from "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock";
  57628. export * from "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock";
  57629. export * from "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock";
  57630. export * from "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock";
  57631. }
  57632. declare module "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock" {
  57633. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57634. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57635. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57636. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57637. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  57638. import { Effect } from "babylonjs/Materials/effect";
  57639. import { Mesh } from "babylonjs/Meshes/mesh";
  57640. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  57641. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  57642. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  57643. /**
  57644. * Block used to add image processing support to fragment shader
  57645. */
  57646. export class ImageProcessingBlock extends NodeMaterialBlock {
  57647. /**
  57648. * Create a new ImageProcessingBlock
  57649. * @param name defines the block name
  57650. */
  57651. constructor(name: string);
  57652. /**
  57653. * Gets the current class name
  57654. * @returns the class name
  57655. */
  57656. getClassName(): string;
  57657. /**
  57658. * Gets the color input component
  57659. */
  57660. readonly color: NodeMaterialConnectionPoint;
  57661. /**
  57662. * Gets the output component
  57663. */
  57664. readonly output: NodeMaterialConnectionPoint;
  57665. /**
  57666. * Initialize the block and prepare the context for build
  57667. * @param state defines the state that will be used for the build
  57668. */
  57669. initialize(state: NodeMaterialBuildState): void;
  57670. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  57671. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  57672. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57673. protected _buildBlock(state: NodeMaterialBuildState): this;
  57674. }
  57675. }
  57676. declare module "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock" {
  57677. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57678. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57679. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57680. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  57681. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57682. import { Effect } from "babylonjs/Materials/effect";
  57683. import { Mesh } from "babylonjs/Meshes/mesh";
  57684. import { Scene } from "babylonjs/scene";
  57685. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  57686. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  57687. /**
  57688. * Block used to pertub normals based on a normal map
  57689. */
  57690. export class PerturbNormalBlock extends NodeMaterialBlock {
  57691. private _tangentSpaceParameterName;
  57692. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  57693. invertX: boolean;
  57694. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  57695. invertY: boolean;
  57696. /**
  57697. * Create a new PerturbNormalBlock
  57698. * @param name defines the block name
  57699. */
  57700. constructor(name: string);
  57701. /**
  57702. * Gets the current class name
  57703. * @returns the class name
  57704. */
  57705. getClassName(): string;
  57706. /**
  57707. * Gets the world position input component
  57708. */
  57709. readonly worldPosition: NodeMaterialConnectionPoint;
  57710. /**
  57711. * Gets the world normal input component
  57712. */
  57713. readonly worldNormal: NodeMaterialConnectionPoint;
  57714. /**
  57715. * Gets the uv input component
  57716. */
  57717. readonly uv: NodeMaterialConnectionPoint;
  57718. /**
  57719. * Gets the normal map color input component
  57720. */
  57721. readonly normalMapColor: NodeMaterialConnectionPoint;
  57722. /**
  57723. * Gets the strength input component
  57724. */
  57725. readonly strength: NodeMaterialConnectionPoint;
  57726. /**
  57727. * Gets the output component
  57728. */
  57729. readonly output: NodeMaterialConnectionPoint;
  57730. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  57731. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57732. autoConfigure(material: NodeMaterial): void;
  57733. protected _buildBlock(state: NodeMaterialBuildState): this;
  57734. protected _dumpPropertiesCode(): string;
  57735. serialize(): any;
  57736. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57737. }
  57738. }
  57739. declare module "babylonjs/Materials/Node/Blocks/Fragment/discardBlock" {
  57740. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57741. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57742. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57743. /**
  57744. * Block used to discard a pixel if a value is smaller than a cutoff
  57745. */
  57746. export class DiscardBlock extends NodeMaterialBlock {
  57747. /**
  57748. * Create a new DiscardBlock
  57749. * @param name defines the block name
  57750. */
  57751. constructor(name: string);
  57752. /**
  57753. * Gets the current class name
  57754. * @returns the class name
  57755. */
  57756. getClassName(): string;
  57757. /**
  57758. * Gets the color input component
  57759. */
  57760. readonly value: NodeMaterialConnectionPoint;
  57761. /**
  57762. * Gets the cutoff input component
  57763. */
  57764. readonly cutoff: NodeMaterialConnectionPoint;
  57765. protected _buildBlock(state: NodeMaterialBuildState): this;
  57766. }
  57767. }
  57768. declare module "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock" {
  57769. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57770. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57771. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57772. /**
  57773. * Block used to test if the fragment shader is front facing
  57774. */
  57775. export class FrontFacingBlock extends NodeMaterialBlock {
  57776. /**
  57777. * Creates a new FrontFacingBlock
  57778. * @param name defines the block name
  57779. */
  57780. constructor(name: string);
  57781. /**
  57782. * Gets the current class name
  57783. * @returns the class name
  57784. */
  57785. getClassName(): string;
  57786. /**
  57787. * Gets the output component
  57788. */
  57789. readonly output: NodeMaterialConnectionPoint;
  57790. protected _buildBlock(state: NodeMaterialBuildState): this;
  57791. }
  57792. }
  57793. declare module "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock" {
  57794. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57795. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57796. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57797. /**
  57798. * Block used to get the derivative value on x and y of a given input
  57799. */
  57800. export class DerivativeBlock extends NodeMaterialBlock {
  57801. /**
  57802. * Create a new DerivativeBlock
  57803. * @param name defines the block name
  57804. */
  57805. constructor(name: string);
  57806. /**
  57807. * Gets the current class name
  57808. * @returns the class name
  57809. */
  57810. getClassName(): string;
  57811. /**
  57812. * Gets the input component
  57813. */
  57814. readonly input: NodeMaterialConnectionPoint;
  57815. /**
  57816. * Gets the derivative output on x
  57817. */
  57818. readonly dx: NodeMaterialConnectionPoint;
  57819. /**
  57820. * Gets the derivative output on y
  57821. */
  57822. readonly dy: NodeMaterialConnectionPoint;
  57823. protected _buildBlock(state: NodeMaterialBuildState): this;
  57824. }
  57825. }
  57826. declare module "babylonjs/Materials/Node/Blocks/Fragment/index" {
  57827. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock";
  57828. export * from "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock";
  57829. export * from "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock";
  57830. export * from "babylonjs/Materials/Node/Blocks/Fragment/discardBlock";
  57831. export * from "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock";
  57832. export * from "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock";
  57833. }
  57834. declare module "babylonjs/Materials/Node/Blocks/Dual/fogBlock" {
  57835. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57836. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57837. import { Mesh } from "babylonjs/Meshes/mesh";
  57838. import { Effect } from "babylonjs/Materials/effect";
  57839. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57840. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57841. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  57842. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  57843. /**
  57844. * Block used to add support for scene fog
  57845. */
  57846. export class FogBlock extends NodeMaterialBlock {
  57847. private _fogDistanceName;
  57848. private _fogParameters;
  57849. /**
  57850. * Create a new FogBlock
  57851. * @param name defines the block name
  57852. */
  57853. constructor(name: string);
  57854. /**
  57855. * Gets the current class name
  57856. * @returns the class name
  57857. */
  57858. getClassName(): string;
  57859. /**
  57860. * Gets the world position input component
  57861. */
  57862. readonly worldPosition: NodeMaterialConnectionPoint;
  57863. /**
  57864. * Gets the view input component
  57865. */
  57866. readonly view: NodeMaterialConnectionPoint;
  57867. /**
  57868. * Gets the color input component
  57869. */
  57870. readonly input: NodeMaterialConnectionPoint;
  57871. /**
  57872. * Gets the fog color input component
  57873. */
  57874. readonly fogColor: NodeMaterialConnectionPoint;
  57875. /**
  57876. * Gets the output component
  57877. */
  57878. readonly output: NodeMaterialConnectionPoint;
  57879. autoConfigure(material: NodeMaterial): void;
  57880. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  57881. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57882. protected _buildBlock(state: NodeMaterialBuildState): this;
  57883. }
  57884. }
  57885. declare module "babylonjs/Materials/Node/Blocks/Dual/lightBlock" {
  57886. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57887. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57888. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57889. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57890. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  57891. import { Effect } from "babylonjs/Materials/effect";
  57892. import { Mesh } from "babylonjs/Meshes/mesh";
  57893. import { Light } from "babylonjs/Lights/light";
  57894. import { Nullable } from "babylonjs/types";
  57895. import { Scene } from "babylonjs/scene";
  57896. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  57897. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  57898. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  57899. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  57900. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  57901. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  57902. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  57903. /**
  57904. * Block used to add light in the fragment shader
  57905. */
  57906. export class LightBlock extends NodeMaterialBlock {
  57907. private _lightId;
  57908. /**
  57909. * Gets or sets the light associated with this block
  57910. */
  57911. light: Nullable<Light>;
  57912. /**
  57913. * Create a new LightBlock
  57914. * @param name defines the block name
  57915. */
  57916. constructor(name: string);
  57917. /**
  57918. * Gets the current class name
  57919. * @returns the class name
  57920. */
  57921. getClassName(): string;
  57922. /**
  57923. * Gets the world position input component
  57924. */
  57925. readonly worldPosition: NodeMaterialConnectionPoint;
  57926. /**
  57927. * Gets the world normal input component
  57928. */
  57929. readonly worldNormal: NodeMaterialConnectionPoint;
  57930. /**
  57931. * Gets the camera (or eye) position component
  57932. */
  57933. readonly cameraPosition: NodeMaterialConnectionPoint;
  57934. /**
  57935. * Gets the glossiness component
  57936. */
  57937. readonly glossiness: NodeMaterialConnectionPoint;
  57938. /**
  57939. * Gets the glossinness power component
  57940. */
  57941. readonly glossPower: NodeMaterialConnectionPoint;
  57942. /**
  57943. * Gets the diffuse color component
  57944. */
  57945. readonly diffuseColor: NodeMaterialConnectionPoint;
  57946. /**
  57947. * Gets the specular color component
  57948. */
  57949. readonly specularColor: NodeMaterialConnectionPoint;
  57950. /**
  57951. * Gets the diffuse output component
  57952. */
  57953. readonly diffuseOutput: NodeMaterialConnectionPoint;
  57954. /**
  57955. * Gets the specular output component
  57956. */
  57957. readonly specularOutput: NodeMaterialConnectionPoint;
  57958. autoConfigure(material: NodeMaterial): void;
  57959. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  57960. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  57961. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57962. private _injectVertexCode;
  57963. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  57964. serialize(): any;
  57965. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57966. }
  57967. }
  57968. declare module "babylonjs/Materials/Node/Blocks/Dual/index" {
  57969. export * from "babylonjs/Materials/Node/Blocks/Dual/fogBlock";
  57970. export * from "babylonjs/Materials/Node/Blocks/Dual/lightBlock";
  57971. export * from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  57972. export * from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  57973. }
  57974. declare module "babylonjs/Materials/Node/Blocks/Input/index" {
  57975. export * from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  57976. export * from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  57977. }
  57978. declare module "babylonjs/Materials/Node/Blocks/multiplyBlock" {
  57979. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57980. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57981. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57982. /**
  57983. * Block used to multiply 2 values
  57984. */
  57985. export class MultiplyBlock extends NodeMaterialBlock {
  57986. /**
  57987. * Creates a new MultiplyBlock
  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 left operand input component
  57998. */
  57999. readonly left: NodeMaterialConnectionPoint;
  58000. /**
  58001. * Gets the right operand input component
  58002. */
  58003. readonly right: NodeMaterialConnectionPoint;
  58004. /**
  58005. * Gets the output component
  58006. */
  58007. readonly output: NodeMaterialConnectionPoint;
  58008. protected _buildBlock(state: NodeMaterialBuildState): this;
  58009. }
  58010. }
  58011. declare module "babylonjs/Materials/Node/Blocks/addBlock" {
  58012. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58013. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58014. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58015. /**
  58016. * Block used to add 2 vectors
  58017. */
  58018. export class AddBlock extends NodeMaterialBlock {
  58019. /**
  58020. * Creates a new AddBlock
  58021. * @param name defines the block name
  58022. */
  58023. constructor(name: string);
  58024. /**
  58025. * Gets the current class name
  58026. * @returns the class name
  58027. */
  58028. getClassName(): string;
  58029. /**
  58030. * Gets the left operand input component
  58031. */
  58032. readonly left: NodeMaterialConnectionPoint;
  58033. /**
  58034. * Gets the right operand input component
  58035. */
  58036. readonly right: NodeMaterialConnectionPoint;
  58037. /**
  58038. * Gets the output component
  58039. */
  58040. readonly output: NodeMaterialConnectionPoint;
  58041. protected _buildBlock(state: NodeMaterialBuildState): this;
  58042. }
  58043. }
  58044. declare module "babylonjs/Materials/Node/Blocks/scaleBlock" {
  58045. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58046. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58047. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58048. /**
  58049. * Block used to scale a vector by a float
  58050. */
  58051. export class ScaleBlock extends NodeMaterialBlock {
  58052. /**
  58053. * Creates a new ScaleBlock
  58054. * @param name defines the block name
  58055. */
  58056. constructor(name: string);
  58057. /**
  58058. * Gets the current class name
  58059. * @returns the class name
  58060. */
  58061. getClassName(): string;
  58062. /**
  58063. * Gets the input component
  58064. */
  58065. readonly input: NodeMaterialConnectionPoint;
  58066. /**
  58067. * Gets the factor input component
  58068. */
  58069. readonly factor: NodeMaterialConnectionPoint;
  58070. /**
  58071. * Gets the output component
  58072. */
  58073. readonly output: NodeMaterialConnectionPoint;
  58074. protected _buildBlock(state: NodeMaterialBuildState): this;
  58075. }
  58076. }
  58077. declare module "babylonjs/Materials/Node/Blocks/clampBlock" {
  58078. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58079. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58080. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58081. import { Scene } from "babylonjs/scene";
  58082. /**
  58083. * Block used to clamp a float
  58084. */
  58085. export class ClampBlock extends NodeMaterialBlock {
  58086. /** Gets or sets the minimum range */
  58087. minimum: number;
  58088. /** Gets or sets the maximum range */
  58089. maximum: number;
  58090. /**
  58091. * Creates a new ClampBlock
  58092. * @param name defines the block name
  58093. */
  58094. constructor(name: string);
  58095. /**
  58096. * Gets the current class name
  58097. * @returns the class name
  58098. */
  58099. getClassName(): string;
  58100. /**
  58101. * Gets the value input component
  58102. */
  58103. readonly value: NodeMaterialConnectionPoint;
  58104. /**
  58105. * Gets the output component
  58106. */
  58107. readonly output: NodeMaterialConnectionPoint;
  58108. protected _buildBlock(state: NodeMaterialBuildState): this;
  58109. protected _dumpPropertiesCode(): string;
  58110. serialize(): any;
  58111. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58112. }
  58113. }
  58114. declare module "babylonjs/Materials/Node/Blocks/crossBlock" {
  58115. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58116. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58117. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58118. /**
  58119. * Block used to apply a cross product between 2 vectors
  58120. */
  58121. export class CrossBlock extends NodeMaterialBlock {
  58122. /**
  58123. * Creates a new CrossBlock
  58124. * @param name defines the block name
  58125. */
  58126. constructor(name: string);
  58127. /**
  58128. * Gets the current class name
  58129. * @returns the class name
  58130. */
  58131. getClassName(): string;
  58132. /**
  58133. * Gets the left operand input component
  58134. */
  58135. readonly left: NodeMaterialConnectionPoint;
  58136. /**
  58137. * Gets the right operand input component
  58138. */
  58139. readonly right: NodeMaterialConnectionPoint;
  58140. /**
  58141. * Gets the output component
  58142. */
  58143. readonly output: NodeMaterialConnectionPoint;
  58144. protected _buildBlock(state: NodeMaterialBuildState): this;
  58145. }
  58146. }
  58147. declare module "babylonjs/Materials/Node/Blocks/dotBlock" {
  58148. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58149. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58150. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58151. /**
  58152. * Block used to apply a dot product between 2 vectors
  58153. */
  58154. export class DotBlock extends NodeMaterialBlock {
  58155. /**
  58156. * Creates a new DotBlock
  58157. * @param name defines the block name
  58158. */
  58159. constructor(name: string);
  58160. /**
  58161. * Gets the current class name
  58162. * @returns the class name
  58163. */
  58164. getClassName(): string;
  58165. /**
  58166. * Gets the left operand input component
  58167. */
  58168. readonly left: NodeMaterialConnectionPoint;
  58169. /**
  58170. * Gets the right operand input component
  58171. */
  58172. readonly right: NodeMaterialConnectionPoint;
  58173. /**
  58174. * Gets the output component
  58175. */
  58176. readonly output: NodeMaterialConnectionPoint;
  58177. protected _buildBlock(state: NodeMaterialBuildState): this;
  58178. }
  58179. }
  58180. declare module "babylonjs/Materials/Node/Blocks/remapBlock" {
  58181. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58182. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58183. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58184. import { Vector2 } from "babylonjs/Maths/math.vector";
  58185. import { Scene } from "babylonjs/scene";
  58186. /**
  58187. * Block used to remap a float from a range to a new one
  58188. */
  58189. export class RemapBlock extends NodeMaterialBlock {
  58190. /**
  58191. * Gets or sets the source range
  58192. */
  58193. sourceRange: Vector2;
  58194. /**
  58195. * Gets or sets the target range
  58196. */
  58197. targetRange: Vector2;
  58198. /**
  58199. * Creates a new RemapBlock
  58200. * @param name defines the block name
  58201. */
  58202. constructor(name: string);
  58203. /**
  58204. * Gets the current class name
  58205. * @returns the class name
  58206. */
  58207. getClassName(): string;
  58208. /**
  58209. * Gets the input component
  58210. */
  58211. readonly input: NodeMaterialConnectionPoint;
  58212. /**
  58213. * Gets the source min input component
  58214. */
  58215. readonly sourceMin: NodeMaterialConnectionPoint;
  58216. /**
  58217. * Gets the source max input component
  58218. */
  58219. readonly sourceMax: NodeMaterialConnectionPoint;
  58220. /**
  58221. * Gets the target min input component
  58222. */
  58223. readonly targetMin: NodeMaterialConnectionPoint;
  58224. /**
  58225. * Gets the target max input component
  58226. */
  58227. readonly targetMax: NodeMaterialConnectionPoint;
  58228. /**
  58229. * Gets the output component
  58230. */
  58231. readonly output: NodeMaterialConnectionPoint;
  58232. protected _buildBlock(state: NodeMaterialBuildState): this;
  58233. protected _dumpPropertiesCode(): string;
  58234. serialize(): any;
  58235. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58236. }
  58237. }
  58238. declare module "babylonjs/Materials/Node/Blocks/normalizeBlock" {
  58239. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58240. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58241. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58242. /**
  58243. * Block used to normalize a vector
  58244. */
  58245. export class NormalizeBlock extends NodeMaterialBlock {
  58246. /**
  58247. * Creates a new NormalizeBlock
  58248. * @param name defines the block name
  58249. */
  58250. constructor(name: string);
  58251. /**
  58252. * Gets the current class name
  58253. * @returns the class name
  58254. */
  58255. getClassName(): string;
  58256. /**
  58257. * Gets the input component
  58258. */
  58259. readonly input: NodeMaterialConnectionPoint;
  58260. /**
  58261. * Gets the output component
  58262. */
  58263. readonly output: NodeMaterialConnectionPoint;
  58264. protected _buildBlock(state: NodeMaterialBuildState): this;
  58265. }
  58266. }
  58267. declare module "babylonjs/Materials/Node/Blocks/trigonometryBlock" {
  58268. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58269. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58270. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58271. import { Scene } from "babylonjs/scene";
  58272. /**
  58273. * Operations supported by the Trigonometry block
  58274. */
  58275. export enum TrigonometryBlockOperations {
  58276. /** Cos */
  58277. Cos = 0,
  58278. /** Sin */
  58279. Sin = 1,
  58280. /** Abs */
  58281. Abs = 2,
  58282. /** Exp */
  58283. Exp = 3,
  58284. /** Exp2 */
  58285. Exp2 = 4,
  58286. /** Round */
  58287. Round = 5,
  58288. /** Floor */
  58289. Floor = 6,
  58290. /** Ceiling */
  58291. Ceiling = 7,
  58292. /** Square root */
  58293. Sqrt = 8,
  58294. /** Log */
  58295. Log = 9,
  58296. /** Tangent */
  58297. Tan = 10,
  58298. /** Arc tangent */
  58299. ArcTan = 11,
  58300. /** Arc cosinus */
  58301. ArcCos = 12,
  58302. /** Arc sinus */
  58303. ArcSin = 13,
  58304. /** Fraction */
  58305. Fract = 14,
  58306. /** Sign */
  58307. Sign = 15,
  58308. /** To radians (from degrees) */
  58309. Radians = 16,
  58310. /** To degrees (from radians) */
  58311. Degrees = 17
  58312. }
  58313. /**
  58314. * Block used to apply trigonometry operation to floats
  58315. */
  58316. export class TrigonometryBlock extends NodeMaterialBlock {
  58317. /**
  58318. * Gets or sets the operation applied by the block
  58319. */
  58320. operation: TrigonometryBlockOperations;
  58321. /**
  58322. * Creates a new TrigonometryBlock
  58323. * @param name defines the block name
  58324. */
  58325. constructor(name: string);
  58326. /**
  58327. * Gets the current class name
  58328. * @returns the class name
  58329. */
  58330. getClassName(): string;
  58331. /**
  58332. * Gets the input component
  58333. */
  58334. readonly input: NodeMaterialConnectionPoint;
  58335. /**
  58336. * Gets the output component
  58337. */
  58338. readonly output: NodeMaterialConnectionPoint;
  58339. protected _buildBlock(state: NodeMaterialBuildState): this;
  58340. serialize(): any;
  58341. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58342. protected _dumpPropertiesCode(): string;
  58343. }
  58344. }
  58345. declare module "babylonjs/Materials/Node/Blocks/colorMergerBlock" {
  58346. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58347. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58348. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58349. /**
  58350. * Block used to create a Color3/4 out of individual inputs (one for each component)
  58351. */
  58352. export class ColorMergerBlock extends NodeMaterialBlock {
  58353. /**
  58354. * Create a new ColorMergerBlock
  58355. * @param name defines the block name
  58356. */
  58357. constructor(name: string);
  58358. /**
  58359. * Gets the current class name
  58360. * @returns the class name
  58361. */
  58362. getClassName(): string;
  58363. /**
  58364. * Gets the r component (input)
  58365. */
  58366. readonly r: NodeMaterialConnectionPoint;
  58367. /**
  58368. * Gets the g component (input)
  58369. */
  58370. readonly g: NodeMaterialConnectionPoint;
  58371. /**
  58372. * Gets the b component (input)
  58373. */
  58374. readonly b: NodeMaterialConnectionPoint;
  58375. /**
  58376. * Gets the a component (input)
  58377. */
  58378. readonly a: NodeMaterialConnectionPoint;
  58379. /**
  58380. * Gets the rgba component (output)
  58381. */
  58382. readonly rgba: NodeMaterialConnectionPoint;
  58383. /**
  58384. * Gets the rgb component (output)
  58385. */
  58386. readonly rgb: NodeMaterialConnectionPoint;
  58387. protected _buildBlock(state: NodeMaterialBuildState): this;
  58388. }
  58389. }
  58390. declare module "babylonjs/Materials/Node/Blocks/vectorMergerBlock" {
  58391. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58392. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58393. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58394. /**
  58395. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  58396. */
  58397. export class VectorMergerBlock extends NodeMaterialBlock {
  58398. /**
  58399. * Create a new VectorMergerBlock
  58400. * @param name defines the block name
  58401. */
  58402. constructor(name: string);
  58403. /**
  58404. * Gets the current class name
  58405. * @returns the class name
  58406. */
  58407. getClassName(): string;
  58408. /**
  58409. * Gets the x component (input)
  58410. */
  58411. readonly x: NodeMaterialConnectionPoint;
  58412. /**
  58413. * Gets the y component (input)
  58414. */
  58415. readonly y: NodeMaterialConnectionPoint;
  58416. /**
  58417. * Gets the z component (input)
  58418. */
  58419. readonly z: NodeMaterialConnectionPoint;
  58420. /**
  58421. * Gets the w component (input)
  58422. */
  58423. readonly w: NodeMaterialConnectionPoint;
  58424. /**
  58425. * Gets the xyzw component (output)
  58426. */
  58427. readonly xyzw: NodeMaterialConnectionPoint;
  58428. /**
  58429. * Gets the xyz component (output)
  58430. */
  58431. readonly xyz: NodeMaterialConnectionPoint;
  58432. /**
  58433. * Gets the xy component (output)
  58434. */
  58435. readonly xy: NodeMaterialConnectionPoint;
  58436. protected _buildBlock(state: NodeMaterialBuildState): this;
  58437. }
  58438. }
  58439. declare module "babylonjs/Materials/Node/Blocks/colorSplitterBlock" {
  58440. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58441. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58442. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58443. /**
  58444. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  58445. */
  58446. export class ColorSplitterBlock extends NodeMaterialBlock {
  58447. /**
  58448. * Create a new ColorSplitterBlock
  58449. * @param name defines the block name
  58450. */
  58451. constructor(name: string);
  58452. /**
  58453. * Gets the current class name
  58454. * @returns the class name
  58455. */
  58456. getClassName(): string;
  58457. /**
  58458. * Gets the rgba component (input)
  58459. */
  58460. readonly rgba: NodeMaterialConnectionPoint;
  58461. /**
  58462. * Gets the rgb component (input)
  58463. */
  58464. readonly rgbIn: NodeMaterialConnectionPoint;
  58465. /**
  58466. * Gets the rgb component (output)
  58467. */
  58468. readonly rgbOut: NodeMaterialConnectionPoint;
  58469. /**
  58470. * Gets the r component (output)
  58471. */
  58472. readonly r: NodeMaterialConnectionPoint;
  58473. /**
  58474. * Gets the g component (output)
  58475. */
  58476. readonly g: NodeMaterialConnectionPoint;
  58477. /**
  58478. * Gets the b component (output)
  58479. */
  58480. readonly b: NodeMaterialConnectionPoint;
  58481. /**
  58482. * Gets the a component (output)
  58483. */
  58484. readonly a: NodeMaterialConnectionPoint;
  58485. protected _inputRename(name: string): string;
  58486. protected _outputRename(name: string): string;
  58487. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  58488. }
  58489. }
  58490. declare module "babylonjs/Materials/Node/Blocks/vectorSplitterBlock" {
  58491. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58492. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58493. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58494. /**
  58495. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  58496. */
  58497. export class VectorSplitterBlock extends NodeMaterialBlock {
  58498. /**
  58499. * Create a new VectorSplitterBlock
  58500. * @param name defines the block name
  58501. */
  58502. constructor(name: string);
  58503. /**
  58504. * Gets the current class name
  58505. * @returns the class name
  58506. */
  58507. getClassName(): string;
  58508. /**
  58509. * Gets the xyzw component (input)
  58510. */
  58511. readonly xyzw: NodeMaterialConnectionPoint;
  58512. /**
  58513. * Gets the xyz component (input)
  58514. */
  58515. readonly xyzIn: NodeMaterialConnectionPoint;
  58516. /**
  58517. * Gets the xy component (input)
  58518. */
  58519. readonly xyIn: NodeMaterialConnectionPoint;
  58520. /**
  58521. * Gets the xyz component (output)
  58522. */
  58523. readonly xyzOut: NodeMaterialConnectionPoint;
  58524. /**
  58525. * Gets the xy component (output)
  58526. */
  58527. readonly xyOut: NodeMaterialConnectionPoint;
  58528. /**
  58529. * Gets the x component (output)
  58530. */
  58531. readonly x: NodeMaterialConnectionPoint;
  58532. /**
  58533. * Gets the y component (output)
  58534. */
  58535. readonly y: NodeMaterialConnectionPoint;
  58536. /**
  58537. * Gets the z component (output)
  58538. */
  58539. readonly z: NodeMaterialConnectionPoint;
  58540. /**
  58541. * Gets the w component (output)
  58542. */
  58543. readonly w: NodeMaterialConnectionPoint;
  58544. protected _inputRename(name: string): string;
  58545. protected _outputRename(name: string): string;
  58546. protected _buildBlock(state: NodeMaterialBuildState): this;
  58547. }
  58548. }
  58549. declare module "babylonjs/Materials/Node/Blocks/lerpBlock" {
  58550. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58551. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58552. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58553. /**
  58554. * Block used to lerp between 2 values
  58555. */
  58556. export class LerpBlock extends NodeMaterialBlock {
  58557. /**
  58558. * Creates a new LerpBlock
  58559. * @param name defines the block name
  58560. */
  58561. constructor(name: string);
  58562. /**
  58563. * Gets the current class name
  58564. * @returns the class name
  58565. */
  58566. getClassName(): string;
  58567. /**
  58568. * Gets the left operand input component
  58569. */
  58570. readonly left: NodeMaterialConnectionPoint;
  58571. /**
  58572. * Gets the right operand input component
  58573. */
  58574. readonly right: NodeMaterialConnectionPoint;
  58575. /**
  58576. * Gets the gradient operand input component
  58577. */
  58578. readonly gradient: NodeMaterialConnectionPoint;
  58579. /**
  58580. * Gets the output component
  58581. */
  58582. readonly output: NodeMaterialConnectionPoint;
  58583. protected _buildBlock(state: NodeMaterialBuildState): this;
  58584. }
  58585. }
  58586. declare module "babylonjs/Materials/Node/Blocks/divideBlock" {
  58587. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58588. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58589. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58590. /**
  58591. * Block used to divide 2 vectors
  58592. */
  58593. export class DivideBlock extends NodeMaterialBlock {
  58594. /**
  58595. * Creates a new DivideBlock
  58596. * @param name defines the block name
  58597. */
  58598. constructor(name: string);
  58599. /**
  58600. * Gets the current class name
  58601. * @returns the class name
  58602. */
  58603. getClassName(): string;
  58604. /**
  58605. * Gets the left operand input component
  58606. */
  58607. readonly left: NodeMaterialConnectionPoint;
  58608. /**
  58609. * Gets the right operand input component
  58610. */
  58611. readonly right: NodeMaterialConnectionPoint;
  58612. /**
  58613. * Gets the output component
  58614. */
  58615. readonly output: NodeMaterialConnectionPoint;
  58616. protected _buildBlock(state: NodeMaterialBuildState): this;
  58617. }
  58618. }
  58619. declare module "babylonjs/Materials/Node/Blocks/subtractBlock" {
  58620. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58621. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58622. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58623. /**
  58624. * Block used to subtract 2 vectors
  58625. */
  58626. export class SubtractBlock extends NodeMaterialBlock {
  58627. /**
  58628. * Creates a new SubtractBlock
  58629. * @param name defines the block name
  58630. */
  58631. constructor(name: string);
  58632. /**
  58633. * Gets the current class name
  58634. * @returns the class name
  58635. */
  58636. getClassName(): string;
  58637. /**
  58638. * Gets the left operand input component
  58639. */
  58640. readonly left: NodeMaterialConnectionPoint;
  58641. /**
  58642. * Gets the right operand input component
  58643. */
  58644. readonly right: NodeMaterialConnectionPoint;
  58645. /**
  58646. * Gets the output component
  58647. */
  58648. readonly output: NodeMaterialConnectionPoint;
  58649. protected _buildBlock(state: NodeMaterialBuildState): this;
  58650. }
  58651. }
  58652. declare module "babylonjs/Materials/Node/Blocks/stepBlock" {
  58653. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58654. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58655. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58656. /**
  58657. * Block used to step a value
  58658. */
  58659. export class StepBlock extends NodeMaterialBlock {
  58660. /**
  58661. * Creates a new StepBlock
  58662. * @param name defines the block name
  58663. */
  58664. constructor(name: string);
  58665. /**
  58666. * Gets the current class name
  58667. * @returns the class name
  58668. */
  58669. getClassName(): string;
  58670. /**
  58671. * Gets the value operand input component
  58672. */
  58673. readonly value: NodeMaterialConnectionPoint;
  58674. /**
  58675. * Gets the edge operand input component
  58676. */
  58677. readonly edge: NodeMaterialConnectionPoint;
  58678. /**
  58679. * Gets the output component
  58680. */
  58681. readonly output: NodeMaterialConnectionPoint;
  58682. protected _buildBlock(state: NodeMaterialBuildState): this;
  58683. }
  58684. }
  58685. declare module "babylonjs/Materials/Node/Blocks/oneMinusBlock" {
  58686. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58687. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58688. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58689. /**
  58690. * Block used to get the opposite (1 - x) of a value
  58691. */
  58692. export class OneMinusBlock extends NodeMaterialBlock {
  58693. /**
  58694. * Creates a new OneMinusBlock
  58695. * @param name defines the block name
  58696. */
  58697. constructor(name: string);
  58698. /**
  58699. * Gets the current class name
  58700. * @returns the class name
  58701. */
  58702. getClassName(): string;
  58703. /**
  58704. * Gets the input component
  58705. */
  58706. readonly input: NodeMaterialConnectionPoint;
  58707. /**
  58708. * Gets the output component
  58709. */
  58710. readonly output: NodeMaterialConnectionPoint;
  58711. protected _buildBlock(state: NodeMaterialBuildState): this;
  58712. }
  58713. }
  58714. declare module "babylonjs/Materials/Node/Blocks/viewDirectionBlock" {
  58715. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58716. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58717. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58718. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  58719. /**
  58720. * Block used to get the view direction
  58721. */
  58722. export class ViewDirectionBlock extends NodeMaterialBlock {
  58723. /**
  58724. * Creates a new ViewDirectionBlock
  58725. * @param name defines the block name
  58726. */
  58727. constructor(name: string);
  58728. /**
  58729. * Gets the current class name
  58730. * @returns the class name
  58731. */
  58732. getClassName(): string;
  58733. /**
  58734. * Gets the world position component
  58735. */
  58736. readonly worldPosition: NodeMaterialConnectionPoint;
  58737. /**
  58738. * Gets the camera position component
  58739. */
  58740. readonly cameraPosition: NodeMaterialConnectionPoint;
  58741. /**
  58742. * Gets the output component
  58743. */
  58744. readonly output: NodeMaterialConnectionPoint;
  58745. autoConfigure(material: NodeMaterial): void;
  58746. protected _buildBlock(state: NodeMaterialBuildState): this;
  58747. }
  58748. }
  58749. declare module "babylonjs/Materials/Node/Blocks/fresnelBlock" {
  58750. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58751. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58752. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58753. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  58754. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  58755. /**
  58756. * Block used to compute fresnel value
  58757. */
  58758. export class FresnelBlock extends NodeMaterialBlock {
  58759. /**
  58760. * Create a new FresnelBlock
  58761. * @param name defines the block name
  58762. */
  58763. constructor(name: string);
  58764. /**
  58765. * Gets the current class name
  58766. * @returns the class name
  58767. */
  58768. getClassName(): string;
  58769. /**
  58770. * Gets the world normal input component
  58771. */
  58772. readonly worldNormal: NodeMaterialConnectionPoint;
  58773. /**
  58774. * Gets the view direction input component
  58775. */
  58776. readonly viewDirection: NodeMaterialConnectionPoint;
  58777. /**
  58778. * Gets the bias input component
  58779. */
  58780. readonly bias: NodeMaterialConnectionPoint;
  58781. /**
  58782. * Gets the camera (or eye) position component
  58783. */
  58784. readonly power: NodeMaterialConnectionPoint;
  58785. /**
  58786. * Gets the fresnel output component
  58787. */
  58788. readonly fresnel: NodeMaterialConnectionPoint;
  58789. autoConfigure(material: NodeMaterial): void;
  58790. protected _buildBlock(state: NodeMaterialBuildState): this;
  58791. }
  58792. }
  58793. declare module "babylonjs/Materials/Node/Blocks/maxBlock" {
  58794. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58795. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58796. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58797. /**
  58798. * Block used to get the max of 2 values
  58799. */
  58800. export class MaxBlock extends NodeMaterialBlock {
  58801. /**
  58802. * Creates a new MaxBlock
  58803. * @param name defines the block name
  58804. */
  58805. constructor(name: string);
  58806. /**
  58807. * Gets the current class name
  58808. * @returns the class name
  58809. */
  58810. getClassName(): string;
  58811. /**
  58812. * Gets the left operand input component
  58813. */
  58814. readonly left: NodeMaterialConnectionPoint;
  58815. /**
  58816. * Gets the right operand input component
  58817. */
  58818. readonly right: NodeMaterialConnectionPoint;
  58819. /**
  58820. * Gets the output component
  58821. */
  58822. readonly output: NodeMaterialConnectionPoint;
  58823. protected _buildBlock(state: NodeMaterialBuildState): this;
  58824. }
  58825. }
  58826. declare module "babylonjs/Materials/Node/Blocks/minBlock" {
  58827. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58828. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58829. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58830. /**
  58831. * Block used to get the min of 2 values
  58832. */
  58833. export class MinBlock extends NodeMaterialBlock {
  58834. /**
  58835. * Creates a new MinBlock
  58836. * @param name defines the block name
  58837. */
  58838. constructor(name: string);
  58839. /**
  58840. * Gets the current class name
  58841. * @returns the class name
  58842. */
  58843. getClassName(): string;
  58844. /**
  58845. * Gets the left operand input component
  58846. */
  58847. readonly left: NodeMaterialConnectionPoint;
  58848. /**
  58849. * Gets the right operand input component
  58850. */
  58851. readonly right: NodeMaterialConnectionPoint;
  58852. /**
  58853. * Gets the output component
  58854. */
  58855. readonly output: NodeMaterialConnectionPoint;
  58856. protected _buildBlock(state: NodeMaterialBuildState): this;
  58857. }
  58858. }
  58859. declare module "babylonjs/Materials/Node/Blocks/distanceBlock" {
  58860. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58861. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58862. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58863. /**
  58864. * Block used to get the distance between 2 values
  58865. */
  58866. export class DistanceBlock extends NodeMaterialBlock {
  58867. /**
  58868. * Creates a new DistanceBlock
  58869. * @param name defines the block name
  58870. */
  58871. constructor(name: string);
  58872. /**
  58873. * Gets the current class name
  58874. * @returns the class name
  58875. */
  58876. getClassName(): string;
  58877. /**
  58878. * Gets the left operand input component
  58879. */
  58880. readonly left: NodeMaterialConnectionPoint;
  58881. /**
  58882. * Gets the right operand input component
  58883. */
  58884. readonly right: NodeMaterialConnectionPoint;
  58885. /**
  58886. * Gets the output component
  58887. */
  58888. readonly output: NodeMaterialConnectionPoint;
  58889. protected _buildBlock(state: NodeMaterialBuildState): this;
  58890. }
  58891. }
  58892. declare module "babylonjs/Materials/Node/Blocks/lengthBlock" {
  58893. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58894. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58895. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58896. /**
  58897. * Block used to get the length of a vector
  58898. */
  58899. export class LengthBlock extends NodeMaterialBlock {
  58900. /**
  58901. * Creates a new LengthBlock
  58902. * @param name defines the block name
  58903. */
  58904. constructor(name: string);
  58905. /**
  58906. * Gets the current class name
  58907. * @returns the class name
  58908. */
  58909. getClassName(): string;
  58910. /**
  58911. * Gets the value input component
  58912. */
  58913. readonly value: NodeMaterialConnectionPoint;
  58914. /**
  58915. * Gets the output component
  58916. */
  58917. readonly output: NodeMaterialConnectionPoint;
  58918. protected _buildBlock(state: NodeMaterialBuildState): this;
  58919. }
  58920. }
  58921. declare module "babylonjs/Materials/Node/Blocks/negateBlock" {
  58922. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58923. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58924. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58925. /**
  58926. * Block used to get negative version of a value (i.e. x * -1)
  58927. */
  58928. export class NegateBlock extends NodeMaterialBlock {
  58929. /**
  58930. * Creates a new NegateBlock
  58931. * @param name defines the block name
  58932. */
  58933. constructor(name: string);
  58934. /**
  58935. * Gets the current class name
  58936. * @returns the class name
  58937. */
  58938. getClassName(): string;
  58939. /**
  58940. * Gets the value input component
  58941. */
  58942. readonly value: NodeMaterialConnectionPoint;
  58943. /**
  58944. * Gets the output component
  58945. */
  58946. readonly output: NodeMaterialConnectionPoint;
  58947. protected _buildBlock(state: NodeMaterialBuildState): this;
  58948. }
  58949. }
  58950. declare module "babylonjs/Materials/Node/Blocks/powBlock" {
  58951. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58952. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58953. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58954. /**
  58955. * Block used to get the value of the first parameter raised to the power of the second
  58956. */
  58957. export class PowBlock extends NodeMaterialBlock {
  58958. /**
  58959. * Creates a new PowBlock
  58960. * @param name defines the block name
  58961. */
  58962. constructor(name: string);
  58963. /**
  58964. * Gets the current class name
  58965. * @returns the class name
  58966. */
  58967. getClassName(): string;
  58968. /**
  58969. * Gets the value operand input component
  58970. */
  58971. readonly value: NodeMaterialConnectionPoint;
  58972. /**
  58973. * Gets the power operand input component
  58974. */
  58975. readonly power: NodeMaterialConnectionPoint;
  58976. /**
  58977. * Gets the output component
  58978. */
  58979. readonly output: NodeMaterialConnectionPoint;
  58980. protected _buildBlock(state: NodeMaterialBuildState): this;
  58981. }
  58982. }
  58983. declare module "babylonjs/Materials/Node/Blocks/randomNumberBlock" {
  58984. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58985. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58986. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58987. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  58988. /**
  58989. * Block used to get a random number
  58990. */
  58991. export class RandomNumberBlock extends NodeMaterialBlock {
  58992. /**
  58993. * Creates a new RandomNumberBlock
  58994. * @param name defines the block name
  58995. */
  58996. constructor(name: string);
  58997. /**
  58998. * Gets the current class name
  58999. * @returns the class name
  59000. */
  59001. getClassName(): string;
  59002. /**
  59003. * Gets the seed input component
  59004. */
  59005. readonly seed: NodeMaterialConnectionPoint;
  59006. /**
  59007. * Gets the output component
  59008. */
  59009. readonly output: NodeMaterialConnectionPoint;
  59010. protected _buildBlock(state: NodeMaterialBuildState): this;
  59011. }
  59012. }
  59013. declare module "babylonjs/Materials/Node/Blocks/arcTan2Block" {
  59014. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59015. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59016. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59017. /**
  59018. * Block used to compute arc tangent of 2 values
  59019. */
  59020. export class ArcTan2Block extends NodeMaterialBlock {
  59021. /**
  59022. * Creates a new ArcTan2Block
  59023. * @param name defines the block name
  59024. */
  59025. constructor(name: string);
  59026. /**
  59027. * Gets the current class name
  59028. * @returns the class name
  59029. */
  59030. getClassName(): string;
  59031. /**
  59032. * Gets the x operand input component
  59033. */
  59034. readonly x: NodeMaterialConnectionPoint;
  59035. /**
  59036. * Gets the y operand input component
  59037. */
  59038. readonly y: NodeMaterialConnectionPoint;
  59039. /**
  59040. * Gets the output component
  59041. */
  59042. readonly output: NodeMaterialConnectionPoint;
  59043. protected _buildBlock(state: NodeMaterialBuildState): this;
  59044. }
  59045. }
  59046. declare module "babylonjs/Materials/Node/Blocks/smoothStepBlock" {
  59047. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59048. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59049. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59050. /**
  59051. * Block used to smooth step a value
  59052. */
  59053. export class SmoothStepBlock extends NodeMaterialBlock {
  59054. /**
  59055. * Creates a new SmoothStepBlock
  59056. * @param name defines the block name
  59057. */
  59058. constructor(name: string);
  59059. /**
  59060. * Gets the current class name
  59061. * @returns the class name
  59062. */
  59063. getClassName(): string;
  59064. /**
  59065. * Gets the value operand input component
  59066. */
  59067. readonly value: NodeMaterialConnectionPoint;
  59068. /**
  59069. * Gets the first edge operand input component
  59070. */
  59071. readonly edge0: NodeMaterialConnectionPoint;
  59072. /**
  59073. * Gets the second edge operand input component
  59074. */
  59075. readonly edge1: NodeMaterialConnectionPoint;
  59076. /**
  59077. * Gets the output component
  59078. */
  59079. readonly output: NodeMaterialConnectionPoint;
  59080. protected _buildBlock(state: NodeMaterialBuildState): this;
  59081. }
  59082. }
  59083. declare module "babylonjs/Materials/Node/Blocks/reciprocalBlock" {
  59084. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59085. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59086. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59087. /**
  59088. * Block used to get the reciprocal (1 / x) of a value
  59089. */
  59090. export class ReciprocalBlock extends NodeMaterialBlock {
  59091. /**
  59092. * Creates a new ReciprocalBlock
  59093. * @param name defines the block name
  59094. */
  59095. constructor(name: string);
  59096. /**
  59097. * Gets the current class name
  59098. * @returns the class name
  59099. */
  59100. getClassName(): string;
  59101. /**
  59102. * Gets the input component
  59103. */
  59104. readonly input: NodeMaterialConnectionPoint;
  59105. /**
  59106. * Gets the output component
  59107. */
  59108. readonly output: NodeMaterialConnectionPoint;
  59109. protected _buildBlock(state: NodeMaterialBuildState): this;
  59110. }
  59111. }
  59112. declare module "babylonjs/Materials/Node/Blocks/replaceColorBlock" {
  59113. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59114. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59115. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59116. /**
  59117. * Block used to replace a color by another one
  59118. */
  59119. export class ReplaceColorBlock extends NodeMaterialBlock {
  59120. /**
  59121. * Creates a new ReplaceColorBlock
  59122. * @param name defines the block name
  59123. */
  59124. constructor(name: string);
  59125. /**
  59126. * Gets the current class name
  59127. * @returns the class name
  59128. */
  59129. getClassName(): string;
  59130. /**
  59131. * Gets the value input component
  59132. */
  59133. readonly value: NodeMaterialConnectionPoint;
  59134. /**
  59135. * Gets the reference input component
  59136. */
  59137. readonly reference: NodeMaterialConnectionPoint;
  59138. /**
  59139. * Gets the distance input component
  59140. */
  59141. readonly distance: NodeMaterialConnectionPoint;
  59142. /**
  59143. * Gets the replacement input component
  59144. */
  59145. readonly replacement: NodeMaterialConnectionPoint;
  59146. /**
  59147. * Gets the output component
  59148. */
  59149. readonly output: NodeMaterialConnectionPoint;
  59150. protected _buildBlock(state: NodeMaterialBuildState): this;
  59151. }
  59152. }
  59153. declare module "babylonjs/Materials/Node/Blocks/posterizeBlock" {
  59154. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59155. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59156. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59157. /**
  59158. * Block used to posterize a value
  59159. * @see https://en.wikipedia.org/wiki/Posterization
  59160. */
  59161. export class PosterizeBlock extends NodeMaterialBlock {
  59162. /**
  59163. * Creates a new PosterizeBlock
  59164. * @param name defines the block name
  59165. */
  59166. constructor(name: string);
  59167. /**
  59168. * Gets the current class name
  59169. * @returns the class name
  59170. */
  59171. getClassName(): string;
  59172. /**
  59173. * Gets the value input component
  59174. */
  59175. readonly value: NodeMaterialConnectionPoint;
  59176. /**
  59177. * Gets the steps input component
  59178. */
  59179. readonly steps: NodeMaterialConnectionPoint;
  59180. /**
  59181. * Gets the output component
  59182. */
  59183. readonly output: NodeMaterialConnectionPoint;
  59184. protected _buildBlock(state: NodeMaterialBuildState): this;
  59185. }
  59186. }
  59187. declare module "babylonjs/Materials/Node/Blocks/waveBlock" {
  59188. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59189. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59190. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59191. import { Scene } from "babylonjs/scene";
  59192. /**
  59193. * Operations supported by the Wave block
  59194. */
  59195. export enum WaveBlockKind {
  59196. /** SawTooth */
  59197. SawTooth = 0,
  59198. /** Square */
  59199. Square = 1,
  59200. /** Triangle */
  59201. Triangle = 2
  59202. }
  59203. /**
  59204. * Block used to apply wave operation to floats
  59205. */
  59206. export class WaveBlock extends NodeMaterialBlock {
  59207. /**
  59208. * Gets or sets the kibnd of wave to be applied by the block
  59209. */
  59210. kind: WaveBlockKind;
  59211. /**
  59212. * Creates a new WaveBlock
  59213. * @param name defines the block name
  59214. */
  59215. constructor(name: string);
  59216. /**
  59217. * Gets the current class name
  59218. * @returns the class name
  59219. */
  59220. getClassName(): string;
  59221. /**
  59222. * Gets the input component
  59223. */
  59224. readonly input: NodeMaterialConnectionPoint;
  59225. /**
  59226. * Gets the output component
  59227. */
  59228. readonly output: NodeMaterialConnectionPoint;
  59229. protected _buildBlock(state: NodeMaterialBuildState): this;
  59230. serialize(): any;
  59231. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59232. }
  59233. }
  59234. declare module "babylonjs/Materials/Node/Blocks/gradientBlock" {
  59235. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59236. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59237. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59238. import { Color3 } from "babylonjs/Maths/math.color";
  59239. import { Scene } from "babylonjs/scene";
  59240. /**
  59241. * Class used to store a color step for the GradientBlock
  59242. */
  59243. export class GradientBlockColorStep {
  59244. /**
  59245. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  59246. */
  59247. step: number;
  59248. /**
  59249. * Gets or sets the color associated with this step
  59250. */
  59251. color: Color3;
  59252. /**
  59253. * Creates a new GradientBlockColorStep
  59254. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  59255. * @param color defines the color associated with this step
  59256. */
  59257. constructor(
  59258. /**
  59259. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  59260. */
  59261. step: number,
  59262. /**
  59263. * Gets or sets the color associated with this step
  59264. */
  59265. color: Color3);
  59266. }
  59267. /**
  59268. * Block used to return a color from a gradient based on an input value between 0 and 1
  59269. */
  59270. export class GradientBlock extends NodeMaterialBlock {
  59271. /**
  59272. * Gets or sets the list of color steps
  59273. */
  59274. colorSteps: GradientBlockColorStep[];
  59275. /**
  59276. * Creates a new GradientBlock
  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 gradient input component
  59287. */
  59288. readonly gradient: NodeMaterialConnectionPoint;
  59289. /**
  59290. * Gets the output component
  59291. */
  59292. readonly output: NodeMaterialConnectionPoint;
  59293. private _writeColorConstant;
  59294. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  59295. serialize(): any;
  59296. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59297. protected _dumpPropertiesCode(): string;
  59298. }
  59299. }
  59300. declare module "babylonjs/Materials/Node/Blocks/nLerpBlock" {
  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. /**
  59305. * Block used to normalize lerp between 2 values
  59306. */
  59307. export class NLerpBlock extends NodeMaterialBlock {
  59308. /**
  59309. * Creates a new NLerpBlock
  59310. * @param name defines the block name
  59311. */
  59312. constructor(name: string);
  59313. /**
  59314. * Gets the current class name
  59315. * @returns the class name
  59316. */
  59317. getClassName(): string;
  59318. /**
  59319. * Gets the left operand input component
  59320. */
  59321. readonly left: NodeMaterialConnectionPoint;
  59322. /**
  59323. * Gets the right operand input component
  59324. */
  59325. readonly right: NodeMaterialConnectionPoint;
  59326. /**
  59327. * Gets the gradient operand input component
  59328. */
  59329. readonly gradient: NodeMaterialConnectionPoint;
  59330. /**
  59331. * Gets the output component
  59332. */
  59333. readonly output: NodeMaterialConnectionPoint;
  59334. protected _buildBlock(state: NodeMaterialBuildState): this;
  59335. }
  59336. }
  59337. declare module "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock" {
  59338. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59339. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59340. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59341. import { Scene } from "babylonjs/scene";
  59342. /**
  59343. * block used to Generate a Worley Noise 3D Noise Pattern
  59344. */
  59345. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  59346. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  59347. manhattanDistance: boolean;
  59348. /**
  59349. * Creates a new WorleyNoise3DBlock
  59350. * @param name defines the block name
  59351. */
  59352. constructor(name: string);
  59353. /**
  59354. * Gets the current class name
  59355. * @returns the class name
  59356. */
  59357. getClassName(): string;
  59358. /**
  59359. * Gets the seed input component
  59360. */
  59361. readonly seed: NodeMaterialConnectionPoint;
  59362. /**
  59363. * Gets the jitter input component
  59364. */
  59365. readonly jitter: NodeMaterialConnectionPoint;
  59366. /**
  59367. * Gets the output component
  59368. */
  59369. readonly output: NodeMaterialConnectionPoint;
  59370. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  59371. /**
  59372. * Exposes the properties to the UI?
  59373. */
  59374. protected _dumpPropertiesCode(): string;
  59375. /**
  59376. * Exposes the properties to the Seralize?
  59377. */
  59378. serialize(): any;
  59379. /**
  59380. * Exposes the properties to the deseralize?
  59381. */
  59382. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59383. }
  59384. }
  59385. declare module "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock" {
  59386. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59387. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59388. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59389. /**
  59390. * block used to Generate a Simplex Perlin 3d Noise Pattern
  59391. */
  59392. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  59393. /**
  59394. * Creates a new SimplexPerlin3DBlock
  59395. * @param name defines the block name
  59396. */
  59397. constructor(name: string);
  59398. /**
  59399. * Gets the current class name
  59400. * @returns the class name
  59401. */
  59402. getClassName(): string;
  59403. /**
  59404. * Gets the seed operand input component
  59405. */
  59406. readonly seed: NodeMaterialConnectionPoint;
  59407. /**
  59408. * Gets the output component
  59409. */
  59410. readonly output: NodeMaterialConnectionPoint;
  59411. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  59412. }
  59413. }
  59414. declare module "babylonjs/Materials/Node/Blocks/normalBlendBlock" {
  59415. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59416. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59417. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59418. /**
  59419. * Block used to blend normals
  59420. */
  59421. export class NormalBlendBlock extends NodeMaterialBlock {
  59422. /**
  59423. * Creates a new NormalBlendBlock
  59424. * @param name defines the block name
  59425. */
  59426. constructor(name: string);
  59427. /**
  59428. * Gets the current class name
  59429. * @returns the class name
  59430. */
  59431. getClassName(): string;
  59432. /**
  59433. * Gets the first input component
  59434. */
  59435. readonly input0: NodeMaterialConnectionPoint;
  59436. /**
  59437. * Gets the second input component
  59438. */
  59439. readonly input1: NodeMaterialConnectionPoint;
  59440. /**
  59441. * Gets the output component
  59442. */
  59443. readonly output: NodeMaterialConnectionPoint;
  59444. protected _buildBlock(state: NodeMaterialBuildState): this;
  59445. }
  59446. }
  59447. declare module "babylonjs/Materials/Node/Blocks/rotate2dBlock" {
  59448. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59449. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59450. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59451. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  59452. /**
  59453. * Block used to rotate a 2d vector by a given angle
  59454. */
  59455. export class Rotate2dBlock extends NodeMaterialBlock {
  59456. /**
  59457. * Creates a new Rotate2dBlock
  59458. * @param name defines the block name
  59459. */
  59460. constructor(name: string);
  59461. /**
  59462. * Gets the current class name
  59463. * @returns the class name
  59464. */
  59465. getClassName(): string;
  59466. /**
  59467. * Gets the input vector
  59468. */
  59469. readonly input: NodeMaterialConnectionPoint;
  59470. /**
  59471. * Gets the input angle
  59472. */
  59473. readonly angle: NodeMaterialConnectionPoint;
  59474. /**
  59475. * Gets the output component
  59476. */
  59477. readonly output: NodeMaterialConnectionPoint;
  59478. autoConfigure(material: NodeMaterial): void;
  59479. protected _buildBlock(state: NodeMaterialBuildState): this;
  59480. }
  59481. }
  59482. declare module "babylonjs/Materials/Node/Blocks/index" {
  59483. export * from "babylonjs/Materials/Node/Blocks/Vertex/index";
  59484. export * from "babylonjs/Materials/Node/Blocks/Fragment/index";
  59485. export * from "babylonjs/Materials/Node/Blocks/Dual/index";
  59486. export * from "babylonjs/Materials/Node/Blocks/Input/index";
  59487. export * from "babylonjs/Materials/Node/Blocks/multiplyBlock";
  59488. export * from "babylonjs/Materials/Node/Blocks/addBlock";
  59489. export * from "babylonjs/Materials/Node/Blocks/scaleBlock";
  59490. export * from "babylonjs/Materials/Node/Blocks/clampBlock";
  59491. export * from "babylonjs/Materials/Node/Blocks/crossBlock";
  59492. export * from "babylonjs/Materials/Node/Blocks/dotBlock";
  59493. export * from "babylonjs/Materials/Node/Blocks/transformBlock";
  59494. export * from "babylonjs/Materials/Node/Blocks/remapBlock";
  59495. export * from "babylonjs/Materials/Node/Blocks/normalizeBlock";
  59496. export * from "babylonjs/Materials/Node/Blocks/trigonometryBlock";
  59497. export * from "babylonjs/Materials/Node/Blocks/colorMergerBlock";
  59498. export * from "babylonjs/Materials/Node/Blocks/vectorMergerBlock";
  59499. export * from "babylonjs/Materials/Node/Blocks/colorSplitterBlock";
  59500. export * from "babylonjs/Materials/Node/Blocks/vectorSplitterBlock";
  59501. export * from "babylonjs/Materials/Node/Blocks/lerpBlock";
  59502. export * from "babylonjs/Materials/Node/Blocks/divideBlock";
  59503. export * from "babylonjs/Materials/Node/Blocks/subtractBlock";
  59504. export * from "babylonjs/Materials/Node/Blocks/stepBlock";
  59505. export * from "babylonjs/Materials/Node/Blocks/oneMinusBlock";
  59506. export * from "babylonjs/Materials/Node/Blocks/viewDirectionBlock";
  59507. export * from "babylonjs/Materials/Node/Blocks/fresnelBlock";
  59508. export * from "babylonjs/Materials/Node/Blocks/maxBlock";
  59509. export * from "babylonjs/Materials/Node/Blocks/minBlock";
  59510. export * from "babylonjs/Materials/Node/Blocks/distanceBlock";
  59511. export * from "babylonjs/Materials/Node/Blocks/lengthBlock";
  59512. export * from "babylonjs/Materials/Node/Blocks/negateBlock";
  59513. export * from "babylonjs/Materials/Node/Blocks/powBlock";
  59514. export * from "babylonjs/Materials/Node/Blocks/randomNumberBlock";
  59515. export * from "babylonjs/Materials/Node/Blocks/arcTan2Block";
  59516. export * from "babylonjs/Materials/Node/Blocks/smoothStepBlock";
  59517. export * from "babylonjs/Materials/Node/Blocks/reciprocalBlock";
  59518. export * from "babylonjs/Materials/Node/Blocks/replaceColorBlock";
  59519. export * from "babylonjs/Materials/Node/Blocks/posterizeBlock";
  59520. export * from "babylonjs/Materials/Node/Blocks/waveBlock";
  59521. export * from "babylonjs/Materials/Node/Blocks/gradientBlock";
  59522. export * from "babylonjs/Materials/Node/Blocks/nLerpBlock";
  59523. export * from "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock";
  59524. export * from "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock";
  59525. export * from "babylonjs/Materials/Node/Blocks/normalBlendBlock";
  59526. export * from "babylonjs/Materials/Node/Blocks/rotate2dBlock";
  59527. }
  59528. declare module "babylonjs/Materials/Node/Optimizers/index" {
  59529. export * from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  59530. }
  59531. declare module "babylonjs/Materials/Node/index" {
  59532. export * from "babylonjs/Materials/Node/Enums/index";
  59533. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59534. export * from "babylonjs/Materials/Node/nodeMaterialBlock";
  59535. export * from "babylonjs/Materials/Node/nodeMaterial";
  59536. export * from "babylonjs/Materials/Node/Blocks/index";
  59537. export * from "babylonjs/Materials/Node/Optimizers/index";
  59538. }
  59539. declare module "babylonjs/Materials/effectRenderer" {
  59540. import { Nullable } from "babylonjs/types";
  59541. import { Texture } from "babylonjs/Materials/Textures/texture";
  59542. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  59543. import { Viewport } from "babylonjs/Maths/math.viewport";
  59544. import { Observable } from "babylonjs/Misc/observable";
  59545. import { Effect } from "babylonjs/Materials/effect";
  59546. import "babylonjs/Engines/Extensions/engine.renderTarget";
  59547. import "babylonjs/Shaders/postprocess.vertex";
  59548. /**
  59549. * Effect Render Options
  59550. */
  59551. export interface IEffectRendererOptions {
  59552. /**
  59553. * Defines the vertices positions.
  59554. */
  59555. positions?: number[];
  59556. /**
  59557. * Defines the indices.
  59558. */
  59559. indices?: number[];
  59560. }
  59561. /**
  59562. * Helper class to render one or more effects
  59563. */
  59564. export class EffectRenderer {
  59565. private engine;
  59566. private static _DefaultOptions;
  59567. private _vertexBuffers;
  59568. private _indexBuffer;
  59569. private _ringBufferIndex;
  59570. private _ringScreenBuffer;
  59571. private _fullscreenViewport;
  59572. private _getNextFrameBuffer;
  59573. /**
  59574. * Creates an effect renderer
  59575. * @param engine the engine to use for rendering
  59576. * @param options defines the options of the effect renderer
  59577. */
  59578. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  59579. /**
  59580. * Sets the current viewport in normalized coordinates 0-1
  59581. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  59582. */
  59583. setViewport(viewport?: Viewport): void;
  59584. /**
  59585. * Binds the embedded attributes buffer to the effect.
  59586. * @param effect Defines the effect to bind the attributes for
  59587. */
  59588. bindBuffers(effect: Effect): void;
  59589. /**
  59590. * Sets the current effect wrapper to use during draw.
  59591. * The effect needs to be ready before calling this api.
  59592. * This also sets the default full screen position attribute.
  59593. * @param effectWrapper Defines the effect to draw with
  59594. */
  59595. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  59596. /**
  59597. * Draws a full screen quad.
  59598. */
  59599. draw(): void;
  59600. /**
  59601. * renders one or more effects to a specified texture
  59602. * @param effectWrappers list of effects to renderer
  59603. * @param outputTexture texture to draw to, if null it will render to the screen
  59604. */
  59605. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  59606. /**
  59607. * Disposes of the effect renderer
  59608. */
  59609. dispose(): void;
  59610. }
  59611. /**
  59612. * Options to create an EffectWrapper
  59613. */
  59614. interface EffectWrapperCreationOptions {
  59615. /**
  59616. * Engine to use to create the effect
  59617. */
  59618. engine: ThinEngine;
  59619. /**
  59620. * Fragment shader for the effect
  59621. */
  59622. fragmentShader: string;
  59623. /**
  59624. * Vertex shader for the effect
  59625. */
  59626. vertexShader?: string;
  59627. /**
  59628. * Attributes to use in the shader
  59629. */
  59630. attributeNames?: Array<string>;
  59631. /**
  59632. * Uniforms to use in the shader
  59633. */
  59634. uniformNames?: Array<string>;
  59635. /**
  59636. * Texture sampler names to use in the shader
  59637. */
  59638. samplerNames?: Array<string>;
  59639. /**
  59640. * The friendly name of the effect displayed in Spector.
  59641. */
  59642. name?: string;
  59643. }
  59644. /**
  59645. * Wraps an effect to be used for rendering
  59646. */
  59647. export class EffectWrapper {
  59648. /**
  59649. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  59650. */
  59651. onApplyObservable: Observable<{}>;
  59652. /**
  59653. * The underlying effect
  59654. */
  59655. effect: Effect;
  59656. /**
  59657. * Creates an effect to be renderer
  59658. * @param creationOptions options to create the effect
  59659. */
  59660. constructor(creationOptions: EffectWrapperCreationOptions);
  59661. /**
  59662. * Disposes of the effect wrapper
  59663. */
  59664. dispose(): void;
  59665. }
  59666. }
  59667. declare module "babylonjs/Materials/index" {
  59668. export * from "babylonjs/Materials/Background/index";
  59669. export * from "babylonjs/Materials/colorCurves";
  59670. export * from "babylonjs/Materials/iEffectFallbacks";
  59671. export * from "babylonjs/Materials/effectFallbacks";
  59672. export * from "babylonjs/Materials/effect";
  59673. export * from "babylonjs/Materials/fresnelParameters";
  59674. export * from "babylonjs/Materials/imageProcessingConfiguration";
  59675. export * from "babylonjs/Materials/material";
  59676. export * from "babylonjs/Materials/materialDefines";
  59677. export * from "babylonjs/Materials/materialHelper";
  59678. export * from "babylonjs/Materials/multiMaterial";
  59679. export * from "babylonjs/Materials/PBR/index";
  59680. export * from "babylonjs/Materials/pushMaterial";
  59681. export * from "babylonjs/Materials/shaderMaterial";
  59682. export * from "babylonjs/Materials/standardMaterial";
  59683. export * from "babylonjs/Materials/Textures/index";
  59684. export * from "babylonjs/Materials/uniformBuffer";
  59685. export * from "babylonjs/Materials/materialFlags";
  59686. export * from "babylonjs/Materials/Node/index";
  59687. export * from "babylonjs/Materials/effectRenderer";
  59688. }
  59689. declare module "babylonjs/Maths/index" {
  59690. export * from "babylonjs/Maths/math.scalar";
  59691. export * from "babylonjs/Maths/math";
  59692. export * from "babylonjs/Maths/sphericalPolynomial";
  59693. }
  59694. declare module "babylonjs/Misc/workerPool" {
  59695. import { IDisposable } from "babylonjs/scene";
  59696. /**
  59697. * Helper class to push actions to a pool of workers.
  59698. */
  59699. export class WorkerPool implements IDisposable {
  59700. private _workerInfos;
  59701. private _pendingActions;
  59702. /**
  59703. * Constructor
  59704. * @param workers Array of workers to use for actions
  59705. */
  59706. constructor(workers: Array<Worker>);
  59707. /**
  59708. * Terminates all workers and clears any pending actions.
  59709. */
  59710. dispose(): void;
  59711. /**
  59712. * Pushes an action to the worker pool. If all the workers are active, the action will be
  59713. * pended until a worker has completed its action.
  59714. * @param action The action to perform. Call onComplete when the action is complete.
  59715. */
  59716. push(action: (worker: Worker, onComplete: () => void) => void): void;
  59717. private _execute;
  59718. }
  59719. }
  59720. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  59721. import { IDisposable } from "babylonjs/scene";
  59722. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  59723. /**
  59724. * Configuration for Draco compression
  59725. */
  59726. export interface IDracoCompressionConfiguration {
  59727. /**
  59728. * Configuration for the decoder.
  59729. */
  59730. decoder: {
  59731. /**
  59732. * The url to the WebAssembly module.
  59733. */
  59734. wasmUrl?: string;
  59735. /**
  59736. * The url to the WebAssembly binary.
  59737. */
  59738. wasmBinaryUrl?: string;
  59739. /**
  59740. * The url to the fallback JavaScript module.
  59741. */
  59742. fallbackUrl?: string;
  59743. };
  59744. }
  59745. /**
  59746. * Draco compression (https://google.github.io/draco/)
  59747. *
  59748. * This class wraps the Draco module.
  59749. *
  59750. * **Encoder**
  59751. *
  59752. * The encoder is not currently implemented.
  59753. *
  59754. * **Decoder**
  59755. *
  59756. * 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.
  59757. *
  59758. * To update the configuration, use the following code:
  59759. * ```javascript
  59760. * DracoCompression.Configuration = {
  59761. * decoder: {
  59762. * wasmUrl: "<url to the WebAssembly library>",
  59763. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  59764. * fallbackUrl: "<url to the fallback JavaScript library>",
  59765. * }
  59766. * };
  59767. * ```
  59768. *
  59769. * 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.
  59770. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  59771. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  59772. *
  59773. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  59774. * ```javascript
  59775. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  59776. * ```
  59777. *
  59778. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  59779. */
  59780. export class DracoCompression implements IDisposable {
  59781. private _workerPoolPromise?;
  59782. private _decoderModulePromise?;
  59783. /**
  59784. * The configuration. Defaults to the following urls:
  59785. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  59786. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  59787. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  59788. */
  59789. static Configuration: IDracoCompressionConfiguration;
  59790. /**
  59791. * Returns true if the decoder configuration is available.
  59792. */
  59793. static readonly DecoderAvailable: boolean;
  59794. /**
  59795. * Default number of workers to create when creating the draco compression object.
  59796. */
  59797. static DefaultNumWorkers: number;
  59798. private static GetDefaultNumWorkers;
  59799. private static _Default;
  59800. /**
  59801. * Default instance for the draco compression object.
  59802. */
  59803. static readonly Default: DracoCompression;
  59804. /**
  59805. * Constructor
  59806. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  59807. */
  59808. constructor(numWorkers?: number);
  59809. /**
  59810. * Stop all async operations and release resources.
  59811. */
  59812. dispose(): void;
  59813. /**
  59814. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  59815. * @returns a promise that resolves when ready
  59816. */
  59817. whenReadyAsync(): Promise<void>;
  59818. /**
  59819. * Decode Draco compressed mesh data to vertex data.
  59820. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  59821. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  59822. * @returns A promise that resolves with the decoded vertex data
  59823. */
  59824. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  59825. [kind: string]: number;
  59826. }): Promise<VertexData>;
  59827. }
  59828. }
  59829. declare module "babylonjs/Meshes/Compression/index" {
  59830. export * from "babylonjs/Meshes/Compression/dracoCompression";
  59831. }
  59832. declare module "babylonjs/Meshes/csg" {
  59833. import { Nullable } from "babylonjs/types";
  59834. import { Scene } from "babylonjs/scene";
  59835. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  59836. import { Mesh } from "babylonjs/Meshes/mesh";
  59837. import { Material } from "babylonjs/Materials/material";
  59838. /**
  59839. * Class for building Constructive Solid Geometry
  59840. */
  59841. export class CSG {
  59842. private polygons;
  59843. /**
  59844. * The world matrix
  59845. */
  59846. matrix: Matrix;
  59847. /**
  59848. * Stores the position
  59849. */
  59850. position: Vector3;
  59851. /**
  59852. * Stores the rotation
  59853. */
  59854. rotation: Vector3;
  59855. /**
  59856. * Stores the rotation quaternion
  59857. */
  59858. rotationQuaternion: Nullable<Quaternion>;
  59859. /**
  59860. * Stores the scaling vector
  59861. */
  59862. scaling: Vector3;
  59863. /**
  59864. * Convert the Mesh to CSG
  59865. * @param mesh The Mesh to convert to CSG
  59866. * @returns A new CSG from the Mesh
  59867. */
  59868. static FromMesh(mesh: Mesh): CSG;
  59869. /**
  59870. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  59871. * @param polygons Polygons used to construct a CSG solid
  59872. */
  59873. private static FromPolygons;
  59874. /**
  59875. * Clones, or makes a deep copy, of the CSG
  59876. * @returns A new CSG
  59877. */
  59878. clone(): CSG;
  59879. /**
  59880. * Unions this CSG with another CSG
  59881. * @param csg The CSG to union against this CSG
  59882. * @returns The unioned CSG
  59883. */
  59884. union(csg: CSG): CSG;
  59885. /**
  59886. * Unions this CSG with another CSG in place
  59887. * @param csg The CSG to union against this CSG
  59888. */
  59889. unionInPlace(csg: CSG): void;
  59890. /**
  59891. * Subtracts this CSG with another CSG
  59892. * @param csg The CSG to subtract against this CSG
  59893. * @returns A new CSG
  59894. */
  59895. subtract(csg: CSG): CSG;
  59896. /**
  59897. * Subtracts this CSG with another CSG in place
  59898. * @param csg The CSG to subtact against this CSG
  59899. */
  59900. subtractInPlace(csg: CSG): void;
  59901. /**
  59902. * Intersect this CSG with another CSG
  59903. * @param csg The CSG to intersect against this CSG
  59904. * @returns A new CSG
  59905. */
  59906. intersect(csg: CSG): CSG;
  59907. /**
  59908. * Intersects this CSG with another CSG in place
  59909. * @param csg The CSG to intersect against this CSG
  59910. */
  59911. intersectInPlace(csg: CSG): void;
  59912. /**
  59913. * Return a new CSG solid with solid and empty space switched. This solid is
  59914. * not modified.
  59915. * @returns A new CSG solid with solid and empty space switched
  59916. */
  59917. inverse(): CSG;
  59918. /**
  59919. * Inverses the CSG in place
  59920. */
  59921. inverseInPlace(): void;
  59922. /**
  59923. * This is used to keep meshes transformations so they can be restored
  59924. * when we build back a Babylon Mesh
  59925. * NB : All CSG operations are performed in world coordinates
  59926. * @param csg The CSG to copy the transform attributes from
  59927. * @returns This CSG
  59928. */
  59929. copyTransformAttributes(csg: CSG): CSG;
  59930. /**
  59931. * Build Raw mesh from CSG
  59932. * Coordinates here are in world space
  59933. * @param name The name of the mesh geometry
  59934. * @param scene The Scene
  59935. * @param keepSubMeshes Specifies if the submeshes should be kept
  59936. * @returns A new Mesh
  59937. */
  59938. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  59939. /**
  59940. * Build Mesh from CSG taking material and transforms into account
  59941. * @param name The name of the Mesh
  59942. * @param material The material of the Mesh
  59943. * @param scene The Scene
  59944. * @param keepSubMeshes Specifies if submeshes should be kept
  59945. * @returns The new Mesh
  59946. */
  59947. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  59948. }
  59949. }
  59950. declare module "babylonjs/Meshes/trailMesh" {
  59951. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59952. import { Mesh } from "babylonjs/Meshes/mesh";
  59953. import { Scene } from "babylonjs/scene";
  59954. /**
  59955. * Class used to create a trail following a mesh
  59956. */
  59957. export class TrailMesh extends Mesh {
  59958. private _generator;
  59959. private _autoStart;
  59960. private _running;
  59961. private _diameter;
  59962. private _length;
  59963. private _sectionPolygonPointsCount;
  59964. private _sectionVectors;
  59965. private _sectionNormalVectors;
  59966. private _beforeRenderObserver;
  59967. /**
  59968. * @constructor
  59969. * @param name The value used by scene.getMeshByName() to do a lookup.
  59970. * @param generator The mesh to generate a trail.
  59971. * @param scene The scene to add this mesh to.
  59972. * @param diameter Diameter of trailing mesh. Default is 1.
  59973. * @param length Length of trailing mesh. Default is 60.
  59974. * @param autoStart Automatically start trailing mesh. Default true.
  59975. */
  59976. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  59977. /**
  59978. * "TrailMesh"
  59979. * @returns "TrailMesh"
  59980. */
  59981. getClassName(): string;
  59982. private _createMesh;
  59983. /**
  59984. * Start trailing mesh.
  59985. */
  59986. start(): void;
  59987. /**
  59988. * Stop trailing mesh.
  59989. */
  59990. stop(): void;
  59991. /**
  59992. * Update trailing mesh geometry.
  59993. */
  59994. update(): void;
  59995. /**
  59996. * Returns a new TrailMesh object.
  59997. * @param name is a string, the name given to the new mesh
  59998. * @param newGenerator use new generator object for cloned trail mesh
  59999. * @returns a new mesh
  60000. */
  60001. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  60002. /**
  60003. * Serializes this trail mesh
  60004. * @param serializationObject object to write serialization to
  60005. */
  60006. serialize(serializationObject: any): void;
  60007. /**
  60008. * Parses a serialized trail mesh
  60009. * @param parsedMesh the serialized mesh
  60010. * @param scene the scene to create the trail mesh in
  60011. * @returns the created trail mesh
  60012. */
  60013. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  60014. }
  60015. }
  60016. declare module "babylonjs/Meshes/Builders/tiledBoxBuilder" {
  60017. import { Nullable } from "babylonjs/types";
  60018. import { Scene } from "babylonjs/scene";
  60019. import { Vector4 } from "babylonjs/Maths/math.vector";
  60020. import { Color4 } from "babylonjs/Maths/math.color";
  60021. import { Mesh } from "babylonjs/Meshes/mesh";
  60022. /**
  60023. * Class containing static functions to help procedurally build meshes
  60024. */
  60025. export class TiledBoxBuilder {
  60026. /**
  60027. * Creates a box mesh
  60028. * 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)
  60029. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  60030. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60031. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60032. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60033. * @param name defines the name of the mesh
  60034. * @param options defines the options used to create the mesh
  60035. * @param scene defines the hosting scene
  60036. * @returns the box mesh
  60037. */
  60038. static CreateTiledBox(name: string, options: {
  60039. pattern?: number;
  60040. width?: number;
  60041. height?: number;
  60042. depth?: number;
  60043. tileSize?: number;
  60044. tileWidth?: number;
  60045. tileHeight?: number;
  60046. alignHorizontal?: number;
  60047. alignVertical?: number;
  60048. faceUV?: Vector4[];
  60049. faceColors?: Color4[];
  60050. sideOrientation?: number;
  60051. updatable?: boolean;
  60052. }, scene?: Nullable<Scene>): Mesh;
  60053. }
  60054. }
  60055. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  60056. import { Vector4 } from "babylonjs/Maths/math.vector";
  60057. import { Mesh } from "babylonjs/Meshes/mesh";
  60058. /**
  60059. * Class containing static functions to help procedurally build meshes
  60060. */
  60061. export class TorusKnotBuilder {
  60062. /**
  60063. * Creates a torus knot mesh
  60064. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  60065. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  60066. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  60067. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  60068. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60069. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60070. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  60071. * @param name defines the name of the mesh
  60072. * @param options defines the options used to create the mesh
  60073. * @param scene defines the hosting scene
  60074. * @returns the torus knot mesh
  60075. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  60076. */
  60077. static CreateTorusKnot(name: string, options: {
  60078. radius?: number;
  60079. tube?: number;
  60080. radialSegments?: number;
  60081. tubularSegments?: number;
  60082. p?: number;
  60083. q?: number;
  60084. updatable?: boolean;
  60085. sideOrientation?: number;
  60086. frontUVs?: Vector4;
  60087. backUVs?: Vector4;
  60088. }, scene: any): Mesh;
  60089. }
  60090. }
  60091. declare module "babylonjs/Meshes/polygonMesh" {
  60092. import { Scene } from "babylonjs/scene";
  60093. import { Vector2 } from "babylonjs/Maths/math.vector";
  60094. import { Mesh } from "babylonjs/Meshes/mesh";
  60095. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  60096. import { Path2 } from "babylonjs/Maths/math.path";
  60097. /**
  60098. * Polygon
  60099. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  60100. */
  60101. export class Polygon {
  60102. /**
  60103. * Creates a rectangle
  60104. * @param xmin bottom X coord
  60105. * @param ymin bottom Y coord
  60106. * @param xmax top X coord
  60107. * @param ymax top Y coord
  60108. * @returns points that make the resulting rectation
  60109. */
  60110. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  60111. /**
  60112. * Creates a circle
  60113. * @param radius radius of circle
  60114. * @param cx scale in x
  60115. * @param cy scale in y
  60116. * @param numberOfSides number of sides that make up the circle
  60117. * @returns points that make the resulting circle
  60118. */
  60119. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  60120. /**
  60121. * Creates a polygon from input string
  60122. * @param input Input polygon data
  60123. * @returns the parsed points
  60124. */
  60125. static Parse(input: string): Vector2[];
  60126. /**
  60127. * Starts building a polygon from x and y coordinates
  60128. * @param x x coordinate
  60129. * @param y y coordinate
  60130. * @returns the started path2
  60131. */
  60132. static StartingAt(x: number, y: number): Path2;
  60133. }
  60134. /**
  60135. * Builds a polygon
  60136. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  60137. */
  60138. export class PolygonMeshBuilder {
  60139. private _points;
  60140. private _outlinepoints;
  60141. private _holes;
  60142. private _name;
  60143. private _scene;
  60144. private _epoints;
  60145. private _eholes;
  60146. private _addToepoint;
  60147. /**
  60148. * Babylon reference to the earcut plugin.
  60149. */
  60150. bjsEarcut: any;
  60151. /**
  60152. * Creates a PolygonMeshBuilder
  60153. * @param name name of the builder
  60154. * @param contours Path of the polygon
  60155. * @param scene scene to add to when creating the mesh
  60156. * @param earcutInjection can be used to inject your own earcut reference
  60157. */
  60158. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  60159. /**
  60160. * Adds a whole within the polygon
  60161. * @param hole Array of points defining the hole
  60162. * @returns this
  60163. */
  60164. addHole(hole: Vector2[]): PolygonMeshBuilder;
  60165. /**
  60166. * Creates the polygon
  60167. * @param updatable If the mesh should be updatable
  60168. * @param depth The depth of the mesh created
  60169. * @returns the created mesh
  60170. */
  60171. build(updatable?: boolean, depth?: number): Mesh;
  60172. /**
  60173. * Creates the polygon
  60174. * @param depth The depth of the mesh created
  60175. * @returns the created VertexData
  60176. */
  60177. buildVertexData(depth?: number): VertexData;
  60178. /**
  60179. * Adds a side to the polygon
  60180. * @param positions points that make the polygon
  60181. * @param normals normals of the polygon
  60182. * @param uvs uvs of the polygon
  60183. * @param indices indices of the polygon
  60184. * @param bounds bounds of the polygon
  60185. * @param points points of the polygon
  60186. * @param depth depth of the polygon
  60187. * @param flip flip of the polygon
  60188. */
  60189. private addSide;
  60190. }
  60191. }
  60192. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  60193. import { Scene } from "babylonjs/scene";
  60194. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  60195. import { Color4 } from "babylonjs/Maths/math.color";
  60196. import { Mesh } from "babylonjs/Meshes/mesh";
  60197. import { Nullable } from "babylonjs/types";
  60198. /**
  60199. * Class containing static functions to help procedurally build meshes
  60200. */
  60201. export class PolygonBuilder {
  60202. /**
  60203. * Creates a polygon mesh
  60204. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  60205. * * 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
  60206. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  60207. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60208. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  60209. * * Remember you can only change the shape positions, not their number when updating a polygon
  60210. * @param name defines the name of the mesh
  60211. * @param options defines the options used to create the mesh
  60212. * @param scene defines the hosting scene
  60213. * @param earcutInjection can be used to inject your own earcut reference
  60214. * @returns the polygon mesh
  60215. */
  60216. static CreatePolygon(name: string, options: {
  60217. shape: Vector3[];
  60218. holes?: Vector3[][];
  60219. depth?: number;
  60220. faceUV?: Vector4[];
  60221. faceColors?: Color4[];
  60222. updatable?: boolean;
  60223. sideOrientation?: number;
  60224. frontUVs?: Vector4;
  60225. backUVs?: Vector4;
  60226. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  60227. /**
  60228. * Creates an extruded polygon mesh, with depth in the Y direction.
  60229. * * 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)
  60230. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  60231. * @param name defines the name of the mesh
  60232. * @param options defines the options used to create the mesh
  60233. * @param scene defines the hosting scene
  60234. * @param earcutInjection can be used to inject your own earcut reference
  60235. * @returns the polygon mesh
  60236. */
  60237. static ExtrudePolygon(name: string, options: {
  60238. shape: Vector3[];
  60239. holes?: Vector3[][];
  60240. depth?: number;
  60241. faceUV?: Vector4[];
  60242. faceColors?: Color4[];
  60243. updatable?: boolean;
  60244. sideOrientation?: number;
  60245. frontUVs?: Vector4;
  60246. backUVs?: Vector4;
  60247. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  60248. }
  60249. }
  60250. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  60251. import { Scene } from "babylonjs/scene";
  60252. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  60253. import { Mesh } from "babylonjs/Meshes/mesh";
  60254. import { Nullable } from "babylonjs/types";
  60255. /**
  60256. * Class containing static functions to help procedurally build meshes
  60257. */
  60258. export class LatheBuilder {
  60259. /**
  60260. * Creates lathe mesh.
  60261. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  60262. * * 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
  60263. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  60264. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  60265. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  60266. * * 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
  60267. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  60268. * * 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
  60269. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60270. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60271. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  60272. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60273. * @param name defines the name of the mesh
  60274. * @param options defines the options used to create the mesh
  60275. * @param scene defines the hosting scene
  60276. * @returns the lathe mesh
  60277. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  60278. */
  60279. static CreateLathe(name: string, options: {
  60280. shape: Vector3[];
  60281. radius?: number;
  60282. tessellation?: number;
  60283. clip?: number;
  60284. arc?: number;
  60285. closed?: boolean;
  60286. updatable?: boolean;
  60287. sideOrientation?: number;
  60288. frontUVs?: Vector4;
  60289. backUVs?: Vector4;
  60290. cap?: number;
  60291. invertUV?: boolean;
  60292. }, scene?: Nullable<Scene>): Mesh;
  60293. }
  60294. }
  60295. declare module "babylonjs/Meshes/Builders/tiledPlaneBuilder" {
  60296. import { Nullable } from "babylonjs/types";
  60297. import { Scene } from "babylonjs/scene";
  60298. import { Vector4 } from "babylonjs/Maths/math.vector";
  60299. import { Mesh } from "babylonjs/Meshes/mesh";
  60300. /**
  60301. * Class containing static functions to help procedurally build meshes
  60302. */
  60303. export class TiledPlaneBuilder {
  60304. /**
  60305. * Creates a tiled plane mesh
  60306. * * The parameter `pattern` will, depending on value, do nothing or
  60307. * * * flip (reflect about central vertical) alternate tiles across and up
  60308. * * * flip every tile on alternate rows
  60309. * * * rotate (180 degs) alternate tiles across and up
  60310. * * * rotate every tile on alternate rows
  60311. * * * flip and rotate alternate tiles across and up
  60312. * * * flip and rotate every tile on alternate rows
  60313. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  60314. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  60315. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60316. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  60317. * * 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)
  60318. * * 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)
  60319. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  60320. * @param name defines the name of the mesh
  60321. * @param options defines the options used to create the mesh
  60322. * @param scene defines the hosting scene
  60323. * @returns the box mesh
  60324. */
  60325. static CreateTiledPlane(name: string, options: {
  60326. pattern?: number;
  60327. tileSize?: number;
  60328. tileWidth?: number;
  60329. tileHeight?: number;
  60330. size?: number;
  60331. width?: number;
  60332. height?: number;
  60333. alignHorizontal?: number;
  60334. alignVertical?: number;
  60335. sideOrientation?: number;
  60336. frontUVs?: Vector4;
  60337. backUVs?: Vector4;
  60338. updatable?: boolean;
  60339. }, scene?: Nullable<Scene>): Mesh;
  60340. }
  60341. }
  60342. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  60343. import { Nullable } from "babylonjs/types";
  60344. import { Scene } from "babylonjs/scene";
  60345. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  60346. import { Mesh } from "babylonjs/Meshes/mesh";
  60347. /**
  60348. * Class containing static functions to help procedurally build meshes
  60349. */
  60350. export class TubeBuilder {
  60351. /**
  60352. * Creates a tube mesh.
  60353. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  60354. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  60355. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  60356. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  60357. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  60358. * * 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)
  60359. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  60360. * * 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
  60361. * * 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
  60362. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60363. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60364. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  60365. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60366. * @param name defines the name of the mesh
  60367. * @param options defines the options used to create the mesh
  60368. * @param scene defines the hosting scene
  60369. * @returns the tube mesh
  60370. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  60371. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  60372. */
  60373. static CreateTube(name: string, options: {
  60374. path: Vector3[];
  60375. radius?: number;
  60376. tessellation?: number;
  60377. radiusFunction?: {
  60378. (i: number, distance: number): number;
  60379. };
  60380. cap?: number;
  60381. arc?: number;
  60382. updatable?: boolean;
  60383. sideOrientation?: number;
  60384. frontUVs?: Vector4;
  60385. backUVs?: Vector4;
  60386. instance?: Mesh;
  60387. invertUV?: boolean;
  60388. }, scene?: Nullable<Scene>): Mesh;
  60389. }
  60390. }
  60391. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  60392. import { Scene } from "babylonjs/scene";
  60393. import { Vector4 } from "babylonjs/Maths/math.vector";
  60394. import { Mesh } from "babylonjs/Meshes/mesh";
  60395. import { Nullable } from "babylonjs/types";
  60396. /**
  60397. * Class containing static functions to help procedurally build meshes
  60398. */
  60399. export class IcoSphereBuilder {
  60400. /**
  60401. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  60402. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  60403. * * 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`)
  60404. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  60405. * * 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
  60406. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60407. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60408. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60409. * @param name defines the name of the mesh
  60410. * @param options defines the options used to create the mesh
  60411. * @param scene defines the hosting scene
  60412. * @returns the icosahedron mesh
  60413. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  60414. */
  60415. static CreateIcoSphere(name: string, options: {
  60416. radius?: number;
  60417. radiusX?: number;
  60418. radiusY?: number;
  60419. radiusZ?: number;
  60420. flat?: boolean;
  60421. subdivisions?: number;
  60422. sideOrientation?: number;
  60423. frontUVs?: Vector4;
  60424. backUVs?: Vector4;
  60425. updatable?: boolean;
  60426. }, scene?: Nullable<Scene>): Mesh;
  60427. }
  60428. }
  60429. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  60430. import { Vector3 } from "babylonjs/Maths/math.vector";
  60431. import { Mesh } from "babylonjs/Meshes/mesh";
  60432. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60433. /**
  60434. * Class containing static functions to help procedurally build meshes
  60435. */
  60436. export class DecalBuilder {
  60437. /**
  60438. * Creates a decal mesh.
  60439. * 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
  60440. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  60441. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  60442. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  60443. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  60444. * @param name defines the name of the mesh
  60445. * @param sourceMesh defines the mesh where the decal must be applied
  60446. * @param options defines the options used to create the mesh
  60447. * @param scene defines the hosting scene
  60448. * @returns the decal mesh
  60449. * @see https://doc.babylonjs.com/how_to/decals
  60450. */
  60451. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  60452. position?: Vector3;
  60453. normal?: Vector3;
  60454. size?: Vector3;
  60455. angle?: number;
  60456. }): Mesh;
  60457. }
  60458. }
  60459. declare module "babylonjs/Meshes/meshBuilder" {
  60460. import { Vector4, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  60461. import { Nullable } from "babylonjs/types";
  60462. import { Scene } from "babylonjs/scene";
  60463. import { Mesh } from "babylonjs/Meshes/mesh";
  60464. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  60465. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  60466. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60467. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  60468. import { Plane } from "babylonjs/Maths/math.plane";
  60469. /**
  60470. * Class containing static functions to help procedurally build meshes
  60471. */
  60472. export class MeshBuilder {
  60473. /**
  60474. * Creates a box mesh
  60475. * * The parameter `size` sets the size (float) of each box side (default 1)
  60476. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  60477. * * 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)
  60478. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  60479. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60480. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60481. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60482. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  60483. * @param name defines the name of the mesh
  60484. * @param options defines the options used to create the mesh
  60485. * @param scene defines the hosting scene
  60486. * @returns the box mesh
  60487. */
  60488. static CreateBox(name: string, options: {
  60489. size?: number;
  60490. width?: number;
  60491. height?: number;
  60492. depth?: number;
  60493. faceUV?: Vector4[];
  60494. faceColors?: Color4[];
  60495. sideOrientation?: number;
  60496. frontUVs?: Vector4;
  60497. backUVs?: Vector4;
  60498. updatable?: boolean;
  60499. }, scene?: Nullable<Scene>): Mesh;
  60500. /**
  60501. * Creates a tiled box mesh
  60502. * * faceTiles sets the pattern, tile size and number of tiles for a face
  60503. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60504. * @param name defines the name of the mesh
  60505. * @param options defines the options used to create the mesh
  60506. * @param scene defines the hosting scene
  60507. * @returns the tiled box mesh
  60508. */
  60509. static CreateTiledBox(name: string, options: {
  60510. pattern?: number;
  60511. size?: number;
  60512. width?: number;
  60513. height?: number;
  60514. depth: number;
  60515. tileSize?: number;
  60516. tileWidth?: number;
  60517. tileHeight?: number;
  60518. faceUV?: Vector4[];
  60519. faceColors?: Color4[];
  60520. alignHorizontal?: number;
  60521. alignVertical?: number;
  60522. sideOrientation?: number;
  60523. updatable?: boolean;
  60524. }, scene?: Nullable<Scene>): Mesh;
  60525. /**
  60526. * Creates a sphere mesh
  60527. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  60528. * * 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`)
  60529. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  60530. * * 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
  60531. * * 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)
  60532. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60533. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60534. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60535. * @param name defines the name of the mesh
  60536. * @param options defines the options used to create the mesh
  60537. * @param scene defines the hosting scene
  60538. * @returns the sphere mesh
  60539. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  60540. */
  60541. static CreateSphere(name: string, options: {
  60542. segments?: number;
  60543. diameter?: number;
  60544. diameterX?: number;
  60545. diameterY?: number;
  60546. diameterZ?: number;
  60547. arc?: number;
  60548. slice?: number;
  60549. sideOrientation?: number;
  60550. frontUVs?: Vector4;
  60551. backUVs?: Vector4;
  60552. updatable?: boolean;
  60553. }, scene?: Nullable<Scene>): Mesh;
  60554. /**
  60555. * Creates a plane polygonal mesh. By default, this is a disc
  60556. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  60557. * * 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
  60558. * * 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
  60559. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60560. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60561. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60562. * @param name defines the name of the mesh
  60563. * @param options defines the options used to create the mesh
  60564. * @param scene defines the hosting scene
  60565. * @returns the plane polygonal mesh
  60566. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  60567. */
  60568. static CreateDisc(name: string, options: {
  60569. radius?: number;
  60570. tessellation?: number;
  60571. arc?: number;
  60572. updatable?: boolean;
  60573. sideOrientation?: number;
  60574. frontUVs?: Vector4;
  60575. backUVs?: Vector4;
  60576. }, scene?: Nullable<Scene>): Mesh;
  60577. /**
  60578. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  60579. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  60580. * * 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`)
  60581. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  60582. * * 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
  60583. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60584. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60585. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60586. * @param name defines the name of the mesh
  60587. * @param options defines the options used to create the mesh
  60588. * @param scene defines the hosting scene
  60589. * @returns the icosahedron mesh
  60590. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  60591. */
  60592. static CreateIcoSphere(name: string, options: {
  60593. radius?: number;
  60594. radiusX?: number;
  60595. radiusY?: number;
  60596. radiusZ?: number;
  60597. flat?: boolean;
  60598. subdivisions?: number;
  60599. sideOrientation?: number;
  60600. frontUVs?: Vector4;
  60601. backUVs?: Vector4;
  60602. updatable?: boolean;
  60603. }, scene?: Nullable<Scene>): Mesh;
  60604. /**
  60605. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  60606. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  60607. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  60608. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  60609. * * 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
  60610. * * 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
  60611. * * 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
  60612. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60613. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60614. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  60615. * * 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
  60616. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  60617. * * 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
  60618. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  60619. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60620. * @param name defines the name of the mesh
  60621. * @param options defines the options used to create the mesh
  60622. * @param scene defines the hosting scene
  60623. * @returns the ribbon mesh
  60624. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  60625. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  60626. */
  60627. static CreateRibbon(name: string, options: {
  60628. pathArray: Vector3[][];
  60629. closeArray?: boolean;
  60630. closePath?: boolean;
  60631. offset?: number;
  60632. updatable?: boolean;
  60633. sideOrientation?: number;
  60634. frontUVs?: Vector4;
  60635. backUVs?: Vector4;
  60636. instance?: Mesh;
  60637. invertUV?: boolean;
  60638. uvs?: Vector2[];
  60639. colors?: Color4[];
  60640. }, scene?: Nullable<Scene>): Mesh;
  60641. /**
  60642. * Creates a cylinder or a cone mesh
  60643. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  60644. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  60645. * * 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.
  60646. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  60647. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  60648. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  60649. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  60650. * * 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).
  60651. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  60652. * * 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).
  60653. * * 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
  60654. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  60655. * * 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
  60656. * * 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.
  60657. * * If `enclose` is false, a ring surface is one element.
  60658. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  60659. * * 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
  60660. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60661. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60662. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  60663. * @param name defines the name of the mesh
  60664. * @param options defines the options used to create the mesh
  60665. * @param scene defines the hosting scene
  60666. * @returns the cylinder mesh
  60667. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  60668. */
  60669. static CreateCylinder(name: string, options: {
  60670. height?: number;
  60671. diameterTop?: number;
  60672. diameterBottom?: number;
  60673. diameter?: number;
  60674. tessellation?: number;
  60675. subdivisions?: number;
  60676. arc?: number;
  60677. faceColors?: Color4[];
  60678. faceUV?: Vector4[];
  60679. updatable?: boolean;
  60680. hasRings?: boolean;
  60681. enclose?: boolean;
  60682. cap?: number;
  60683. sideOrientation?: number;
  60684. frontUVs?: Vector4;
  60685. backUVs?: Vector4;
  60686. }, scene?: Nullable<Scene>): Mesh;
  60687. /**
  60688. * Creates a torus mesh
  60689. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  60690. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  60691. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  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 mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  60695. * @param name defines the name of the mesh
  60696. * @param options defines the options used to create the mesh
  60697. * @param scene defines the hosting scene
  60698. * @returns the torus mesh
  60699. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  60700. */
  60701. static CreateTorus(name: string, options: {
  60702. diameter?: number;
  60703. thickness?: number;
  60704. tessellation?: number;
  60705. updatable?: boolean;
  60706. sideOrientation?: number;
  60707. frontUVs?: Vector4;
  60708. backUVs?: Vector4;
  60709. }, scene?: Nullable<Scene>): Mesh;
  60710. /**
  60711. * Creates a torus knot mesh
  60712. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  60713. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  60714. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  60715. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  60716. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60717. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60718. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  60719. * @param name defines the name of the mesh
  60720. * @param options defines the options used to create the mesh
  60721. * @param scene defines the hosting scene
  60722. * @returns the torus knot mesh
  60723. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  60724. */
  60725. static CreateTorusKnot(name: string, options: {
  60726. radius?: number;
  60727. tube?: number;
  60728. radialSegments?: number;
  60729. tubularSegments?: number;
  60730. p?: number;
  60731. q?: number;
  60732. updatable?: boolean;
  60733. sideOrientation?: number;
  60734. frontUVs?: Vector4;
  60735. backUVs?: Vector4;
  60736. }, scene?: Nullable<Scene>): Mesh;
  60737. /**
  60738. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  60739. * * 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
  60740. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  60741. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  60742. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  60743. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  60744. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  60745. * * 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
  60746. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  60747. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60748. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  60749. * @param name defines the name of the new line system
  60750. * @param options defines the options used to create the line system
  60751. * @param scene defines the hosting scene
  60752. * @returns a new line system mesh
  60753. */
  60754. static CreateLineSystem(name: string, options: {
  60755. lines: Vector3[][];
  60756. updatable?: boolean;
  60757. instance?: Nullable<LinesMesh>;
  60758. colors?: Nullable<Color4[][]>;
  60759. useVertexAlpha?: boolean;
  60760. }, scene: Nullable<Scene>): LinesMesh;
  60761. /**
  60762. * Creates a line mesh
  60763. * 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
  60764. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  60765. * * The parameter `points` is an array successive Vector3
  60766. * * 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
  60767. * * The optional parameter `colors` is an array of successive Color4, one per line point
  60768. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  60769. * * When updating an instance, remember that only point positions can change, not the number of points
  60770. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60771. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  60772. * @param name defines the name of the new line system
  60773. * @param options defines the options used to create the line system
  60774. * @param scene defines the hosting scene
  60775. * @returns a new line mesh
  60776. */
  60777. static CreateLines(name: string, options: {
  60778. points: Vector3[];
  60779. updatable?: boolean;
  60780. instance?: Nullable<LinesMesh>;
  60781. colors?: Color4[];
  60782. useVertexAlpha?: boolean;
  60783. }, scene?: Nullable<Scene>): LinesMesh;
  60784. /**
  60785. * Creates a dashed line mesh
  60786. * * 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
  60787. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  60788. * * The parameter `points` is an array successive Vector3
  60789. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  60790. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  60791. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  60792. * * 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
  60793. * * When updating an instance, remember that only point positions can change, not the number of points
  60794. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60795. * @param name defines the name of the mesh
  60796. * @param options defines the options used to create the mesh
  60797. * @param scene defines the hosting scene
  60798. * @returns the dashed line mesh
  60799. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  60800. */
  60801. static CreateDashedLines(name: string, options: {
  60802. points: Vector3[];
  60803. dashSize?: number;
  60804. gapSize?: number;
  60805. dashNb?: number;
  60806. updatable?: boolean;
  60807. instance?: LinesMesh;
  60808. }, scene?: Nullable<Scene>): LinesMesh;
  60809. /**
  60810. * 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.
  60811. * * 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.
  60812. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  60813. * * 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.
  60814. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  60815. * * 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
  60816. * * 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
  60817. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  60818. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60819. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60820. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  60821. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  60822. * @param name defines the name of the mesh
  60823. * @param options defines the options used to create the mesh
  60824. * @param scene defines the hosting scene
  60825. * @returns the extruded shape mesh
  60826. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  60827. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  60828. */
  60829. static ExtrudeShape(name: string, options: {
  60830. shape: Vector3[];
  60831. path: Vector3[];
  60832. scale?: number;
  60833. rotation?: number;
  60834. cap?: number;
  60835. updatable?: boolean;
  60836. sideOrientation?: number;
  60837. frontUVs?: Vector4;
  60838. backUVs?: Vector4;
  60839. instance?: Mesh;
  60840. invertUV?: boolean;
  60841. }, scene?: Nullable<Scene>): Mesh;
  60842. /**
  60843. * Creates an custom extruded shape mesh.
  60844. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  60845. * * 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.
  60846. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  60847. * * 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
  60848. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  60849. * * 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
  60850. * * It must returns a float value that will be the scale value applied to the shape on each path point
  60851. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  60852. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  60853. * * 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
  60854. * * 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
  60855. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  60856. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60857. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60858. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  60859. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60860. * @param name defines the name of the mesh
  60861. * @param options defines the options used to create the mesh
  60862. * @param scene defines the hosting scene
  60863. * @returns the custom extruded shape mesh
  60864. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  60865. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  60866. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  60867. */
  60868. static ExtrudeShapeCustom(name: string, options: {
  60869. shape: Vector3[];
  60870. path: Vector3[];
  60871. scaleFunction?: any;
  60872. rotationFunction?: any;
  60873. ribbonCloseArray?: boolean;
  60874. ribbonClosePath?: boolean;
  60875. cap?: number;
  60876. updatable?: boolean;
  60877. sideOrientation?: number;
  60878. frontUVs?: Vector4;
  60879. backUVs?: Vector4;
  60880. instance?: Mesh;
  60881. invertUV?: boolean;
  60882. }, scene?: Nullable<Scene>): Mesh;
  60883. /**
  60884. * Creates lathe mesh.
  60885. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  60886. * * 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
  60887. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  60888. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  60889. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  60890. * * 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
  60891. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  60892. * * 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
  60893. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60894. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60895. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  60896. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60897. * @param name defines the name of the mesh
  60898. * @param options defines the options used to create the mesh
  60899. * @param scene defines the hosting scene
  60900. * @returns the lathe mesh
  60901. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  60902. */
  60903. static CreateLathe(name: string, options: {
  60904. shape: Vector3[];
  60905. radius?: number;
  60906. tessellation?: number;
  60907. clip?: number;
  60908. arc?: number;
  60909. closed?: boolean;
  60910. updatable?: boolean;
  60911. sideOrientation?: number;
  60912. frontUVs?: Vector4;
  60913. backUVs?: Vector4;
  60914. cap?: number;
  60915. invertUV?: boolean;
  60916. }, scene?: Nullable<Scene>): Mesh;
  60917. /**
  60918. * Creates a tiled plane mesh
  60919. * * You can set a limited pattern arrangement with the tiles
  60920. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60921. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60922. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60923. * @param name defines the name of the mesh
  60924. * @param options defines the options used to create the mesh
  60925. * @param scene defines the hosting scene
  60926. * @returns the plane mesh
  60927. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  60928. */
  60929. static CreateTiledPlane(name: string, options: {
  60930. pattern?: number;
  60931. tileSize?: number;
  60932. tileWidth?: number;
  60933. tileHeight?: number;
  60934. size?: number;
  60935. width?: number;
  60936. height?: number;
  60937. alignHorizontal?: number;
  60938. alignVertical?: number;
  60939. sideOrientation?: number;
  60940. frontUVs?: Vector4;
  60941. backUVs?: Vector4;
  60942. updatable?: boolean;
  60943. }, scene?: Nullable<Scene>): Mesh;
  60944. /**
  60945. * Creates a plane mesh
  60946. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  60947. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  60948. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  60949. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60950. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60951. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60952. * @param name defines the name of the mesh
  60953. * @param options defines the options used to create the mesh
  60954. * @param scene defines the hosting scene
  60955. * @returns the plane mesh
  60956. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  60957. */
  60958. static CreatePlane(name: string, options: {
  60959. size?: number;
  60960. width?: number;
  60961. height?: number;
  60962. sideOrientation?: number;
  60963. frontUVs?: Vector4;
  60964. backUVs?: Vector4;
  60965. updatable?: boolean;
  60966. sourcePlane?: Plane;
  60967. }, scene?: Nullable<Scene>): Mesh;
  60968. /**
  60969. * Creates a ground mesh
  60970. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  60971. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  60972. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60973. * @param name defines the name of the mesh
  60974. * @param options defines the options used to create the mesh
  60975. * @param scene defines the hosting scene
  60976. * @returns the ground mesh
  60977. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  60978. */
  60979. static CreateGround(name: string, options: {
  60980. width?: number;
  60981. height?: number;
  60982. subdivisions?: number;
  60983. subdivisionsX?: number;
  60984. subdivisionsY?: number;
  60985. updatable?: boolean;
  60986. }, scene?: Nullable<Scene>): Mesh;
  60987. /**
  60988. * Creates a tiled ground mesh
  60989. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  60990. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  60991. * * 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
  60992. * * 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
  60993. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  60994. * @param name defines the name of the mesh
  60995. * @param options defines the options used to create the mesh
  60996. * @param scene defines the hosting scene
  60997. * @returns the tiled ground mesh
  60998. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  60999. */
  61000. static CreateTiledGround(name: string, options: {
  61001. xmin: number;
  61002. zmin: number;
  61003. xmax: number;
  61004. zmax: number;
  61005. subdivisions?: {
  61006. w: number;
  61007. h: number;
  61008. };
  61009. precision?: {
  61010. w: number;
  61011. h: number;
  61012. };
  61013. updatable?: boolean;
  61014. }, scene?: Nullable<Scene>): Mesh;
  61015. /**
  61016. * Creates a ground mesh from a height map
  61017. * * The parameter `url` sets the URL of the height map image resource.
  61018. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  61019. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  61020. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  61021. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  61022. * * 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.
  61023. * * 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).
  61024. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  61025. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61026. * @param name defines the name of the mesh
  61027. * @param url defines the url to the height map
  61028. * @param options defines the options used to create the mesh
  61029. * @param scene defines the hosting scene
  61030. * @returns the ground mesh
  61031. * @see https://doc.babylonjs.com/babylon101/height_map
  61032. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  61033. */
  61034. static CreateGroundFromHeightMap(name: string, url: string, options: {
  61035. width?: number;
  61036. height?: number;
  61037. subdivisions?: number;
  61038. minHeight?: number;
  61039. maxHeight?: number;
  61040. colorFilter?: Color3;
  61041. alphaFilter?: number;
  61042. updatable?: boolean;
  61043. onReady?: (mesh: GroundMesh) => void;
  61044. }, scene?: Nullable<Scene>): GroundMesh;
  61045. /**
  61046. * Creates a polygon mesh
  61047. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  61048. * * 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
  61049. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  61050. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61051. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  61052. * * Remember you can only change the shape positions, not their number when updating a polygon
  61053. * @param name defines the name of the mesh
  61054. * @param options defines the options used to create the mesh
  61055. * @param scene defines the hosting scene
  61056. * @param earcutInjection can be used to inject your own earcut reference
  61057. * @returns the polygon mesh
  61058. */
  61059. static CreatePolygon(name: string, options: {
  61060. shape: Vector3[];
  61061. holes?: Vector3[][];
  61062. depth?: number;
  61063. faceUV?: Vector4[];
  61064. faceColors?: Color4[];
  61065. updatable?: boolean;
  61066. sideOrientation?: number;
  61067. frontUVs?: Vector4;
  61068. backUVs?: Vector4;
  61069. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  61070. /**
  61071. * Creates an extruded polygon mesh, with depth in the Y direction.
  61072. * * 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)
  61073. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  61074. * @param name defines the name of the mesh
  61075. * @param options defines the options used to create the mesh
  61076. * @param scene defines the hosting scene
  61077. * @param earcutInjection can be used to inject your own earcut reference
  61078. * @returns the polygon mesh
  61079. */
  61080. static ExtrudePolygon(name: string, options: {
  61081. shape: Vector3[];
  61082. holes?: Vector3[][];
  61083. depth?: number;
  61084. faceUV?: Vector4[];
  61085. faceColors?: Color4[];
  61086. updatable?: boolean;
  61087. sideOrientation?: number;
  61088. frontUVs?: Vector4;
  61089. backUVs?: Vector4;
  61090. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  61091. /**
  61092. * Creates a tube mesh.
  61093. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  61094. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  61095. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  61096. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  61097. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  61098. * * 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)
  61099. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  61100. * * 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
  61101. * * 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
  61102. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61103. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  61104. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  61105. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61106. * @param name defines the name of the mesh
  61107. * @param options defines the options used to create the mesh
  61108. * @param scene defines the hosting scene
  61109. * @returns the tube mesh
  61110. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  61111. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  61112. */
  61113. static CreateTube(name: string, options: {
  61114. path: Vector3[];
  61115. radius?: number;
  61116. tessellation?: number;
  61117. radiusFunction?: {
  61118. (i: number, distance: number): number;
  61119. };
  61120. cap?: number;
  61121. arc?: number;
  61122. updatable?: boolean;
  61123. sideOrientation?: number;
  61124. frontUVs?: Vector4;
  61125. backUVs?: Vector4;
  61126. instance?: Mesh;
  61127. invertUV?: boolean;
  61128. }, scene?: Nullable<Scene>): Mesh;
  61129. /**
  61130. * Creates a polyhedron mesh
  61131. * * 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
  61132. * * The parameter `size` (positive float, default 1) sets the polygon size
  61133. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  61134. * * 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`
  61135. * * 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
  61136. * * 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)`)
  61137. * * 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
  61138. * * 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
  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 polyhedron mesh
  61146. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  61147. */
  61148. static CreatePolyhedron(name: string, options: {
  61149. type?: number;
  61150. size?: number;
  61151. sizeX?: number;
  61152. sizeY?: number;
  61153. sizeZ?: number;
  61154. custom?: any;
  61155. faceUV?: Vector4[];
  61156. faceColors?: Color4[];
  61157. flat?: boolean;
  61158. updatable?: boolean;
  61159. sideOrientation?: number;
  61160. frontUVs?: Vector4;
  61161. backUVs?: Vector4;
  61162. }, scene?: Nullable<Scene>): Mesh;
  61163. /**
  61164. * Creates a decal mesh.
  61165. * 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
  61166. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  61167. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  61168. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  61169. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  61170. * @param name defines the name of the mesh
  61171. * @param sourceMesh defines the mesh where the decal must be applied
  61172. * @param options defines the options used to create the mesh
  61173. * @param scene defines the hosting scene
  61174. * @returns the decal mesh
  61175. * @see https://doc.babylonjs.com/how_to/decals
  61176. */
  61177. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  61178. position?: Vector3;
  61179. normal?: Vector3;
  61180. size?: Vector3;
  61181. angle?: number;
  61182. }): Mesh;
  61183. }
  61184. }
  61185. declare module "babylonjs/Meshes/meshSimplification" {
  61186. import { Mesh } from "babylonjs/Meshes/mesh";
  61187. /**
  61188. * A simplifier interface for future simplification implementations
  61189. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  61190. */
  61191. export interface ISimplifier {
  61192. /**
  61193. * Simplification of a given mesh according to the given settings.
  61194. * Since this requires computation, it is assumed that the function runs async.
  61195. * @param settings The settings of the simplification, including quality and distance
  61196. * @param successCallback A callback that will be called after the mesh was simplified.
  61197. * @param errorCallback in case of an error, this callback will be called. optional.
  61198. */
  61199. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  61200. }
  61201. /**
  61202. * Expected simplification settings.
  61203. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  61204. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  61205. */
  61206. export interface ISimplificationSettings {
  61207. /**
  61208. * Gets or sets the expected quality
  61209. */
  61210. quality: number;
  61211. /**
  61212. * Gets or sets the distance when this optimized version should be used
  61213. */
  61214. distance: number;
  61215. /**
  61216. * Gets an already optimized mesh
  61217. */
  61218. optimizeMesh?: boolean;
  61219. }
  61220. /**
  61221. * Class used to specify simplification options
  61222. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  61223. */
  61224. export class SimplificationSettings implements ISimplificationSettings {
  61225. /** expected quality */
  61226. quality: number;
  61227. /** distance when this optimized version should be used */
  61228. distance: number;
  61229. /** already optimized mesh */
  61230. optimizeMesh?: boolean | undefined;
  61231. /**
  61232. * Creates a SimplificationSettings
  61233. * @param quality expected quality
  61234. * @param distance distance when this optimized version should be used
  61235. * @param optimizeMesh already optimized mesh
  61236. */
  61237. constructor(
  61238. /** expected quality */
  61239. quality: number,
  61240. /** distance when this optimized version should be used */
  61241. distance: number,
  61242. /** already optimized mesh */
  61243. optimizeMesh?: boolean | undefined);
  61244. }
  61245. /**
  61246. * Interface used to define a simplification task
  61247. */
  61248. export interface ISimplificationTask {
  61249. /**
  61250. * Array of settings
  61251. */
  61252. settings: Array<ISimplificationSettings>;
  61253. /**
  61254. * Simplification type
  61255. */
  61256. simplificationType: SimplificationType;
  61257. /**
  61258. * Mesh to simplify
  61259. */
  61260. mesh: Mesh;
  61261. /**
  61262. * Callback called on success
  61263. */
  61264. successCallback?: () => void;
  61265. /**
  61266. * Defines if parallel processing can be used
  61267. */
  61268. parallelProcessing: boolean;
  61269. }
  61270. /**
  61271. * Queue used to order the simplification tasks
  61272. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  61273. */
  61274. export class SimplificationQueue {
  61275. private _simplificationArray;
  61276. /**
  61277. * Gets a boolean indicating that the process is still running
  61278. */
  61279. running: boolean;
  61280. /**
  61281. * Creates a new queue
  61282. */
  61283. constructor();
  61284. /**
  61285. * Adds a new simplification task
  61286. * @param task defines a task to add
  61287. */
  61288. addTask(task: ISimplificationTask): void;
  61289. /**
  61290. * Execute next task
  61291. */
  61292. executeNext(): void;
  61293. /**
  61294. * Execute a simplification task
  61295. * @param task defines the task to run
  61296. */
  61297. runSimplification(task: ISimplificationTask): void;
  61298. private getSimplifier;
  61299. }
  61300. /**
  61301. * The implemented types of simplification
  61302. * At the moment only Quadratic Error Decimation is implemented
  61303. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  61304. */
  61305. export enum SimplificationType {
  61306. /** Quadratic error decimation */
  61307. QUADRATIC = 0
  61308. }
  61309. }
  61310. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  61311. import { Scene } from "babylonjs/scene";
  61312. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  61313. import { ISceneComponent } from "babylonjs/sceneComponent";
  61314. module "babylonjs/scene" {
  61315. interface Scene {
  61316. /** @hidden (Backing field) */
  61317. _simplificationQueue: SimplificationQueue;
  61318. /**
  61319. * Gets or sets the simplification queue attached to the scene
  61320. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  61321. */
  61322. simplificationQueue: SimplificationQueue;
  61323. }
  61324. }
  61325. module "babylonjs/Meshes/mesh" {
  61326. interface Mesh {
  61327. /**
  61328. * Simplify the mesh according to the given array of settings.
  61329. * Function will return immediately and will simplify async
  61330. * @param settings a collection of simplification settings
  61331. * @param parallelProcessing should all levels calculate parallel or one after the other
  61332. * @param simplificationType the type of simplification to run
  61333. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  61334. * @returns the current mesh
  61335. */
  61336. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  61337. }
  61338. }
  61339. /**
  61340. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  61341. * created in a scene
  61342. */
  61343. export class SimplicationQueueSceneComponent implements ISceneComponent {
  61344. /**
  61345. * The component name helpfull to identify the component in the list of scene components.
  61346. */
  61347. readonly name: string;
  61348. /**
  61349. * The scene the component belongs to.
  61350. */
  61351. scene: Scene;
  61352. /**
  61353. * Creates a new instance of the component for the given scene
  61354. * @param scene Defines the scene to register the component in
  61355. */
  61356. constructor(scene: Scene);
  61357. /**
  61358. * Registers the component in a given scene
  61359. */
  61360. register(): void;
  61361. /**
  61362. * Rebuilds the elements related to this component in case of
  61363. * context lost for instance.
  61364. */
  61365. rebuild(): void;
  61366. /**
  61367. * Disposes the component and the associated ressources
  61368. */
  61369. dispose(): void;
  61370. private _beforeCameraUpdate;
  61371. }
  61372. }
  61373. declare module "babylonjs/Meshes/Builders/index" {
  61374. export * from "babylonjs/Meshes/Builders/boxBuilder";
  61375. export * from "babylonjs/Meshes/Builders/tiledBoxBuilder";
  61376. export * from "babylonjs/Meshes/Builders/discBuilder";
  61377. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  61378. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  61379. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  61380. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  61381. export * from "babylonjs/Meshes/Builders/torusBuilder";
  61382. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  61383. export * from "babylonjs/Meshes/Builders/linesBuilder";
  61384. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  61385. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  61386. export * from "babylonjs/Meshes/Builders/latheBuilder";
  61387. export * from "babylonjs/Meshes/Builders/planeBuilder";
  61388. export * from "babylonjs/Meshes/Builders/tiledPlaneBuilder";
  61389. export * from "babylonjs/Meshes/Builders/groundBuilder";
  61390. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  61391. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  61392. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  61393. export * from "babylonjs/Meshes/Builders/decalBuilder";
  61394. }
  61395. declare module "babylonjs/Meshes/index" {
  61396. export * from "babylonjs/Meshes/abstractMesh";
  61397. export * from "babylonjs/Meshes/buffer";
  61398. export * from "babylonjs/Meshes/Compression/index";
  61399. export * from "babylonjs/Meshes/csg";
  61400. export * from "babylonjs/Meshes/geometry";
  61401. export * from "babylonjs/Meshes/groundMesh";
  61402. export * from "babylonjs/Meshes/trailMesh";
  61403. export * from "babylonjs/Meshes/instancedMesh";
  61404. export * from "babylonjs/Meshes/linesMesh";
  61405. export * from "babylonjs/Meshes/mesh";
  61406. export * from "babylonjs/Meshes/mesh.vertexData";
  61407. export * from "babylonjs/Meshes/meshBuilder";
  61408. export * from "babylonjs/Meshes/meshSimplification";
  61409. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  61410. export * from "babylonjs/Meshes/polygonMesh";
  61411. export * from "babylonjs/Meshes/subMesh";
  61412. export * from "babylonjs/Meshes/meshLODLevel";
  61413. export * from "babylonjs/Meshes/transformNode";
  61414. export * from "babylonjs/Meshes/Builders/index";
  61415. export * from "babylonjs/Meshes/dataBuffer";
  61416. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  61417. }
  61418. declare module "babylonjs/Morph/index" {
  61419. export * from "babylonjs/Morph/morphTarget";
  61420. export * from "babylonjs/Morph/morphTargetManager";
  61421. }
  61422. declare module "babylonjs/Navigation/INavigationEngine" {
  61423. import { TransformNode } from "babylonjs/Meshes/transformNode";
  61424. import { Vector3 } from "babylonjs/Maths/math";
  61425. import { Mesh } from "babylonjs/Meshes/mesh";
  61426. import { Scene } from "babylonjs/scene";
  61427. /**
  61428. * Navigation plugin interface to add navigation constrained by a navigation mesh
  61429. */
  61430. export interface INavigationEnginePlugin {
  61431. /**
  61432. * plugin name
  61433. */
  61434. name: string;
  61435. /**
  61436. * Creates a navigation mesh
  61437. * @param meshes array of all the geometry used to compute the navigatio mesh
  61438. * @param parameters bunch of parameters used to filter geometry
  61439. */
  61440. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  61441. /**
  61442. * Create a navigation mesh debug mesh
  61443. * @param scene is where the mesh will be added
  61444. * @returns debug display mesh
  61445. */
  61446. createDebugNavMesh(scene: Scene): Mesh;
  61447. /**
  61448. * Get a navigation mesh constrained position, closest to the parameter position
  61449. * @param position world position
  61450. * @returns the closest point to position constrained by the navigation mesh
  61451. */
  61452. getClosestPoint(position: Vector3): Vector3;
  61453. /**
  61454. * Get a navigation mesh constrained position, within a particular radius
  61455. * @param position world position
  61456. * @param maxRadius the maximum distance to the constrained world position
  61457. * @returns the closest point to position constrained by the navigation mesh
  61458. */
  61459. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  61460. /**
  61461. * Compute the final position from a segment made of destination-position
  61462. * @param position world position
  61463. * @param destination world position
  61464. * @returns the resulting point along the navmesh
  61465. */
  61466. moveAlong(position: Vector3, destination: Vector3): Vector3;
  61467. /**
  61468. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  61469. * @param start world position
  61470. * @param end world position
  61471. * @returns array containing world position composing the path
  61472. */
  61473. computePath(start: Vector3, end: Vector3): Vector3[];
  61474. /**
  61475. * If this plugin is supported
  61476. * @returns true if plugin is supported
  61477. */
  61478. isSupported(): boolean;
  61479. /**
  61480. * Create a new Crowd so you can add agents
  61481. * @param maxAgents the maximum agent count in the crowd
  61482. * @param maxAgentRadius the maximum radius an agent can have
  61483. * @param scene to attach the crowd to
  61484. * @returns the crowd you can add agents to
  61485. */
  61486. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  61487. /**
  61488. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  61489. * The queries will try to find a solution within those bounds
  61490. * default is (1,1,1)
  61491. * @param extent x,y,z value that define the extent around the queries point of reference
  61492. */
  61493. setDefaultQueryExtent(extent: Vector3): void;
  61494. /**
  61495. * Get the Bounding box extent specified by setDefaultQueryExtent
  61496. * @returns the box extent values
  61497. */
  61498. getDefaultQueryExtent(): Vector3;
  61499. /**
  61500. * Release all resources
  61501. */
  61502. dispose(): void;
  61503. }
  61504. /**
  61505. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  61506. */
  61507. export interface ICrowd {
  61508. /**
  61509. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  61510. * You can attach anything to that node. The node position is updated in the scene update tick.
  61511. * @param pos world position that will be constrained by the navigation mesh
  61512. * @param parameters agent parameters
  61513. * @param transform hooked to the agent that will be update by the scene
  61514. * @returns agent index
  61515. */
  61516. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  61517. /**
  61518. * Returns the agent position in world space
  61519. * @param index agent index returned by addAgent
  61520. * @returns world space position
  61521. */
  61522. getAgentPosition(index: number): Vector3;
  61523. /**
  61524. * Gets the agent velocity in world space
  61525. * @param index agent index returned by addAgent
  61526. * @returns world space velocity
  61527. */
  61528. getAgentVelocity(index: number): Vector3;
  61529. /**
  61530. * remove a particular agent previously created
  61531. * @param index agent index returned by addAgent
  61532. */
  61533. removeAgent(index: number): void;
  61534. /**
  61535. * get the list of all agents attached to this crowd
  61536. * @returns list of agent indices
  61537. */
  61538. getAgents(): number[];
  61539. /**
  61540. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  61541. * @param deltaTime in seconds
  61542. */
  61543. update(deltaTime: number): void;
  61544. /**
  61545. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  61546. * @param index agent index returned by addAgent
  61547. * @param destination targeted world position
  61548. */
  61549. agentGoto(index: number, destination: Vector3): void;
  61550. /**
  61551. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  61552. * The queries will try to find a solution within those bounds
  61553. * default is (1,1,1)
  61554. * @param extent x,y,z value that define the extent around the queries point of reference
  61555. */
  61556. setDefaultQueryExtent(extent: Vector3): void;
  61557. /**
  61558. * Get the Bounding box extent specified by setDefaultQueryExtent
  61559. * @returns the box extent values
  61560. */
  61561. getDefaultQueryExtent(): Vector3;
  61562. /**
  61563. * Release all resources
  61564. */
  61565. dispose(): void;
  61566. }
  61567. /**
  61568. * Configures an agent
  61569. */
  61570. export interface IAgentParameters {
  61571. /**
  61572. * Agent radius. [Limit: >= 0]
  61573. */
  61574. radius: number;
  61575. /**
  61576. * Agent height. [Limit: > 0]
  61577. */
  61578. height: number;
  61579. /**
  61580. * Maximum allowed acceleration. [Limit: >= 0]
  61581. */
  61582. maxAcceleration: number;
  61583. /**
  61584. * Maximum allowed speed. [Limit: >= 0]
  61585. */
  61586. maxSpeed: number;
  61587. /**
  61588. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  61589. */
  61590. collisionQueryRange: number;
  61591. /**
  61592. * The path visibility optimization range. [Limit: > 0]
  61593. */
  61594. pathOptimizationRange: number;
  61595. /**
  61596. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  61597. */
  61598. separationWeight: number;
  61599. }
  61600. /**
  61601. * Configures the navigation mesh creation
  61602. */
  61603. export interface INavMeshParameters {
  61604. /**
  61605. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  61606. */
  61607. cs: number;
  61608. /**
  61609. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  61610. */
  61611. ch: number;
  61612. /**
  61613. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  61614. */
  61615. walkableSlopeAngle: number;
  61616. /**
  61617. * Minimum floor to 'ceiling' height that will still allow the floor area to
  61618. * be considered walkable. [Limit: >= 3] [Units: vx]
  61619. */
  61620. walkableHeight: number;
  61621. /**
  61622. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  61623. */
  61624. walkableClimb: number;
  61625. /**
  61626. * The distance to erode/shrink the walkable area of the heightfield away from
  61627. * obstructions. [Limit: >=0] [Units: vx]
  61628. */
  61629. walkableRadius: number;
  61630. /**
  61631. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  61632. */
  61633. maxEdgeLen: number;
  61634. /**
  61635. * The maximum distance a simplfied contour's border edges should deviate
  61636. * the original raw contour. [Limit: >=0] [Units: vx]
  61637. */
  61638. maxSimplificationError: number;
  61639. /**
  61640. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  61641. */
  61642. minRegionArea: number;
  61643. /**
  61644. * Any regions with a span count smaller than this value will, if possible,
  61645. * be merged with larger regions. [Limit: >=0] [Units: vx]
  61646. */
  61647. mergeRegionArea: number;
  61648. /**
  61649. * The maximum number of vertices allowed for polygons generated during the
  61650. * contour to polygon conversion process. [Limit: >= 3]
  61651. */
  61652. maxVertsPerPoly: number;
  61653. /**
  61654. * Sets the sampling distance to use when generating the detail mesh.
  61655. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  61656. */
  61657. detailSampleDist: number;
  61658. /**
  61659. * The maximum distance the detail mesh surface should deviate from heightfield
  61660. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  61661. */
  61662. detailSampleMaxError: number;
  61663. }
  61664. }
  61665. declare module "babylonjs/Navigation/Plugins/recastJSPlugin" {
  61666. import { INavigationEnginePlugin, ICrowd, IAgentParameters, INavMeshParameters } from "babylonjs/Navigation/INavigationEngine";
  61667. import { Mesh } from "babylonjs/Meshes/mesh";
  61668. import { Scene } from "babylonjs/scene";
  61669. import { Vector3 } from "babylonjs/Maths/math";
  61670. import { TransformNode } from "babylonjs/Meshes/transformNode";
  61671. /**
  61672. * RecastJS navigation plugin
  61673. */
  61674. export class RecastJSPlugin implements INavigationEnginePlugin {
  61675. /**
  61676. * Reference to the Recast library
  61677. */
  61678. bjsRECAST: any;
  61679. /**
  61680. * plugin name
  61681. */
  61682. name: string;
  61683. /**
  61684. * the first navmesh created. We might extend this to support multiple navmeshes
  61685. */
  61686. navMesh: any;
  61687. /**
  61688. * Initializes the recastJS plugin
  61689. * @param recastInjection can be used to inject your own recast reference
  61690. */
  61691. constructor(recastInjection?: any);
  61692. /**
  61693. * Creates a navigation mesh
  61694. * @param meshes array of all the geometry used to compute the navigatio mesh
  61695. * @param parameters bunch of parameters used to filter geometry
  61696. */
  61697. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  61698. /**
  61699. * Create a navigation mesh debug mesh
  61700. * @param scene is where the mesh will be added
  61701. * @returns debug display mesh
  61702. */
  61703. createDebugNavMesh(scene: Scene): Mesh;
  61704. /**
  61705. * Get a navigation mesh constrained position, closest to the parameter position
  61706. * @param position world position
  61707. * @returns the closest point to position constrained by the navigation mesh
  61708. */
  61709. getClosestPoint(position: Vector3): Vector3;
  61710. /**
  61711. * Get a navigation mesh constrained position, within a particular radius
  61712. * @param position world position
  61713. * @param maxRadius the maximum distance to the constrained world position
  61714. * @returns the closest point to position constrained by the navigation mesh
  61715. */
  61716. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  61717. /**
  61718. * Compute the final position from a segment made of destination-position
  61719. * @param position world position
  61720. * @param destination world position
  61721. * @returns the resulting point along the navmesh
  61722. */
  61723. moveAlong(position: Vector3, destination: Vector3): Vector3;
  61724. /**
  61725. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  61726. * @param start world position
  61727. * @param end world position
  61728. * @returns array containing world position composing the path
  61729. */
  61730. computePath(start: Vector3, end: Vector3): Vector3[];
  61731. /**
  61732. * Create a new Crowd so you can add agents
  61733. * @param maxAgents the maximum agent count in the crowd
  61734. * @param maxAgentRadius the maximum radius an agent can have
  61735. * @param scene to attach the crowd to
  61736. * @returns the crowd you can add agents to
  61737. */
  61738. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  61739. /**
  61740. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  61741. * The queries will try to find a solution within those bounds
  61742. * default is (1,1,1)
  61743. * @param extent x,y,z value that define the extent around the queries point of reference
  61744. */
  61745. setDefaultQueryExtent(extent: Vector3): void;
  61746. /**
  61747. * Get the Bounding box extent specified by setDefaultQueryExtent
  61748. * @returns the box extent values
  61749. */
  61750. getDefaultQueryExtent(): Vector3;
  61751. /**
  61752. * Disposes
  61753. */
  61754. dispose(): void;
  61755. /**
  61756. * If this plugin is supported
  61757. * @returns true if plugin is supported
  61758. */
  61759. isSupported(): boolean;
  61760. }
  61761. /**
  61762. * Recast detour crowd implementation
  61763. */
  61764. export class RecastJSCrowd implements ICrowd {
  61765. /**
  61766. * Recast/detour plugin
  61767. */
  61768. bjsRECASTPlugin: RecastJSPlugin;
  61769. /**
  61770. * Link to the detour crowd
  61771. */
  61772. recastCrowd: any;
  61773. /**
  61774. * One transform per agent
  61775. */
  61776. transforms: TransformNode[];
  61777. /**
  61778. * All agents created
  61779. */
  61780. agents: number[];
  61781. /**
  61782. * Link to the scene is kept to unregister the crowd from the scene
  61783. */
  61784. private _scene;
  61785. /**
  61786. * Observer for crowd updates
  61787. */
  61788. private _onBeforeAnimationsObserver;
  61789. /**
  61790. * Constructor
  61791. * @param plugin recastJS plugin
  61792. * @param maxAgents the maximum agent count in the crowd
  61793. * @param maxAgentRadius the maximum radius an agent can have
  61794. * @param scene to attach the crowd to
  61795. * @returns the crowd you can add agents to
  61796. */
  61797. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  61798. /**
  61799. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  61800. * You can attach anything to that node. The node position is updated in the scene update tick.
  61801. * @param pos world position that will be constrained by the navigation mesh
  61802. * @param parameters agent parameters
  61803. * @param transform hooked to the agent that will be update by the scene
  61804. * @returns agent index
  61805. */
  61806. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  61807. /**
  61808. * Returns the agent position in world space
  61809. * @param index agent index returned by addAgent
  61810. * @returns world space position
  61811. */
  61812. getAgentPosition(index: number): Vector3;
  61813. /**
  61814. * Returns the agent velocity in world space
  61815. * @param index agent index returned by addAgent
  61816. * @returns world space velocity
  61817. */
  61818. getAgentVelocity(index: number): Vector3;
  61819. /**
  61820. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  61821. * @param index agent index returned by addAgent
  61822. * @param destination targeted world position
  61823. */
  61824. agentGoto(index: number, destination: Vector3): void;
  61825. /**
  61826. * remove a particular agent previously created
  61827. * @param index agent index returned by addAgent
  61828. */
  61829. removeAgent(index: number): void;
  61830. /**
  61831. * get the list of all agents attached to this crowd
  61832. * @returns list of agent indices
  61833. */
  61834. getAgents(): number[];
  61835. /**
  61836. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  61837. * @param deltaTime in seconds
  61838. */
  61839. update(deltaTime: number): void;
  61840. /**
  61841. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  61842. * The queries will try to find a solution within those bounds
  61843. * default is (1,1,1)
  61844. * @param extent x,y,z value that define the extent around the queries point of reference
  61845. */
  61846. setDefaultQueryExtent(extent: Vector3): void;
  61847. /**
  61848. * Get the Bounding box extent specified by setDefaultQueryExtent
  61849. * @returns the box extent values
  61850. */
  61851. getDefaultQueryExtent(): Vector3;
  61852. /**
  61853. * Release all resources
  61854. */
  61855. dispose(): void;
  61856. }
  61857. }
  61858. declare module "babylonjs/Navigation/Plugins/index" {
  61859. export * from "babylonjs/Navigation/Plugins/recastJSPlugin";
  61860. }
  61861. declare module "babylonjs/Navigation/index" {
  61862. export * from "babylonjs/Navigation/INavigationEngine";
  61863. export * from "babylonjs/Navigation/Plugins/index";
  61864. }
  61865. declare module "babylonjs/Offline/database" {
  61866. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  61867. /**
  61868. * Class used to enable access to IndexedDB
  61869. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  61870. */
  61871. export class Database implements IOfflineProvider {
  61872. private _callbackManifestChecked;
  61873. private _currentSceneUrl;
  61874. private _db;
  61875. private _enableSceneOffline;
  61876. private _enableTexturesOffline;
  61877. private _manifestVersionFound;
  61878. private _mustUpdateRessources;
  61879. private _hasReachedQuota;
  61880. private _isSupported;
  61881. private _idbFactory;
  61882. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  61883. private static IsUASupportingBlobStorage;
  61884. /**
  61885. * Gets a boolean indicating if Database storate is enabled (off by default)
  61886. */
  61887. static IDBStorageEnabled: boolean;
  61888. /**
  61889. * Gets a boolean indicating if scene must be saved in the database
  61890. */
  61891. readonly enableSceneOffline: boolean;
  61892. /**
  61893. * Gets a boolean indicating if textures must be saved in the database
  61894. */
  61895. readonly enableTexturesOffline: boolean;
  61896. /**
  61897. * Creates a new Database
  61898. * @param urlToScene defines the url to load the scene
  61899. * @param callbackManifestChecked defines the callback to use when manifest is checked
  61900. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  61901. */
  61902. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  61903. private static _ParseURL;
  61904. private static _ReturnFullUrlLocation;
  61905. private _checkManifestFile;
  61906. /**
  61907. * Open the database and make it available
  61908. * @param successCallback defines the callback to call on success
  61909. * @param errorCallback defines the callback to call on error
  61910. */
  61911. open(successCallback: () => void, errorCallback: () => void): void;
  61912. /**
  61913. * Loads an image from the database
  61914. * @param url defines the url to load from
  61915. * @param image defines the target DOM image
  61916. */
  61917. loadImage(url: string, image: HTMLImageElement): void;
  61918. private _loadImageFromDBAsync;
  61919. private _saveImageIntoDBAsync;
  61920. private _checkVersionFromDB;
  61921. private _loadVersionFromDBAsync;
  61922. private _saveVersionIntoDBAsync;
  61923. /**
  61924. * Loads a file from database
  61925. * @param url defines the URL to load from
  61926. * @param sceneLoaded defines a callback to call on success
  61927. * @param progressCallBack defines a callback to call when progress changed
  61928. * @param errorCallback defines a callback to call on error
  61929. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  61930. */
  61931. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  61932. private _loadFileAsync;
  61933. private _saveFileAsync;
  61934. /**
  61935. * Validates if xhr data is correct
  61936. * @param xhr defines the request to validate
  61937. * @param dataType defines the expected data type
  61938. * @returns true if data is correct
  61939. */
  61940. private static _ValidateXHRData;
  61941. }
  61942. }
  61943. declare module "babylonjs/Offline/index" {
  61944. export * from "babylonjs/Offline/database";
  61945. export * from "babylonjs/Offline/IOfflineProvider";
  61946. }
  61947. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  61948. /** @hidden */
  61949. export var gpuUpdateParticlesPixelShader: {
  61950. name: string;
  61951. shader: string;
  61952. };
  61953. }
  61954. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  61955. /** @hidden */
  61956. export var gpuUpdateParticlesVertexShader: {
  61957. name: string;
  61958. shader: string;
  61959. };
  61960. }
  61961. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  61962. /** @hidden */
  61963. export var clipPlaneFragmentDeclaration2: {
  61964. name: string;
  61965. shader: string;
  61966. };
  61967. }
  61968. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  61969. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  61970. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  61971. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  61972. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  61973. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  61974. /** @hidden */
  61975. export var gpuRenderParticlesPixelShader: {
  61976. name: string;
  61977. shader: string;
  61978. };
  61979. }
  61980. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  61981. /** @hidden */
  61982. export var clipPlaneVertexDeclaration2: {
  61983. name: string;
  61984. shader: string;
  61985. };
  61986. }
  61987. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  61988. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  61989. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  61990. /** @hidden */
  61991. export var gpuRenderParticlesVertexShader: {
  61992. name: string;
  61993. shader: string;
  61994. };
  61995. }
  61996. declare module "babylonjs/Particles/gpuParticleSystem" {
  61997. import { Nullable } from "babylonjs/types";
  61998. import { Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  61999. import { Observable } from "babylonjs/Misc/observable";
  62000. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  62001. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  62002. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  62003. import { Scene, IDisposable } from "babylonjs/scene";
  62004. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  62005. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  62006. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  62007. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  62008. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  62009. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  62010. /**
  62011. * This represents a GPU particle system in Babylon
  62012. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  62013. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  62014. */
  62015. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  62016. /**
  62017. * The layer mask we are rendering the particles through.
  62018. */
  62019. layerMask: number;
  62020. private _capacity;
  62021. private _activeCount;
  62022. private _currentActiveCount;
  62023. private _accumulatedCount;
  62024. private _renderEffect;
  62025. private _updateEffect;
  62026. private _buffer0;
  62027. private _buffer1;
  62028. private _spriteBuffer;
  62029. private _updateVAO;
  62030. private _renderVAO;
  62031. private _targetIndex;
  62032. private _sourceBuffer;
  62033. private _targetBuffer;
  62034. private _engine;
  62035. private _currentRenderId;
  62036. private _started;
  62037. private _stopped;
  62038. private _timeDelta;
  62039. private _randomTexture;
  62040. private _randomTexture2;
  62041. private _attributesStrideSize;
  62042. private _updateEffectOptions;
  62043. private _randomTextureSize;
  62044. private _actualFrame;
  62045. private readonly _rawTextureWidth;
  62046. /**
  62047. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  62048. */
  62049. static readonly IsSupported: boolean;
  62050. /**
  62051. * An event triggered when the system is disposed.
  62052. */
  62053. onDisposeObservable: Observable<GPUParticleSystem>;
  62054. /**
  62055. * Gets the maximum number of particles active at the same time.
  62056. * @returns The max number of active particles.
  62057. */
  62058. getCapacity(): number;
  62059. /**
  62060. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  62061. * to override the particles.
  62062. */
  62063. forceDepthWrite: boolean;
  62064. /**
  62065. * Gets or set the number of active particles
  62066. */
  62067. activeParticleCount: number;
  62068. private _preWarmDone;
  62069. /**
  62070. * Is this system ready to be used/rendered
  62071. * @return true if the system is ready
  62072. */
  62073. isReady(): boolean;
  62074. /**
  62075. * Gets if the system has been started. (Note: this will still be true after stop is called)
  62076. * @returns True if it has been started, otherwise false.
  62077. */
  62078. isStarted(): boolean;
  62079. /**
  62080. * Starts the particle system and begins to emit
  62081. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  62082. */
  62083. start(delay?: number): void;
  62084. /**
  62085. * Stops the particle system.
  62086. */
  62087. stop(): void;
  62088. /**
  62089. * Remove all active particles
  62090. */
  62091. reset(): void;
  62092. /**
  62093. * Returns the string "GPUParticleSystem"
  62094. * @returns a string containing the class name
  62095. */
  62096. getClassName(): string;
  62097. private _colorGradientsTexture;
  62098. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  62099. /**
  62100. * Adds a new color gradient
  62101. * @param gradient defines the gradient to use (between 0 and 1)
  62102. * @param color1 defines the color to affect to the specified gradient
  62103. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  62104. * @returns the current particle system
  62105. */
  62106. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  62107. /**
  62108. * Remove a specific color gradient
  62109. * @param gradient defines the gradient to remove
  62110. * @returns the current particle system
  62111. */
  62112. removeColorGradient(gradient: number): GPUParticleSystem;
  62113. private _angularSpeedGradientsTexture;
  62114. private _sizeGradientsTexture;
  62115. private _velocityGradientsTexture;
  62116. private _limitVelocityGradientsTexture;
  62117. private _dragGradientsTexture;
  62118. private _addFactorGradient;
  62119. /**
  62120. * Adds a new size gradient
  62121. * @param gradient defines the gradient to use (between 0 and 1)
  62122. * @param factor defines the size factor to affect to the specified gradient
  62123. * @returns the current particle system
  62124. */
  62125. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  62126. /**
  62127. * Remove a specific size gradient
  62128. * @param gradient defines the gradient to remove
  62129. * @returns the current particle system
  62130. */
  62131. removeSizeGradient(gradient: number): GPUParticleSystem;
  62132. /**
  62133. * Adds a new angular speed gradient
  62134. * @param gradient defines the gradient to use (between 0 and 1)
  62135. * @param factor defines the angular speed to affect to the specified gradient
  62136. * @returns the current particle system
  62137. */
  62138. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  62139. /**
  62140. * Remove a specific angular speed gradient
  62141. * @param gradient defines the gradient to remove
  62142. * @returns the current particle system
  62143. */
  62144. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  62145. /**
  62146. * Adds a new velocity gradient
  62147. * @param gradient defines the gradient to use (between 0 and 1)
  62148. * @param factor defines the velocity to affect to the specified gradient
  62149. * @returns the current particle system
  62150. */
  62151. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  62152. /**
  62153. * Remove a specific velocity gradient
  62154. * @param gradient defines the gradient to remove
  62155. * @returns the current particle system
  62156. */
  62157. removeVelocityGradient(gradient: number): GPUParticleSystem;
  62158. /**
  62159. * Adds a new limit velocity gradient
  62160. * @param gradient defines the gradient to use (between 0 and 1)
  62161. * @param factor defines the limit velocity value to affect to the specified gradient
  62162. * @returns the current particle system
  62163. */
  62164. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  62165. /**
  62166. * Remove a specific limit velocity gradient
  62167. * @param gradient defines the gradient to remove
  62168. * @returns the current particle system
  62169. */
  62170. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  62171. /**
  62172. * Adds a new drag gradient
  62173. * @param gradient defines the gradient to use (between 0 and 1)
  62174. * @param factor defines the drag value to affect to the specified gradient
  62175. * @returns the current particle system
  62176. */
  62177. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  62178. /**
  62179. * Remove a specific drag gradient
  62180. * @param gradient defines the gradient to remove
  62181. * @returns the current particle system
  62182. */
  62183. removeDragGradient(gradient: number): GPUParticleSystem;
  62184. /**
  62185. * Not supported by GPUParticleSystem
  62186. * @param gradient defines the gradient to use (between 0 and 1)
  62187. * @param factor defines the emit rate value to affect to the specified gradient
  62188. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  62189. * @returns the current particle system
  62190. */
  62191. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  62192. /**
  62193. * Not supported by GPUParticleSystem
  62194. * @param gradient defines the gradient to remove
  62195. * @returns the current particle system
  62196. */
  62197. removeEmitRateGradient(gradient: number): IParticleSystem;
  62198. /**
  62199. * Not supported by GPUParticleSystem
  62200. * @param gradient defines the gradient to use (between 0 and 1)
  62201. * @param factor defines the start size value to affect to the specified gradient
  62202. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  62203. * @returns the current particle system
  62204. */
  62205. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  62206. /**
  62207. * Not supported by GPUParticleSystem
  62208. * @param gradient defines the gradient to remove
  62209. * @returns the current particle system
  62210. */
  62211. removeStartSizeGradient(gradient: number): IParticleSystem;
  62212. /**
  62213. * Not supported by GPUParticleSystem
  62214. * @param gradient defines the gradient to use (between 0 and 1)
  62215. * @param min defines the color remap minimal range
  62216. * @param max defines the color remap maximal range
  62217. * @returns the current particle system
  62218. */
  62219. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  62220. /**
  62221. * Not supported by GPUParticleSystem
  62222. * @param gradient defines the gradient to remove
  62223. * @returns the current particle system
  62224. */
  62225. removeColorRemapGradient(): IParticleSystem;
  62226. /**
  62227. * Not supported by GPUParticleSystem
  62228. * @param gradient defines the gradient to use (between 0 and 1)
  62229. * @param min defines the alpha remap minimal range
  62230. * @param max defines the alpha remap maximal range
  62231. * @returns the current particle system
  62232. */
  62233. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  62234. /**
  62235. * Not supported by GPUParticleSystem
  62236. * @param gradient defines the gradient to remove
  62237. * @returns the current particle system
  62238. */
  62239. removeAlphaRemapGradient(): IParticleSystem;
  62240. /**
  62241. * Not supported by GPUParticleSystem
  62242. * @param gradient defines the gradient to use (between 0 and 1)
  62243. * @param color defines the color to affect to the specified gradient
  62244. * @returns the current particle system
  62245. */
  62246. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  62247. /**
  62248. * Not supported by GPUParticleSystem
  62249. * @param gradient defines the gradient to remove
  62250. * @returns the current particle system
  62251. */
  62252. removeRampGradient(): IParticleSystem;
  62253. /**
  62254. * Not supported by GPUParticleSystem
  62255. * @returns the list of ramp gradients
  62256. */
  62257. getRampGradients(): Nullable<Array<Color3Gradient>>;
  62258. /**
  62259. * Not supported by GPUParticleSystem
  62260. * Gets or sets a boolean indicating that ramp gradients must be used
  62261. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  62262. */
  62263. useRampGradients: boolean;
  62264. /**
  62265. * Not supported by GPUParticleSystem
  62266. * @param gradient defines the gradient to use (between 0 and 1)
  62267. * @param factor defines the life time factor to affect to the specified gradient
  62268. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  62269. * @returns the current particle system
  62270. */
  62271. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  62272. /**
  62273. * Not supported by GPUParticleSystem
  62274. * @param gradient defines the gradient to remove
  62275. * @returns the current particle system
  62276. */
  62277. removeLifeTimeGradient(gradient: number): IParticleSystem;
  62278. /**
  62279. * Instantiates a GPU particle system.
  62280. * 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.
  62281. * @param name The name of the particle system
  62282. * @param options The options used to create the system
  62283. * @param scene The scene the particle system belongs to
  62284. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  62285. */
  62286. constructor(name: string, options: Partial<{
  62287. capacity: number;
  62288. randomTextureSize: number;
  62289. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  62290. protected _reset(): void;
  62291. private _createUpdateVAO;
  62292. private _createRenderVAO;
  62293. private _initialize;
  62294. /** @hidden */
  62295. _recreateUpdateEffect(): void;
  62296. /** @hidden */
  62297. _recreateRenderEffect(): void;
  62298. /**
  62299. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  62300. * @param preWarm defines if we are in the pre-warmimg phase
  62301. */
  62302. animate(preWarm?: boolean): void;
  62303. private _createFactorGradientTexture;
  62304. private _createSizeGradientTexture;
  62305. private _createAngularSpeedGradientTexture;
  62306. private _createVelocityGradientTexture;
  62307. private _createLimitVelocityGradientTexture;
  62308. private _createDragGradientTexture;
  62309. private _createColorGradientTexture;
  62310. /**
  62311. * Renders the particle system in its current state
  62312. * @param preWarm defines if the system should only update the particles but not render them
  62313. * @returns the current number of particles
  62314. */
  62315. render(preWarm?: boolean): number;
  62316. /**
  62317. * Rebuilds the particle system
  62318. */
  62319. rebuild(): void;
  62320. private _releaseBuffers;
  62321. private _releaseVAOs;
  62322. /**
  62323. * Disposes the particle system and free the associated resources
  62324. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  62325. */
  62326. dispose(disposeTexture?: boolean): void;
  62327. /**
  62328. * Clones the particle system.
  62329. * @param name The name of the cloned object
  62330. * @param newEmitter The new emitter to use
  62331. * @returns the cloned particle system
  62332. */
  62333. clone(name: string, newEmitter: any): GPUParticleSystem;
  62334. /**
  62335. * Serializes the particle system to a JSON object.
  62336. * @returns the JSON object
  62337. */
  62338. serialize(): any;
  62339. /**
  62340. * Parses a JSON object to create a GPU particle system.
  62341. * @param parsedParticleSystem The JSON object to parse
  62342. * @param scene The scene to create the particle system in
  62343. * @param rootUrl The root url to use to load external dependencies like texture
  62344. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  62345. * @returns the parsed GPU particle system
  62346. */
  62347. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  62348. }
  62349. }
  62350. declare module "babylonjs/Particles/particleSystemSet" {
  62351. import { Nullable } from "babylonjs/types";
  62352. import { Color3 } from "babylonjs/Maths/math.color";
  62353. import { TransformNode } from "babylonjs/Meshes/transformNode";
  62354. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62355. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  62356. import { Scene, IDisposable } from "babylonjs/scene";
  62357. /**
  62358. * Represents a set of particle systems working together to create a specific effect
  62359. */
  62360. export class ParticleSystemSet implements IDisposable {
  62361. /**
  62362. * Gets or sets base Assets URL
  62363. */
  62364. static BaseAssetsUrl: string;
  62365. private _emitterCreationOptions;
  62366. private _emitterNode;
  62367. /**
  62368. * Gets the particle system list
  62369. */
  62370. systems: IParticleSystem[];
  62371. /**
  62372. * Gets the emitter node used with this set
  62373. */
  62374. readonly emitterNode: Nullable<TransformNode>;
  62375. /**
  62376. * Creates a new emitter mesh as a sphere
  62377. * @param options defines the options used to create the sphere
  62378. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  62379. * @param scene defines the hosting scene
  62380. */
  62381. setEmitterAsSphere(options: {
  62382. diameter: number;
  62383. segments: number;
  62384. color: Color3;
  62385. }, renderingGroupId: number, scene: Scene): void;
  62386. /**
  62387. * Starts all particle systems of the set
  62388. * @param emitter defines an optional mesh to use as emitter for the particle systems
  62389. */
  62390. start(emitter?: AbstractMesh): void;
  62391. /**
  62392. * Release all associated resources
  62393. */
  62394. dispose(): void;
  62395. /**
  62396. * Serialize the set into a JSON compatible object
  62397. * @returns a JSON compatible representation of the set
  62398. */
  62399. serialize(): any;
  62400. /**
  62401. * Parse a new ParticleSystemSet from a serialized source
  62402. * @param data defines a JSON compatible representation of the set
  62403. * @param scene defines the hosting scene
  62404. * @param gpu defines if we want GPU particles or CPU particles
  62405. * @returns a new ParticleSystemSet
  62406. */
  62407. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  62408. }
  62409. }
  62410. declare module "babylonjs/Particles/particleHelper" {
  62411. import { Nullable } from "babylonjs/types";
  62412. import { Scene } from "babylonjs/scene";
  62413. import { Vector3 } from "babylonjs/Maths/math.vector";
  62414. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62415. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  62416. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  62417. /**
  62418. * This class is made for on one-liner static method to help creating particle system set.
  62419. */
  62420. export class ParticleHelper {
  62421. /**
  62422. * Gets or sets base Assets URL
  62423. */
  62424. static BaseAssetsUrl: string;
  62425. /**
  62426. * Create a default particle system that you can tweak
  62427. * @param emitter defines the emitter to use
  62428. * @param capacity defines the system capacity (default is 500 particles)
  62429. * @param scene defines the hosting scene
  62430. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  62431. * @returns the new Particle system
  62432. */
  62433. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  62434. /**
  62435. * This is the main static method (one-liner) of this helper to create different particle systems
  62436. * @param type This string represents the type to the particle system to create
  62437. * @param scene The scene where the particle system should live
  62438. * @param gpu If the system will use gpu
  62439. * @returns the ParticleSystemSet created
  62440. */
  62441. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  62442. /**
  62443. * Static function used to export a particle system to a ParticleSystemSet variable.
  62444. * Please note that the emitter shape is not exported
  62445. * @param systems defines the particle systems to export
  62446. * @returns the created particle system set
  62447. */
  62448. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  62449. }
  62450. }
  62451. declare module "babylonjs/Particles/particleSystemComponent" {
  62452. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  62453. import { Effect } from "babylonjs/Materials/effect";
  62454. import "babylonjs/Shaders/particles.vertex";
  62455. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  62456. module "babylonjs/Engines/engine" {
  62457. interface Engine {
  62458. /**
  62459. * Create an effect to use with particle systems.
  62460. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  62461. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  62462. * @param uniformsNames defines a list of attribute names
  62463. * @param samplers defines an array of string used to represent textures
  62464. * @param defines defines the string containing the defines to use to compile the shaders
  62465. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  62466. * @param onCompiled defines a function to call when the effect creation is successful
  62467. * @param onError defines a function to call when the effect creation has failed
  62468. * @returns the new Effect
  62469. */
  62470. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  62471. }
  62472. }
  62473. module "babylonjs/Meshes/mesh" {
  62474. interface Mesh {
  62475. /**
  62476. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  62477. * @returns an array of IParticleSystem
  62478. */
  62479. getEmittedParticleSystems(): IParticleSystem[];
  62480. /**
  62481. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  62482. * @returns an array of IParticleSystem
  62483. */
  62484. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  62485. }
  62486. }
  62487. /**
  62488. * @hidden
  62489. */
  62490. export var _IDoNeedToBeInTheBuild: number;
  62491. }
  62492. declare module "babylonjs/Particles/pointsCloudSystem" {
  62493. import { Color4 } from "babylonjs/Maths/math";
  62494. import { Mesh } from "babylonjs/Meshes/mesh";
  62495. import { Scene, IDisposable } from "babylonjs/scene";
  62496. import { CloudPoint } from "babylonjs/Particles/cloudPoint";
  62497. /** Defines the 4 color options */
  62498. export enum PointColor {
  62499. /** color value */
  62500. Color = 2,
  62501. /** uv value */
  62502. UV = 1,
  62503. /** random value */
  62504. Random = 0,
  62505. /** stated value */
  62506. Stated = 3
  62507. }
  62508. /**
  62509. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  62510. * 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.
  62511. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  62512. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  62513. *
  62514. * Full documentation here : TO BE ENTERED
  62515. */
  62516. export class PointsCloudSystem implements IDisposable {
  62517. /**
  62518. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  62519. * Example : var p = SPS.particles[i];
  62520. */
  62521. particles: CloudPoint[];
  62522. /**
  62523. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  62524. */
  62525. nbParticles: number;
  62526. /**
  62527. * This a counter for your own usage. It's not set by any SPS functions.
  62528. */
  62529. counter: number;
  62530. /**
  62531. * The PCS name. This name is also given to the underlying mesh.
  62532. */
  62533. name: string;
  62534. /**
  62535. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  62536. */
  62537. mesh: Mesh;
  62538. /**
  62539. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  62540. * Please read :
  62541. */
  62542. vars: any;
  62543. /**
  62544. * @hidden
  62545. */
  62546. _size: number;
  62547. private _scene;
  62548. private _promises;
  62549. private _positions;
  62550. private _indices;
  62551. private _normals;
  62552. private _colors;
  62553. private _uvs;
  62554. private _indices32;
  62555. private _positions32;
  62556. private _colors32;
  62557. private _uvs32;
  62558. private _updatable;
  62559. private _isVisibilityBoxLocked;
  62560. private _alwaysVisible;
  62561. private _groups;
  62562. private _groupCounter;
  62563. private _computeParticleColor;
  62564. private _computeParticleTexture;
  62565. private _computeParticleRotation;
  62566. private _computeBoundingBox;
  62567. private _isReady;
  62568. /**
  62569. * Creates a PCS (Points Cloud System) object
  62570. * @param name (String) is the PCS name, this will be the underlying mesh name
  62571. * @param pointSize (number) is the size for each point
  62572. * @param scene (Scene) is the scene in which the PCS is added
  62573. * @param options defines the options of the PCS e.g.
  62574. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  62575. */
  62576. constructor(name: string, pointSize: number, scene: Scene, options?: {
  62577. updatable?: boolean;
  62578. });
  62579. /**
  62580. * Builds the PCS underlying mesh. Returns a standard Mesh.
  62581. * If no points were added to the PCS, the returned mesh is just a single point.
  62582. * @returns a promise for the created mesh
  62583. */
  62584. buildMeshAsync(): Promise<Mesh>;
  62585. /**
  62586. * @hidden
  62587. */
  62588. private _buildMesh;
  62589. private _addParticle;
  62590. private _randomUnitVector;
  62591. private _getColorIndicesForCoord;
  62592. private _setPointsColorOrUV;
  62593. private _colorFromTexture;
  62594. private _calculateDensity;
  62595. /**
  62596. * Adds points to the PCS in random positions within a unit sphere
  62597. * @param nb (positive integer) the number of particles to be created from this model
  62598. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  62599. * @returns the number of groups in the system
  62600. */
  62601. addPoints(nb: number, pointFunction?: any): number;
  62602. /**
  62603. * Adds points to the PCS from the surface of the model shape
  62604. * @param mesh is any Mesh object that will be used as a surface model for the points
  62605. * @param nb (positive integer) the number of particles to be created from this model
  62606. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  62607. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  62608. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  62609. * @returns the number of groups in the system
  62610. */
  62611. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  62612. /**
  62613. * Adds points to the PCS inside the model shape
  62614. * @param mesh is any Mesh object that will be used as a surface model for the points
  62615. * @param nb (positive integer) the number of particles to be created from this model
  62616. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  62617. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  62618. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  62619. * @returns the number of groups in the system
  62620. */
  62621. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  62622. /**
  62623. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  62624. * This method calls `updateParticle()` for each particle of the SPS.
  62625. * For an animated SPS, it is usually called within the render loop.
  62626. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  62627. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  62628. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  62629. * @returns the PCS.
  62630. */
  62631. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  62632. /**
  62633. * Disposes the PCS.
  62634. */
  62635. dispose(): void;
  62636. /**
  62637. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  62638. * doc :
  62639. * @returns the PCS.
  62640. */
  62641. refreshVisibleSize(): PointsCloudSystem;
  62642. /**
  62643. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  62644. * @param size the size (float) of the visibility box
  62645. * note : this doesn't lock the PCS mesh bounding box.
  62646. * doc :
  62647. */
  62648. setVisibilityBox(size: number): void;
  62649. /**
  62650. * Gets whether the PCS is always visible or not
  62651. * doc :
  62652. */
  62653. /**
  62654. * Sets the PCS as always visible or not
  62655. * doc :
  62656. */
  62657. isAlwaysVisible: boolean;
  62658. /**
  62659. * Tells to `setParticles()` to compute the particle rotations or not
  62660. * Default value : false. The PCS is faster when it's set to false
  62661. * Note : particle rotations are only applied to parent particles
  62662. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  62663. */
  62664. computeParticleRotation: boolean;
  62665. /**
  62666. * Tells to `setParticles()` to compute the particle colors or not.
  62667. * Default value : true. The PCS is faster when it's set to false.
  62668. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  62669. */
  62670. /**
  62671. * Gets if `setParticles()` computes the particle colors or not.
  62672. * Default value : false. The PCS is faster when it's set to false.
  62673. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  62674. */
  62675. computeParticleColor: boolean;
  62676. /**
  62677. * Gets if `setParticles()` computes the particle textures or not.
  62678. * Default value : false. The PCS is faster when it's set to false.
  62679. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  62680. */
  62681. computeParticleTexture: boolean;
  62682. /**
  62683. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  62684. */
  62685. /**
  62686. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  62687. */
  62688. computeBoundingBox: boolean;
  62689. /**
  62690. * This function does nothing. It may be overwritten to set all the particle first values.
  62691. * The PCS doesn't call this function, you may have to call it by your own.
  62692. * doc :
  62693. */
  62694. initParticles(): void;
  62695. /**
  62696. * This function does nothing. It may be overwritten to recycle a particle
  62697. * The PCS doesn't call this function, you can to call it
  62698. * doc :
  62699. * @param particle The particle to recycle
  62700. * @returns the recycled particle
  62701. */
  62702. recycleParticle(particle: CloudPoint): CloudPoint;
  62703. /**
  62704. * Updates a particle : this function should be overwritten by the user.
  62705. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  62706. * doc :
  62707. * @example : just set a particle position or velocity and recycle conditions
  62708. * @param particle The particle to update
  62709. * @returns the updated particle
  62710. */
  62711. updateParticle(particle: CloudPoint): CloudPoint;
  62712. /**
  62713. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  62714. * This does nothing and may be overwritten by the user.
  62715. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  62716. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  62717. * @param update the boolean update value actually passed to setParticles()
  62718. */
  62719. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  62720. /**
  62721. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  62722. * This will be passed three parameters.
  62723. * This does nothing and may be overwritten by the user.
  62724. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  62725. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  62726. * @param update the boolean update value actually passed to setParticles()
  62727. */
  62728. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  62729. }
  62730. }
  62731. declare module "babylonjs/Particles/cloudPoint" {
  62732. import { Nullable } from "babylonjs/types";
  62733. import { Color4, Vector2, Vector3, Matrix, Quaternion } from "babylonjs/Maths/math";
  62734. import { Mesh } from "babylonjs/Meshes/mesh";
  62735. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  62736. import { PointsCloudSystem } from "babylonjs/Particles/pointsCloudSystem";
  62737. /**
  62738. * Represents one particle of a points cloud system.
  62739. */
  62740. export class CloudPoint {
  62741. /**
  62742. * particle global index
  62743. */
  62744. idx: number;
  62745. /**
  62746. * The color of the particle
  62747. */
  62748. color: Nullable<Color4>;
  62749. /**
  62750. * The world space position of the particle.
  62751. */
  62752. position: Vector3;
  62753. /**
  62754. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  62755. */
  62756. rotation: Vector3;
  62757. /**
  62758. * The world space rotation quaternion of the particle.
  62759. */
  62760. rotationQuaternion: Nullable<Quaternion>;
  62761. /**
  62762. * The uv of the particle.
  62763. */
  62764. uv: Nullable<Vector2>;
  62765. /**
  62766. * The current speed of the particle.
  62767. */
  62768. velocity: Vector3;
  62769. /**
  62770. * The pivot point in the particle local space.
  62771. */
  62772. pivot: Vector3;
  62773. /**
  62774. * Must the particle be translated from its pivot point in its local space ?
  62775. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  62776. * Default : false
  62777. */
  62778. translateFromPivot: boolean;
  62779. /**
  62780. * Index of this particle in the global "positions" array (Internal use)
  62781. * @hidden
  62782. */
  62783. _pos: number;
  62784. /**
  62785. * @hidden Index of this particle in the global "indices" array (Internal use)
  62786. */
  62787. _ind: number;
  62788. /**
  62789. * Group this particle belongs to
  62790. */
  62791. _group: PointsGroup;
  62792. /**
  62793. * Group id of this particle
  62794. */
  62795. groupId: number;
  62796. /**
  62797. * Index of the particle in its group id (Internal use)
  62798. */
  62799. idxInGroup: number;
  62800. /**
  62801. * @hidden Particle BoundingInfo object (Internal use)
  62802. */
  62803. _boundingInfo: BoundingInfo;
  62804. /**
  62805. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  62806. */
  62807. _pcs: PointsCloudSystem;
  62808. /**
  62809. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  62810. */
  62811. _stillInvisible: boolean;
  62812. /**
  62813. * @hidden Last computed particle rotation matrix
  62814. */
  62815. _rotationMatrix: number[];
  62816. /**
  62817. * Parent particle Id, if any.
  62818. * Default null.
  62819. */
  62820. parentId: Nullable<number>;
  62821. /**
  62822. * @hidden Internal global position in the PCS.
  62823. */
  62824. _globalPosition: Vector3;
  62825. /**
  62826. * Creates a Point Cloud object.
  62827. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  62828. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  62829. * @param group (PointsGroup) is the group the particle belongs to
  62830. * @param groupId (integer) is the group identifier in the PCS.
  62831. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  62832. * @param pcs defines the PCS it is associated to
  62833. */
  62834. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  62835. /**
  62836. * get point size
  62837. */
  62838. /**
  62839. * Set point size
  62840. */
  62841. size: Vector3;
  62842. /**
  62843. * Legacy support, changed quaternion to rotationQuaternion
  62844. */
  62845. /**
  62846. * Legacy support, changed quaternion to rotationQuaternion
  62847. */
  62848. quaternion: Nullable<Quaternion>;
  62849. /**
  62850. * Returns a boolean. True if the particle intersects a mesh, else false
  62851. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  62852. * @param target is the object (point or mesh) what the intersection is computed against
  62853. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  62854. * @returns true if it intersects
  62855. */
  62856. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  62857. /**
  62858. * get the rotation matrix of the particle
  62859. * @hidden
  62860. */
  62861. getRotationMatrix(m: Matrix): void;
  62862. }
  62863. /**
  62864. * Represents a group of points in a points cloud system
  62865. * * PCS internal tool, don't use it manually.
  62866. */
  62867. export class PointsGroup {
  62868. /**
  62869. * The group id
  62870. * @hidden
  62871. */
  62872. groupID: number;
  62873. /**
  62874. * image data for group (internal use)
  62875. * @hidden
  62876. */
  62877. _groupImageData: Nullable<ArrayBufferView>;
  62878. /**
  62879. * Image Width (internal use)
  62880. * @hidden
  62881. */
  62882. _groupImgWidth: number;
  62883. /**
  62884. * Image Height (internal use)
  62885. * @hidden
  62886. */
  62887. _groupImgHeight: number;
  62888. /**
  62889. * Custom position function (internal use)
  62890. * @hidden
  62891. */
  62892. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  62893. /**
  62894. * density per facet for surface points
  62895. * @hidden
  62896. */
  62897. _groupDensity: number[];
  62898. /**
  62899. * Only when points are colored by texture carries pointer to texture list array
  62900. * @hidden
  62901. */
  62902. _textureNb: number;
  62903. /**
  62904. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  62905. * PCS internal tool, don't use it manually.
  62906. * @hidden
  62907. */
  62908. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  62909. }
  62910. }
  62911. declare module "babylonjs/Particles/index" {
  62912. export * from "babylonjs/Particles/baseParticleSystem";
  62913. export * from "babylonjs/Particles/EmitterTypes/index";
  62914. export * from "babylonjs/Particles/gpuParticleSystem";
  62915. export * from "babylonjs/Particles/IParticleSystem";
  62916. export * from "babylonjs/Particles/particle";
  62917. export * from "babylonjs/Particles/particleHelper";
  62918. export * from "babylonjs/Particles/particleSystem";
  62919. export * from "babylonjs/Particles/particleSystemComponent";
  62920. export * from "babylonjs/Particles/particleSystemSet";
  62921. export * from "babylonjs/Particles/solidParticle";
  62922. export * from "babylonjs/Particles/solidParticleSystem";
  62923. export * from "babylonjs/Particles/cloudPoint";
  62924. export * from "babylonjs/Particles/pointsCloudSystem";
  62925. export * from "babylonjs/Particles/subEmitter";
  62926. }
  62927. declare module "babylonjs/Physics/physicsEngineComponent" {
  62928. import { Nullable } from "babylonjs/types";
  62929. import { Observable, Observer } from "babylonjs/Misc/observable";
  62930. import { Vector3 } from "babylonjs/Maths/math.vector";
  62931. import { Mesh } from "babylonjs/Meshes/mesh";
  62932. import { ISceneComponent } from "babylonjs/sceneComponent";
  62933. import { Scene } from "babylonjs/scene";
  62934. import { Node } from "babylonjs/node";
  62935. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  62936. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  62937. module "babylonjs/scene" {
  62938. interface Scene {
  62939. /** @hidden (Backing field) */
  62940. _physicsEngine: Nullable<IPhysicsEngine>;
  62941. /**
  62942. * Gets the current physics engine
  62943. * @returns a IPhysicsEngine or null if none attached
  62944. */
  62945. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  62946. /**
  62947. * Enables physics to the current scene
  62948. * @param gravity defines the scene's gravity for the physics engine
  62949. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  62950. * @return a boolean indicating if the physics engine was initialized
  62951. */
  62952. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  62953. /**
  62954. * Disables and disposes the physics engine associated with the scene
  62955. */
  62956. disablePhysicsEngine(): void;
  62957. /**
  62958. * Gets a boolean indicating if there is an active physics engine
  62959. * @returns a boolean indicating if there is an active physics engine
  62960. */
  62961. isPhysicsEnabled(): boolean;
  62962. /**
  62963. * Deletes a physics compound impostor
  62964. * @param compound defines the compound to delete
  62965. */
  62966. deleteCompoundImpostor(compound: any): void;
  62967. /**
  62968. * An event triggered when physic simulation is about to be run
  62969. */
  62970. onBeforePhysicsObservable: Observable<Scene>;
  62971. /**
  62972. * An event triggered when physic simulation has been done
  62973. */
  62974. onAfterPhysicsObservable: Observable<Scene>;
  62975. }
  62976. }
  62977. module "babylonjs/Meshes/abstractMesh" {
  62978. interface AbstractMesh {
  62979. /** @hidden */
  62980. _physicsImpostor: Nullable<PhysicsImpostor>;
  62981. /**
  62982. * Gets or sets impostor used for physic simulation
  62983. * @see http://doc.babylonjs.com/features/physics_engine
  62984. */
  62985. physicsImpostor: Nullable<PhysicsImpostor>;
  62986. /**
  62987. * Gets the current physics impostor
  62988. * @see http://doc.babylonjs.com/features/physics_engine
  62989. * @returns a physics impostor or null
  62990. */
  62991. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  62992. /** Apply a physic impulse to the mesh
  62993. * @param force defines the force to apply
  62994. * @param contactPoint defines where to apply the force
  62995. * @returns the current mesh
  62996. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  62997. */
  62998. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  62999. /**
  63000. * Creates a physic joint between two meshes
  63001. * @param otherMesh defines the other mesh to use
  63002. * @param pivot1 defines the pivot to use on this mesh
  63003. * @param pivot2 defines the pivot to use on the other mesh
  63004. * @param options defines additional options (can be plugin dependent)
  63005. * @returns the current mesh
  63006. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  63007. */
  63008. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  63009. /** @hidden */
  63010. _disposePhysicsObserver: Nullable<Observer<Node>>;
  63011. }
  63012. }
  63013. /**
  63014. * Defines the physics engine scene component responsible to manage a physics engine
  63015. */
  63016. export class PhysicsEngineSceneComponent implements ISceneComponent {
  63017. /**
  63018. * The component name helpful to identify the component in the list of scene components.
  63019. */
  63020. readonly name: string;
  63021. /**
  63022. * The scene the component belongs to.
  63023. */
  63024. scene: Scene;
  63025. /**
  63026. * Creates a new instance of the component for the given scene
  63027. * @param scene Defines the scene to register the component in
  63028. */
  63029. constructor(scene: Scene);
  63030. /**
  63031. * Registers the component in a given scene
  63032. */
  63033. register(): void;
  63034. /**
  63035. * Rebuilds the elements related to this component in case of
  63036. * context lost for instance.
  63037. */
  63038. rebuild(): void;
  63039. /**
  63040. * Disposes the component and the associated ressources
  63041. */
  63042. dispose(): void;
  63043. }
  63044. }
  63045. declare module "babylonjs/Physics/physicsHelper" {
  63046. import { Nullable } from "babylonjs/types";
  63047. import { Vector3 } from "babylonjs/Maths/math.vector";
  63048. import { Mesh } from "babylonjs/Meshes/mesh";
  63049. import { Scene } from "babylonjs/scene";
  63050. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  63051. /**
  63052. * A helper for physics simulations
  63053. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63054. */
  63055. export class PhysicsHelper {
  63056. private _scene;
  63057. private _physicsEngine;
  63058. /**
  63059. * Initializes the Physics helper
  63060. * @param scene Babylon.js scene
  63061. */
  63062. constructor(scene: Scene);
  63063. /**
  63064. * Applies a radial explosion impulse
  63065. * @param origin the origin of the explosion
  63066. * @param radiusOrEventOptions the radius or the options of radial explosion
  63067. * @param strength the explosion strength
  63068. * @param falloff possible options: Constant & Linear. Defaults to Constant
  63069. * @returns A physics radial explosion event, or null
  63070. */
  63071. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  63072. /**
  63073. * Applies a radial explosion force
  63074. * @param origin the origin of the explosion
  63075. * @param radiusOrEventOptions the radius or the options of radial explosion
  63076. * @param strength the explosion strength
  63077. * @param falloff possible options: Constant & Linear. Defaults to Constant
  63078. * @returns A physics radial explosion event, or null
  63079. */
  63080. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  63081. /**
  63082. * Creates a gravitational field
  63083. * @param origin the origin of the explosion
  63084. * @param radiusOrEventOptions the radius or the options of radial explosion
  63085. * @param strength the explosion strength
  63086. * @param falloff possible options: Constant & Linear. Defaults to Constant
  63087. * @returns A physics gravitational field event, or null
  63088. */
  63089. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  63090. /**
  63091. * Creates a physics updraft event
  63092. * @param origin the origin of the updraft
  63093. * @param radiusOrEventOptions the radius or the options of the updraft
  63094. * @param strength the strength of the updraft
  63095. * @param height the height of the updraft
  63096. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  63097. * @returns A physics updraft event, or null
  63098. */
  63099. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  63100. /**
  63101. * Creates a physics vortex event
  63102. * @param origin the of the vortex
  63103. * @param radiusOrEventOptions the radius or the options of the vortex
  63104. * @param strength the strength of the vortex
  63105. * @param height the height of the vortex
  63106. * @returns a Physics vortex event, or null
  63107. * A physics vortex event or null
  63108. */
  63109. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  63110. }
  63111. /**
  63112. * Represents a physics radial explosion event
  63113. */
  63114. class PhysicsRadialExplosionEvent {
  63115. private _scene;
  63116. private _options;
  63117. private _sphere;
  63118. private _dataFetched;
  63119. /**
  63120. * Initializes a radial explosioin event
  63121. * @param _scene BabylonJS scene
  63122. * @param _options The options for the vortex event
  63123. */
  63124. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  63125. /**
  63126. * Returns the data related to the radial explosion event (sphere).
  63127. * @returns The radial explosion event data
  63128. */
  63129. getData(): PhysicsRadialExplosionEventData;
  63130. /**
  63131. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  63132. * @param impostor A physics imposter
  63133. * @param origin the origin of the explosion
  63134. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  63135. */
  63136. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  63137. /**
  63138. * Triggers affecterd impostors callbacks
  63139. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  63140. */
  63141. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  63142. /**
  63143. * Disposes the sphere.
  63144. * @param force Specifies if the sphere should be disposed by force
  63145. */
  63146. dispose(force?: boolean): void;
  63147. /*** Helpers ***/
  63148. private _prepareSphere;
  63149. private _intersectsWithSphere;
  63150. }
  63151. /**
  63152. * Represents a gravitational field event
  63153. */
  63154. class PhysicsGravitationalFieldEvent {
  63155. private _physicsHelper;
  63156. private _scene;
  63157. private _origin;
  63158. private _options;
  63159. private _tickCallback;
  63160. private _sphere;
  63161. private _dataFetched;
  63162. /**
  63163. * Initializes the physics gravitational field event
  63164. * @param _physicsHelper A physics helper
  63165. * @param _scene BabylonJS scene
  63166. * @param _origin The origin position of the gravitational field event
  63167. * @param _options The options for the vortex event
  63168. */
  63169. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  63170. /**
  63171. * Returns the data related to the gravitational field event (sphere).
  63172. * @returns A gravitational field event
  63173. */
  63174. getData(): PhysicsGravitationalFieldEventData;
  63175. /**
  63176. * Enables the gravitational field.
  63177. */
  63178. enable(): void;
  63179. /**
  63180. * Disables the gravitational field.
  63181. */
  63182. disable(): void;
  63183. /**
  63184. * Disposes the sphere.
  63185. * @param force The force to dispose from the gravitational field event
  63186. */
  63187. dispose(force?: boolean): void;
  63188. private _tick;
  63189. }
  63190. /**
  63191. * Represents a physics updraft event
  63192. */
  63193. class PhysicsUpdraftEvent {
  63194. private _scene;
  63195. private _origin;
  63196. private _options;
  63197. private _physicsEngine;
  63198. private _originTop;
  63199. private _originDirection;
  63200. private _tickCallback;
  63201. private _cylinder;
  63202. private _cylinderPosition;
  63203. private _dataFetched;
  63204. /**
  63205. * Initializes the physics updraft event
  63206. * @param _scene BabylonJS scene
  63207. * @param _origin The origin position of the updraft
  63208. * @param _options The options for the updraft event
  63209. */
  63210. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  63211. /**
  63212. * Returns the data related to the updraft event (cylinder).
  63213. * @returns A physics updraft event
  63214. */
  63215. getData(): PhysicsUpdraftEventData;
  63216. /**
  63217. * Enables the updraft.
  63218. */
  63219. enable(): void;
  63220. /**
  63221. * Disables the updraft.
  63222. */
  63223. disable(): void;
  63224. /**
  63225. * Disposes the cylinder.
  63226. * @param force Specifies if the updraft should be disposed by force
  63227. */
  63228. dispose(force?: boolean): void;
  63229. private getImpostorHitData;
  63230. private _tick;
  63231. /*** Helpers ***/
  63232. private _prepareCylinder;
  63233. private _intersectsWithCylinder;
  63234. }
  63235. /**
  63236. * Represents a physics vortex event
  63237. */
  63238. class PhysicsVortexEvent {
  63239. private _scene;
  63240. private _origin;
  63241. private _options;
  63242. private _physicsEngine;
  63243. private _originTop;
  63244. private _tickCallback;
  63245. private _cylinder;
  63246. private _cylinderPosition;
  63247. private _dataFetched;
  63248. /**
  63249. * Initializes the physics vortex event
  63250. * @param _scene The BabylonJS scene
  63251. * @param _origin The origin position of the vortex
  63252. * @param _options The options for the vortex event
  63253. */
  63254. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  63255. /**
  63256. * Returns the data related to the vortex event (cylinder).
  63257. * @returns The physics vortex event data
  63258. */
  63259. getData(): PhysicsVortexEventData;
  63260. /**
  63261. * Enables the vortex.
  63262. */
  63263. enable(): void;
  63264. /**
  63265. * Disables the cortex.
  63266. */
  63267. disable(): void;
  63268. /**
  63269. * Disposes the sphere.
  63270. * @param force
  63271. */
  63272. dispose(force?: boolean): void;
  63273. private getImpostorHitData;
  63274. private _tick;
  63275. /*** Helpers ***/
  63276. private _prepareCylinder;
  63277. private _intersectsWithCylinder;
  63278. }
  63279. /**
  63280. * Options fot the radial explosion event
  63281. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63282. */
  63283. export class PhysicsRadialExplosionEventOptions {
  63284. /**
  63285. * The radius of the sphere for the radial explosion.
  63286. */
  63287. radius: number;
  63288. /**
  63289. * The strenth of the explosion.
  63290. */
  63291. strength: number;
  63292. /**
  63293. * The strenght of the force in correspondence to the distance of the affected object
  63294. */
  63295. falloff: PhysicsRadialImpulseFalloff;
  63296. /**
  63297. * Sphere options for the radial explosion.
  63298. */
  63299. sphere: {
  63300. segments: number;
  63301. diameter: number;
  63302. };
  63303. /**
  63304. * Sphere options for the radial explosion.
  63305. */
  63306. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  63307. }
  63308. /**
  63309. * Options fot the updraft event
  63310. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63311. */
  63312. export class PhysicsUpdraftEventOptions {
  63313. /**
  63314. * The radius of the cylinder for the vortex
  63315. */
  63316. radius: number;
  63317. /**
  63318. * The strenth of the updraft.
  63319. */
  63320. strength: number;
  63321. /**
  63322. * The height of the cylinder for the updraft.
  63323. */
  63324. height: number;
  63325. /**
  63326. * The mode for the the updraft.
  63327. */
  63328. updraftMode: PhysicsUpdraftMode;
  63329. }
  63330. /**
  63331. * Options fot the vortex event
  63332. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63333. */
  63334. export class PhysicsVortexEventOptions {
  63335. /**
  63336. * The radius of the cylinder for the vortex
  63337. */
  63338. radius: number;
  63339. /**
  63340. * The strenth of the vortex.
  63341. */
  63342. strength: number;
  63343. /**
  63344. * The height of the cylinder for the vortex.
  63345. */
  63346. height: number;
  63347. /**
  63348. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  63349. */
  63350. centripetalForceThreshold: number;
  63351. /**
  63352. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  63353. */
  63354. centripetalForceMultiplier: number;
  63355. /**
  63356. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  63357. */
  63358. centrifugalForceMultiplier: number;
  63359. /**
  63360. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  63361. */
  63362. updraftForceMultiplier: number;
  63363. }
  63364. /**
  63365. * The strenght of the force in correspondence to the distance of the affected object
  63366. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63367. */
  63368. export enum PhysicsRadialImpulseFalloff {
  63369. /** Defines that impulse is constant in strength across it's whole radius */
  63370. Constant = 0,
  63371. /** Defines that impulse gets weaker if it's further from the origin */
  63372. Linear = 1
  63373. }
  63374. /**
  63375. * The strength of the force in correspondence to the distance of the affected object
  63376. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63377. */
  63378. export enum PhysicsUpdraftMode {
  63379. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  63380. Center = 0,
  63381. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  63382. Perpendicular = 1
  63383. }
  63384. /**
  63385. * Interface for a physics hit data
  63386. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63387. */
  63388. export interface PhysicsHitData {
  63389. /**
  63390. * The force applied at the contact point
  63391. */
  63392. force: Vector3;
  63393. /**
  63394. * The contact point
  63395. */
  63396. contactPoint: Vector3;
  63397. /**
  63398. * The distance from the origin to the contact point
  63399. */
  63400. distanceFromOrigin: number;
  63401. }
  63402. /**
  63403. * Interface for radial explosion event data
  63404. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63405. */
  63406. export interface PhysicsRadialExplosionEventData {
  63407. /**
  63408. * A sphere used for the radial explosion event
  63409. */
  63410. sphere: Mesh;
  63411. }
  63412. /**
  63413. * Interface for gravitational field event data
  63414. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63415. */
  63416. export interface PhysicsGravitationalFieldEventData {
  63417. /**
  63418. * A sphere mesh used for the gravitational field event
  63419. */
  63420. sphere: Mesh;
  63421. }
  63422. /**
  63423. * Interface for updraft event data
  63424. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63425. */
  63426. export interface PhysicsUpdraftEventData {
  63427. /**
  63428. * A cylinder used for the updraft event
  63429. */
  63430. cylinder: Mesh;
  63431. }
  63432. /**
  63433. * Interface for vortex event data
  63434. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63435. */
  63436. export interface PhysicsVortexEventData {
  63437. /**
  63438. * A cylinder used for the vortex event
  63439. */
  63440. cylinder: Mesh;
  63441. }
  63442. /**
  63443. * Interface for an affected physics impostor
  63444. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63445. */
  63446. export interface PhysicsAffectedImpostorWithData {
  63447. /**
  63448. * The impostor affected by the effect
  63449. */
  63450. impostor: PhysicsImpostor;
  63451. /**
  63452. * The data about the hit/horce from the explosion
  63453. */
  63454. hitData: PhysicsHitData;
  63455. }
  63456. }
  63457. declare module "babylonjs/Physics/Plugins/index" {
  63458. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  63459. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  63460. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  63461. }
  63462. declare module "babylonjs/Physics/index" {
  63463. export * from "babylonjs/Physics/IPhysicsEngine";
  63464. export * from "babylonjs/Physics/physicsEngine";
  63465. export * from "babylonjs/Physics/physicsEngineComponent";
  63466. export * from "babylonjs/Physics/physicsHelper";
  63467. export * from "babylonjs/Physics/physicsImpostor";
  63468. export * from "babylonjs/Physics/physicsJoint";
  63469. export * from "babylonjs/Physics/Plugins/index";
  63470. }
  63471. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  63472. /** @hidden */
  63473. export var blackAndWhitePixelShader: {
  63474. name: string;
  63475. shader: string;
  63476. };
  63477. }
  63478. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  63479. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63480. import { Camera } from "babylonjs/Cameras/camera";
  63481. import { Engine } from "babylonjs/Engines/engine";
  63482. import "babylonjs/Shaders/blackAndWhite.fragment";
  63483. /**
  63484. * Post process used to render in black and white
  63485. */
  63486. export class BlackAndWhitePostProcess extends PostProcess {
  63487. /**
  63488. * Linear about to convert he result to black and white (default: 1)
  63489. */
  63490. degree: number;
  63491. /**
  63492. * Creates a black and white post process
  63493. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  63494. * @param name The name of the effect.
  63495. * @param options The required width/height ratio to downsize to before computing the render pass.
  63496. * @param camera The camera to apply the render pass to.
  63497. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63498. * @param engine The engine which the post process will be applied. (default: current engine)
  63499. * @param reusable If the post process can be reused on the same frame. (default: false)
  63500. */
  63501. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  63502. }
  63503. }
  63504. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  63505. import { Nullable } from "babylonjs/types";
  63506. import { Camera } from "babylonjs/Cameras/camera";
  63507. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  63508. import { Engine } from "babylonjs/Engines/engine";
  63509. /**
  63510. * This represents a set of one or more post processes in Babylon.
  63511. * A post process can be used to apply a shader to a texture after it is rendered.
  63512. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  63513. */
  63514. export class PostProcessRenderEffect {
  63515. private _postProcesses;
  63516. private _getPostProcesses;
  63517. private _singleInstance;
  63518. private _cameras;
  63519. private _indicesForCamera;
  63520. /**
  63521. * Name of the effect
  63522. * @hidden
  63523. */
  63524. _name: string;
  63525. /**
  63526. * Instantiates a post process render effect.
  63527. * A post process can be used to apply a shader to a texture after it is rendered.
  63528. * @param engine The engine the effect is tied to
  63529. * @param name The name of the effect
  63530. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  63531. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  63532. */
  63533. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  63534. /**
  63535. * Checks if all the post processes in the effect are supported.
  63536. */
  63537. readonly isSupported: boolean;
  63538. /**
  63539. * Updates the current state of the effect
  63540. * @hidden
  63541. */
  63542. _update(): void;
  63543. /**
  63544. * Attaches the effect on cameras
  63545. * @param cameras The camera to attach to.
  63546. * @hidden
  63547. */
  63548. _attachCameras(cameras: Camera): void;
  63549. /**
  63550. * Attaches the effect on cameras
  63551. * @param cameras The camera to attach to.
  63552. * @hidden
  63553. */
  63554. _attachCameras(cameras: Camera[]): void;
  63555. /**
  63556. * Detaches the effect on cameras
  63557. * @param cameras The camera to detatch from.
  63558. * @hidden
  63559. */
  63560. _detachCameras(cameras: Camera): void;
  63561. /**
  63562. * Detatches the effect on cameras
  63563. * @param cameras The camera to detatch from.
  63564. * @hidden
  63565. */
  63566. _detachCameras(cameras: Camera[]): void;
  63567. /**
  63568. * Enables the effect on given cameras
  63569. * @param cameras The camera to enable.
  63570. * @hidden
  63571. */
  63572. _enable(cameras: Camera): void;
  63573. /**
  63574. * Enables the effect on given cameras
  63575. * @param cameras The camera to enable.
  63576. * @hidden
  63577. */
  63578. _enable(cameras: Nullable<Camera[]>): void;
  63579. /**
  63580. * Disables the effect on the given cameras
  63581. * @param cameras The camera to disable.
  63582. * @hidden
  63583. */
  63584. _disable(cameras: Camera): void;
  63585. /**
  63586. * Disables the effect on the given cameras
  63587. * @param cameras The camera to disable.
  63588. * @hidden
  63589. */
  63590. _disable(cameras: Nullable<Camera[]>): void;
  63591. /**
  63592. * Gets a list of the post processes contained in the effect.
  63593. * @param camera The camera to get the post processes on.
  63594. * @returns The list of the post processes in the effect.
  63595. */
  63596. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  63597. }
  63598. }
  63599. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  63600. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  63601. /** @hidden */
  63602. export var extractHighlightsPixelShader: {
  63603. name: string;
  63604. shader: string;
  63605. };
  63606. }
  63607. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  63608. import { Nullable } from "babylonjs/types";
  63609. import { Camera } from "babylonjs/Cameras/camera";
  63610. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63611. import { Engine } from "babylonjs/Engines/engine";
  63612. import "babylonjs/Shaders/extractHighlights.fragment";
  63613. /**
  63614. * 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.
  63615. */
  63616. export class ExtractHighlightsPostProcess extends PostProcess {
  63617. /**
  63618. * The luminance threshold, pixels below this value will be set to black.
  63619. */
  63620. threshold: number;
  63621. /** @hidden */
  63622. _exposure: number;
  63623. /**
  63624. * Post process which has the input texture to be used when performing highlight extraction
  63625. * @hidden
  63626. */
  63627. _inputPostProcess: Nullable<PostProcess>;
  63628. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  63629. }
  63630. }
  63631. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  63632. /** @hidden */
  63633. export var bloomMergePixelShader: {
  63634. name: string;
  63635. shader: string;
  63636. };
  63637. }
  63638. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  63639. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63640. import { Nullable } from "babylonjs/types";
  63641. import { Engine } from "babylonjs/Engines/engine";
  63642. import { Camera } from "babylonjs/Cameras/camera";
  63643. import "babylonjs/Shaders/bloomMerge.fragment";
  63644. /**
  63645. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  63646. */
  63647. export class BloomMergePostProcess extends PostProcess {
  63648. /** Weight of the bloom to be added to the original input. */
  63649. weight: number;
  63650. /**
  63651. * Creates a new instance of @see BloomMergePostProcess
  63652. * @param name The name of the effect.
  63653. * @param originalFromInput Post process which's input will be used for the merge.
  63654. * @param blurred Blurred highlights post process which's output will be used.
  63655. * @param weight Weight of the bloom to be added to the original input.
  63656. * @param options The required width/height ratio to downsize to before computing the render pass.
  63657. * @param camera The camera to apply the render pass to.
  63658. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63659. * @param engine The engine which the post process will be applied. (default: current engine)
  63660. * @param reusable If the post process can be reused on the same frame. (default: false)
  63661. * @param textureType Type of textures used when performing the post process. (default: 0)
  63662. * @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)
  63663. */
  63664. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  63665. /** Weight of the bloom to be added to the original input. */
  63666. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  63667. }
  63668. }
  63669. declare module "babylonjs/PostProcesses/bloomEffect" {
  63670. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  63671. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  63672. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  63673. import { Camera } from "babylonjs/Cameras/camera";
  63674. import { Scene } from "babylonjs/scene";
  63675. /**
  63676. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  63677. */
  63678. export class BloomEffect extends PostProcessRenderEffect {
  63679. private bloomScale;
  63680. /**
  63681. * @hidden Internal
  63682. */
  63683. _effects: Array<PostProcess>;
  63684. /**
  63685. * @hidden Internal
  63686. */
  63687. _downscale: ExtractHighlightsPostProcess;
  63688. private _blurX;
  63689. private _blurY;
  63690. private _merge;
  63691. /**
  63692. * The luminance threshold to find bright areas of the image to bloom.
  63693. */
  63694. threshold: number;
  63695. /**
  63696. * The strength of the bloom.
  63697. */
  63698. weight: number;
  63699. /**
  63700. * Specifies the size of the bloom blur kernel, relative to the final output size
  63701. */
  63702. kernel: number;
  63703. /**
  63704. * Creates a new instance of @see BloomEffect
  63705. * @param scene The scene the effect belongs to.
  63706. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  63707. * @param bloomKernel The size of the kernel to be used when applying the blur.
  63708. * @param bloomWeight The the strength of bloom.
  63709. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  63710. * @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)
  63711. */
  63712. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  63713. /**
  63714. * Disposes each of the internal effects for a given camera.
  63715. * @param camera The camera to dispose the effect on.
  63716. */
  63717. disposeEffects(camera: Camera): void;
  63718. /**
  63719. * @hidden Internal
  63720. */
  63721. _updateEffects(): void;
  63722. /**
  63723. * Internal
  63724. * @returns if all the contained post processes are ready.
  63725. * @hidden
  63726. */
  63727. _isReady(): boolean;
  63728. }
  63729. }
  63730. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  63731. /** @hidden */
  63732. export var chromaticAberrationPixelShader: {
  63733. name: string;
  63734. shader: string;
  63735. };
  63736. }
  63737. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  63738. import { Vector2 } from "babylonjs/Maths/math.vector";
  63739. import { Nullable } from "babylonjs/types";
  63740. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63741. import { Camera } from "babylonjs/Cameras/camera";
  63742. import { Engine } from "babylonjs/Engines/engine";
  63743. import "babylonjs/Shaders/chromaticAberration.fragment";
  63744. /**
  63745. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  63746. */
  63747. export class ChromaticAberrationPostProcess extends PostProcess {
  63748. /**
  63749. * The amount of seperation of rgb channels (default: 30)
  63750. */
  63751. aberrationAmount: number;
  63752. /**
  63753. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  63754. */
  63755. radialIntensity: number;
  63756. /**
  63757. * 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))
  63758. */
  63759. direction: Vector2;
  63760. /**
  63761. * 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))
  63762. */
  63763. centerPosition: Vector2;
  63764. /**
  63765. * Creates a new instance ChromaticAberrationPostProcess
  63766. * @param name The name of the effect.
  63767. * @param screenWidth The width of the screen to apply the effect on.
  63768. * @param screenHeight The height of the screen to apply the effect on.
  63769. * @param options The required width/height ratio to downsize to before computing the render pass.
  63770. * @param camera The camera to apply the render pass to.
  63771. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63772. * @param engine The engine which the post process will be applied. (default: current engine)
  63773. * @param reusable If the post process can be reused on the same frame. (default: false)
  63774. * @param textureType Type of textures used when performing the post process. (default: 0)
  63775. * @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)
  63776. */
  63777. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  63778. }
  63779. }
  63780. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  63781. /** @hidden */
  63782. export var circleOfConfusionPixelShader: {
  63783. name: string;
  63784. shader: string;
  63785. };
  63786. }
  63787. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  63788. import { Nullable } from "babylonjs/types";
  63789. import { Engine } from "babylonjs/Engines/engine";
  63790. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63791. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  63792. import { Camera } from "babylonjs/Cameras/camera";
  63793. import "babylonjs/Shaders/circleOfConfusion.fragment";
  63794. /**
  63795. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  63796. */
  63797. export class CircleOfConfusionPostProcess extends PostProcess {
  63798. /**
  63799. * 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.
  63800. */
  63801. lensSize: number;
  63802. /**
  63803. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  63804. */
  63805. fStop: number;
  63806. /**
  63807. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  63808. */
  63809. focusDistance: number;
  63810. /**
  63811. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  63812. */
  63813. focalLength: number;
  63814. private _depthTexture;
  63815. /**
  63816. * Creates a new instance CircleOfConfusionPostProcess
  63817. * @param name The name of the effect.
  63818. * @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.
  63819. * @param options The required width/height ratio to downsize to before computing the render pass.
  63820. * @param camera The camera to apply the render pass to.
  63821. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63822. * @param engine The engine which the post process will be applied. (default: current engine)
  63823. * @param reusable If the post process can be reused on the same frame. (default: false)
  63824. * @param textureType Type of textures used when performing the post process. (default: 0)
  63825. * @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)
  63826. */
  63827. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  63828. /**
  63829. * 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.
  63830. */
  63831. depthTexture: RenderTargetTexture;
  63832. }
  63833. }
  63834. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  63835. /** @hidden */
  63836. export var colorCorrectionPixelShader: {
  63837. name: string;
  63838. shader: string;
  63839. };
  63840. }
  63841. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  63842. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63843. import { Engine } from "babylonjs/Engines/engine";
  63844. import { Camera } from "babylonjs/Cameras/camera";
  63845. import "babylonjs/Shaders/colorCorrection.fragment";
  63846. /**
  63847. *
  63848. * This post-process allows the modification of rendered colors by using
  63849. * a 'look-up table' (LUT). This effect is also called Color Grading.
  63850. *
  63851. * The object needs to be provided an url to a texture containing the color
  63852. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  63853. * Use an image editing software to tweak the LUT to match your needs.
  63854. *
  63855. * For an example of a color LUT, see here:
  63856. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  63857. * For explanations on color grading, see here:
  63858. * @see http://udn.epicgames.com/Three/ColorGrading.html
  63859. *
  63860. */
  63861. export class ColorCorrectionPostProcess extends PostProcess {
  63862. private _colorTableTexture;
  63863. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  63864. }
  63865. }
  63866. declare module "babylonjs/Shaders/convolution.fragment" {
  63867. /** @hidden */
  63868. export var convolutionPixelShader: {
  63869. name: string;
  63870. shader: string;
  63871. };
  63872. }
  63873. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  63874. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63875. import { Nullable } from "babylonjs/types";
  63876. import { Camera } from "babylonjs/Cameras/camera";
  63877. import { Engine } from "babylonjs/Engines/engine";
  63878. import "babylonjs/Shaders/convolution.fragment";
  63879. /**
  63880. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  63881. * input texture to perform effects such as edge detection or sharpening
  63882. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  63883. */
  63884. export class ConvolutionPostProcess extends PostProcess {
  63885. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  63886. kernel: number[];
  63887. /**
  63888. * Creates a new instance ConvolutionPostProcess
  63889. * @param name The name of the effect.
  63890. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  63891. * @param options The required width/height ratio to downsize to before computing the render pass.
  63892. * @param camera The camera to apply the render pass to.
  63893. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63894. * @param engine The engine which the post process will be applied. (default: current engine)
  63895. * @param reusable If the post process can be reused on the same frame. (default: false)
  63896. * @param textureType Type of textures used when performing the post process. (default: 0)
  63897. */
  63898. constructor(name: string,
  63899. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  63900. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  63901. /**
  63902. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  63903. */
  63904. static EdgeDetect0Kernel: number[];
  63905. /**
  63906. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  63907. */
  63908. static EdgeDetect1Kernel: number[];
  63909. /**
  63910. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  63911. */
  63912. static EdgeDetect2Kernel: number[];
  63913. /**
  63914. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  63915. */
  63916. static SharpenKernel: number[];
  63917. /**
  63918. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  63919. */
  63920. static EmbossKernel: number[];
  63921. /**
  63922. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  63923. */
  63924. static GaussianKernel: number[];
  63925. }
  63926. }
  63927. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  63928. import { Nullable } from "babylonjs/types";
  63929. import { Vector2 } from "babylonjs/Maths/math.vector";
  63930. import { Camera } from "babylonjs/Cameras/camera";
  63931. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63932. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  63933. import { Engine } from "babylonjs/Engines/engine";
  63934. import { Scene } from "babylonjs/scene";
  63935. /**
  63936. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  63937. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  63938. * based on samples that have a large difference in distance than the center pixel.
  63939. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  63940. */
  63941. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  63942. direction: Vector2;
  63943. /**
  63944. * Creates a new instance CircleOfConfusionPostProcess
  63945. * @param name The name of the effect.
  63946. * @param scene The scene the effect belongs to.
  63947. * @param direction The direction the blur should be applied.
  63948. * @param kernel The size of the kernel used to blur.
  63949. * @param options The required width/height ratio to downsize to before computing the render pass.
  63950. * @param camera The camera to apply the render pass to.
  63951. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  63952. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  63953. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63954. * @param engine The engine which the post process will be applied. (default: current engine)
  63955. * @param reusable If the post process can be reused on the same frame. (default: false)
  63956. * @param textureType Type of textures used when performing the post process. (default: 0)
  63957. * @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)
  63958. */
  63959. 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);
  63960. }
  63961. }
  63962. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  63963. /** @hidden */
  63964. export var depthOfFieldMergePixelShader: {
  63965. name: string;
  63966. shader: string;
  63967. };
  63968. }
  63969. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  63970. import { Nullable } from "babylonjs/types";
  63971. import { Camera } from "babylonjs/Cameras/camera";
  63972. import { Effect } from "babylonjs/Materials/effect";
  63973. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63974. import { Engine } from "babylonjs/Engines/engine";
  63975. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  63976. /**
  63977. * Options to be set when merging outputs from the default pipeline.
  63978. */
  63979. export class DepthOfFieldMergePostProcessOptions {
  63980. /**
  63981. * The original image to merge on top of
  63982. */
  63983. originalFromInput: PostProcess;
  63984. /**
  63985. * Parameters to perform the merge of the depth of field effect
  63986. */
  63987. depthOfField?: {
  63988. circleOfConfusion: PostProcess;
  63989. blurSteps: Array<PostProcess>;
  63990. };
  63991. /**
  63992. * Parameters to perform the merge of bloom effect
  63993. */
  63994. bloom?: {
  63995. blurred: PostProcess;
  63996. weight: number;
  63997. };
  63998. }
  63999. /**
  64000. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  64001. */
  64002. export class DepthOfFieldMergePostProcess extends PostProcess {
  64003. private blurSteps;
  64004. /**
  64005. * Creates a new instance of DepthOfFieldMergePostProcess
  64006. * @param name The name of the effect.
  64007. * @param originalFromInput Post process which's input will be used for the merge.
  64008. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  64009. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  64010. * @param options The required width/height ratio to downsize to before computing the render pass.
  64011. * @param camera The camera to apply the render pass to.
  64012. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64013. * @param engine The engine which the post process will be applied. (default: current engine)
  64014. * @param reusable If the post process can be reused on the same frame. (default: false)
  64015. * @param textureType Type of textures used when performing the post process. (default: 0)
  64016. * @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)
  64017. */
  64018. 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);
  64019. /**
  64020. * Updates the effect with the current post process compile time values and recompiles the shader.
  64021. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  64022. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  64023. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  64024. * @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
  64025. * @param onCompiled Called when the shader has been compiled.
  64026. * @param onError Called if there is an error when compiling a shader.
  64027. */
  64028. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  64029. }
  64030. }
  64031. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  64032. import { Nullable } from "babylonjs/types";
  64033. import { Camera } from "babylonjs/Cameras/camera";
  64034. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  64035. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  64036. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  64037. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  64038. import { Scene } from "babylonjs/scene";
  64039. /**
  64040. * Specifies the level of max blur that should be applied when using the depth of field effect
  64041. */
  64042. export enum DepthOfFieldEffectBlurLevel {
  64043. /**
  64044. * Subtle blur
  64045. */
  64046. Low = 0,
  64047. /**
  64048. * Medium blur
  64049. */
  64050. Medium = 1,
  64051. /**
  64052. * Large blur
  64053. */
  64054. High = 2
  64055. }
  64056. /**
  64057. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  64058. */
  64059. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  64060. private _circleOfConfusion;
  64061. /**
  64062. * @hidden Internal, blurs from high to low
  64063. */
  64064. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  64065. private _depthOfFieldBlurY;
  64066. private _dofMerge;
  64067. /**
  64068. * @hidden Internal post processes in depth of field effect
  64069. */
  64070. _effects: Array<PostProcess>;
  64071. /**
  64072. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  64073. */
  64074. focalLength: number;
  64075. /**
  64076. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  64077. */
  64078. fStop: number;
  64079. /**
  64080. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  64081. */
  64082. focusDistance: number;
  64083. /**
  64084. * 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.
  64085. */
  64086. lensSize: number;
  64087. /**
  64088. * Creates a new instance DepthOfFieldEffect
  64089. * @param scene The scene the effect belongs to.
  64090. * @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.
  64091. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  64092. * @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)
  64093. */
  64094. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  64095. /**
  64096. * Get the current class name of the current effet
  64097. * @returns "DepthOfFieldEffect"
  64098. */
  64099. getClassName(): string;
  64100. /**
  64101. * 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.
  64102. */
  64103. depthTexture: RenderTargetTexture;
  64104. /**
  64105. * Disposes each of the internal effects for a given camera.
  64106. * @param camera The camera to dispose the effect on.
  64107. */
  64108. disposeEffects(camera: Camera): void;
  64109. /**
  64110. * @hidden Internal
  64111. */
  64112. _updateEffects(): void;
  64113. /**
  64114. * Internal
  64115. * @returns if all the contained post processes are ready.
  64116. * @hidden
  64117. */
  64118. _isReady(): boolean;
  64119. }
  64120. }
  64121. declare module "babylonjs/Shaders/displayPass.fragment" {
  64122. /** @hidden */
  64123. export var displayPassPixelShader: {
  64124. name: string;
  64125. shader: string;
  64126. };
  64127. }
  64128. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  64129. import { Nullable } from "babylonjs/types";
  64130. import { Camera } from "babylonjs/Cameras/camera";
  64131. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  64132. import { Engine } from "babylonjs/Engines/engine";
  64133. import "babylonjs/Shaders/displayPass.fragment";
  64134. /**
  64135. * DisplayPassPostProcess which produces an output the same as it's input
  64136. */
  64137. export class DisplayPassPostProcess extends PostProcess {
  64138. /**
  64139. * Creates the DisplayPassPostProcess
  64140. * @param name The name of the effect.
  64141. * @param options The required width/height ratio to downsize to before computing the render pass.
  64142. * @param camera The camera to apply the render pass to.
  64143. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64144. * @param engine The engine which the post process will be applied. (default: current engine)
  64145. * @param reusable If the post process can be reused on the same frame. (default: false)
  64146. */
  64147. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  64148. }
  64149. }
  64150. declare module "babylonjs/Shaders/filter.fragment" {
  64151. /** @hidden */
  64152. export var filterPixelShader: {
  64153. name: string;
  64154. shader: string;
  64155. };
  64156. }
  64157. declare module "babylonjs/PostProcesses/filterPostProcess" {
  64158. import { Nullable } from "babylonjs/types";
  64159. import { Matrix } from "babylonjs/Maths/math.vector";
  64160. import { Camera } from "babylonjs/Cameras/camera";
  64161. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  64162. import { Engine } from "babylonjs/Engines/engine";
  64163. import "babylonjs/Shaders/filter.fragment";
  64164. /**
  64165. * Applies a kernel filter to the image
  64166. */
  64167. export class FilterPostProcess extends PostProcess {
  64168. /** The matrix to be applied to the image */
  64169. kernelMatrix: Matrix;
  64170. /**
  64171. *
  64172. * @param name The name of the effect.
  64173. * @param kernelMatrix The matrix to be applied to the image
  64174. * @param options The required width/height ratio to downsize to before computing the render pass.
  64175. * @param camera The camera to apply the render pass to.
  64176. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64177. * @param engine The engine which the post process will be applied. (default: current engine)
  64178. * @param reusable If the post process can be reused on the same frame. (default: false)
  64179. */
  64180. constructor(name: string,
  64181. /** The matrix to be applied to the image */
  64182. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  64183. }
  64184. }
  64185. declare module "babylonjs/Shaders/fxaa.fragment" {
  64186. /** @hidden */
  64187. export var fxaaPixelShader: {
  64188. name: string;
  64189. shader: string;
  64190. };
  64191. }
  64192. declare module "babylonjs/Shaders/fxaa.vertex" {
  64193. /** @hidden */
  64194. export var fxaaVertexShader: {
  64195. name: string;
  64196. shader: string;
  64197. };
  64198. }
  64199. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  64200. import { Nullable } from "babylonjs/types";
  64201. import { Camera } from "babylonjs/Cameras/camera";
  64202. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  64203. import { Engine } from "babylonjs/Engines/engine";
  64204. import "babylonjs/Shaders/fxaa.fragment";
  64205. import "babylonjs/Shaders/fxaa.vertex";
  64206. /**
  64207. * Fxaa post process
  64208. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  64209. */
  64210. export class FxaaPostProcess extends PostProcess {
  64211. /** @hidden */
  64212. texelWidth: number;
  64213. /** @hidden */
  64214. texelHeight: number;
  64215. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  64216. private _getDefines;
  64217. }
  64218. }
  64219. declare module "babylonjs/Shaders/grain.fragment" {
  64220. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  64221. /** @hidden */
  64222. export var grainPixelShader: {
  64223. name: string;
  64224. shader: string;
  64225. };
  64226. }
  64227. declare module "babylonjs/PostProcesses/grainPostProcess" {
  64228. import { Nullable } from "babylonjs/types";
  64229. import { Camera } from "babylonjs/Cameras/camera";
  64230. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  64231. import { Engine } from "babylonjs/Engines/engine";
  64232. import "babylonjs/Shaders/grain.fragment";
  64233. /**
  64234. * The GrainPostProcess adds noise to the image at mid luminance levels
  64235. */
  64236. export class GrainPostProcess extends PostProcess {
  64237. /**
  64238. * The intensity of the grain added (default: 30)
  64239. */
  64240. intensity: number;
  64241. /**
  64242. * If the grain should be randomized on every frame
  64243. */
  64244. animated: boolean;
  64245. /**
  64246. * Creates a new instance of @see GrainPostProcess
  64247. * @param name The name of the effect.
  64248. * @param options The required width/height ratio to downsize to before computing the render pass.
  64249. * @param camera The camera to apply the render pass to.
  64250. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64251. * @param engine The engine which the post process will be applied. (default: current engine)
  64252. * @param reusable If the post process can be reused on the same frame. (default: false)
  64253. * @param textureType Type of textures used when performing the post process. (default: 0)
  64254. * @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)
  64255. */
  64256. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64257. }
  64258. }
  64259. declare module "babylonjs/Shaders/highlights.fragment" {
  64260. /** @hidden */
  64261. export var highlightsPixelShader: {
  64262. name: string;
  64263. shader: string;
  64264. };
  64265. }
  64266. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  64267. import { Nullable } from "babylonjs/types";
  64268. import { Camera } from "babylonjs/Cameras/camera";
  64269. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  64270. import { Engine } from "babylonjs/Engines/engine";
  64271. import "babylonjs/Shaders/highlights.fragment";
  64272. /**
  64273. * Extracts highlights from the image
  64274. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  64275. */
  64276. export class HighlightsPostProcess extends PostProcess {
  64277. /**
  64278. * Extracts highlights from the image
  64279. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  64280. * @param name The name of the effect.
  64281. * @param options The required width/height ratio to downsize to before computing the render pass.
  64282. * @param camera The camera to apply the render pass to.
  64283. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64284. * @param engine The engine which the post process will be applied. (default: current engine)
  64285. * @param reusable If the post process can be reused on the same frame. (default: false)
  64286. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  64287. */
  64288. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  64289. }
  64290. }
  64291. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  64292. /** @hidden */
  64293. export var mrtFragmentDeclaration: {
  64294. name: string;
  64295. shader: string;
  64296. };
  64297. }
  64298. declare module "babylonjs/Shaders/geometry.fragment" {
  64299. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  64300. /** @hidden */
  64301. export var geometryPixelShader: {
  64302. name: string;
  64303. shader: string;
  64304. };
  64305. }
  64306. declare module "babylonjs/Shaders/geometry.vertex" {
  64307. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  64308. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  64309. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  64310. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  64311. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  64312. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  64313. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  64314. /** @hidden */
  64315. export var geometryVertexShader: {
  64316. name: string;
  64317. shader: string;
  64318. };
  64319. }
  64320. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  64321. import { Matrix } from "babylonjs/Maths/math.vector";
  64322. import { SubMesh } from "babylonjs/Meshes/subMesh";
  64323. import { Mesh } from "babylonjs/Meshes/mesh";
  64324. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  64325. import { Effect } from "babylonjs/Materials/effect";
  64326. import { Scene } from "babylonjs/scene";
  64327. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64328. import "babylonjs/Shaders/geometry.fragment";
  64329. import "babylonjs/Shaders/geometry.vertex";
  64330. /** @hidden */
  64331. interface ISavedTransformationMatrix {
  64332. world: Matrix;
  64333. viewProjection: Matrix;
  64334. }
  64335. /**
  64336. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  64337. */
  64338. export class GeometryBufferRenderer {
  64339. /**
  64340. * Constant used to retrieve the position texture index in the G-Buffer textures array
  64341. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  64342. */
  64343. static readonly POSITION_TEXTURE_TYPE: number;
  64344. /**
  64345. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  64346. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  64347. */
  64348. static readonly VELOCITY_TEXTURE_TYPE: number;
  64349. /**
  64350. * Dictionary used to store the previous transformation matrices of each rendered mesh
  64351. * in order to compute objects velocities when enableVelocity is set to "true"
  64352. * @hidden
  64353. */
  64354. _previousTransformationMatrices: {
  64355. [index: number]: ISavedTransformationMatrix;
  64356. };
  64357. /**
  64358. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  64359. * in order to compute objects velocities when enableVelocity is set to "true"
  64360. * @hidden
  64361. */
  64362. _previousBonesTransformationMatrices: {
  64363. [index: number]: Float32Array;
  64364. };
  64365. /**
  64366. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  64367. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  64368. */
  64369. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  64370. private _scene;
  64371. private _multiRenderTarget;
  64372. private _ratio;
  64373. private _enablePosition;
  64374. private _enableVelocity;
  64375. private _positionIndex;
  64376. private _velocityIndex;
  64377. protected _effect: Effect;
  64378. protected _cachedDefines: string;
  64379. /**
  64380. * Set the render list (meshes to be rendered) used in the G buffer.
  64381. */
  64382. renderList: Mesh[];
  64383. /**
  64384. * Gets wether or not G buffer are supported by the running hardware.
  64385. * This requires draw buffer supports
  64386. */
  64387. readonly isSupported: boolean;
  64388. /**
  64389. * Returns the index of the given texture type in the G-Buffer textures array
  64390. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  64391. * @returns the index of the given texture type in the G-Buffer textures array
  64392. */
  64393. getTextureIndex(textureType: number): number;
  64394. /**
  64395. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  64396. */
  64397. /**
  64398. * Sets whether or not objects positions are enabled for the G buffer.
  64399. */
  64400. enablePosition: boolean;
  64401. /**
  64402. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  64403. */
  64404. /**
  64405. * Sets wether or not objects velocities are enabled for the G buffer.
  64406. */
  64407. enableVelocity: boolean;
  64408. /**
  64409. * Gets the scene associated with the buffer.
  64410. */
  64411. readonly scene: Scene;
  64412. /**
  64413. * Gets the ratio used by the buffer during its creation.
  64414. * How big is the buffer related to the main canvas.
  64415. */
  64416. readonly ratio: number;
  64417. /** @hidden */
  64418. static _SceneComponentInitialization: (scene: Scene) => void;
  64419. /**
  64420. * Creates a new G Buffer for the scene
  64421. * @param scene The scene the buffer belongs to
  64422. * @param ratio How big is the buffer related to the main canvas.
  64423. */
  64424. constructor(scene: Scene, ratio?: number);
  64425. /**
  64426. * Checks wether everything is ready to render a submesh to the G buffer.
  64427. * @param subMesh the submesh to check readiness for
  64428. * @param useInstances is the mesh drawn using instance or not
  64429. * @returns true if ready otherwise false
  64430. */
  64431. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  64432. /**
  64433. * Gets the current underlying G Buffer.
  64434. * @returns the buffer
  64435. */
  64436. getGBuffer(): MultiRenderTarget;
  64437. /**
  64438. * Gets the number of samples used to render the buffer (anti aliasing).
  64439. */
  64440. /**
  64441. * Sets the number of samples used to render the buffer (anti aliasing).
  64442. */
  64443. samples: number;
  64444. /**
  64445. * Disposes the renderer and frees up associated resources.
  64446. */
  64447. dispose(): void;
  64448. protected _createRenderTargets(): void;
  64449. private _copyBonesTransformationMatrices;
  64450. }
  64451. }
  64452. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  64453. import { Nullable } from "babylonjs/types";
  64454. import { Scene } from "babylonjs/scene";
  64455. import { ISceneComponent } from "babylonjs/sceneComponent";
  64456. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  64457. module "babylonjs/scene" {
  64458. interface Scene {
  64459. /** @hidden (Backing field) */
  64460. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  64461. /**
  64462. * Gets or Sets the current geometry buffer associated to the scene.
  64463. */
  64464. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  64465. /**
  64466. * Enables a GeometryBufferRender and associates it with the scene
  64467. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  64468. * @returns the GeometryBufferRenderer
  64469. */
  64470. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  64471. /**
  64472. * Disables the GeometryBufferRender associated with the scene
  64473. */
  64474. disableGeometryBufferRenderer(): void;
  64475. }
  64476. }
  64477. /**
  64478. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  64479. * in several rendering techniques.
  64480. */
  64481. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  64482. /**
  64483. * The component name helpful to identify the component in the list of scene components.
  64484. */
  64485. readonly name: string;
  64486. /**
  64487. * The scene the component belongs to.
  64488. */
  64489. scene: Scene;
  64490. /**
  64491. * Creates a new instance of the component for the given scene
  64492. * @param scene Defines the scene to register the component in
  64493. */
  64494. constructor(scene: Scene);
  64495. /**
  64496. * Registers the component in a given scene
  64497. */
  64498. register(): void;
  64499. /**
  64500. * Rebuilds the elements related to this component in case of
  64501. * context lost for instance.
  64502. */
  64503. rebuild(): void;
  64504. /**
  64505. * Disposes the component and the associated ressources
  64506. */
  64507. dispose(): void;
  64508. private _gatherRenderTargets;
  64509. }
  64510. }
  64511. declare module "babylonjs/Shaders/motionBlur.fragment" {
  64512. /** @hidden */
  64513. export var motionBlurPixelShader: {
  64514. name: string;
  64515. shader: string;
  64516. };
  64517. }
  64518. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  64519. import { Nullable } from "babylonjs/types";
  64520. import { Camera } from "babylonjs/Cameras/camera";
  64521. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  64522. import { Scene } from "babylonjs/scene";
  64523. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64524. import "babylonjs/Animations/animatable";
  64525. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  64526. import "babylonjs/Shaders/motionBlur.fragment";
  64527. import { Engine } from "babylonjs/Engines/engine";
  64528. /**
  64529. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  64530. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  64531. * As an example, all you have to do is to create the post-process:
  64532. * var mb = new BABYLON.MotionBlurPostProcess(
  64533. * 'mb', // The name of the effect.
  64534. * scene, // The scene containing the objects to blur according to their velocity.
  64535. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  64536. * camera // The camera to apply the render pass to.
  64537. * );
  64538. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  64539. */
  64540. export class MotionBlurPostProcess extends PostProcess {
  64541. /**
  64542. * Defines how much the image is blurred by the movement. Default value is equal to 1
  64543. */
  64544. motionStrength: number;
  64545. /**
  64546. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  64547. */
  64548. /**
  64549. * Sets the number of iterations to be used for motion blur quality
  64550. */
  64551. motionBlurSamples: number;
  64552. private _motionBlurSamples;
  64553. private _geometryBufferRenderer;
  64554. /**
  64555. * Creates a new instance MotionBlurPostProcess
  64556. * @param name The name of the effect.
  64557. * @param scene The scene containing the objects to blur according to their velocity.
  64558. * @param options The required width/height ratio to downsize to before computing the render pass.
  64559. * @param camera The camera to apply the render pass to.
  64560. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64561. * @param engine The engine which the post process will be applied. (default: current engine)
  64562. * @param reusable If the post process can be reused on the same frame. (default: false)
  64563. * @param textureType Type of textures used when performing the post process. (default: 0)
  64564. * @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)
  64565. */
  64566. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64567. /**
  64568. * Excludes the given skinned mesh from computing bones velocities.
  64569. * 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.
  64570. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  64571. */
  64572. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  64573. /**
  64574. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  64575. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  64576. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  64577. */
  64578. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  64579. /**
  64580. * Disposes the post process.
  64581. * @param camera The camera to dispose the post process on.
  64582. */
  64583. dispose(camera?: Camera): void;
  64584. }
  64585. }
  64586. declare module "babylonjs/Shaders/refraction.fragment" {
  64587. /** @hidden */
  64588. export var refractionPixelShader: {
  64589. name: string;
  64590. shader: string;
  64591. };
  64592. }
  64593. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  64594. import { Color3 } from "babylonjs/Maths/math.color";
  64595. import { Camera } from "babylonjs/Cameras/camera";
  64596. import { Texture } from "babylonjs/Materials/Textures/texture";
  64597. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  64598. import { Engine } from "babylonjs/Engines/engine";
  64599. import "babylonjs/Shaders/refraction.fragment";
  64600. /**
  64601. * Post process which applies a refractin texture
  64602. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  64603. */
  64604. export class RefractionPostProcess extends PostProcess {
  64605. /** the base color of the refraction (used to taint the rendering) */
  64606. color: Color3;
  64607. /** simulated refraction depth */
  64608. depth: number;
  64609. /** the coefficient of the base color (0 to remove base color tainting) */
  64610. colorLevel: number;
  64611. private _refTexture;
  64612. private _ownRefractionTexture;
  64613. /**
  64614. * Gets or sets the refraction texture
  64615. * Please note that you are responsible for disposing the texture if you set it manually
  64616. */
  64617. refractionTexture: Texture;
  64618. /**
  64619. * Initializes the RefractionPostProcess
  64620. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  64621. * @param name The name of the effect.
  64622. * @param refractionTextureUrl Url of the refraction texture to use
  64623. * @param color the base color of the refraction (used to taint the rendering)
  64624. * @param depth simulated refraction depth
  64625. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  64626. * @param camera The camera to apply the render pass to.
  64627. * @param options The required width/height ratio to downsize to before computing the render pass.
  64628. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64629. * @param engine The engine which the post process will be applied. (default: current engine)
  64630. * @param reusable If the post process can be reused on the same frame. (default: false)
  64631. */
  64632. constructor(name: string, refractionTextureUrl: string,
  64633. /** the base color of the refraction (used to taint the rendering) */
  64634. color: Color3,
  64635. /** simulated refraction depth */
  64636. depth: number,
  64637. /** the coefficient of the base color (0 to remove base color tainting) */
  64638. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  64639. /**
  64640. * Disposes of the post process
  64641. * @param camera Camera to dispose post process on
  64642. */
  64643. dispose(camera: Camera): void;
  64644. }
  64645. }
  64646. declare module "babylonjs/Shaders/sharpen.fragment" {
  64647. /** @hidden */
  64648. export var sharpenPixelShader: {
  64649. name: string;
  64650. shader: string;
  64651. };
  64652. }
  64653. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  64654. import { Nullable } from "babylonjs/types";
  64655. import { Camera } from "babylonjs/Cameras/camera";
  64656. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  64657. import "babylonjs/Shaders/sharpen.fragment";
  64658. import { Engine } from "babylonjs/Engines/engine";
  64659. /**
  64660. * The SharpenPostProcess applies a sharpen kernel to every pixel
  64661. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  64662. */
  64663. export class SharpenPostProcess extends PostProcess {
  64664. /**
  64665. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  64666. */
  64667. colorAmount: number;
  64668. /**
  64669. * How much sharpness should be applied (default: 0.3)
  64670. */
  64671. edgeAmount: number;
  64672. /**
  64673. * Creates a new instance ConvolutionPostProcess
  64674. * @param name The name of the effect.
  64675. * @param options The required width/height ratio to downsize to before computing the render pass.
  64676. * @param camera The camera to apply the render pass to.
  64677. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64678. * @param engine The engine which the post process will be applied. (default: current engine)
  64679. * @param reusable If the post process can be reused on the same frame. (default: false)
  64680. * @param textureType Type of textures used when performing the post process. (default: 0)
  64681. * @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)
  64682. */
  64683. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64684. }
  64685. }
  64686. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  64687. import { Nullable } from "babylonjs/types";
  64688. import { Camera } from "babylonjs/Cameras/camera";
  64689. import { Engine } from "babylonjs/Engines/engine";
  64690. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  64691. import { IInspectable } from "babylonjs/Misc/iInspectable";
  64692. /**
  64693. * PostProcessRenderPipeline
  64694. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  64695. */
  64696. export class PostProcessRenderPipeline {
  64697. private engine;
  64698. private _renderEffects;
  64699. private _renderEffectsForIsolatedPass;
  64700. /**
  64701. * List of inspectable custom properties (used by the Inspector)
  64702. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  64703. */
  64704. inspectableCustomProperties: IInspectable[];
  64705. /**
  64706. * @hidden
  64707. */
  64708. protected _cameras: Camera[];
  64709. /** @hidden */
  64710. _name: string;
  64711. /**
  64712. * Gets pipeline name
  64713. */
  64714. readonly name: string;
  64715. /** Gets the list of attached cameras */
  64716. readonly cameras: Camera[];
  64717. /**
  64718. * Initializes a PostProcessRenderPipeline
  64719. * @param engine engine to add the pipeline to
  64720. * @param name name of the pipeline
  64721. */
  64722. constructor(engine: Engine, name: string);
  64723. /**
  64724. * Gets the class name
  64725. * @returns "PostProcessRenderPipeline"
  64726. */
  64727. getClassName(): string;
  64728. /**
  64729. * If all the render effects in the pipeline are supported
  64730. */
  64731. readonly isSupported: boolean;
  64732. /**
  64733. * Adds an effect to the pipeline
  64734. * @param renderEffect the effect to add
  64735. */
  64736. addEffect(renderEffect: PostProcessRenderEffect): void;
  64737. /** @hidden */
  64738. _rebuild(): void;
  64739. /** @hidden */
  64740. _enableEffect(renderEffectName: string, cameras: Camera): void;
  64741. /** @hidden */
  64742. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  64743. /** @hidden */
  64744. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  64745. /** @hidden */
  64746. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  64747. /** @hidden */
  64748. _attachCameras(cameras: Camera, unique: boolean): void;
  64749. /** @hidden */
  64750. _attachCameras(cameras: Camera[], unique: boolean): void;
  64751. /** @hidden */
  64752. _detachCameras(cameras: Camera): void;
  64753. /** @hidden */
  64754. _detachCameras(cameras: Nullable<Camera[]>): void;
  64755. /** @hidden */
  64756. _update(): void;
  64757. /** @hidden */
  64758. _reset(): void;
  64759. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  64760. /**
  64761. * Disposes of the pipeline
  64762. */
  64763. dispose(): void;
  64764. }
  64765. }
  64766. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  64767. import { Camera } from "babylonjs/Cameras/camera";
  64768. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  64769. /**
  64770. * PostProcessRenderPipelineManager class
  64771. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  64772. */
  64773. export class PostProcessRenderPipelineManager {
  64774. private _renderPipelines;
  64775. /**
  64776. * Initializes a PostProcessRenderPipelineManager
  64777. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  64778. */
  64779. constructor();
  64780. /**
  64781. * Gets the list of supported render pipelines
  64782. */
  64783. readonly supportedPipelines: PostProcessRenderPipeline[];
  64784. /**
  64785. * Adds a pipeline to the manager
  64786. * @param renderPipeline The pipeline to add
  64787. */
  64788. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  64789. /**
  64790. * Attaches a camera to the pipeline
  64791. * @param renderPipelineName The name of the pipeline to attach to
  64792. * @param cameras the camera to attach
  64793. * @param unique if the camera can be attached multiple times to the pipeline
  64794. */
  64795. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  64796. /**
  64797. * Detaches a camera from the pipeline
  64798. * @param renderPipelineName The name of the pipeline to detach from
  64799. * @param cameras the camera to detach
  64800. */
  64801. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  64802. /**
  64803. * Enables an effect by name on a pipeline
  64804. * @param renderPipelineName the name of the pipeline to enable the effect in
  64805. * @param renderEffectName the name of the effect to enable
  64806. * @param cameras the cameras that the effect should be enabled on
  64807. */
  64808. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  64809. /**
  64810. * Disables an effect by name on a pipeline
  64811. * @param renderPipelineName the name of the pipeline to disable the effect in
  64812. * @param renderEffectName the name of the effect to disable
  64813. * @param cameras the cameras that the effect should be disabled on
  64814. */
  64815. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  64816. /**
  64817. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  64818. */
  64819. update(): void;
  64820. /** @hidden */
  64821. _rebuild(): void;
  64822. /**
  64823. * Disposes of the manager and pipelines
  64824. */
  64825. dispose(): void;
  64826. }
  64827. }
  64828. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  64829. import { ISceneComponent } from "babylonjs/sceneComponent";
  64830. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  64831. import { Scene } from "babylonjs/scene";
  64832. module "babylonjs/scene" {
  64833. interface Scene {
  64834. /** @hidden (Backing field) */
  64835. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  64836. /**
  64837. * Gets the postprocess render pipeline manager
  64838. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  64839. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  64840. */
  64841. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  64842. }
  64843. }
  64844. /**
  64845. * Defines the Render Pipeline scene component responsible to rendering pipelines
  64846. */
  64847. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  64848. /**
  64849. * The component name helpfull to identify the component in the list of scene components.
  64850. */
  64851. readonly name: string;
  64852. /**
  64853. * The scene the component belongs to.
  64854. */
  64855. scene: Scene;
  64856. /**
  64857. * Creates a new instance of the component for the given scene
  64858. * @param scene Defines the scene to register the component in
  64859. */
  64860. constructor(scene: Scene);
  64861. /**
  64862. * Registers the component in a given scene
  64863. */
  64864. register(): void;
  64865. /**
  64866. * Rebuilds the elements related to this component in case of
  64867. * context lost for instance.
  64868. */
  64869. rebuild(): void;
  64870. /**
  64871. * Disposes the component and the associated ressources
  64872. */
  64873. dispose(): void;
  64874. private _gatherRenderTargets;
  64875. }
  64876. }
  64877. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  64878. import { Nullable } from "babylonjs/types";
  64879. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  64880. import { Camera } from "babylonjs/Cameras/camera";
  64881. import { IDisposable } from "babylonjs/scene";
  64882. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  64883. import { Scene } from "babylonjs/scene";
  64884. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  64885. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  64886. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  64887. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  64888. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  64889. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  64890. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  64891. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  64892. import { Animation } from "babylonjs/Animations/animation";
  64893. /**
  64894. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  64895. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  64896. */
  64897. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  64898. private _scene;
  64899. private _camerasToBeAttached;
  64900. /**
  64901. * ID of the sharpen post process,
  64902. */
  64903. private readonly SharpenPostProcessId;
  64904. /**
  64905. * @ignore
  64906. * ID of the image processing post process;
  64907. */
  64908. readonly ImageProcessingPostProcessId: string;
  64909. /**
  64910. * @ignore
  64911. * ID of the Fast Approximate Anti-Aliasing post process;
  64912. */
  64913. readonly FxaaPostProcessId: string;
  64914. /**
  64915. * ID of the chromatic aberration post process,
  64916. */
  64917. private readonly ChromaticAberrationPostProcessId;
  64918. /**
  64919. * ID of the grain post process
  64920. */
  64921. private readonly GrainPostProcessId;
  64922. /**
  64923. * Sharpen post process which will apply a sharpen convolution to enhance edges
  64924. */
  64925. sharpen: SharpenPostProcess;
  64926. private _sharpenEffect;
  64927. private bloom;
  64928. /**
  64929. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  64930. */
  64931. depthOfField: DepthOfFieldEffect;
  64932. /**
  64933. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  64934. */
  64935. fxaa: FxaaPostProcess;
  64936. /**
  64937. * Image post processing pass used to perform operations such as tone mapping or color grading.
  64938. */
  64939. imageProcessing: ImageProcessingPostProcess;
  64940. /**
  64941. * Chromatic aberration post process which will shift rgb colors in the image
  64942. */
  64943. chromaticAberration: ChromaticAberrationPostProcess;
  64944. private _chromaticAberrationEffect;
  64945. /**
  64946. * Grain post process which add noise to the image
  64947. */
  64948. grain: GrainPostProcess;
  64949. private _grainEffect;
  64950. /**
  64951. * Glow post process which adds a glow to emissive areas of the image
  64952. */
  64953. private _glowLayer;
  64954. /**
  64955. * Animations which can be used to tweak settings over a period of time
  64956. */
  64957. animations: Animation[];
  64958. private _imageProcessingConfigurationObserver;
  64959. private _sharpenEnabled;
  64960. private _bloomEnabled;
  64961. private _depthOfFieldEnabled;
  64962. private _depthOfFieldBlurLevel;
  64963. private _fxaaEnabled;
  64964. private _imageProcessingEnabled;
  64965. private _defaultPipelineTextureType;
  64966. private _bloomScale;
  64967. private _chromaticAberrationEnabled;
  64968. private _grainEnabled;
  64969. private _buildAllowed;
  64970. /**
  64971. * Gets active scene
  64972. */
  64973. readonly scene: Scene;
  64974. /**
  64975. * Enable or disable the sharpen process from the pipeline
  64976. */
  64977. sharpenEnabled: boolean;
  64978. private _resizeObserver;
  64979. private _hardwareScaleLevel;
  64980. private _bloomKernel;
  64981. /**
  64982. * Specifies the size of the bloom blur kernel, relative to the final output size
  64983. */
  64984. bloomKernel: number;
  64985. /**
  64986. * Specifies the weight of the bloom in the final rendering
  64987. */
  64988. private _bloomWeight;
  64989. /**
  64990. * Specifies the luma threshold for the area that will be blurred by the bloom
  64991. */
  64992. private _bloomThreshold;
  64993. private _hdr;
  64994. /**
  64995. * The strength of the bloom.
  64996. */
  64997. bloomWeight: number;
  64998. /**
  64999. * The strength of the bloom.
  65000. */
  65001. bloomThreshold: number;
  65002. /**
  65003. * The scale of the bloom, lower value will provide better performance.
  65004. */
  65005. bloomScale: number;
  65006. /**
  65007. * Enable or disable the bloom from the pipeline
  65008. */
  65009. bloomEnabled: boolean;
  65010. private _rebuildBloom;
  65011. /**
  65012. * If the depth of field is enabled.
  65013. */
  65014. depthOfFieldEnabled: boolean;
  65015. /**
  65016. * Blur level of the depth of field effect. (Higher blur will effect performance)
  65017. */
  65018. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  65019. /**
  65020. * If the anti aliasing is enabled.
  65021. */
  65022. fxaaEnabled: boolean;
  65023. private _samples;
  65024. /**
  65025. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  65026. */
  65027. samples: number;
  65028. /**
  65029. * If image processing is enabled.
  65030. */
  65031. imageProcessingEnabled: boolean;
  65032. /**
  65033. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  65034. */
  65035. glowLayerEnabled: boolean;
  65036. /**
  65037. * Gets the glow layer (or null if not defined)
  65038. */
  65039. readonly glowLayer: Nullable<GlowLayer>;
  65040. /**
  65041. * Enable or disable the chromaticAberration process from the pipeline
  65042. */
  65043. chromaticAberrationEnabled: boolean;
  65044. /**
  65045. * Enable or disable the grain process from the pipeline
  65046. */
  65047. grainEnabled: boolean;
  65048. /**
  65049. * @constructor
  65050. * @param name - The rendering pipeline name (default: "")
  65051. * @param hdr - If high dynamic range textures should be used (default: true)
  65052. * @param scene - The scene linked to this pipeline (default: the last created scene)
  65053. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  65054. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  65055. */
  65056. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  65057. /**
  65058. * Get the class name
  65059. * @returns "DefaultRenderingPipeline"
  65060. */
  65061. getClassName(): string;
  65062. /**
  65063. * Force the compilation of the entire pipeline.
  65064. */
  65065. prepare(): void;
  65066. private _hasCleared;
  65067. private _prevPostProcess;
  65068. private _prevPrevPostProcess;
  65069. private _setAutoClearAndTextureSharing;
  65070. private _depthOfFieldSceneObserver;
  65071. private _buildPipeline;
  65072. private _disposePostProcesses;
  65073. /**
  65074. * Adds a camera to the pipeline
  65075. * @param camera the camera to be added
  65076. */
  65077. addCamera(camera: Camera): void;
  65078. /**
  65079. * Removes a camera from the pipeline
  65080. * @param camera the camera to remove
  65081. */
  65082. removeCamera(camera: Camera): void;
  65083. /**
  65084. * Dispose of the pipeline and stop all post processes
  65085. */
  65086. dispose(): void;
  65087. /**
  65088. * Serialize the rendering pipeline (Used when exporting)
  65089. * @returns the serialized object
  65090. */
  65091. serialize(): any;
  65092. /**
  65093. * Parse the serialized pipeline
  65094. * @param source Source pipeline.
  65095. * @param scene The scene to load the pipeline to.
  65096. * @param rootUrl The URL of the serialized pipeline.
  65097. * @returns An instantiated pipeline from the serialized object.
  65098. */
  65099. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  65100. }
  65101. }
  65102. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  65103. /** @hidden */
  65104. export var lensHighlightsPixelShader: {
  65105. name: string;
  65106. shader: string;
  65107. };
  65108. }
  65109. declare module "babylonjs/Shaders/depthOfField.fragment" {
  65110. /** @hidden */
  65111. export var depthOfFieldPixelShader: {
  65112. name: string;
  65113. shader: string;
  65114. };
  65115. }
  65116. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  65117. import { Camera } from "babylonjs/Cameras/camera";
  65118. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  65119. import { Scene } from "babylonjs/scene";
  65120. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  65121. import "babylonjs/Shaders/chromaticAberration.fragment";
  65122. import "babylonjs/Shaders/lensHighlights.fragment";
  65123. import "babylonjs/Shaders/depthOfField.fragment";
  65124. /**
  65125. * BABYLON.JS Chromatic Aberration GLSL Shader
  65126. * Author: Olivier Guyot
  65127. * Separates very slightly R, G and B colors on the edges of the screen
  65128. * Inspired by Francois Tarlier & Martins Upitis
  65129. */
  65130. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  65131. /**
  65132. * @ignore
  65133. * The chromatic aberration PostProcess id in the pipeline
  65134. */
  65135. LensChromaticAberrationEffect: string;
  65136. /**
  65137. * @ignore
  65138. * The highlights enhancing PostProcess id in the pipeline
  65139. */
  65140. HighlightsEnhancingEffect: string;
  65141. /**
  65142. * @ignore
  65143. * The depth-of-field PostProcess id in the pipeline
  65144. */
  65145. LensDepthOfFieldEffect: string;
  65146. private _scene;
  65147. private _depthTexture;
  65148. private _grainTexture;
  65149. private _chromaticAberrationPostProcess;
  65150. private _highlightsPostProcess;
  65151. private _depthOfFieldPostProcess;
  65152. private _edgeBlur;
  65153. private _grainAmount;
  65154. private _chromaticAberration;
  65155. private _distortion;
  65156. private _highlightsGain;
  65157. private _highlightsThreshold;
  65158. private _dofDistance;
  65159. private _dofAperture;
  65160. private _dofDarken;
  65161. private _dofPentagon;
  65162. private _blurNoise;
  65163. /**
  65164. * @constructor
  65165. *
  65166. * Effect parameters are as follow:
  65167. * {
  65168. * chromatic_aberration: number; // from 0 to x (1 for realism)
  65169. * edge_blur: number; // from 0 to x (1 for realism)
  65170. * distortion: number; // from 0 to x (1 for realism)
  65171. * grain_amount: number; // from 0 to 1
  65172. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  65173. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  65174. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  65175. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  65176. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  65177. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  65178. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  65179. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  65180. * }
  65181. * Note: if an effect parameter is unset, effect is disabled
  65182. *
  65183. * @param name The rendering pipeline name
  65184. * @param parameters - An object containing all parameters (see above)
  65185. * @param scene The scene linked to this pipeline
  65186. * @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)
  65187. * @param cameras The array of cameras that the rendering pipeline will be attached to
  65188. */
  65189. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  65190. /**
  65191. * Get the class name
  65192. * @returns "LensRenderingPipeline"
  65193. */
  65194. getClassName(): string;
  65195. /**
  65196. * Gets associated scene
  65197. */
  65198. readonly scene: Scene;
  65199. /**
  65200. * Gets or sets the edge blur
  65201. */
  65202. edgeBlur: number;
  65203. /**
  65204. * Gets or sets the grain amount
  65205. */
  65206. grainAmount: number;
  65207. /**
  65208. * Gets or sets the chromatic aberration amount
  65209. */
  65210. chromaticAberration: number;
  65211. /**
  65212. * Gets or sets the depth of field aperture
  65213. */
  65214. dofAperture: number;
  65215. /**
  65216. * Gets or sets the edge distortion
  65217. */
  65218. edgeDistortion: number;
  65219. /**
  65220. * Gets or sets the depth of field distortion
  65221. */
  65222. dofDistortion: number;
  65223. /**
  65224. * Gets or sets the darken out of focus amount
  65225. */
  65226. darkenOutOfFocus: number;
  65227. /**
  65228. * Gets or sets a boolean indicating if blur noise is enabled
  65229. */
  65230. blurNoise: boolean;
  65231. /**
  65232. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  65233. */
  65234. pentagonBokeh: boolean;
  65235. /**
  65236. * Gets or sets the highlight grain amount
  65237. */
  65238. highlightsGain: number;
  65239. /**
  65240. * Gets or sets the highlight threshold
  65241. */
  65242. highlightsThreshold: number;
  65243. /**
  65244. * Sets the amount of blur at the edges
  65245. * @param amount blur amount
  65246. */
  65247. setEdgeBlur(amount: number): void;
  65248. /**
  65249. * Sets edge blur to 0
  65250. */
  65251. disableEdgeBlur(): void;
  65252. /**
  65253. * Sets the amout of grain
  65254. * @param amount Amount of grain
  65255. */
  65256. setGrainAmount(amount: number): void;
  65257. /**
  65258. * Set grain amount to 0
  65259. */
  65260. disableGrain(): void;
  65261. /**
  65262. * Sets the chromatic aberration amount
  65263. * @param amount amount of chromatic aberration
  65264. */
  65265. setChromaticAberration(amount: number): void;
  65266. /**
  65267. * Sets chromatic aberration amount to 0
  65268. */
  65269. disableChromaticAberration(): void;
  65270. /**
  65271. * Sets the EdgeDistortion amount
  65272. * @param amount amount of EdgeDistortion
  65273. */
  65274. setEdgeDistortion(amount: number): void;
  65275. /**
  65276. * Sets edge distortion to 0
  65277. */
  65278. disableEdgeDistortion(): void;
  65279. /**
  65280. * Sets the FocusDistance amount
  65281. * @param amount amount of FocusDistance
  65282. */
  65283. setFocusDistance(amount: number): void;
  65284. /**
  65285. * Disables depth of field
  65286. */
  65287. disableDepthOfField(): void;
  65288. /**
  65289. * Sets the Aperture amount
  65290. * @param amount amount of Aperture
  65291. */
  65292. setAperture(amount: number): void;
  65293. /**
  65294. * Sets the DarkenOutOfFocus amount
  65295. * @param amount amount of DarkenOutOfFocus
  65296. */
  65297. setDarkenOutOfFocus(amount: number): void;
  65298. private _pentagonBokehIsEnabled;
  65299. /**
  65300. * Creates a pentagon bokeh effect
  65301. */
  65302. enablePentagonBokeh(): void;
  65303. /**
  65304. * Disables the pentagon bokeh effect
  65305. */
  65306. disablePentagonBokeh(): void;
  65307. /**
  65308. * Enables noise blur
  65309. */
  65310. enableNoiseBlur(): void;
  65311. /**
  65312. * Disables noise blur
  65313. */
  65314. disableNoiseBlur(): void;
  65315. /**
  65316. * Sets the HighlightsGain amount
  65317. * @param amount amount of HighlightsGain
  65318. */
  65319. setHighlightsGain(amount: number): void;
  65320. /**
  65321. * Sets the HighlightsThreshold amount
  65322. * @param amount amount of HighlightsThreshold
  65323. */
  65324. setHighlightsThreshold(amount: number): void;
  65325. /**
  65326. * Disables highlights
  65327. */
  65328. disableHighlights(): void;
  65329. /**
  65330. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  65331. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  65332. */
  65333. dispose(disableDepthRender?: boolean): void;
  65334. private _createChromaticAberrationPostProcess;
  65335. private _createHighlightsPostProcess;
  65336. private _createDepthOfFieldPostProcess;
  65337. private _createGrainTexture;
  65338. }
  65339. }
  65340. declare module "babylonjs/Shaders/ssao2.fragment" {
  65341. /** @hidden */
  65342. export var ssao2PixelShader: {
  65343. name: string;
  65344. shader: string;
  65345. };
  65346. }
  65347. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  65348. /** @hidden */
  65349. export var ssaoCombinePixelShader: {
  65350. name: string;
  65351. shader: string;
  65352. };
  65353. }
  65354. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  65355. import { Camera } from "babylonjs/Cameras/camera";
  65356. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  65357. import { Scene } from "babylonjs/scene";
  65358. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  65359. import "babylonjs/Shaders/ssao2.fragment";
  65360. import "babylonjs/Shaders/ssaoCombine.fragment";
  65361. /**
  65362. * Render pipeline to produce ssao effect
  65363. */
  65364. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  65365. /**
  65366. * @ignore
  65367. * The PassPostProcess id in the pipeline that contains the original scene color
  65368. */
  65369. SSAOOriginalSceneColorEffect: string;
  65370. /**
  65371. * @ignore
  65372. * The SSAO PostProcess id in the pipeline
  65373. */
  65374. SSAORenderEffect: string;
  65375. /**
  65376. * @ignore
  65377. * The horizontal blur PostProcess id in the pipeline
  65378. */
  65379. SSAOBlurHRenderEffect: string;
  65380. /**
  65381. * @ignore
  65382. * The vertical blur PostProcess id in the pipeline
  65383. */
  65384. SSAOBlurVRenderEffect: string;
  65385. /**
  65386. * @ignore
  65387. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  65388. */
  65389. SSAOCombineRenderEffect: string;
  65390. /**
  65391. * The output strength of the SSAO post-process. Default value is 1.0.
  65392. */
  65393. totalStrength: number;
  65394. /**
  65395. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  65396. */
  65397. maxZ: number;
  65398. /**
  65399. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  65400. */
  65401. minZAspect: number;
  65402. private _samples;
  65403. /**
  65404. * Number of samples used for the SSAO calculations. Default value is 8
  65405. */
  65406. samples: number;
  65407. private _textureSamples;
  65408. /**
  65409. * Number of samples to use for antialiasing
  65410. */
  65411. textureSamples: number;
  65412. /**
  65413. * Ratio object used for SSAO ratio and blur ratio
  65414. */
  65415. private _ratio;
  65416. /**
  65417. * Dynamically generated sphere sampler.
  65418. */
  65419. private _sampleSphere;
  65420. /**
  65421. * Blur filter offsets
  65422. */
  65423. private _samplerOffsets;
  65424. private _expensiveBlur;
  65425. /**
  65426. * If bilateral blur should be used
  65427. */
  65428. expensiveBlur: boolean;
  65429. /**
  65430. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  65431. */
  65432. radius: number;
  65433. /**
  65434. * The base color of the SSAO post-process
  65435. * The final result is "base + ssao" between [0, 1]
  65436. */
  65437. base: number;
  65438. /**
  65439. * Support test.
  65440. */
  65441. static readonly IsSupported: boolean;
  65442. private _scene;
  65443. private _depthTexture;
  65444. private _normalTexture;
  65445. private _randomTexture;
  65446. private _originalColorPostProcess;
  65447. private _ssaoPostProcess;
  65448. private _blurHPostProcess;
  65449. private _blurVPostProcess;
  65450. private _ssaoCombinePostProcess;
  65451. /**
  65452. * Gets active scene
  65453. */
  65454. readonly scene: Scene;
  65455. /**
  65456. * @constructor
  65457. * @param name The rendering pipeline name
  65458. * @param scene The scene linked to this pipeline
  65459. * @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 }
  65460. * @param cameras The array of cameras that the rendering pipeline will be attached to
  65461. */
  65462. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  65463. /**
  65464. * Get the class name
  65465. * @returns "SSAO2RenderingPipeline"
  65466. */
  65467. getClassName(): string;
  65468. /**
  65469. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  65470. */
  65471. dispose(disableGeometryBufferRenderer?: boolean): void;
  65472. private _createBlurPostProcess;
  65473. /** @hidden */
  65474. _rebuild(): void;
  65475. private _bits;
  65476. private _radicalInverse_VdC;
  65477. private _hammersley;
  65478. private _hemisphereSample_uniform;
  65479. private _generateHemisphere;
  65480. private _createSSAOPostProcess;
  65481. private _createSSAOCombinePostProcess;
  65482. private _createRandomTexture;
  65483. /**
  65484. * Serialize the rendering pipeline (Used when exporting)
  65485. * @returns the serialized object
  65486. */
  65487. serialize(): any;
  65488. /**
  65489. * Parse the serialized pipeline
  65490. * @param source Source pipeline.
  65491. * @param scene The scene to load the pipeline to.
  65492. * @param rootUrl The URL of the serialized pipeline.
  65493. * @returns An instantiated pipeline from the serialized object.
  65494. */
  65495. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  65496. }
  65497. }
  65498. declare module "babylonjs/Shaders/ssao.fragment" {
  65499. /** @hidden */
  65500. export var ssaoPixelShader: {
  65501. name: string;
  65502. shader: string;
  65503. };
  65504. }
  65505. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  65506. import { Camera } from "babylonjs/Cameras/camera";
  65507. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  65508. import { Scene } from "babylonjs/scene";
  65509. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  65510. import "babylonjs/Shaders/ssao.fragment";
  65511. import "babylonjs/Shaders/ssaoCombine.fragment";
  65512. /**
  65513. * Render pipeline to produce ssao effect
  65514. */
  65515. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  65516. /**
  65517. * @ignore
  65518. * The PassPostProcess id in the pipeline that contains the original scene color
  65519. */
  65520. SSAOOriginalSceneColorEffect: string;
  65521. /**
  65522. * @ignore
  65523. * The SSAO PostProcess id in the pipeline
  65524. */
  65525. SSAORenderEffect: string;
  65526. /**
  65527. * @ignore
  65528. * The horizontal blur PostProcess id in the pipeline
  65529. */
  65530. SSAOBlurHRenderEffect: string;
  65531. /**
  65532. * @ignore
  65533. * The vertical blur PostProcess id in the pipeline
  65534. */
  65535. SSAOBlurVRenderEffect: string;
  65536. /**
  65537. * @ignore
  65538. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  65539. */
  65540. SSAOCombineRenderEffect: string;
  65541. /**
  65542. * The output strength of the SSAO post-process. Default value is 1.0.
  65543. */
  65544. totalStrength: number;
  65545. /**
  65546. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  65547. */
  65548. radius: number;
  65549. /**
  65550. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  65551. * Must not be equal to fallOff and superior to fallOff.
  65552. * Default value is 0.0075
  65553. */
  65554. area: number;
  65555. /**
  65556. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  65557. * Must not be equal to area and inferior to area.
  65558. * Default value is 0.000001
  65559. */
  65560. fallOff: number;
  65561. /**
  65562. * The base color of the SSAO post-process
  65563. * The final result is "base + ssao" between [0, 1]
  65564. */
  65565. base: number;
  65566. private _scene;
  65567. private _depthTexture;
  65568. private _randomTexture;
  65569. private _originalColorPostProcess;
  65570. private _ssaoPostProcess;
  65571. private _blurHPostProcess;
  65572. private _blurVPostProcess;
  65573. private _ssaoCombinePostProcess;
  65574. private _firstUpdate;
  65575. /**
  65576. * Gets active scene
  65577. */
  65578. readonly scene: Scene;
  65579. /**
  65580. * @constructor
  65581. * @param name - The rendering pipeline name
  65582. * @param scene - The scene linked to this pipeline
  65583. * @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 }
  65584. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  65585. */
  65586. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  65587. /**
  65588. * Get the class name
  65589. * @returns "SSAORenderingPipeline"
  65590. */
  65591. getClassName(): string;
  65592. /**
  65593. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  65594. */
  65595. dispose(disableDepthRender?: boolean): void;
  65596. private _createBlurPostProcess;
  65597. /** @hidden */
  65598. _rebuild(): void;
  65599. private _createSSAOPostProcess;
  65600. private _createSSAOCombinePostProcess;
  65601. private _createRandomTexture;
  65602. }
  65603. }
  65604. declare module "babylonjs/Shaders/standard.fragment" {
  65605. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  65606. /** @hidden */
  65607. export var standardPixelShader: {
  65608. name: string;
  65609. shader: string;
  65610. };
  65611. }
  65612. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  65613. import { Nullable } from "babylonjs/types";
  65614. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  65615. import { Camera } from "babylonjs/Cameras/camera";
  65616. import { Texture } from "babylonjs/Materials/Textures/texture";
  65617. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  65618. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  65619. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  65620. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  65621. import { IDisposable } from "babylonjs/scene";
  65622. import { SpotLight } from "babylonjs/Lights/spotLight";
  65623. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  65624. import { Scene } from "babylonjs/scene";
  65625. import { Animation } from "babylonjs/Animations/animation";
  65626. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  65627. import "babylonjs/Shaders/standard.fragment";
  65628. /**
  65629. * Standard rendering pipeline
  65630. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  65631. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  65632. */
  65633. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  65634. /**
  65635. * Public members
  65636. */
  65637. /**
  65638. * Post-process which contains the original scene color before the pipeline applies all the effects
  65639. */
  65640. originalPostProcess: Nullable<PostProcess>;
  65641. /**
  65642. * Post-process used to down scale an image x4
  65643. */
  65644. downSampleX4PostProcess: Nullable<PostProcess>;
  65645. /**
  65646. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  65647. */
  65648. brightPassPostProcess: Nullable<PostProcess>;
  65649. /**
  65650. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  65651. */
  65652. blurHPostProcesses: PostProcess[];
  65653. /**
  65654. * Post-process array storing all the vertical blur post-processes used by the pipeline
  65655. */
  65656. blurVPostProcesses: PostProcess[];
  65657. /**
  65658. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  65659. */
  65660. textureAdderPostProcess: Nullable<PostProcess>;
  65661. /**
  65662. * Post-process used to create volumetric lighting effect
  65663. */
  65664. volumetricLightPostProcess: Nullable<PostProcess>;
  65665. /**
  65666. * Post-process used to smooth the previous volumetric light post-process on the X axis
  65667. */
  65668. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  65669. /**
  65670. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  65671. */
  65672. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  65673. /**
  65674. * Post-process used to merge the volumetric light effect and the real scene color
  65675. */
  65676. volumetricLightMergePostProces: Nullable<PostProcess>;
  65677. /**
  65678. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  65679. */
  65680. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  65681. /**
  65682. * Base post-process used to calculate the average luminance of the final image for HDR
  65683. */
  65684. luminancePostProcess: Nullable<PostProcess>;
  65685. /**
  65686. * Post-processes used to create down sample post-processes in order to get
  65687. * the average luminance of the final image for HDR
  65688. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  65689. */
  65690. luminanceDownSamplePostProcesses: PostProcess[];
  65691. /**
  65692. * Post-process used to create a HDR effect (light adaptation)
  65693. */
  65694. hdrPostProcess: Nullable<PostProcess>;
  65695. /**
  65696. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  65697. */
  65698. textureAdderFinalPostProcess: Nullable<PostProcess>;
  65699. /**
  65700. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  65701. */
  65702. lensFlareFinalPostProcess: Nullable<PostProcess>;
  65703. /**
  65704. * Post-process used to merge the final HDR post-process and the real scene color
  65705. */
  65706. hdrFinalPostProcess: Nullable<PostProcess>;
  65707. /**
  65708. * Post-process used to create a lens flare effect
  65709. */
  65710. lensFlarePostProcess: Nullable<PostProcess>;
  65711. /**
  65712. * Post-process that merges the result of the lens flare post-process and the real scene color
  65713. */
  65714. lensFlareComposePostProcess: Nullable<PostProcess>;
  65715. /**
  65716. * Post-process used to create a motion blur effect
  65717. */
  65718. motionBlurPostProcess: Nullable<PostProcess>;
  65719. /**
  65720. * Post-process used to create a depth of field effect
  65721. */
  65722. depthOfFieldPostProcess: Nullable<PostProcess>;
  65723. /**
  65724. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  65725. */
  65726. fxaaPostProcess: Nullable<FxaaPostProcess>;
  65727. /**
  65728. * Represents the brightness threshold in order to configure the illuminated surfaces
  65729. */
  65730. brightThreshold: number;
  65731. /**
  65732. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  65733. */
  65734. blurWidth: number;
  65735. /**
  65736. * Sets if the blur for highlighted surfaces must be only horizontal
  65737. */
  65738. horizontalBlur: boolean;
  65739. /**
  65740. * Gets the overall exposure used by the pipeline
  65741. */
  65742. /**
  65743. * Sets the overall exposure used by the pipeline
  65744. */
  65745. exposure: number;
  65746. /**
  65747. * Texture used typically to simulate "dirty" on camera lens
  65748. */
  65749. lensTexture: Nullable<Texture>;
  65750. /**
  65751. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  65752. */
  65753. volumetricLightCoefficient: number;
  65754. /**
  65755. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  65756. */
  65757. volumetricLightPower: number;
  65758. /**
  65759. * Used the set the blur intensity to smooth the volumetric lights
  65760. */
  65761. volumetricLightBlurScale: number;
  65762. /**
  65763. * Light (spot or directional) used to generate the volumetric lights rays
  65764. * The source light must have a shadow generate so the pipeline can get its
  65765. * depth map
  65766. */
  65767. sourceLight: Nullable<SpotLight | DirectionalLight>;
  65768. /**
  65769. * For eye adaptation, represents the minimum luminance the eye can see
  65770. */
  65771. hdrMinimumLuminance: number;
  65772. /**
  65773. * For eye adaptation, represents the decrease luminance speed
  65774. */
  65775. hdrDecreaseRate: number;
  65776. /**
  65777. * For eye adaptation, represents the increase luminance speed
  65778. */
  65779. hdrIncreaseRate: number;
  65780. /**
  65781. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  65782. */
  65783. /**
  65784. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  65785. */
  65786. hdrAutoExposure: boolean;
  65787. /**
  65788. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  65789. */
  65790. lensColorTexture: Nullable<Texture>;
  65791. /**
  65792. * The overall strengh for the lens flare effect
  65793. */
  65794. lensFlareStrength: number;
  65795. /**
  65796. * Dispersion coefficient for lens flare ghosts
  65797. */
  65798. lensFlareGhostDispersal: number;
  65799. /**
  65800. * Main lens flare halo width
  65801. */
  65802. lensFlareHaloWidth: number;
  65803. /**
  65804. * Based on the lens distortion effect, defines how much the lens flare result
  65805. * is distorted
  65806. */
  65807. lensFlareDistortionStrength: number;
  65808. /**
  65809. * Configures the blur intensity used for for lens flare (halo)
  65810. */
  65811. lensFlareBlurWidth: number;
  65812. /**
  65813. * Lens star texture must be used to simulate rays on the flares and is available
  65814. * in the documentation
  65815. */
  65816. lensStarTexture: Nullable<Texture>;
  65817. /**
  65818. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  65819. * flare effect by taking account of the dirt texture
  65820. */
  65821. lensFlareDirtTexture: Nullable<Texture>;
  65822. /**
  65823. * Represents the focal length for the depth of field effect
  65824. */
  65825. depthOfFieldDistance: number;
  65826. /**
  65827. * Represents the blur intensity for the blurred part of the depth of field effect
  65828. */
  65829. depthOfFieldBlurWidth: number;
  65830. /**
  65831. * Gets how much the image is blurred by the movement while using the motion blur post-process
  65832. */
  65833. /**
  65834. * Sets how much the image is blurred by the movement while using the motion blur post-process
  65835. */
  65836. motionStrength: number;
  65837. /**
  65838. * Gets wether or not the motion blur post-process is object based or screen based.
  65839. */
  65840. /**
  65841. * Sets wether or not the motion blur post-process should be object based or screen based
  65842. */
  65843. objectBasedMotionBlur: boolean;
  65844. /**
  65845. * List of animations for the pipeline (IAnimatable implementation)
  65846. */
  65847. animations: Animation[];
  65848. /**
  65849. * Private members
  65850. */
  65851. private _scene;
  65852. private _currentDepthOfFieldSource;
  65853. private _basePostProcess;
  65854. private _fixedExposure;
  65855. private _currentExposure;
  65856. private _hdrAutoExposure;
  65857. private _hdrCurrentLuminance;
  65858. private _motionStrength;
  65859. private _isObjectBasedMotionBlur;
  65860. private _floatTextureType;
  65861. private _camerasToBeAttached;
  65862. private _ratio;
  65863. private _bloomEnabled;
  65864. private _depthOfFieldEnabled;
  65865. private _vlsEnabled;
  65866. private _lensFlareEnabled;
  65867. private _hdrEnabled;
  65868. private _motionBlurEnabled;
  65869. private _fxaaEnabled;
  65870. private _motionBlurSamples;
  65871. private _volumetricLightStepsCount;
  65872. private _samples;
  65873. /**
  65874. * @ignore
  65875. * Specifies if the bloom pipeline is enabled
  65876. */
  65877. BloomEnabled: boolean;
  65878. /**
  65879. * @ignore
  65880. * Specifies if the depth of field pipeline is enabed
  65881. */
  65882. DepthOfFieldEnabled: boolean;
  65883. /**
  65884. * @ignore
  65885. * Specifies if the lens flare pipeline is enabed
  65886. */
  65887. LensFlareEnabled: boolean;
  65888. /**
  65889. * @ignore
  65890. * Specifies if the HDR pipeline is enabled
  65891. */
  65892. HDREnabled: boolean;
  65893. /**
  65894. * @ignore
  65895. * Specifies if the volumetric lights scattering effect is enabled
  65896. */
  65897. VLSEnabled: boolean;
  65898. /**
  65899. * @ignore
  65900. * Specifies if the motion blur effect is enabled
  65901. */
  65902. MotionBlurEnabled: boolean;
  65903. /**
  65904. * Specifies if anti-aliasing is enabled
  65905. */
  65906. fxaaEnabled: boolean;
  65907. /**
  65908. * Specifies the number of steps used to calculate the volumetric lights
  65909. * Typically in interval [50, 200]
  65910. */
  65911. volumetricLightStepsCount: number;
  65912. /**
  65913. * Specifies the number of samples used for the motion blur effect
  65914. * Typically in interval [16, 64]
  65915. */
  65916. motionBlurSamples: number;
  65917. /**
  65918. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  65919. */
  65920. samples: number;
  65921. /**
  65922. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  65923. * @constructor
  65924. * @param name The rendering pipeline name
  65925. * @param scene The scene linked to this pipeline
  65926. * @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)
  65927. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  65928. * @param cameras The array of cameras that the rendering pipeline will be attached to
  65929. */
  65930. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  65931. private _buildPipeline;
  65932. private _createDownSampleX4PostProcess;
  65933. private _createBrightPassPostProcess;
  65934. private _createBlurPostProcesses;
  65935. private _createTextureAdderPostProcess;
  65936. private _createVolumetricLightPostProcess;
  65937. private _createLuminancePostProcesses;
  65938. private _createHdrPostProcess;
  65939. private _createLensFlarePostProcess;
  65940. private _createDepthOfFieldPostProcess;
  65941. private _createMotionBlurPostProcess;
  65942. private _getDepthTexture;
  65943. private _disposePostProcesses;
  65944. /**
  65945. * Dispose of the pipeline and stop all post processes
  65946. */
  65947. dispose(): void;
  65948. /**
  65949. * Serialize the rendering pipeline (Used when exporting)
  65950. * @returns the serialized object
  65951. */
  65952. serialize(): any;
  65953. /**
  65954. * Parse the serialized pipeline
  65955. * @param source Source pipeline.
  65956. * @param scene The scene to load the pipeline to.
  65957. * @param rootUrl The URL of the serialized pipeline.
  65958. * @returns An instantiated pipeline from the serialized object.
  65959. */
  65960. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  65961. /**
  65962. * Luminance steps
  65963. */
  65964. static LuminanceSteps: number;
  65965. }
  65966. }
  65967. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  65968. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  65969. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  65970. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  65971. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  65972. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  65973. }
  65974. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  65975. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  65976. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  65977. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  65978. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  65979. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  65980. }
  65981. declare module "babylonjs/Shaders/tonemap.fragment" {
  65982. /** @hidden */
  65983. export var tonemapPixelShader: {
  65984. name: string;
  65985. shader: string;
  65986. };
  65987. }
  65988. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  65989. import { Camera } from "babylonjs/Cameras/camera";
  65990. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  65991. import "babylonjs/Shaders/tonemap.fragment";
  65992. import { Engine } from "babylonjs/Engines/engine";
  65993. /** Defines operator used for tonemapping */
  65994. export enum TonemappingOperator {
  65995. /** Hable */
  65996. Hable = 0,
  65997. /** Reinhard */
  65998. Reinhard = 1,
  65999. /** HejiDawson */
  66000. HejiDawson = 2,
  66001. /** Photographic */
  66002. Photographic = 3
  66003. }
  66004. /**
  66005. * Defines a post process to apply tone mapping
  66006. */
  66007. export class TonemapPostProcess extends PostProcess {
  66008. private _operator;
  66009. /** Defines the required exposure adjustement */
  66010. exposureAdjustment: number;
  66011. /**
  66012. * Creates a new TonemapPostProcess
  66013. * @param name defines the name of the postprocess
  66014. * @param _operator defines the operator to use
  66015. * @param exposureAdjustment defines the required exposure adjustement
  66016. * @param camera defines the camera to use (can be null)
  66017. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  66018. * @param engine defines the hosting engine (can be ignore if camera is set)
  66019. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  66020. */
  66021. constructor(name: string, _operator: TonemappingOperator,
  66022. /** Defines the required exposure adjustement */
  66023. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  66024. }
  66025. }
  66026. declare module "babylonjs/Shaders/depth.vertex" {
  66027. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  66028. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  66029. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  66030. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  66031. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  66032. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  66033. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  66034. /** @hidden */
  66035. export var depthVertexShader: {
  66036. name: string;
  66037. shader: string;
  66038. };
  66039. }
  66040. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  66041. /** @hidden */
  66042. export var volumetricLightScatteringPixelShader: {
  66043. name: string;
  66044. shader: string;
  66045. };
  66046. }
  66047. declare module "babylonjs/Shaders/volumetricLightScatteringPass.vertex" {
  66048. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  66049. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  66050. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  66051. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  66052. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  66053. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  66054. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  66055. /** @hidden */
  66056. export var volumetricLightScatteringPassVertexShader: {
  66057. name: string;
  66058. shader: string;
  66059. };
  66060. }
  66061. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  66062. /** @hidden */
  66063. export var volumetricLightScatteringPassPixelShader: {
  66064. name: string;
  66065. shader: string;
  66066. };
  66067. }
  66068. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  66069. import { Vector3 } from "babylonjs/Maths/math.vector";
  66070. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66071. import { Mesh } from "babylonjs/Meshes/mesh";
  66072. import { Camera } from "babylonjs/Cameras/camera";
  66073. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  66074. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  66075. import { Scene } from "babylonjs/scene";
  66076. import "babylonjs/Meshes/Builders/planeBuilder";
  66077. import "babylonjs/Shaders/depth.vertex";
  66078. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  66079. import "babylonjs/Shaders/volumetricLightScatteringPass.vertex";
  66080. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  66081. import { Engine } from "babylonjs/Engines/engine";
  66082. /**
  66083. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  66084. */
  66085. export class VolumetricLightScatteringPostProcess extends PostProcess {
  66086. private _volumetricLightScatteringPass;
  66087. private _volumetricLightScatteringRTT;
  66088. private _viewPort;
  66089. private _screenCoordinates;
  66090. private _cachedDefines;
  66091. /**
  66092. * If not undefined, the mesh position is computed from the attached node position
  66093. */
  66094. attachedNode: {
  66095. position: Vector3;
  66096. };
  66097. /**
  66098. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  66099. */
  66100. customMeshPosition: Vector3;
  66101. /**
  66102. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  66103. */
  66104. useCustomMeshPosition: boolean;
  66105. /**
  66106. * If the post-process should inverse the light scattering direction
  66107. */
  66108. invert: boolean;
  66109. /**
  66110. * The internal mesh used by the post-process
  66111. */
  66112. mesh: Mesh;
  66113. /**
  66114. * @hidden
  66115. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  66116. */
  66117. useDiffuseColor: boolean;
  66118. /**
  66119. * Array containing the excluded meshes not rendered in the internal pass
  66120. */
  66121. excludedMeshes: AbstractMesh[];
  66122. /**
  66123. * Controls the overall intensity of the post-process
  66124. */
  66125. exposure: number;
  66126. /**
  66127. * Dissipates each sample's contribution in range [0, 1]
  66128. */
  66129. decay: number;
  66130. /**
  66131. * Controls the overall intensity of each sample
  66132. */
  66133. weight: number;
  66134. /**
  66135. * Controls the density of each sample
  66136. */
  66137. density: number;
  66138. /**
  66139. * @constructor
  66140. * @param name The post-process name
  66141. * @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)
  66142. * @param camera The camera that the post-process will be attached to
  66143. * @param mesh The mesh used to create the light scattering
  66144. * @param samples The post-process quality, default 100
  66145. * @param samplingModeThe post-process filtering mode
  66146. * @param engine The babylon engine
  66147. * @param reusable If the post-process is reusable
  66148. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  66149. */
  66150. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  66151. /**
  66152. * Returns the string "VolumetricLightScatteringPostProcess"
  66153. * @returns "VolumetricLightScatteringPostProcess"
  66154. */
  66155. getClassName(): string;
  66156. private _isReady;
  66157. /**
  66158. * Sets the new light position for light scattering effect
  66159. * @param position The new custom light position
  66160. */
  66161. setCustomMeshPosition(position: Vector3): void;
  66162. /**
  66163. * Returns the light position for light scattering effect
  66164. * @return Vector3 The custom light position
  66165. */
  66166. getCustomMeshPosition(): Vector3;
  66167. /**
  66168. * Disposes the internal assets and detaches the post-process from the camera
  66169. */
  66170. dispose(camera: Camera): void;
  66171. /**
  66172. * Returns the render target texture used by the post-process
  66173. * @return the render target texture used by the post-process
  66174. */
  66175. getPass(): RenderTargetTexture;
  66176. private _meshExcluded;
  66177. private _createPass;
  66178. private _updateMeshScreenCoordinates;
  66179. /**
  66180. * Creates a default mesh for the Volumeric Light Scattering post-process
  66181. * @param name The mesh name
  66182. * @param scene The scene where to create the mesh
  66183. * @return the default mesh
  66184. */
  66185. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  66186. }
  66187. }
  66188. declare module "babylonjs/PostProcesses/index" {
  66189. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  66190. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  66191. export * from "babylonjs/PostProcesses/bloomEffect";
  66192. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  66193. export * from "babylonjs/PostProcesses/blurPostProcess";
  66194. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  66195. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  66196. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  66197. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  66198. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  66199. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  66200. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  66201. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  66202. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  66203. export * from "babylonjs/PostProcesses/filterPostProcess";
  66204. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  66205. export * from "babylonjs/PostProcesses/grainPostProcess";
  66206. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  66207. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  66208. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  66209. export * from "babylonjs/PostProcesses/passPostProcess";
  66210. export * from "babylonjs/PostProcesses/postProcess";
  66211. export * from "babylonjs/PostProcesses/postProcessManager";
  66212. export * from "babylonjs/PostProcesses/refractionPostProcess";
  66213. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  66214. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  66215. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  66216. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  66217. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  66218. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  66219. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  66220. }
  66221. declare module "babylonjs/Probes/index" {
  66222. export * from "babylonjs/Probes/reflectionProbe";
  66223. }
  66224. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  66225. import { Scene } from "babylonjs/scene";
  66226. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66227. import { SmartArray } from "babylonjs/Misc/smartArray";
  66228. import { ISceneComponent } from "babylonjs/sceneComponent";
  66229. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  66230. import "babylonjs/Meshes/Builders/boxBuilder";
  66231. import "babylonjs/Shaders/color.fragment";
  66232. import "babylonjs/Shaders/color.vertex";
  66233. import { Color3 } from "babylonjs/Maths/math.color";
  66234. module "babylonjs/scene" {
  66235. interface Scene {
  66236. /** @hidden (Backing field) */
  66237. _boundingBoxRenderer: BoundingBoxRenderer;
  66238. /** @hidden (Backing field) */
  66239. _forceShowBoundingBoxes: boolean;
  66240. /**
  66241. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  66242. */
  66243. forceShowBoundingBoxes: boolean;
  66244. /**
  66245. * Gets the bounding box renderer associated with the scene
  66246. * @returns a BoundingBoxRenderer
  66247. */
  66248. getBoundingBoxRenderer(): BoundingBoxRenderer;
  66249. }
  66250. }
  66251. module "babylonjs/Meshes/abstractMesh" {
  66252. interface AbstractMesh {
  66253. /** @hidden (Backing field) */
  66254. _showBoundingBox: boolean;
  66255. /**
  66256. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  66257. */
  66258. showBoundingBox: boolean;
  66259. }
  66260. }
  66261. /**
  66262. * Component responsible of rendering the bounding box of the meshes in a scene.
  66263. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  66264. */
  66265. export class BoundingBoxRenderer implements ISceneComponent {
  66266. /**
  66267. * The component name helpfull to identify the component in the list of scene components.
  66268. */
  66269. readonly name: string;
  66270. /**
  66271. * The scene the component belongs to.
  66272. */
  66273. scene: Scene;
  66274. /**
  66275. * Color of the bounding box lines placed in front of an object
  66276. */
  66277. frontColor: Color3;
  66278. /**
  66279. * Color of the bounding box lines placed behind an object
  66280. */
  66281. backColor: Color3;
  66282. /**
  66283. * Defines if the renderer should show the back lines or not
  66284. */
  66285. showBackLines: boolean;
  66286. /**
  66287. * @hidden
  66288. */
  66289. renderList: SmartArray<BoundingBox>;
  66290. private _colorShader;
  66291. private _vertexBuffers;
  66292. private _indexBuffer;
  66293. private _fillIndexBuffer;
  66294. private _fillIndexData;
  66295. /**
  66296. * Instantiates a new bounding box renderer in a scene.
  66297. * @param scene the scene the renderer renders in
  66298. */
  66299. constructor(scene: Scene);
  66300. /**
  66301. * Registers the component in a given scene
  66302. */
  66303. register(): void;
  66304. private _evaluateSubMesh;
  66305. private _activeMesh;
  66306. private _prepareRessources;
  66307. private _createIndexBuffer;
  66308. /**
  66309. * Rebuilds the elements related to this component in case of
  66310. * context lost for instance.
  66311. */
  66312. rebuild(): void;
  66313. /**
  66314. * @hidden
  66315. */
  66316. reset(): void;
  66317. /**
  66318. * Render the bounding boxes of a specific rendering group
  66319. * @param renderingGroupId defines the rendering group to render
  66320. */
  66321. render(renderingGroupId: number): void;
  66322. /**
  66323. * In case of occlusion queries, we can render the occlusion bounding box through this method
  66324. * @param mesh Define the mesh to render the occlusion bounding box for
  66325. */
  66326. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  66327. /**
  66328. * Dispose and release the resources attached to this renderer.
  66329. */
  66330. dispose(): void;
  66331. }
  66332. }
  66333. declare module "babylonjs/Shaders/depth.fragment" {
  66334. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  66335. /** @hidden */
  66336. export var depthPixelShader: {
  66337. name: string;
  66338. shader: string;
  66339. };
  66340. }
  66341. declare module "babylonjs/Rendering/depthRenderer" {
  66342. import { Nullable } from "babylonjs/types";
  66343. import { SubMesh } from "babylonjs/Meshes/subMesh";
  66344. import { Scene } from "babylonjs/scene";
  66345. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  66346. import { Camera } from "babylonjs/Cameras/camera";
  66347. import "babylonjs/Shaders/depth.fragment";
  66348. import "babylonjs/Shaders/depth.vertex";
  66349. /**
  66350. * This represents a depth renderer in Babylon.
  66351. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  66352. */
  66353. export class DepthRenderer {
  66354. private _scene;
  66355. private _depthMap;
  66356. private _effect;
  66357. private readonly _storeNonLinearDepth;
  66358. private readonly _clearColor;
  66359. /** Get if the depth renderer is using packed depth or not */
  66360. readonly isPacked: boolean;
  66361. private _cachedDefines;
  66362. private _camera;
  66363. /**
  66364. * Specifiess that the depth renderer will only be used within
  66365. * the camera it is created for.
  66366. * This can help forcing its rendering during the camera processing.
  66367. */
  66368. useOnlyInActiveCamera: boolean;
  66369. /** @hidden */
  66370. static _SceneComponentInitialization: (scene: Scene) => void;
  66371. /**
  66372. * Instantiates a depth renderer
  66373. * @param scene The scene the renderer belongs to
  66374. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  66375. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  66376. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  66377. */
  66378. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  66379. /**
  66380. * Creates the depth rendering effect and checks if the effect is ready.
  66381. * @param subMesh The submesh to be used to render the depth map of
  66382. * @param useInstances If multiple world instances should be used
  66383. * @returns if the depth renderer is ready to render the depth map
  66384. */
  66385. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  66386. /**
  66387. * Gets the texture which the depth map will be written to.
  66388. * @returns The depth map texture
  66389. */
  66390. getDepthMap(): RenderTargetTexture;
  66391. /**
  66392. * Disposes of the depth renderer.
  66393. */
  66394. dispose(): void;
  66395. }
  66396. }
  66397. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  66398. import { Nullable } from "babylonjs/types";
  66399. import { Scene } from "babylonjs/scene";
  66400. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  66401. import { Camera } from "babylonjs/Cameras/camera";
  66402. import { ISceneComponent } from "babylonjs/sceneComponent";
  66403. module "babylonjs/scene" {
  66404. interface Scene {
  66405. /** @hidden (Backing field) */
  66406. _depthRenderer: {
  66407. [id: string]: DepthRenderer;
  66408. };
  66409. /**
  66410. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  66411. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  66412. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  66413. * @returns the created depth renderer
  66414. */
  66415. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  66416. /**
  66417. * Disables a depth renderer for a given camera
  66418. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  66419. */
  66420. disableDepthRenderer(camera?: Nullable<Camera>): void;
  66421. }
  66422. }
  66423. /**
  66424. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  66425. * in several rendering techniques.
  66426. */
  66427. export class DepthRendererSceneComponent implements ISceneComponent {
  66428. /**
  66429. * The component name helpfull to identify the component in the list of scene components.
  66430. */
  66431. readonly name: string;
  66432. /**
  66433. * The scene the component belongs to.
  66434. */
  66435. scene: Scene;
  66436. /**
  66437. * Creates a new instance of the component for the given scene
  66438. * @param scene Defines the scene to register the component in
  66439. */
  66440. constructor(scene: Scene);
  66441. /**
  66442. * Registers the component in a given scene
  66443. */
  66444. register(): void;
  66445. /**
  66446. * Rebuilds the elements related to this component in case of
  66447. * context lost for instance.
  66448. */
  66449. rebuild(): void;
  66450. /**
  66451. * Disposes the component and the associated ressources
  66452. */
  66453. dispose(): void;
  66454. private _gatherRenderTargets;
  66455. private _gatherActiveCameraRenderTargets;
  66456. }
  66457. }
  66458. declare module "babylonjs/Shaders/outline.fragment" {
  66459. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  66460. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  66461. /** @hidden */
  66462. export var outlinePixelShader: {
  66463. name: string;
  66464. shader: string;
  66465. };
  66466. }
  66467. declare module "babylonjs/Shaders/outline.vertex" {
  66468. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  66469. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  66470. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  66471. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  66472. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  66473. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  66474. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  66475. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  66476. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  66477. /** @hidden */
  66478. export var outlineVertexShader: {
  66479. name: string;
  66480. shader: string;
  66481. };
  66482. }
  66483. declare module "babylonjs/Rendering/outlineRenderer" {
  66484. import { SubMesh } from "babylonjs/Meshes/subMesh";
  66485. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  66486. import { Scene } from "babylonjs/scene";
  66487. import { ISceneComponent } from "babylonjs/sceneComponent";
  66488. import "babylonjs/Shaders/outline.fragment";
  66489. import "babylonjs/Shaders/outline.vertex";
  66490. module "babylonjs/scene" {
  66491. interface Scene {
  66492. /** @hidden */
  66493. _outlineRenderer: OutlineRenderer;
  66494. /**
  66495. * Gets the outline renderer associated with the scene
  66496. * @returns a OutlineRenderer
  66497. */
  66498. getOutlineRenderer(): OutlineRenderer;
  66499. }
  66500. }
  66501. module "babylonjs/Meshes/abstractMesh" {
  66502. interface AbstractMesh {
  66503. /** @hidden (Backing field) */
  66504. _renderOutline: boolean;
  66505. /**
  66506. * Gets or sets a boolean indicating if the outline must be rendered as well
  66507. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  66508. */
  66509. renderOutline: boolean;
  66510. /** @hidden (Backing field) */
  66511. _renderOverlay: boolean;
  66512. /**
  66513. * Gets or sets a boolean indicating if the overlay must be rendered as well
  66514. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  66515. */
  66516. renderOverlay: boolean;
  66517. }
  66518. }
  66519. /**
  66520. * This class is responsible to draw bothe outline/overlay of meshes.
  66521. * It should not be used directly but through the available method on mesh.
  66522. */
  66523. export class OutlineRenderer implements ISceneComponent {
  66524. /**
  66525. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  66526. */
  66527. private static _StencilReference;
  66528. /**
  66529. * The name of the component. Each component must have a unique name.
  66530. */
  66531. name: string;
  66532. /**
  66533. * The scene the component belongs to.
  66534. */
  66535. scene: Scene;
  66536. /**
  66537. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  66538. */
  66539. zOffset: number;
  66540. private _engine;
  66541. private _effect;
  66542. private _cachedDefines;
  66543. private _savedDepthWrite;
  66544. /**
  66545. * Instantiates a new outline renderer. (There could be only one per scene).
  66546. * @param scene Defines the scene it belongs to
  66547. */
  66548. constructor(scene: Scene);
  66549. /**
  66550. * Register the component to one instance of a scene.
  66551. */
  66552. register(): void;
  66553. /**
  66554. * Rebuilds the elements related to this component in case of
  66555. * context lost for instance.
  66556. */
  66557. rebuild(): void;
  66558. /**
  66559. * Disposes the component and the associated ressources.
  66560. */
  66561. dispose(): void;
  66562. /**
  66563. * Renders the outline in the canvas.
  66564. * @param subMesh Defines the sumesh to render
  66565. * @param batch Defines the batch of meshes in case of instances
  66566. * @param useOverlay Defines if the rendering is for the overlay or the outline
  66567. */
  66568. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  66569. /**
  66570. * Returns whether or not the outline renderer is ready for a given submesh.
  66571. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  66572. * @param subMesh Defines the submesh to check readyness for
  66573. * @param useInstances Defines wheter wee are trying to render instances or not
  66574. * @returns true if ready otherwise false
  66575. */
  66576. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  66577. private _beforeRenderingMesh;
  66578. private _afterRenderingMesh;
  66579. }
  66580. }
  66581. declare module "babylonjs/Rendering/index" {
  66582. export * from "babylonjs/Rendering/boundingBoxRenderer";
  66583. export * from "babylonjs/Rendering/depthRenderer";
  66584. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  66585. export * from "babylonjs/Rendering/edgesRenderer";
  66586. export * from "babylonjs/Rendering/geometryBufferRenderer";
  66587. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  66588. export * from "babylonjs/Rendering/outlineRenderer";
  66589. export * from "babylonjs/Rendering/renderingGroup";
  66590. export * from "babylonjs/Rendering/renderingManager";
  66591. export * from "babylonjs/Rendering/utilityLayerRenderer";
  66592. }
  66593. declare module "babylonjs/Sprites/spritePackedManager" {
  66594. import { SpriteManager } from "babylonjs/Sprites/spriteManager";
  66595. import { Scene } from "babylonjs/scene";
  66596. /**
  66597. * Class used to manage multiple sprites of different sizes on the same spritesheet
  66598. * @see http://doc.babylonjs.com/babylon101/sprites
  66599. */
  66600. export class SpritePackedManager extends SpriteManager {
  66601. /** defines the packed manager's name */
  66602. name: string;
  66603. /**
  66604. * Creates a new sprite manager from a packed sprite sheet
  66605. * @param name defines the manager's name
  66606. * @param imgUrl defines the sprite sheet url
  66607. * @param capacity defines the maximum allowed number of sprites
  66608. * @param scene defines the hosting scene
  66609. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  66610. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  66611. * @param samplingMode defines the smapling mode to use with spritesheet
  66612. * @param fromPacked set to true; do not alter
  66613. */
  66614. constructor(
  66615. /** defines the packed manager's name */
  66616. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  66617. }
  66618. }
  66619. declare module "babylonjs/Sprites/index" {
  66620. export * from "babylonjs/Sprites/sprite";
  66621. export * from "babylonjs/Sprites/spriteManager";
  66622. export * from "babylonjs/Sprites/spritePackedManager";
  66623. export * from "babylonjs/Sprites/spriteSceneComponent";
  66624. }
  66625. declare module "babylonjs/States/index" {
  66626. export * from "babylonjs/States/alphaCullingState";
  66627. export * from "babylonjs/States/depthCullingState";
  66628. export * from "babylonjs/States/stencilState";
  66629. }
  66630. declare module "babylonjs/Misc/assetsManager" {
  66631. import { Scene } from "babylonjs/scene";
  66632. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66633. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  66634. import { Skeleton } from "babylonjs/Bones/skeleton";
  66635. import { Observable } from "babylonjs/Misc/observable";
  66636. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  66637. import { Texture } from "babylonjs/Materials/Textures/texture";
  66638. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  66639. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  66640. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  66641. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  66642. /**
  66643. * Defines the list of states available for a task inside a AssetsManager
  66644. */
  66645. export enum AssetTaskState {
  66646. /**
  66647. * Initialization
  66648. */
  66649. INIT = 0,
  66650. /**
  66651. * Running
  66652. */
  66653. RUNNING = 1,
  66654. /**
  66655. * Done
  66656. */
  66657. DONE = 2,
  66658. /**
  66659. * Error
  66660. */
  66661. ERROR = 3
  66662. }
  66663. /**
  66664. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  66665. */
  66666. export abstract class AbstractAssetTask {
  66667. /**
  66668. * Task name
  66669. */ name: string;
  66670. /**
  66671. * Callback called when the task is successful
  66672. */
  66673. onSuccess: (task: any) => void;
  66674. /**
  66675. * Callback called when the task is not successful
  66676. */
  66677. onError: (task: any, message?: string, exception?: any) => void;
  66678. /**
  66679. * Creates a new AssetsManager
  66680. * @param name defines the name of the task
  66681. */
  66682. constructor(
  66683. /**
  66684. * Task name
  66685. */ name: string);
  66686. private _isCompleted;
  66687. private _taskState;
  66688. private _errorObject;
  66689. /**
  66690. * Get if the task is completed
  66691. */
  66692. readonly isCompleted: boolean;
  66693. /**
  66694. * Gets the current state of the task
  66695. */
  66696. readonly taskState: AssetTaskState;
  66697. /**
  66698. * Gets the current error object (if task is in error)
  66699. */
  66700. readonly errorObject: {
  66701. message?: string;
  66702. exception?: any;
  66703. };
  66704. /**
  66705. * Internal only
  66706. * @hidden
  66707. */
  66708. _setErrorObject(message?: string, exception?: any): void;
  66709. /**
  66710. * Execute the current task
  66711. * @param scene defines the scene where you want your assets to be loaded
  66712. * @param onSuccess is a callback called when the task is successfully executed
  66713. * @param onError is a callback called if an error occurs
  66714. */
  66715. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  66716. /**
  66717. * Execute the current task
  66718. * @param scene defines the scene where you want your assets to be loaded
  66719. * @param onSuccess is a callback called when the task is successfully executed
  66720. * @param onError is a callback called if an error occurs
  66721. */
  66722. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  66723. /**
  66724. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  66725. * This can be used with failed tasks that have the reason for failure fixed.
  66726. */
  66727. reset(): void;
  66728. private onErrorCallback;
  66729. private onDoneCallback;
  66730. }
  66731. /**
  66732. * Define the interface used by progress events raised during assets loading
  66733. */
  66734. export interface IAssetsProgressEvent {
  66735. /**
  66736. * Defines the number of remaining tasks to process
  66737. */
  66738. remainingCount: number;
  66739. /**
  66740. * Defines the total number of tasks
  66741. */
  66742. totalCount: number;
  66743. /**
  66744. * Defines the task that was just processed
  66745. */
  66746. task: AbstractAssetTask;
  66747. }
  66748. /**
  66749. * Class used to share progress information about assets loading
  66750. */
  66751. export class AssetsProgressEvent implements IAssetsProgressEvent {
  66752. /**
  66753. * Defines the number of remaining tasks to process
  66754. */
  66755. remainingCount: number;
  66756. /**
  66757. * Defines the total number of tasks
  66758. */
  66759. totalCount: number;
  66760. /**
  66761. * Defines the task that was just processed
  66762. */
  66763. task: AbstractAssetTask;
  66764. /**
  66765. * Creates a AssetsProgressEvent
  66766. * @param remainingCount defines the number of remaining tasks to process
  66767. * @param totalCount defines the total number of tasks
  66768. * @param task defines the task that was just processed
  66769. */
  66770. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  66771. }
  66772. /**
  66773. * Define a task used by AssetsManager to load meshes
  66774. */
  66775. export class MeshAssetTask extends AbstractAssetTask {
  66776. /**
  66777. * Defines the name of the task
  66778. */
  66779. name: string;
  66780. /**
  66781. * Defines the list of mesh's names you want to load
  66782. */
  66783. meshesNames: any;
  66784. /**
  66785. * Defines the root url to use as a base to load your meshes and associated resources
  66786. */
  66787. rootUrl: string;
  66788. /**
  66789. * Defines the filename of the scene to load from
  66790. */
  66791. sceneFilename: string;
  66792. /**
  66793. * Gets the list of loaded meshes
  66794. */
  66795. loadedMeshes: Array<AbstractMesh>;
  66796. /**
  66797. * Gets the list of loaded particle systems
  66798. */
  66799. loadedParticleSystems: Array<IParticleSystem>;
  66800. /**
  66801. * Gets the list of loaded skeletons
  66802. */
  66803. loadedSkeletons: Array<Skeleton>;
  66804. /**
  66805. * Gets the list of loaded animation groups
  66806. */
  66807. loadedAnimationGroups: Array<AnimationGroup>;
  66808. /**
  66809. * Callback called when the task is successful
  66810. */
  66811. onSuccess: (task: MeshAssetTask) => void;
  66812. /**
  66813. * Callback called when the task is successful
  66814. */
  66815. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  66816. /**
  66817. * Creates a new MeshAssetTask
  66818. * @param name defines the name of the task
  66819. * @param meshesNames defines the list of mesh's names you want to load
  66820. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  66821. * @param sceneFilename defines the filename of the scene to load from
  66822. */
  66823. constructor(
  66824. /**
  66825. * Defines the name of the task
  66826. */
  66827. name: string,
  66828. /**
  66829. * Defines the list of mesh's names you want to load
  66830. */
  66831. meshesNames: any,
  66832. /**
  66833. * Defines the root url to use as a base to load your meshes and associated resources
  66834. */
  66835. rootUrl: string,
  66836. /**
  66837. * Defines the filename of the scene to load from
  66838. */
  66839. sceneFilename: string);
  66840. /**
  66841. * Execute the current task
  66842. * @param scene defines the scene where you want your assets to be loaded
  66843. * @param onSuccess is a callback called when the task is successfully executed
  66844. * @param onError is a callback called if an error occurs
  66845. */
  66846. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  66847. }
  66848. /**
  66849. * Define a task used by AssetsManager to load text content
  66850. */
  66851. export class TextFileAssetTask extends AbstractAssetTask {
  66852. /**
  66853. * Defines the name of the task
  66854. */
  66855. name: string;
  66856. /**
  66857. * Defines the location of the file to load
  66858. */
  66859. url: string;
  66860. /**
  66861. * Gets the loaded text string
  66862. */
  66863. text: string;
  66864. /**
  66865. * Callback called when the task is successful
  66866. */
  66867. onSuccess: (task: TextFileAssetTask) => void;
  66868. /**
  66869. * Callback called when the task is successful
  66870. */
  66871. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  66872. /**
  66873. * Creates a new TextFileAssetTask object
  66874. * @param name defines the name of the task
  66875. * @param url defines the location of the file to load
  66876. */
  66877. constructor(
  66878. /**
  66879. * Defines the name of the task
  66880. */
  66881. name: string,
  66882. /**
  66883. * Defines the location of the file to load
  66884. */
  66885. url: string);
  66886. /**
  66887. * Execute the current task
  66888. * @param scene defines the scene where you want your assets to be loaded
  66889. * @param onSuccess is a callback called when the task is successfully executed
  66890. * @param onError is a callback called if an error occurs
  66891. */
  66892. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  66893. }
  66894. /**
  66895. * Define a task used by AssetsManager to load binary data
  66896. */
  66897. export class BinaryFileAssetTask extends AbstractAssetTask {
  66898. /**
  66899. * Defines the name of the task
  66900. */
  66901. name: string;
  66902. /**
  66903. * Defines the location of the file to load
  66904. */
  66905. url: string;
  66906. /**
  66907. * Gets the lodaded data (as an array buffer)
  66908. */
  66909. data: ArrayBuffer;
  66910. /**
  66911. * Callback called when the task is successful
  66912. */
  66913. onSuccess: (task: BinaryFileAssetTask) => void;
  66914. /**
  66915. * Callback called when the task is successful
  66916. */
  66917. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  66918. /**
  66919. * Creates a new BinaryFileAssetTask object
  66920. * @param name defines the name of the new task
  66921. * @param url defines the location of the file to load
  66922. */
  66923. constructor(
  66924. /**
  66925. * Defines the name of the task
  66926. */
  66927. name: string,
  66928. /**
  66929. * Defines the location of the file to load
  66930. */
  66931. url: string);
  66932. /**
  66933. * Execute the current task
  66934. * @param scene defines the scene where you want your assets to be loaded
  66935. * @param onSuccess is a callback called when the task is successfully executed
  66936. * @param onError is a callback called if an error occurs
  66937. */
  66938. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  66939. }
  66940. /**
  66941. * Define a task used by AssetsManager to load images
  66942. */
  66943. export class ImageAssetTask extends AbstractAssetTask {
  66944. /**
  66945. * Defines the name of the task
  66946. */
  66947. name: string;
  66948. /**
  66949. * Defines the location of the image to load
  66950. */
  66951. url: string;
  66952. /**
  66953. * Gets the loaded images
  66954. */
  66955. image: HTMLImageElement;
  66956. /**
  66957. * Callback called when the task is successful
  66958. */
  66959. onSuccess: (task: ImageAssetTask) => void;
  66960. /**
  66961. * Callback called when the task is successful
  66962. */
  66963. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  66964. /**
  66965. * Creates a new ImageAssetTask
  66966. * @param name defines the name of the task
  66967. * @param url defines the location of the image to load
  66968. */
  66969. constructor(
  66970. /**
  66971. * Defines the name of the task
  66972. */
  66973. name: string,
  66974. /**
  66975. * Defines the location of the image to load
  66976. */
  66977. url: string);
  66978. /**
  66979. * Execute the current task
  66980. * @param scene defines the scene where you want your assets to be loaded
  66981. * @param onSuccess is a callback called when the task is successfully executed
  66982. * @param onError is a callback called if an error occurs
  66983. */
  66984. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  66985. }
  66986. /**
  66987. * Defines the interface used by texture loading tasks
  66988. */
  66989. export interface ITextureAssetTask<TEX extends BaseTexture> {
  66990. /**
  66991. * Gets the loaded texture
  66992. */
  66993. texture: TEX;
  66994. }
  66995. /**
  66996. * Define a task used by AssetsManager to load 2D textures
  66997. */
  66998. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  66999. /**
  67000. * Defines the name of the task
  67001. */
  67002. name: string;
  67003. /**
  67004. * Defines the location of the file to load
  67005. */
  67006. url: string;
  67007. /**
  67008. * Defines if mipmap should not be generated (default is false)
  67009. */
  67010. noMipmap?: boolean | undefined;
  67011. /**
  67012. * Defines if texture must be inverted on Y axis (default is false)
  67013. */
  67014. invertY?: boolean | undefined;
  67015. /**
  67016. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  67017. */
  67018. samplingMode: number;
  67019. /**
  67020. * Gets the loaded texture
  67021. */
  67022. texture: Texture;
  67023. /**
  67024. * Callback called when the task is successful
  67025. */
  67026. onSuccess: (task: TextureAssetTask) => void;
  67027. /**
  67028. * Callback called when the task is successful
  67029. */
  67030. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  67031. /**
  67032. * Creates a new TextureAssetTask object
  67033. * @param name defines the name of the task
  67034. * @param url defines the location of the file to load
  67035. * @param noMipmap defines if mipmap should not be generated (default is false)
  67036. * @param invertY defines if texture must be inverted on Y axis (default is false)
  67037. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  67038. */
  67039. constructor(
  67040. /**
  67041. * Defines the name of the task
  67042. */
  67043. name: string,
  67044. /**
  67045. * Defines the location of the file to load
  67046. */
  67047. url: string,
  67048. /**
  67049. * Defines if mipmap should not be generated (default is false)
  67050. */
  67051. noMipmap?: boolean | undefined,
  67052. /**
  67053. * Defines if texture must be inverted on Y axis (default is false)
  67054. */
  67055. invertY?: boolean | undefined,
  67056. /**
  67057. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  67058. */
  67059. samplingMode?: number);
  67060. /**
  67061. * Execute the current task
  67062. * @param scene defines the scene where you want your assets to be loaded
  67063. * @param onSuccess is a callback called when the task is successfully executed
  67064. * @param onError is a callback called if an error occurs
  67065. */
  67066. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67067. }
  67068. /**
  67069. * Define a task used by AssetsManager to load cube textures
  67070. */
  67071. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  67072. /**
  67073. * Defines the name of the task
  67074. */
  67075. name: string;
  67076. /**
  67077. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  67078. */
  67079. url: string;
  67080. /**
  67081. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  67082. */
  67083. extensions?: string[] | undefined;
  67084. /**
  67085. * Defines if mipmaps should not be generated (default is false)
  67086. */
  67087. noMipmap?: boolean | undefined;
  67088. /**
  67089. * Defines the explicit list of files (undefined by default)
  67090. */
  67091. files?: string[] | undefined;
  67092. /**
  67093. * Gets the loaded texture
  67094. */
  67095. texture: CubeTexture;
  67096. /**
  67097. * Callback called when the task is successful
  67098. */
  67099. onSuccess: (task: CubeTextureAssetTask) => void;
  67100. /**
  67101. * Callback called when the task is successful
  67102. */
  67103. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  67104. /**
  67105. * Creates a new CubeTextureAssetTask
  67106. * @param name defines the name of the task
  67107. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  67108. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  67109. * @param noMipmap defines if mipmaps should not be generated (default is false)
  67110. * @param files defines the explicit list of files (undefined by default)
  67111. */
  67112. constructor(
  67113. /**
  67114. * Defines the name of the task
  67115. */
  67116. name: string,
  67117. /**
  67118. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  67119. */
  67120. url: string,
  67121. /**
  67122. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  67123. */
  67124. extensions?: string[] | undefined,
  67125. /**
  67126. * Defines if mipmaps should not be generated (default is false)
  67127. */
  67128. noMipmap?: boolean | undefined,
  67129. /**
  67130. * Defines the explicit list of files (undefined by default)
  67131. */
  67132. files?: string[] | undefined);
  67133. /**
  67134. * Execute the current task
  67135. * @param scene defines the scene where you want your assets to be loaded
  67136. * @param onSuccess is a callback called when the task is successfully executed
  67137. * @param onError is a callback called if an error occurs
  67138. */
  67139. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67140. }
  67141. /**
  67142. * Define a task used by AssetsManager to load HDR cube textures
  67143. */
  67144. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  67145. /**
  67146. * Defines the name of the task
  67147. */
  67148. name: string;
  67149. /**
  67150. * Defines the location of the file to load
  67151. */
  67152. url: string;
  67153. /**
  67154. * Defines the desired size (the more it increases the longer the generation will be)
  67155. */
  67156. size: number;
  67157. /**
  67158. * Defines if mipmaps should not be generated (default is false)
  67159. */
  67160. noMipmap: boolean;
  67161. /**
  67162. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  67163. */
  67164. generateHarmonics: boolean;
  67165. /**
  67166. * 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)
  67167. */
  67168. gammaSpace: boolean;
  67169. /**
  67170. * Internal Use Only
  67171. */
  67172. reserved: boolean;
  67173. /**
  67174. * Gets the loaded texture
  67175. */
  67176. texture: HDRCubeTexture;
  67177. /**
  67178. * Callback called when the task is successful
  67179. */
  67180. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  67181. /**
  67182. * Callback called when the task is successful
  67183. */
  67184. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  67185. /**
  67186. * Creates a new HDRCubeTextureAssetTask object
  67187. * @param name defines the name of the task
  67188. * @param url defines the location of the file to load
  67189. * @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.
  67190. * @param noMipmap defines if mipmaps should not be generated (default is false)
  67191. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  67192. * @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)
  67193. * @param reserved Internal use only
  67194. */
  67195. constructor(
  67196. /**
  67197. * Defines the name of the task
  67198. */
  67199. name: string,
  67200. /**
  67201. * Defines the location of the file to load
  67202. */
  67203. url: string,
  67204. /**
  67205. * Defines the desired size (the more it increases the longer the generation will be)
  67206. */
  67207. size: number,
  67208. /**
  67209. * Defines if mipmaps should not be generated (default is false)
  67210. */
  67211. noMipmap?: boolean,
  67212. /**
  67213. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  67214. */
  67215. generateHarmonics?: boolean,
  67216. /**
  67217. * 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)
  67218. */
  67219. gammaSpace?: boolean,
  67220. /**
  67221. * Internal Use Only
  67222. */
  67223. reserved?: boolean);
  67224. /**
  67225. * Execute the current task
  67226. * @param scene defines the scene where you want your assets to be loaded
  67227. * @param onSuccess is a callback called when the task is successfully executed
  67228. * @param onError is a callback called if an error occurs
  67229. */
  67230. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67231. }
  67232. /**
  67233. * Define a task used by AssetsManager to load Equirectangular cube textures
  67234. */
  67235. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  67236. /**
  67237. * Defines the name of the task
  67238. */
  67239. name: string;
  67240. /**
  67241. * Defines the location of the file to load
  67242. */
  67243. url: string;
  67244. /**
  67245. * Defines the desired size (the more it increases the longer the generation will be)
  67246. */
  67247. size: number;
  67248. /**
  67249. * Defines if mipmaps should not be generated (default is false)
  67250. */
  67251. noMipmap: boolean;
  67252. /**
  67253. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  67254. * but the standard material would require them in Gamma space) (default is true)
  67255. */
  67256. gammaSpace: boolean;
  67257. /**
  67258. * Gets the loaded texture
  67259. */
  67260. texture: EquiRectangularCubeTexture;
  67261. /**
  67262. * Callback called when the task is successful
  67263. */
  67264. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  67265. /**
  67266. * Callback called when the task is successful
  67267. */
  67268. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  67269. /**
  67270. * Creates a new EquiRectangularCubeTextureAssetTask object
  67271. * @param name defines the name of the task
  67272. * @param url defines the location of the file to load
  67273. * @param size defines the desired size (the more it increases the longer the generation will be)
  67274. * If the size is omitted this implies you are using a preprocessed cubemap.
  67275. * @param noMipmap defines if mipmaps should not be generated (default is false)
  67276. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  67277. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  67278. * (default is true)
  67279. */
  67280. constructor(
  67281. /**
  67282. * Defines the name of the task
  67283. */
  67284. name: string,
  67285. /**
  67286. * Defines the location of the file to load
  67287. */
  67288. url: string,
  67289. /**
  67290. * Defines the desired size (the more it increases the longer the generation will be)
  67291. */
  67292. size: number,
  67293. /**
  67294. * Defines if mipmaps should not be generated (default is false)
  67295. */
  67296. noMipmap?: boolean,
  67297. /**
  67298. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  67299. * but the standard material would require them in Gamma space) (default is true)
  67300. */
  67301. gammaSpace?: boolean);
  67302. /**
  67303. * Execute the current task
  67304. * @param scene defines the scene where you want your assets to be loaded
  67305. * @param onSuccess is a callback called when the task is successfully executed
  67306. * @param onError is a callback called if an error occurs
  67307. */
  67308. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67309. }
  67310. /**
  67311. * This class can be used to easily import assets into a scene
  67312. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  67313. */
  67314. export class AssetsManager {
  67315. private _scene;
  67316. private _isLoading;
  67317. protected _tasks: AbstractAssetTask[];
  67318. protected _waitingTasksCount: number;
  67319. protected _totalTasksCount: number;
  67320. /**
  67321. * Callback called when all tasks are processed
  67322. */
  67323. onFinish: (tasks: AbstractAssetTask[]) => void;
  67324. /**
  67325. * Callback called when a task is successful
  67326. */
  67327. onTaskSuccess: (task: AbstractAssetTask) => void;
  67328. /**
  67329. * Callback called when a task had an error
  67330. */
  67331. onTaskError: (task: AbstractAssetTask) => void;
  67332. /**
  67333. * Callback called when a task is done (whatever the result is)
  67334. */
  67335. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  67336. /**
  67337. * Observable called when all tasks are processed
  67338. */
  67339. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  67340. /**
  67341. * Observable called when a task had an error
  67342. */
  67343. onTaskErrorObservable: Observable<AbstractAssetTask>;
  67344. /**
  67345. * Observable called when all tasks were executed
  67346. */
  67347. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  67348. /**
  67349. * Observable called when a task is done (whatever the result is)
  67350. */
  67351. onProgressObservable: Observable<IAssetsProgressEvent>;
  67352. /**
  67353. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  67354. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  67355. */
  67356. useDefaultLoadingScreen: boolean;
  67357. /**
  67358. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  67359. * when all assets have been downloaded.
  67360. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  67361. */
  67362. autoHideLoadingUI: boolean;
  67363. /**
  67364. * Creates a new AssetsManager
  67365. * @param scene defines the scene to work on
  67366. */
  67367. constructor(scene: Scene);
  67368. /**
  67369. * Add a MeshAssetTask to the list of active tasks
  67370. * @param taskName defines the name of the new task
  67371. * @param meshesNames defines the name of meshes to load
  67372. * @param rootUrl defines the root url to use to locate files
  67373. * @param sceneFilename defines the filename of the scene file
  67374. * @returns a new MeshAssetTask object
  67375. */
  67376. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  67377. /**
  67378. * Add a TextFileAssetTask to the list of active tasks
  67379. * @param taskName defines the name of the new task
  67380. * @param url defines the url of the file to load
  67381. * @returns a new TextFileAssetTask object
  67382. */
  67383. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  67384. /**
  67385. * Add a BinaryFileAssetTask to the list of active tasks
  67386. * @param taskName defines the name of the new task
  67387. * @param url defines the url of the file to load
  67388. * @returns a new BinaryFileAssetTask object
  67389. */
  67390. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  67391. /**
  67392. * Add a ImageAssetTask to the list of active tasks
  67393. * @param taskName defines the name of the new task
  67394. * @param url defines the url of the file to load
  67395. * @returns a new ImageAssetTask object
  67396. */
  67397. addImageTask(taskName: string, url: string): ImageAssetTask;
  67398. /**
  67399. * Add a TextureAssetTask to the list of active tasks
  67400. * @param taskName defines the name of the new task
  67401. * @param url defines the url of the file to load
  67402. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  67403. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  67404. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  67405. * @returns a new TextureAssetTask object
  67406. */
  67407. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  67408. /**
  67409. * Add a CubeTextureAssetTask to the list of active tasks
  67410. * @param taskName defines the name of the new task
  67411. * @param url defines the url of the file to load
  67412. * @param extensions defines the extension to use to load the cube map (can be null)
  67413. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  67414. * @param files defines the list of files to load (can be null)
  67415. * @returns a new CubeTextureAssetTask object
  67416. */
  67417. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  67418. /**
  67419. *
  67420. * Add a HDRCubeTextureAssetTask to the list of active tasks
  67421. * @param taskName defines the name of the new task
  67422. * @param url defines the url of the file to load
  67423. * @param size defines the size you want for the cubemap (can be null)
  67424. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  67425. * @param generateHarmonics defines if you want to automatically generate (true by default)
  67426. * @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)
  67427. * @param reserved Internal use only
  67428. * @returns a new HDRCubeTextureAssetTask object
  67429. */
  67430. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  67431. /**
  67432. *
  67433. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  67434. * @param taskName defines the name of the new task
  67435. * @param url defines the url of the file to load
  67436. * @param size defines the size you want for the cubemap (can be null)
  67437. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  67438. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  67439. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  67440. * @returns a new EquiRectangularCubeTextureAssetTask object
  67441. */
  67442. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  67443. /**
  67444. * Remove a task from the assets manager.
  67445. * @param task the task to remove
  67446. */
  67447. removeTask(task: AbstractAssetTask): void;
  67448. private _decreaseWaitingTasksCount;
  67449. private _runTask;
  67450. /**
  67451. * Reset the AssetsManager and remove all tasks
  67452. * @return the current instance of the AssetsManager
  67453. */
  67454. reset(): AssetsManager;
  67455. /**
  67456. * Start the loading process
  67457. * @return the current instance of the AssetsManager
  67458. */
  67459. load(): AssetsManager;
  67460. /**
  67461. * Start the loading process as an async operation
  67462. * @return a promise returning the list of failed tasks
  67463. */
  67464. loadAsync(): Promise<void>;
  67465. }
  67466. }
  67467. declare module "babylonjs/Misc/deferred" {
  67468. /**
  67469. * Wrapper class for promise with external resolve and reject.
  67470. */
  67471. export class Deferred<T> {
  67472. /**
  67473. * The promise associated with this deferred object.
  67474. */
  67475. readonly promise: Promise<T>;
  67476. private _resolve;
  67477. private _reject;
  67478. /**
  67479. * The resolve method of the promise associated with this deferred object.
  67480. */
  67481. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  67482. /**
  67483. * The reject method of the promise associated with this deferred object.
  67484. */
  67485. readonly reject: (reason?: any) => void;
  67486. /**
  67487. * Constructor for this deferred object.
  67488. */
  67489. constructor();
  67490. }
  67491. }
  67492. declare module "babylonjs/Misc/meshExploder" {
  67493. import { Mesh } from "babylonjs/Meshes/mesh";
  67494. /**
  67495. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  67496. */
  67497. export class MeshExploder {
  67498. private _centerMesh;
  67499. private _meshes;
  67500. private _meshesOrigins;
  67501. private _toCenterVectors;
  67502. private _scaledDirection;
  67503. private _newPosition;
  67504. private _centerPosition;
  67505. /**
  67506. * Explodes meshes from a center mesh.
  67507. * @param meshes The meshes to explode.
  67508. * @param centerMesh The mesh to be center of explosion.
  67509. */
  67510. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  67511. private _setCenterMesh;
  67512. /**
  67513. * Get class name
  67514. * @returns "MeshExploder"
  67515. */
  67516. getClassName(): string;
  67517. /**
  67518. * "Exploded meshes"
  67519. * @returns Array of meshes with the centerMesh at index 0.
  67520. */
  67521. getMeshes(): Array<Mesh>;
  67522. /**
  67523. * Explodes meshes giving a specific direction
  67524. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  67525. */
  67526. explode(direction?: number): void;
  67527. }
  67528. }
  67529. declare module "babylonjs/Misc/filesInput" {
  67530. import { Engine } from "babylonjs/Engines/engine";
  67531. import { Scene } from "babylonjs/scene";
  67532. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  67533. /**
  67534. * Class used to help managing file picking and drag'n'drop
  67535. */
  67536. export class FilesInput {
  67537. /**
  67538. * List of files ready to be loaded
  67539. */
  67540. static readonly FilesToLoad: {
  67541. [key: string]: File;
  67542. };
  67543. /**
  67544. * Callback called when a file is processed
  67545. */
  67546. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  67547. private _engine;
  67548. private _currentScene;
  67549. private _sceneLoadedCallback;
  67550. private _progressCallback;
  67551. private _additionalRenderLoopLogicCallback;
  67552. private _textureLoadingCallback;
  67553. private _startingProcessingFilesCallback;
  67554. private _onReloadCallback;
  67555. private _errorCallback;
  67556. private _elementToMonitor;
  67557. private _sceneFileToLoad;
  67558. private _filesToLoad;
  67559. /**
  67560. * Creates a new FilesInput
  67561. * @param engine defines the rendering engine
  67562. * @param scene defines the hosting scene
  67563. * @param sceneLoadedCallback callback called when scene is loaded
  67564. * @param progressCallback callback called to track progress
  67565. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  67566. * @param textureLoadingCallback callback called when a texture is loading
  67567. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  67568. * @param onReloadCallback callback called when a reload is requested
  67569. * @param errorCallback callback call if an error occurs
  67570. */
  67571. 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);
  67572. private _dragEnterHandler;
  67573. private _dragOverHandler;
  67574. private _dropHandler;
  67575. /**
  67576. * Calls this function to listen to drag'n'drop events on a specific DOM element
  67577. * @param elementToMonitor defines the DOM element to track
  67578. */
  67579. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  67580. /**
  67581. * Release all associated resources
  67582. */
  67583. dispose(): void;
  67584. private renderFunction;
  67585. private drag;
  67586. private drop;
  67587. private _traverseFolder;
  67588. private _processFiles;
  67589. /**
  67590. * Load files from a drop event
  67591. * @param event defines the drop event to use as source
  67592. */
  67593. loadFiles(event: any): void;
  67594. private _processReload;
  67595. /**
  67596. * Reload the current scene from the loaded files
  67597. */
  67598. reload(): void;
  67599. }
  67600. }
  67601. declare module "babylonjs/Misc/HighDynamicRange/index" {
  67602. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  67603. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  67604. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  67605. }
  67606. declare module "babylonjs/Misc/sceneOptimizer" {
  67607. import { Scene, IDisposable } from "babylonjs/scene";
  67608. import { Observable } from "babylonjs/Misc/observable";
  67609. /**
  67610. * Defines the root class used to create scene optimization to use with SceneOptimizer
  67611. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  67612. */
  67613. export class SceneOptimization {
  67614. /**
  67615. * Defines the priority of this optimization (0 by default which means first in the list)
  67616. */
  67617. priority: number;
  67618. /**
  67619. * Gets a string describing the action executed by the current optimization
  67620. * @returns description string
  67621. */
  67622. getDescription(): string;
  67623. /**
  67624. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  67625. * @param scene defines the current scene where to apply this optimization
  67626. * @param optimizer defines the current optimizer
  67627. * @returns true if everything that can be done was applied
  67628. */
  67629. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  67630. /**
  67631. * Creates the SceneOptimization object
  67632. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  67633. * @param desc defines the description associated with the optimization
  67634. */
  67635. constructor(
  67636. /**
  67637. * Defines the priority of this optimization (0 by default which means first in the list)
  67638. */
  67639. priority?: number);
  67640. }
  67641. /**
  67642. * Defines an optimization used to reduce the size of render target textures
  67643. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  67644. */
  67645. export class TextureOptimization extends SceneOptimization {
  67646. /**
  67647. * Defines the priority of this optimization (0 by default which means first in the list)
  67648. */
  67649. priority: number;
  67650. /**
  67651. * 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
  67652. */
  67653. maximumSize: number;
  67654. /**
  67655. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  67656. */
  67657. step: number;
  67658. /**
  67659. * Gets a string describing the action executed by the current optimization
  67660. * @returns description string
  67661. */
  67662. getDescription(): string;
  67663. /**
  67664. * Creates the TextureOptimization object
  67665. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  67666. * @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
  67667. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  67668. */
  67669. constructor(
  67670. /**
  67671. * Defines the priority of this optimization (0 by default which means first in the list)
  67672. */
  67673. priority?: number,
  67674. /**
  67675. * 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
  67676. */
  67677. maximumSize?: number,
  67678. /**
  67679. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  67680. */
  67681. step?: number);
  67682. /**
  67683. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  67684. * @param scene defines the current scene where to apply this optimization
  67685. * @param optimizer defines the current optimizer
  67686. * @returns true if everything that can be done was applied
  67687. */
  67688. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  67689. }
  67690. /**
  67691. * Defines an optimization used to increase or decrease the rendering resolution
  67692. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  67693. */
  67694. export class HardwareScalingOptimization extends SceneOptimization {
  67695. /**
  67696. * Defines the priority of this optimization (0 by default which means first in the list)
  67697. */
  67698. priority: number;
  67699. /**
  67700. * Defines the maximum scale to use (2 by default)
  67701. */
  67702. maximumScale: number;
  67703. /**
  67704. * Defines the step to use between two passes (0.5 by default)
  67705. */
  67706. step: number;
  67707. private _currentScale;
  67708. private _directionOffset;
  67709. /**
  67710. * Gets a string describing the action executed by the current optimization
  67711. * @return description string
  67712. */
  67713. getDescription(): string;
  67714. /**
  67715. * Creates the HardwareScalingOptimization object
  67716. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  67717. * @param maximumScale defines the maximum scale to use (2 by default)
  67718. * @param step defines the step to use between two passes (0.5 by default)
  67719. */
  67720. constructor(
  67721. /**
  67722. * Defines the priority of this optimization (0 by default which means first in the list)
  67723. */
  67724. priority?: number,
  67725. /**
  67726. * Defines the maximum scale to use (2 by default)
  67727. */
  67728. maximumScale?: number,
  67729. /**
  67730. * Defines the step to use between two passes (0.5 by default)
  67731. */
  67732. step?: number);
  67733. /**
  67734. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  67735. * @param scene defines the current scene where to apply this optimization
  67736. * @param optimizer defines the current optimizer
  67737. * @returns true if everything that can be done was applied
  67738. */
  67739. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  67740. }
  67741. /**
  67742. * Defines an optimization used to remove shadows
  67743. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  67744. */
  67745. export class ShadowsOptimization extends SceneOptimization {
  67746. /**
  67747. * Gets a string describing the action executed by the current optimization
  67748. * @return description string
  67749. */
  67750. getDescription(): string;
  67751. /**
  67752. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  67753. * @param scene defines the current scene where to apply this optimization
  67754. * @param optimizer defines the current optimizer
  67755. * @returns true if everything that can be done was applied
  67756. */
  67757. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  67758. }
  67759. /**
  67760. * Defines an optimization used to turn post-processes off
  67761. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  67762. */
  67763. export class PostProcessesOptimization extends SceneOptimization {
  67764. /**
  67765. * Gets a string describing the action executed by the current optimization
  67766. * @return description string
  67767. */
  67768. getDescription(): string;
  67769. /**
  67770. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  67771. * @param scene defines the current scene where to apply this optimization
  67772. * @param optimizer defines the current optimizer
  67773. * @returns true if everything that can be done was applied
  67774. */
  67775. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  67776. }
  67777. /**
  67778. * Defines an optimization used to turn lens flares off
  67779. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  67780. */
  67781. export class LensFlaresOptimization extends SceneOptimization {
  67782. /**
  67783. * Gets a string describing the action executed by the current optimization
  67784. * @return description string
  67785. */
  67786. getDescription(): string;
  67787. /**
  67788. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  67789. * @param scene defines the current scene where to apply this optimization
  67790. * @param optimizer defines the current optimizer
  67791. * @returns true if everything that can be done was applied
  67792. */
  67793. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  67794. }
  67795. /**
  67796. * Defines an optimization based on user defined callback.
  67797. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  67798. */
  67799. export class CustomOptimization extends SceneOptimization {
  67800. /**
  67801. * Callback called to apply the custom optimization.
  67802. */
  67803. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  67804. /**
  67805. * Callback called to get custom description
  67806. */
  67807. onGetDescription: () => string;
  67808. /**
  67809. * Gets a string describing the action executed by the current optimization
  67810. * @returns description string
  67811. */
  67812. getDescription(): string;
  67813. /**
  67814. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  67815. * @param scene defines the current scene where to apply this optimization
  67816. * @param optimizer defines the current optimizer
  67817. * @returns true if everything that can be done was applied
  67818. */
  67819. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  67820. }
  67821. /**
  67822. * Defines an optimization used to turn particles off
  67823. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  67824. */
  67825. export class ParticlesOptimization extends SceneOptimization {
  67826. /**
  67827. * Gets a string describing the action executed by the current optimization
  67828. * @return description string
  67829. */
  67830. getDescription(): string;
  67831. /**
  67832. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  67833. * @param scene defines the current scene where to apply this optimization
  67834. * @param optimizer defines the current optimizer
  67835. * @returns true if everything that can be done was applied
  67836. */
  67837. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  67838. }
  67839. /**
  67840. * Defines an optimization used to turn render targets off
  67841. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  67842. */
  67843. export class RenderTargetsOptimization extends SceneOptimization {
  67844. /**
  67845. * Gets a string describing the action executed by the current optimization
  67846. * @return description string
  67847. */
  67848. getDescription(): string;
  67849. /**
  67850. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  67851. * @param scene defines the current scene where to apply this optimization
  67852. * @param optimizer defines the current optimizer
  67853. * @returns true if everything that can be done was applied
  67854. */
  67855. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  67856. }
  67857. /**
  67858. * Defines an optimization used to merge meshes with compatible materials
  67859. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  67860. */
  67861. export class MergeMeshesOptimization extends SceneOptimization {
  67862. private static _UpdateSelectionTree;
  67863. /**
  67864. * Gets or sets a boolean which defines if optimization octree has to be updated
  67865. */
  67866. /**
  67867. * Gets or sets a boolean which defines if optimization octree has to be updated
  67868. */
  67869. static UpdateSelectionTree: boolean;
  67870. /**
  67871. * Gets a string describing the action executed by the current optimization
  67872. * @return description string
  67873. */
  67874. getDescription(): string;
  67875. private _canBeMerged;
  67876. /**
  67877. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  67878. * @param scene defines the current scene where to apply this optimization
  67879. * @param optimizer defines the current optimizer
  67880. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  67881. * @returns true if everything that can be done was applied
  67882. */
  67883. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  67884. }
  67885. /**
  67886. * Defines a list of options used by SceneOptimizer
  67887. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  67888. */
  67889. export class SceneOptimizerOptions {
  67890. /**
  67891. * Defines the target frame rate to reach (60 by default)
  67892. */
  67893. targetFrameRate: number;
  67894. /**
  67895. * Defines the interval between two checkes (2000ms by default)
  67896. */
  67897. trackerDuration: number;
  67898. /**
  67899. * Gets the list of optimizations to apply
  67900. */
  67901. optimizations: SceneOptimization[];
  67902. /**
  67903. * Creates a new list of options used by SceneOptimizer
  67904. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  67905. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  67906. */
  67907. constructor(
  67908. /**
  67909. * Defines the target frame rate to reach (60 by default)
  67910. */
  67911. targetFrameRate?: number,
  67912. /**
  67913. * Defines the interval between two checkes (2000ms by default)
  67914. */
  67915. trackerDuration?: number);
  67916. /**
  67917. * Add a new optimization
  67918. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  67919. * @returns the current SceneOptimizerOptions
  67920. */
  67921. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  67922. /**
  67923. * Add a new custom optimization
  67924. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  67925. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  67926. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  67927. * @returns the current SceneOptimizerOptions
  67928. */
  67929. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  67930. /**
  67931. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  67932. * @param targetFrameRate defines the target frame rate (60 by default)
  67933. * @returns a SceneOptimizerOptions object
  67934. */
  67935. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  67936. /**
  67937. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  67938. * @param targetFrameRate defines the target frame rate (60 by default)
  67939. * @returns a SceneOptimizerOptions object
  67940. */
  67941. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  67942. /**
  67943. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  67944. * @param targetFrameRate defines the target frame rate (60 by default)
  67945. * @returns a SceneOptimizerOptions object
  67946. */
  67947. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  67948. }
  67949. /**
  67950. * Class used to run optimizations in order to reach a target frame rate
  67951. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  67952. */
  67953. export class SceneOptimizer implements IDisposable {
  67954. private _isRunning;
  67955. private _options;
  67956. private _scene;
  67957. private _currentPriorityLevel;
  67958. private _targetFrameRate;
  67959. private _trackerDuration;
  67960. private _currentFrameRate;
  67961. private _sceneDisposeObserver;
  67962. private _improvementMode;
  67963. /**
  67964. * Defines an observable called when the optimizer reaches the target frame rate
  67965. */
  67966. onSuccessObservable: Observable<SceneOptimizer>;
  67967. /**
  67968. * Defines an observable called when the optimizer enables an optimization
  67969. */
  67970. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  67971. /**
  67972. * Defines an observable called when the optimizer is not able to reach the target frame rate
  67973. */
  67974. onFailureObservable: Observable<SceneOptimizer>;
  67975. /**
  67976. * Gets a boolean indicating if the optimizer is in improvement mode
  67977. */
  67978. readonly isInImprovementMode: boolean;
  67979. /**
  67980. * Gets the current priority level (0 at start)
  67981. */
  67982. readonly currentPriorityLevel: number;
  67983. /**
  67984. * Gets the current frame rate checked by the SceneOptimizer
  67985. */
  67986. readonly currentFrameRate: number;
  67987. /**
  67988. * Gets or sets the current target frame rate (60 by default)
  67989. */
  67990. /**
  67991. * Gets or sets the current target frame rate (60 by default)
  67992. */
  67993. targetFrameRate: number;
  67994. /**
  67995. * Gets or sets the current interval between two checks (every 2000ms by default)
  67996. */
  67997. /**
  67998. * Gets or sets the current interval between two checks (every 2000ms by default)
  67999. */
  68000. trackerDuration: number;
  68001. /**
  68002. * Gets the list of active optimizations
  68003. */
  68004. readonly optimizations: SceneOptimization[];
  68005. /**
  68006. * Creates a new SceneOptimizer
  68007. * @param scene defines the scene to work on
  68008. * @param options defines the options to use with the SceneOptimizer
  68009. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  68010. * @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)
  68011. */
  68012. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  68013. /**
  68014. * Stops the current optimizer
  68015. */
  68016. stop(): void;
  68017. /**
  68018. * Reset the optimizer to initial step (current priority level = 0)
  68019. */
  68020. reset(): void;
  68021. /**
  68022. * Start the optimizer. By default it will try to reach a specific framerate
  68023. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  68024. */
  68025. start(): void;
  68026. private _checkCurrentState;
  68027. /**
  68028. * Release all resources
  68029. */
  68030. dispose(): void;
  68031. /**
  68032. * Helper function to create a SceneOptimizer with one single line of code
  68033. * @param scene defines the scene to work on
  68034. * @param options defines the options to use with the SceneOptimizer
  68035. * @param onSuccess defines a callback to call on success
  68036. * @param onFailure defines a callback to call on failure
  68037. * @returns the new SceneOptimizer object
  68038. */
  68039. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  68040. }
  68041. }
  68042. declare module "babylonjs/Misc/sceneSerializer" {
  68043. import { Scene } from "babylonjs/scene";
  68044. /**
  68045. * Class used to serialize a scene into a string
  68046. */
  68047. export class SceneSerializer {
  68048. /**
  68049. * Clear cache used by a previous serialization
  68050. */
  68051. static ClearCache(): void;
  68052. /**
  68053. * Serialize a scene into a JSON compatible object
  68054. * @param scene defines the scene to serialize
  68055. * @returns a JSON compatible object
  68056. */
  68057. static Serialize(scene: Scene): any;
  68058. /**
  68059. * Serialize a mesh into a JSON compatible object
  68060. * @param toSerialize defines the mesh to serialize
  68061. * @param withParents defines if parents must be serialized as well
  68062. * @param withChildren defines if children must be serialized as well
  68063. * @returns a JSON compatible object
  68064. */
  68065. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  68066. }
  68067. }
  68068. declare module "babylonjs/Misc/textureTools" {
  68069. import { Texture } from "babylonjs/Materials/Textures/texture";
  68070. /**
  68071. * Class used to host texture specific utilities
  68072. */
  68073. export class TextureTools {
  68074. /**
  68075. * Uses the GPU to create a copy texture rescaled at a given size
  68076. * @param texture Texture to copy from
  68077. * @param width defines the desired width
  68078. * @param height defines the desired height
  68079. * @param useBilinearMode defines if bilinear mode has to be used
  68080. * @return the generated texture
  68081. */
  68082. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  68083. }
  68084. }
  68085. declare module "babylonjs/Misc/videoRecorder" {
  68086. import { Nullable } from "babylonjs/types";
  68087. import { Engine } from "babylonjs/Engines/engine";
  68088. /**
  68089. * This represents the different options available for the video capture.
  68090. */
  68091. export interface VideoRecorderOptions {
  68092. /** Defines the mime type of the video. */
  68093. mimeType: string;
  68094. /** Defines the FPS the video should be recorded at. */
  68095. fps: number;
  68096. /** Defines the chunk size for the recording data. */
  68097. recordChunckSize: number;
  68098. /** The audio tracks to attach to the recording. */
  68099. audioTracks?: MediaStreamTrack[];
  68100. }
  68101. /**
  68102. * This can help with recording videos from BabylonJS.
  68103. * This is based on the available WebRTC functionalities of the browser.
  68104. *
  68105. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  68106. */
  68107. export class VideoRecorder {
  68108. private static readonly _defaultOptions;
  68109. /**
  68110. * Returns whether or not the VideoRecorder is available in your browser.
  68111. * @param engine Defines the Babylon Engine.
  68112. * @returns true if supported otherwise false.
  68113. */
  68114. static IsSupported(engine: Engine): boolean;
  68115. private readonly _options;
  68116. private _canvas;
  68117. private _mediaRecorder;
  68118. private _recordedChunks;
  68119. private _fileName;
  68120. private _resolve;
  68121. private _reject;
  68122. /**
  68123. * True when a recording is already in progress.
  68124. */
  68125. readonly isRecording: boolean;
  68126. /**
  68127. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  68128. * @param engine Defines the BabylonJS Engine you wish to record.
  68129. * @param options Defines options that can be used to customize the capture.
  68130. */
  68131. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  68132. /**
  68133. * Stops the current recording before the default capture timeout passed in the startRecording function.
  68134. */
  68135. stopRecording(): void;
  68136. /**
  68137. * Starts recording the canvas for a max duration specified in parameters.
  68138. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  68139. * If null no automatic download will start and you can rely on the promise to get the data back.
  68140. * @param maxDuration Defines the maximum recording time in seconds.
  68141. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  68142. * @return A promise callback at the end of the recording with the video data in Blob.
  68143. */
  68144. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  68145. /**
  68146. * Releases internal resources used during the recording.
  68147. */
  68148. dispose(): void;
  68149. private _handleDataAvailable;
  68150. private _handleError;
  68151. private _handleStop;
  68152. }
  68153. }
  68154. declare module "babylonjs/Misc/screenshotTools" {
  68155. import { Camera } from "babylonjs/Cameras/camera";
  68156. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  68157. import { Engine } from "babylonjs/Engines/engine";
  68158. /**
  68159. * Class containing a set of static utilities functions for screenshots
  68160. */
  68161. export class ScreenshotTools {
  68162. /**
  68163. * Captures a screenshot of the current rendering
  68164. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  68165. * @param engine defines the rendering engine
  68166. * @param camera defines the source camera
  68167. * @param size This parameter can be set to a single number or to an object with the
  68168. * following (optional) properties: precision, width, height. If a single number is passed,
  68169. * it will be used for both width and height. If an object is passed, the screenshot size
  68170. * will be derived from the parameters. The precision property is a multiplier allowing
  68171. * rendering at a higher or lower resolution
  68172. * @param successCallback defines the callback receives a single parameter which contains the
  68173. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  68174. * src parameter of an <img> to display it
  68175. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  68176. * Check your browser for supported MIME types
  68177. */
  68178. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  68179. /**
  68180. * Captures a screenshot of the current rendering
  68181. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  68182. * @param engine defines the rendering engine
  68183. * @param camera defines the source camera
  68184. * @param size This parameter can be set to a single number or to an object with the
  68185. * following (optional) properties: precision, width, height. If a single number is passed,
  68186. * it will be used for both width and height. If an object is passed, the screenshot size
  68187. * will be derived from the parameters. The precision property is a multiplier allowing
  68188. * rendering at a higher or lower resolution
  68189. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  68190. * Check your browser for supported MIME types
  68191. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  68192. * to the src parameter of an <img> to display it
  68193. */
  68194. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  68195. /**
  68196. * Generates an image screenshot from the specified camera.
  68197. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  68198. * @param engine The engine to use for rendering
  68199. * @param camera The camera to use for rendering
  68200. * @param size This parameter can be set to a single number or to an object with the
  68201. * following (optional) properties: precision, width, height. If a single number is passed,
  68202. * it will be used for both width and height. If an object is passed, the screenshot size
  68203. * will be derived from the parameters. The precision property is a multiplier allowing
  68204. * rendering at a higher or lower resolution
  68205. * @param successCallback The callback receives a single parameter which contains the
  68206. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  68207. * src parameter of an <img> to display it
  68208. * @param mimeType The MIME type of the screenshot image (default: image/png).
  68209. * Check your browser for supported MIME types
  68210. * @param samples Texture samples (default: 1)
  68211. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  68212. * @param fileName A name for for the downloaded file.
  68213. */
  68214. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  68215. /**
  68216. * Generates an image screenshot from the specified camera.
  68217. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  68218. * @param engine The engine to use for rendering
  68219. * @param camera The camera to use for rendering
  68220. * @param size This parameter can be set to a single number or to an object with the
  68221. * following (optional) properties: precision, width, height. If a single number is passed,
  68222. * it will be used for both width and height. If an object is passed, the screenshot size
  68223. * will be derived from the parameters. The precision property is a multiplier allowing
  68224. * rendering at a higher or lower resolution
  68225. * @param mimeType The MIME type of the screenshot image (default: image/png).
  68226. * Check your browser for supported MIME types
  68227. * @param samples Texture samples (default: 1)
  68228. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  68229. * @param fileName A name for for the downloaded file.
  68230. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  68231. * to the src parameter of an <img> to display it
  68232. */
  68233. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  68234. /**
  68235. * Gets height and width for screenshot size
  68236. * @private
  68237. */
  68238. private static _getScreenshotSize;
  68239. }
  68240. }
  68241. declare module "babylonjs/Misc/dataReader" {
  68242. /**
  68243. * Interface for a data buffer
  68244. */
  68245. export interface IDataBuffer {
  68246. /**
  68247. * Reads bytes from the data buffer.
  68248. * @param byteOffset The byte offset to read
  68249. * @param byteLength The byte length to read
  68250. * @returns A promise that resolves when the bytes are read
  68251. */
  68252. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  68253. /**
  68254. * The byte length of the buffer.
  68255. */
  68256. readonly byteLength: number;
  68257. }
  68258. /**
  68259. * Utility class for reading from a data buffer
  68260. */
  68261. export class DataReader {
  68262. /**
  68263. * The data buffer associated with this data reader.
  68264. */
  68265. readonly buffer: IDataBuffer;
  68266. /**
  68267. * The current byte offset from the beginning of the data buffer.
  68268. */
  68269. byteOffset: number;
  68270. private _dataView;
  68271. private _dataByteOffset;
  68272. /**
  68273. * Constructor
  68274. * @param buffer The buffer to read
  68275. */
  68276. constructor(buffer: IDataBuffer);
  68277. /**
  68278. * Loads the given byte length.
  68279. * @param byteLength The byte length to load
  68280. * @returns A promise that resolves when the load is complete
  68281. */
  68282. loadAsync(byteLength: number): Promise<void>;
  68283. /**
  68284. * Read a unsigned 32-bit integer from the currently loaded data range.
  68285. * @returns The 32-bit integer read
  68286. */
  68287. readUint32(): number;
  68288. /**
  68289. * Read a byte array from the currently loaded data range.
  68290. * @param byteLength The byte length to read
  68291. * @returns The byte array read
  68292. */
  68293. readUint8Array(byteLength: number): Uint8Array;
  68294. /**
  68295. * Read a string from the currently loaded data range.
  68296. * @param byteLength The byte length to read
  68297. * @returns The string read
  68298. */
  68299. readString(byteLength: number): string;
  68300. /**
  68301. * Skips the given byte length the currently loaded data range.
  68302. * @param byteLength The byte length to skip
  68303. */
  68304. skipBytes(byteLength: number): void;
  68305. }
  68306. }
  68307. declare module "babylonjs/Misc/index" {
  68308. export * from "babylonjs/Misc/andOrNotEvaluator";
  68309. export * from "babylonjs/Misc/assetsManager";
  68310. export * from "babylonjs/Misc/dds";
  68311. export * from "babylonjs/Misc/decorators";
  68312. export * from "babylonjs/Misc/deferred";
  68313. export * from "babylonjs/Misc/environmentTextureTools";
  68314. export * from "babylonjs/Misc/meshExploder";
  68315. export * from "babylonjs/Misc/filesInput";
  68316. export * from "babylonjs/Misc/HighDynamicRange/index";
  68317. export * from "babylonjs/Misc/khronosTextureContainer";
  68318. export * from "babylonjs/Misc/observable";
  68319. export * from "babylonjs/Misc/performanceMonitor";
  68320. export * from "babylonjs/Misc/promise";
  68321. export * from "babylonjs/Misc/sceneOptimizer";
  68322. export * from "babylonjs/Misc/sceneSerializer";
  68323. export * from "babylonjs/Misc/smartArray";
  68324. export * from "babylonjs/Misc/stringDictionary";
  68325. export * from "babylonjs/Misc/tags";
  68326. export * from "babylonjs/Misc/textureTools";
  68327. export * from "babylonjs/Misc/tga";
  68328. export * from "babylonjs/Misc/tools";
  68329. export * from "babylonjs/Misc/videoRecorder";
  68330. export * from "babylonjs/Misc/virtualJoystick";
  68331. export * from "babylonjs/Misc/workerPool";
  68332. export * from "babylonjs/Misc/logger";
  68333. export * from "babylonjs/Misc/typeStore";
  68334. export * from "babylonjs/Misc/filesInputStore";
  68335. export * from "babylonjs/Misc/deepCopier";
  68336. export * from "babylonjs/Misc/pivotTools";
  68337. export * from "babylonjs/Misc/precisionDate";
  68338. export * from "babylonjs/Misc/screenshotTools";
  68339. export * from "babylonjs/Misc/typeStore";
  68340. export * from "babylonjs/Misc/webRequest";
  68341. export * from "babylonjs/Misc/iInspectable";
  68342. export * from "babylonjs/Misc/brdfTextureTools";
  68343. export * from "babylonjs/Misc/rgbdTextureTools";
  68344. export * from "babylonjs/Misc/gradients";
  68345. export * from "babylonjs/Misc/perfCounter";
  68346. export * from "babylonjs/Misc/fileRequest";
  68347. export * from "babylonjs/Misc/customAnimationFrameRequester";
  68348. export * from "babylonjs/Misc/retryStrategy";
  68349. export * from "babylonjs/Misc/interfaces/screenshotSize";
  68350. export * from "babylonjs/Misc/canvasGenerator";
  68351. export * from "babylonjs/Misc/fileTools";
  68352. export * from "babylonjs/Misc/stringTools";
  68353. export * from "babylonjs/Misc/dataReader";
  68354. }
  68355. declare module "babylonjs/index" {
  68356. export * from "babylonjs/abstractScene";
  68357. export * from "babylonjs/Actions/index";
  68358. export * from "babylonjs/Animations/index";
  68359. export * from "babylonjs/assetContainer";
  68360. export * from "babylonjs/Audio/index";
  68361. export * from "babylonjs/Behaviors/index";
  68362. export * from "babylonjs/Bones/index";
  68363. export * from "babylonjs/Cameras/index";
  68364. export * from "babylonjs/Collisions/index";
  68365. export * from "babylonjs/Culling/index";
  68366. export * from "babylonjs/Debug/index";
  68367. export * from "babylonjs/Engines/index";
  68368. export * from "babylonjs/Events/index";
  68369. export * from "babylonjs/Gamepads/index";
  68370. export * from "babylonjs/Gizmos/index";
  68371. export * from "babylonjs/Helpers/index";
  68372. export * from "babylonjs/Instrumentation/index";
  68373. export * from "babylonjs/Layers/index";
  68374. export * from "babylonjs/LensFlares/index";
  68375. export * from "babylonjs/Lights/index";
  68376. export * from "babylonjs/Loading/index";
  68377. export * from "babylonjs/Materials/index";
  68378. export * from "babylonjs/Maths/index";
  68379. export * from "babylonjs/Meshes/index";
  68380. export * from "babylonjs/Morph/index";
  68381. export * from "babylonjs/Navigation/index";
  68382. export * from "babylonjs/node";
  68383. export * from "babylonjs/Offline/index";
  68384. export * from "babylonjs/Particles/index";
  68385. export * from "babylonjs/Physics/index";
  68386. export * from "babylonjs/PostProcesses/index";
  68387. export * from "babylonjs/Probes/index";
  68388. export * from "babylonjs/Rendering/index";
  68389. export * from "babylonjs/scene";
  68390. export * from "babylonjs/sceneComponent";
  68391. export * from "babylonjs/Sprites/index";
  68392. export * from "babylonjs/States/index";
  68393. export * from "babylonjs/Misc/index";
  68394. export * from "babylonjs/types";
  68395. }
  68396. declare module "babylonjs/Animations/pathCursor" {
  68397. import { Vector3 } from "babylonjs/Maths/math.vector";
  68398. import { Path2 } from "babylonjs/Maths/math.path";
  68399. /**
  68400. * A cursor which tracks a point on a path
  68401. */
  68402. export class PathCursor {
  68403. private path;
  68404. /**
  68405. * Stores path cursor callbacks for when an onchange event is triggered
  68406. */
  68407. private _onchange;
  68408. /**
  68409. * The value of the path cursor
  68410. */
  68411. value: number;
  68412. /**
  68413. * The animation array of the path cursor
  68414. */
  68415. animations: Animation[];
  68416. /**
  68417. * Initializes the path cursor
  68418. * @param path The path to track
  68419. */
  68420. constructor(path: Path2);
  68421. /**
  68422. * Gets the cursor point on the path
  68423. * @returns A point on the path cursor at the cursor location
  68424. */
  68425. getPoint(): Vector3;
  68426. /**
  68427. * Moves the cursor ahead by the step amount
  68428. * @param step The amount to move the cursor forward
  68429. * @returns This path cursor
  68430. */
  68431. moveAhead(step?: number): PathCursor;
  68432. /**
  68433. * Moves the cursor behind by the step amount
  68434. * @param step The amount to move the cursor back
  68435. * @returns This path cursor
  68436. */
  68437. moveBack(step?: number): PathCursor;
  68438. /**
  68439. * Moves the cursor by the step amount
  68440. * If the step amount is greater than one, an exception is thrown
  68441. * @param step The amount to move the cursor
  68442. * @returns This path cursor
  68443. */
  68444. move(step: number): PathCursor;
  68445. /**
  68446. * Ensures that the value is limited between zero and one
  68447. * @returns This path cursor
  68448. */
  68449. private ensureLimits;
  68450. /**
  68451. * Runs onchange callbacks on change (used by the animation engine)
  68452. * @returns This path cursor
  68453. */
  68454. private raiseOnChange;
  68455. /**
  68456. * Executes a function on change
  68457. * @param f A path cursor onchange callback
  68458. * @returns This path cursor
  68459. */
  68460. onchange(f: (cursor: PathCursor) => void): PathCursor;
  68461. }
  68462. }
  68463. declare module "babylonjs/Engines/Processors/Expressions/Operators/index" {
  68464. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator";
  68465. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator";
  68466. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator";
  68467. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator";
  68468. }
  68469. declare module "babylonjs/Engines/Processors/Expressions/index" {
  68470. export * from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  68471. export * from "babylonjs/Engines/Processors/Expressions/Operators/index";
  68472. }
  68473. declare module "babylonjs/Engines/Processors/index" {
  68474. export * from "babylonjs/Engines/Processors/iShaderProcessor";
  68475. export * from "babylonjs/Engines/Processors/Expressions/index";
  68476. export * from "babylonjs/Engines/Processors/shaderCodeConditionNode";
  68477. export * from "babylonjs/Engines/Processors/shaderCodeCursor";
  68478. export * from "babylonjs/Engines/Processors/shaderCodeNode";
  68479. export * from "babylonjs/Engines/Processors/shaderCodeTestNode";
  68480. export * from "babylonjs/Engines/Processors/shaderProcessingOptions";
  68481. export * from "babylonjs/Engines/Processors/shaderProcessor";
  68482. }
  68483. declare module "babylonjs/Legacy/legacy" {
  68484. import * as Babylon from "babylonjs/index";
  68485. export * from "babylonjs/index";
  68486. }
  68487. declare module "babylonjs/Shaders/blur.fragment" {
  68488. /** @hidden */
  68489. export var blurPixelShader: {
  68490. name: string;
  68491. shader: string;
  68492. };
  68493. }
  68494. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  68495. /** @hidden */
  68496. export var pointCloudVertexDeclaration: {
  68497. name: string;
  68498. shader: string;
  68499. };
  68500. }
  68501. declare module "babylonjs" {
  68502. export * from "babylonjs/Legacy/legacy";
  68503. }
  68504. declare module BABYLON {
  68505. /** Alias type for value that can be null */
  68506. export type Nullable<T> = T | null;
  68507. /**
  68508. * Alias type for number that are floats
  68509. * @ignorenaming
  68510. */
  68511. export type float = number;
  68512. /**
  68513. * Alias type for number that are doubles.
  68514. * @ignorenaming
  68515. */
  68516. export type double = number;
  68517. /**
  68518. * Alias type for number that are integer
  68519. * @ignorenaming
  68520. */
  68521. export type int = number;
  68522. /** Alias type for number array or Float32Array */
  68523. export type FloatArray = number[] | Float32Array;
  68524. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  68525. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  68526. /**
  68527. * Alias for types that can be used by a Buffer or VertexBuffer.
  68528. */
  68529. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  68530. /**
  68531. * Alias type for primitive types
  68532. * @ignorenaming
  68533. */
  68534. type Primitive = undefined | null | boolean | string | number | Function;
  68535. /**
  68536. * Type modifier to make all the properties of an object Readonly
  68537. */
  68538. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  68539. /**
  68540. * Type modifier to make all the properties of an object Readonly recursively
  68541. */
  68542. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  68543. /**
  68544. * Type modifier to make object properties readonly.
  68545. */
  68546. export type DeepImmutableObject<T> = {
  68547. readonly [K in keyof T]: DeepImmutable<T[K]>;
  68548. };
  68549. /** @hidden */
  68550. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  68551. }
  68552. }
  68553. declare module BABYLON {
  68554. /**
  68555. * A class serves as a medium between the observable and its observers
  68556. */
  68557. export class EventState {
  68558. /**
  68559. * Create a new EventState
  68560. * @param mask defines the mask associated with this state
  68561. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  68562. * @param target defines the original target of the state
  68563. * @param currentTarget defines the current target of the state
  68564. */
  68565. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  68566. /**
  68567. * Initialize the current event state
  68568. * @param mask defines the mask associated with this state
  68569. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  68570. * @param target defines the original target of the state
  68571. * @param currentTarget defines the current target of the state
  68572. * @returns the current event state
  68573. */
  68574. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  68575. /**
  68576. * An Observer can set this property to true to prevent subsequent observers of being notified
  68577. */
  68578. skipNextObservers: boolean;
  68579. /**
  68580. * Get the mask value that were used to trigger the event corresponding to this EventState object
  68581. */
  68582. mask: number;
  68583. /**
  68584. * The object that originally notified the event
  68585. */
  68586. target?: any;
  68587. /**
  68588. * The current object in the bubbling phase
  68589. */
  68590. currentTarget?: any;
  68591. /**
  68592. * This will be populated with the return value of the last function that was executed.
  68593. * If it is the first function in the callback chain it will be the event data.
  68594. */
  68595. lastReturnValue?: any;
  68596. }
  68597. /**
  68598. * Represent an Observer registered to a given Observable object.
  68599. */
  68600. export class Observer<T> {
  68601. /**
  68602. * Defines the callback to call when the observer is notified
  68603. */
  68604. callback: (eventData: T, eventState: EventState) => void;
  68605. /**
  68606. * Defines the mask of the observer (used to filter notifications)
  68607. */
  68608. mask: number;
  68609. /**
  68610. * Defines the current scope used to restore the JS context
  68611. */
  68612. scope: any;
  68613. /** @hidden */
  68614. _willBeUnregistered: boolean;
  68615. /**
  68616. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  68617. */
  68618. unregisterOnNextCall: boolean;
  68619. /**
  68620. * Creates a new observer
  68621. * @param callback defines the callback to call when the observer is notified
  68622. * @param mask defines the mask of the observer (used to filter notifications)
  68623. * @param scope defines the current scope used to restore the JS context
  68624. */
  68625. constructor(
  68626. /**
  68627. * Defines the callback to call when the observer is notified
  68628. */
  68629. callback: (eventData: T, eventState: EventState) => void,
  68630. /**
  68631. * Defines the mask of the observer (used to filter notifications)
  68632. */
  68633. mask: number,
  68634. /**
  68635. * Defines the current scope used to restore the JS context
  68636. */
  68637. scope?: any);
  68638. }
  68639. /**
  68640. * Represent a list of observers registered to multiple Observables object.
  68641. */
  68642. export class MultiObserver<T> {
  68643. private _observers;
  68644. private _observables;
  68645. /**
  68646. * Release associated resources
  68647. */
  68648. dispose(): void;
  68649. /**
  68650. * Raise a callback when one of the observable will notify
  68651. * @param observables defines a list of observables to watch
  68652. * @param callback defines the callback to call on notification
  68653. * @param mask defines the mask used to filter notifications
  68654. * @param scope defines the current scope used to restore the JS context
  68655. * @returns the new MultiObserver
  68656. */
  68657. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  68658. }
  68659. /**
  68660. * The Observable class is a simple implementation of the Observable pattern.
  68661. *
  68662. * 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.
  68663. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  68664. * 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).
  68665. * 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.
  68666. */
  68667. export class Observable<T> {
  68668. private _observers;
  68669. private _eventState;
  68670. private _onObserverAdded;
  68671. /**
  68672. * Gets the list of observers
  68673. */
  68674. readonly observers: Array<Observer<T>>;
  68675. /**
  68676. * Creates a new observable
  68677. * @param onObserverAdded defines a callback to call when a new observer is added
  68678. */
  68679. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  68680. /**
  68681. * Create a new Observer with the specified callback
  68682. * @param callback the callback that will be executed for that Observer
  68683. * @param mask the mask used to filter observers
  68684. * @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.
  68685. * @param scope optional scope for the callback to be called from
  68686. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  68687. * @returns the new observer created for the callback
  68688. */
  68689. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  68690. /**
  68691. * Create a new Observer with the specified callback and unregisters after the next notification
  68692. * @param callback the callback that will be executed for that Observer
  68693. * @returns the new observer created for the callback
  68694. */
  68695. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  68696. /**
  68697. * Remove an Observer from the Observable object
  68698. * @param observer the instance of the Observer to remove
  68699. * @returns false if it doesn't belong to this Observable
  68700. */
  68701. remove(observer: Nullable<Observer<T>>): boolean;
  68702. /**
  68703. * Remove a callback from the Observable object
  68704. * @param callback the callback to remove
  68705. * @param scope optional scope. If used only the callbacks with this scope will be removed
  68706. * @returns false if it doesn't belong to this Observable
  68707. */
  68708. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  68709. private _deferUnregister;
  68710. private _remove;
  68711. /**
  68712. * Moves the observable to the top of the observer list making it get called first when notified
  68713. * @param observer the observer to move
  68714. */
  68715. makeObserverTopPriority(observer: Observer<T>): void;
  68716. /**
  68717. * Moves the observable to the bottom of the observer list making it get called last when notified
  68718. * @param observer the observer to move
  68719. */
  68720. makeObserverBottomPriority(observer: Observer<T>): void;
  68721. /**
  68722. * Notify all Observers by calling their respective callback with the given data
  68723. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  68724. * @param eventData defines the data to send to all observers
  68725. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  68726. * @param target defines the original target of the state
  68727. * @param currentTarget defines the current target of the state
  68728. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  68729. */
  68730. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  68731. /**
  68732. * Calling this will execute each callback, expecting it to be a promise or return a value.
  68733. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  68734. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  68735. * and it is crucial that all callbacks will be executed.
  68736. * The order of the callbacks is kept, callbacks are not executed parallel.
  68737. *
  68738. * @param eventData The data to be sent to each callback
  68739. * @param mask is used to filter observers defaults to -1
  68740. * @param target defines the callback target (see EventState)
  68741. * @param currentTarget defines he current object in the bubbling phase
  68742. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  68743. */
  68744. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  68745. /**
  68746. * Notify a specific observer
  68747. * @param observer defines the observer to notify
  68748. * @param eventData defines the data to be sent to each callback
  68749. * @param mask is used to filter observers defaults to -1
  68750. */
  68751. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  68752. /**
  68753. * Gets a boolean indicating if the observable has at least one observer
  68754. * @returns true is the Observable has at least one Observer registered
  68755. */
  68756. hasObservers(): boolean;
  68757. /**
  68758. * Clear the list of observers
  68759. */
  68760. clear(): void;
  68761. /**
  68762. * Clone the current observable
  68763. * @returns a new observable
  68764. */
  68765. clone(): Observable<T>;
  68766. /**
  68767. * Does this observable handles observer registered with a given mask
  68768. * @param mask defines the mask to be tested
  68769. * @return whether or not one observer registered with the given mask is handeled
  68770. **/
  68771. hasSpecificMask(mask?: number): boolean;
  68772. }
  68773. }
  68774. declare module BABYLON {
  68775. /**
  68776. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  68777. * Babylon.js
  68778. */
  68779. export class DomManagement {
  68780. /**
  68781. * Checks if the window object exists
  68782. * @returns true if the window object exists
  68783. */
  68784. static IsWindowObjectExist(): boolean;
  68785. /**
  68786. * Checks if the navigator object exists
  68787. * @returns true if the navigator object exists
  68788. */
  68789. static IsNavigatorAvailable(): boolean;
  68790. /**
  68791. * Extracts text content from a DOM element hierarchy
  68792. * @param element defines the root element
  68793. * @returns a string
  68794. */
  68795. static GetDOMTextContent(element: HTMLElement): string;
  68796. }
  68797. }
  68798. declare module BABYLON {
  68799. /**
  68800. * Logger used througouht the application to allow configuration of
  68801. * the log level required for the messages.
  68802. */
  68803. export class Logger {
  68804. /**
  68805. * No log
  68806. */
  68807. static readonly NoneLogLevel: number;
  68808. /**
  68809. * Only message logs
  68810. */
  68811. static readonly MessageLogLevel: number;
  68812. /**
  68813. * Only warning logs
  68814. */
  68815. static readonly WarningLogLevel: number;
  68816. /**
  68817. * Only error logs
  68818. */
  68819. static readonly ErrorLogLevel: number;
  68820. /**
  68821. * All logs
  68822. */
  68823. static readonly AllLogLevel: number;
  68824. private static _LogCache;
  68825. /**
  68826. * Gets a value indicating the number of loading errors
  68827. * @ignorenaming
  68828. */
  68829. static errorsCount: number;
  68830. /**
  68831. * Callback called when a new log is added
  68832. */
  68833. static OnNewCacheEntry: (entry: string) => void;
  68834. private static _AddLogEntry;
  68835. private static _FormatMessage;
  68836. private static _LogDisabled;
  68837. private static _LogEnabled;
  68838. private static _WarnDisabled;
  68839. private static _WarnEnabled;
  68840. private static _ErrorDisabled;
  68841. private static _ErrorEnabled;
  68842. /**
  68843. * Log a message to the console
  68844. */
  68845. static Log: (message: string) => void;
  68846. /**
  68847. * Write a warning message to the console
  68848. */
  68849. static Warn: (message: string) => void;
  68850. /**
  68851. * Write an error message to the console
  68852. */
  68853. static Error: (message: string) => void;
  68854. /**
  68855. * Gets current log cache (list of logs)
  68856. */
  68857. static readonly LogCache: string;
  68858. /**
  68859. * Clears the log cache
  68860. */
  68861. static ClearLogCache(): void;
  68862. /**
  68863. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  68864. */
  68865. static LogLevels: number;
  68866. }
  68867. }
  68868. declare module BABYLON {
  68869. /** @hidden */
  68870. export class _TypeStore {
  68871. /** @hidden */
  68872. static RegisteredTypes: {
  68873. [key: string]: Object;
  68874. };
  68875. /** @hidden */
  68876. static GetClass(fqdn: string): any;
  68877. }
  68878. }
  68879. declare module BABYLON {
  68880. /**
  68881. * Helper to manipulate strings
  68882. */
  68883. export class StringTools {
  68884. /**
  68885. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  68886. * @param str Source string
  68887. * @param suffix Suffix to search for in the source string
  68888. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  68889. */
  68890. static EndsWith(str: string, suffix: string): boolean;
  68891. /**
  68892. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  68893. * @param str Source string
  68894. * @param suffix Suffix to search for in the source string
  68895. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  68896. */
  68897. static StartsWith(str: string, suffix: string): boolean;
  68898. /**
  68899. * Decodes a buffer into a string
  68900. * @param buffer The buffer to decode
  68901. * @returns The decoded string
  68902. */
  68903. static Decode(buffer: Uint8Array | Uint16Array): string;
  68904. /**
  68905. * Encode a buffer to a base64 string
  68906. * @param buffer defines the buffer to encode
  68907. * @returns the encoded string
  68908. */
  68909. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  68910. }
  68911. }
  68912. declare module BABYLON {
  68913. /**
  68914. * Class containing a set of static utilities functions for deep copy.
  68915. */
  68916. export class DeepCopier {
  68917. /**
  68918. * Tries to copy an object by duplicating every property
  68919. * @param source defines the source object
  68920. * @param destination defines the target object
  68921. * @param doNotCopyList defines a list of properties to avoid
  68922. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  68923. */
  68924. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  68925. }
  68926. }
  68927. declare module BABYLON {
  68928. /**
  68929. * Class containing a set of static utilities functions for precision date
  68930. */
  68931. export class PrecisionDate {
  68932. /**
  68933. * Gets either window.performance.now() if supported or Date.now() else
  68934. */
  68935. static readonly Now: number;
  68936. }
  68937. }
  68938. declare module BABYLON {
  68939. /** @hidden */
  68940. export class _DevTools {
  68941. static WarnImport(name: string): string;
  68942. }
  68943. }
  68944. declare module BABYLON {
  68945. /**
  68946. * Interface used to define the mechanism to get data from the network
  68947. */
  68948. export interface IWebRequest {
  68949. /**
  68950. * Returns client's response url
  68951. */
  68952. responseURL: string;
  68953. /**
  68954. * Returns client's status
  68955. */
  68956. status: number;
  68957. /**
  68958. * Returns client's status as a text
  68959. */
  68960. statusText: string;
  68961. }
  68962. }
  68963. declare module BABYLON {
  68964. /**
  68965. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  68966. */
  68967. export class WebRequest implements IWebRequest {
  68968. private _xhr;
  68969. /**
  68970. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  68971. * i.e. when loading files, where the server/service expects an Authorization header
  68972. */
  68973. static CustomRequestHeaders: {
  68974. [key: string]: string;
  68975. };
  68976. /**
  68977. * Add callback functions in this array to update all the requests before they get sent to the network
  68978. */
  68979. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  68980. private _injectCustomRequestHeaders;
  68981. /**
  68982. * Gets or sets a function to be called when loading progress changes
  68983. */
  68984. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  68985. /**
  68986. * Returns client's state
  68987. */
  68988. readonly readyState: number;
  68989. /**
  68990. * Returns client's status
  68991. */
  68992. readonly status: number;
  68993. /**
  68994. * Returns client's status as a text
  68995. */
  68996. readonly statusText: string;
  68997. /**
  68998. * Returns client's response
  68999. */
  69000. readonly response: any;
  69001. /**
  69002. * Returns client's response url
  69003. */
  69004. readonly responseURL: string;
  69005. /**
  69006. * Returns client's response as text
  69007. */
  69008. readonly responseText: string;
  69009. /**
  69010. * Gets or sets the expected response type
  69011. */
  69012. responseType: XMLHttpRequestResponseType;
  69013. /** @hidden */
  69014. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  69015. /** @hidden */
  69016. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  69017. /**
  69018. * Cancels any network activity
  69019. */
  69020. abort(): void;
  69021. /**
  69022. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  69023. * @param body defines an optional request body
  69024. */
  69025. send(body?: Document | BodyInit | null): void;
  69026. /**
  69027. * Sets the request method, request URL
  69028. * @param method defines the method to use (GET, POST, etc..)
  69029. * @param url defines the url to connect with
  69030. */
  69031. open(method: string, url: string): void;
  69032. /**
  69033. * Sets the value of a request header.
  69034. * @param name The name of the header whose value is to be set
  69035. * @param value The value to set as the body of the header
  69036. */
  69037. setRequestHeader(name: string, value: string): void;
  69038. /**
  69039. * Get the string containing the text of a particular header's value.
  69040. * @param name The name of the header
  69041. * @returns The string containing the text of the given header name
  69042. */
  69043. getResponseHeader(name: string): Nullable<string>;
  69044. }
  69045. }
  69046. declare module BABYLON {
  69047. /**
  69048. * File request interface
  69049. */
  69050. export interface IFileRequest {
  69051. /**
  69052. * Raised when the request is complete (success or error).
  69053. */
  69054. onCompleteObservable: Observable<IFileRequest>;
  69055. /**
  69056. * Aborts the request for a file.
  69057. */
  69058. abort: () => void;
  69059. }
  69060. }
  69061. declare module BABYLON {
  69062. /**
  69063. * Define options used to create a render target texture
  69064. */
  69065. export class RenderTargetCreationOptions {
  69066. /**
  69067. * Specifies is mipmaps must be generated
  69068. */
  69069. generateMipMaps?: boolean;
  69070. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  69071. generateDepthBuffer?: boolean;
  69072. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  69073. generateStencilBuffer?: boolean;
  69074. /** Defines texture type (int by default) */
  69075. type?: number;
  69076. /** Defines sampling mode (trilinear by default) */
  69077. samplingMode?: number;
  69078. /** Defines format (RGBA by default) */
  69079. format?: number;
  69080. }
  69081. }
  69082. declare module BABYLON {
  69083. /**
  69084. * @hidden
  69085. **/
  69086. export class _TimeToken {
  69087. _startTimeQuery: Nullable<WebGLQuery>;
  69088. _endTimeQuery: Nullable<WebGLQuery>;
  69089. _timeElapsedQuery: Nullable<WebGLQuery>;
  69090. _timeElapsedQueryEnded: boolean;
  69091. }
  69092. }
  69093. declare module BABYLON {
  69094. /** Defines the cross module used constants to avoid circular dependncies */
  69095. export class Constants {
  69096. /** Defines that alpha blending is disabled */
  69097. static readonly ALPHA_DISABLE: number;
  69098. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  69099. static readonly ALPHA_ADD: number;
  69100. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  69101. static readonly ALPHA_COMBINE: number;
  69102. /** Defines that alpha blending to DEST - SRC * DEST */
  69103. static readonly ALPHA_SUBTRACT: number;
  69104. /** Defines that alpha blending to SRC * DEST */
  69105. static readonly ALPHA_MULTIPLY: number;
  69106. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  69107. static readonly ALPHA_MAXIMIZED: number;
  69108. /** Defines that alpha blending to SRC + DEST */
  69109. static readonly ALPHA_ONEONE: number;
  69110. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  69111. static readonly ALPHA_PREMULTIPLIED: number;
  69112. /**
  69113. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  69114. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  69115. */
  69116. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  69117. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  69118. static readonly ALPHA_INTERPOLATE: number;
  69119. /**
  69120. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  69121. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  69122. */
  69123. static readonly ALPHA_SCREENMODE: number;
  69124. /**
  69125. * Defines that alpha blending to SRC + DST
  69126. * Alpha will be set to SRC ALPHA + DST ALPHA
  69127. */
  69128. static readonly ALPHA_ONEONE_ONEONE: number;
  69129. /**
  69130. * Defines that alpha blending to SRC * DST ALPHA + DST
  69131. * Alpha will be set to 0
  69132. */
  69133. static readonly ALPHA_ALPHATOCOLOR: number;
  69134. /**
  69135. * Defines that alpha blending to SRC * (1 - DST) + DST * (1 - SRC)
  69136. */
  69137. static readonly ALPHA_REVERSEONEMINUS: number;
  69138. /**
  69139. * Defines that alpha blending to SRC + DST * (1 - SRC ALPHA)
  69140. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  69141. */
  69142. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  69143. /**
  69144. * Defines that alpha blending to SRC + DST
  69145. * Alpha will be set to SRC ALPHA
  69146. */
  69147. static readonly ALPHA_ONEONE_ONEZERO: number;
  69148. /** Defines that alpha blending equation a SUM */
  69149. static readonly ALPHA_EQUATION_ADD: number;
  69150. /** Defines that alpha blending equation a SUBSTRACTION */
  69151. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  69152. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  69153. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  69154. /** Defines that alpha blending equation a MAX operation */
  69155. static readonly ALPHA_EQUATION_MAX: number;
  69156. /** Defines that alpha blending equation a MIN operation */
  69157. static readonly ALPHA_EQUATION_MIN: number;
  69158. /**
  69159. * Defines that alpha blending equation a DARKEN operation:
  69160. * It takes the min of the src and sums the alpha channels.
  69161. */
  69162. static readonly ALPHA_EQUATION_DARKEN: number;
  69163. /** Defines that the ressource is not delayed*/
  69164. static readonly DELAYLOADSTATE_NONE: number;
  69165. /** Defines that the ressource was successfully delay loaded */
  69166. static readonly DELAYLOADSTATE_LOADED: number;
  69167. /** Defines that the ressource is currently delay loading */
  69168. static readonly DELAYLOADSTATE_LOADING: number;
  69169. /** Defines that the ressource is delayed and has not started loading */
  69170. static readonly DELAYLOADSTATE_NOTLOADED: number;
  69171. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  69172. static readonly NEVER: number;
  69173. /** 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 */
  69174. static readonly ALWAYS: number;
  69175. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  69176. static readonly LESS: number;
  69177. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  69178. static readonly EQUAL: number;
  69179. /** 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 */
  69180. static readonly LEQUAL: number;
  69181. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  69182. static readonly GREATER: number;
  69183. /** 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 */
  69184. static readonly GEQUAL: number;
  69185. /** 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 */
  69186. static readonly NOTEQUAL: number;
  69187. /** Passed to stencilOperation to specify that stencil value must be kept */
  69188. static readonly KEEP: number;
  69189. /** Passed to stencilOperation to specify that stencil value must be replaced */
  69190. static readonly REPLACE: number;
  69191. /** Passed to stencilOperation to specify that stencil value must be incremented */
  69192. static readonly INCR: number;
  69193. /** Passed to stencilOperation to specify that stencil value must be decremented */
  69194. static readonly DECR: number;
  69195. /** Passed to stencilOperation to specify that stencil value must be inverted */
  69196. static readonly INVERT: number;
  69197. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  69198. static readonly INCR_WRAP: number;
  69199. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  69200. static readonly DECR_WRAP: number;
  69201. /** Texture is not repeating outside of 0..1 UVs */
  69202. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  69203. /** Texture is repeating outside of 0..1 UVs */
  69204. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  69205. /** Texture is repeating and mirrored */
  69206. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  69207. /** ALPHA */
  69208. static readonly TEXTUREFORMAT_ALPHA: number;
  69209. /** LUMINANCE */
  69210. static readonly TEXTUREFORMAT_LUMINANCE: number;
  69211. /** LUMINANCE_ALPHA */
  69212. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  69213. /** RGB */
  69214. static readonly TEXTUREFORMAT_RGB: number;
  69215. /** RGBA */
  69216. static readonly TEXTUREFORMAT_RGBA: number;
  69217. /** RED */
  69218. static readonly TEXTUREFORMAT_RED: number;
  69219. /** RED (2nd reference) */
  69220. static readonly TEXTUREFORMAT_R: number;
  69221. /** RG */
  69222. static readonly TEXTUREFORMAT_RG: number;
  69223. /** RED_INTEGER */
  69224. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  69225. /** RED_INTEGER (2nd reference) */
  69226. static readonly TEXTUREFORMAT_R_INTEGER: number;
  69227. /** RG_INTEGER */
  69228. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  69229. /** RGB_INTEGER */
  69230. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  69231. /** RGBA_INTEGER */
  69232. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  69233. /** UNSIGNED_BYTE */
  69234. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  69235. /** UNSIGNED_BYTE (2nd reference) */
  69236. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  69237. /** FLOAT */
  69238. static readonly TEXTURETYPE_FLOAT: number;
  69239. /** HALF_FLOAT */
  69240. static readonly TEXTURETYPE_HALF_FLOAT: number;
  69241. /** BYTE */
  69242. static readonly TEXTURETYPE_BYTE: number;
  69243. /** SHORT */
  69244. static readonly TEXTURETYPE_SHORT: number;
  69245. /** UNSIGNED_SHORT */
  69246. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  69247. /** INT */
  69248. static readonly TEXTURETYPE_INT: number;
  69249. /** UNSIGNED_INT */
  69250. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  69251. /** UNSIGNED_SHORT_4_4_4_4 */
  69252. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  69253. /** UNSIGNED_SHORT_5_5_5_1 */
  69254. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  69255. /** UNSIGNED_SHORT_5_6_5 */
  69256. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  69257. /** UNSIGNED_INT_2_10_10_10_REV */
  69258. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  69259. /** UNSIGNED_INT_24_8 */
  69260. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  69261. /** UNSIGNED_INT_10F_11F_11F_REV */
  69262. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  69263. /** UNSIGNED_INT_5_9_9_9_REV */
  69264. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  69265. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  69266. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  69267. /** nearest is mag = nearest and min = nearest and mip = nearest */
  69268. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  69269. /** Bilinear is mag = linear and min = linear and mip = nearest */
  69270. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  69271. /** Trilinear is mag = linear and min = linear and mip = linear */
  69272. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  69273. /** nearest is mag = nearest and min = nearest and mip = linear */
  69274. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  69275. /** Bilinear is mag = linear and min = linear and mip = nearest */
  69276. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  69277. /** Trilinear is mag = linear and min = linear and mip = linear */
  69278. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  69279. /** mag = nearest and min = nearest and mip = nearest */
  69280. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  69281. /** mag = nearest and min = linear and mip = nearest */
  69282. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  69283. /** mag = nearest and min = linear and mip = linear */
  69284. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  69285. /** mag = nearest and min = linear and mip = none */
  69286. static readonly TEXTURE_NEAREST_LINEAR: number;
  69287. /** mag = nearest and min = nearest and mip = none */
  69288. static readonly TEXTURE_NEAREST_NEAREST: number;
  69289. /** mag = linear and min = nearest and mip = nearest */
  69290. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  69291. /** mag = linear and min = nearest and mip = linear */
  69292. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  69293. /** mag = linear and min = linear and mip = none */
  69294. static readonly TEXTURE_LINEAR_LINEAR: number;
  69295. /** mag = linear and min = nearest and mip = none */
  69296. static readonly TEXTURE_LINEAR_NEAREST: number;
  69297. /** Explicit coordinates mode */
  69298. static readonly TEXTURE_EXPLICIT_MODE: number;
  69299. /** Spherical coordinates mode */
  69300. static readonly TEXTURE_SPHERICAL_MODE: number;
  69301. /** Planar coordinates mode */
  69302. static readonly TEXTURE_PLANAR_MODE: number;
  69303. /** Cubic coordinates mode */
  69304. static readonly TEXTURE_CUBIC_MODE: number;
  69305. /** Projection coordinates mode */
  69306. static readonly TEXTURE_PROJECTION_MODE: number;
  69307. /** Skybox coordinates mode */
  69308. static readonly TEXTURE_SKYBOX_MODE: number;
  69309. /** Inverse Cubic coordinates mode */
  69310. static readonly TEXTURE_INVCUBIC_MODE: number;
  69311. /** Equirectangular coordinates mode */
  69312. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  69313. /** Equirectangular Fixed coordinates mode */
  69314. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  69315. /** Equirectangular Fixed Mirrored coordinates mode */
  69316. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  69317. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  69318. static readonly SCALEMODE_FLOOR: number;
  69319. /** Defines that texture rescaling will look for the nearest power of 2 size */
  69320. static readonly SCALEMODE_NEAREST: number;
  69321. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  69322. static readonly SCALEMODE_CEILING: number;
  69323. /**
  69324. * The dirty texture flag value
  69325. */
  69326. static readonly MATERIAL_TextureDirtyFlag: number;
  69327. /**
  69328. * The dirty light flag value
  69329. */
  69330. static readonly MATERIAL_LightDirtyFlag: number;
  69331. /**
  69332. * The dirty fresnel flag value
  69333. */
  69334. static readonly MATERIAL_FresnelDirtyFlag: number;
  69335. /**
  69336. * The dirty attribute flag value
  69337. */
  69338. static readonly MATERIAL_AttributesDirtyFlag: number;
  69339. /**
  69340. * The dirty misc flag value
  69341. */
  69342. static readonly MATERIAL_MiscDirtyFlag: number;
  69343. /**
  69344. * The all dirty flag value
  69345. */
  69346. static readonly MATERIAL_AllDirtyFlag: number;
  69347. /**
  69348. * Returns the triangle fill mode
  69349. */
  69350. static readonly MATERIAL_TriangleFillMode: number;
  69351. /**
  69352. * Returns the wireframe mode
  69353. */
  69354. static readonly MATERIAL_WireFrameFillMode: number;
  69355. /**
  69356. * Returns the point fill mode
  69357. */
  69358. static readonly MATERIAL_PointFillMode: number;
  69359. /**
  69360. * Returns the point list draw mode
  69361. */
  69362. static readonly MATERIAL_PointListDrawMode: number;
  69363. /**
  69364. * Returns the line list draw mode
  69365. */
  69366. static readonly MATERIAL_LineListDrawMode: number;
  69367. /**
  69368. * Returns the line loop draw mode
  69369. */
  69370. static readonly MATERIAL_LineLoopDrawMode: number;
  69371. /**
  69372. * Returns the line strip draw mode
  69373. */
  69374. static readonly MATERIAL_LineStripDrawMode: number;
  69375. /**
  69376. * Returns the triangle strip draw mode
  69377. */
  69378. static readonly MATERIAL_TriangleStripDrawMode: number;
  69379. /**
  69380. * Returns the triangle fan draw mode
  69381. */
  69382. static readonly MATERIAL_TriangleFanDrawMode: number;
  69383. /**
  69384. * Stores the clock-wise side orientation
  69385. */
  69386. static readonly MATERIAL_ClockWiseSideOrientation: number;
  69387. /**
  69388. * Stores the counter clock-wise side orientation
  69389. */
  69390. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  69391. /**
  69392. * Nothing
  69393. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69394. */
  69395. static readonly ACTION_NothingTrigger: number;
  69396. /**
  69397. * On pick
  69398. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69399. */
  69400. static readonly ACTION_OnPickTrigger: number;
  69401. /**
  69402. * On left pick
  69403. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69404. */
  69405. static readonly ACTION_OnLeftPickTrigger: number;
  69406. /**
  69407. * On right pick
  69408. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69409. */
  69410. static readonly ACTION_OnRightPickTrigger: number;
  69411. /**
  69412. * On center pick
  69413. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69414. */
  69415. static readonly ACTION_OnCenterPickTrigger: number;
  69416. /**
  69417. * On pick down
  69418. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69419. */
  69420. static readonly ACTION_OnPickDownTrigger: number;
  69421. /**
  69422. * On double pick
  69423. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69424. */
  69425. static readonly ACTION_OnDoublePickTrigger: number;
  69426. /**
  69427. * On pick up
  69428. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69429. */
  69430. static readonly ACTION_OnPickUpTrigger: number;
  69431. /**
  69432. * On pick out.
  69433. * This trigger will only be raised if you also declared a OnPickDown
  69434. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69435. */
  69436. static readonly ACTION_OnPickOutTrigger: number;
  69437. /**
  69438. * On long press
  69439. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69440. */
  69441. static readonly ACTION_OnLongPressTrigger: number;
  69442. /**
  69443. * On pointer over
  69444. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69445. */
  69446. static readonly ACTION_OnPointerOverTrigger: number;
  69447. /**
  69448. * On pointer out
  69449. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69450. */
  69451. static readonly ACTION_OnPointerOutTrigger: number;
  69452. /**
  69453. * On every frame
  69454. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69455. */
  69456. static readonly ACTION_OnEveryFrameTrigger: number;
  69457. /**
  69458. * On intersection enter
  69459. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69460. */
  69461. static readonly ACTION_OnIntersectionEnterTrigger: number;
  69462. /**
  69463. * On intersection exit
  69464. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69465. */
  69466. static readonly ACTION_OnIntersectionExitTrigger: number;
  69467. /**
  69468. * On key down
  69469. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69470. */
  69471. static readonly ACTION_OnKeyDownTrigger: number;
  69472. /**
  69473. * On key up
  69474. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69475. */
  69476. static readonly ACTION_OnKeyUpTrigger: number;
  69477. /**
  69478. * Billboard mode will only apply to Y axis
  69479. */
  69480. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  69481. /**
  69482. * Billboard mode will apply to all axes
  69483. */
  69484. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  69485. /**
  69486. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  69487. */
  69488. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  69489. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  69490. * Test order :
  69491. * Is the bounding sphere outside the frustum ?
  69492. * If not, are the bounding box vertices outside the frustum ?
  69493. * It not, then the cullable object is in the frustum.
  69494. */
  69495. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  69496. /** Culling strategy : Bounding Sphere Only.
  69497. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  69498. * It's also less accurate than the standard because some not visible objects can still be selected.
  69499. * Test : is the bounding sphere outside the frustum ?
  69500. * If not, then the cullable object is in the frustum.
  69501. */
  69502. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  69503. /** Culling strategy : Optimistic Inclusion.
  69504. * This in an inclusion test first, then the standard exclusion test.
  69505. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  69506. * 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.
  69507. * Anyway, it's as accurate as the standard strategy.
  69508. * Test :
  69509. * Is the cullable object bounding sphere center in the frustum ?
  69510. * If not, apply the default culling strategy.
  69511. */
  69512. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  69513. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  69514. * This in an inclusion test first, then the bounding sphere only exclusion test.
  69515. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  69516. * 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.
  69517. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  69518. * Test :
  69519. * Is the cullable object bounding sphere center in the frustum ?
  69520. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  69521. */
  69522. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  69523. /**
  69524. * No logging while loading
  69525. */
  69526. static readonly SCENELOADER_NO_LOGGING: number;
  69527. /**
  69528. * Minimal logging while loading
  69529. */
  69530. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  69531. /**
  69532. * Summary logging while loading
  69533. */
  69534. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  69535. /**
  69536. * Detailled logging while loading
  69537. */
  69538. static readonly SCENELOADER_DETAILED_LOGGING: number;
  69539. }
  69540. }
  69541. declare module BABYLON {
  69542. /**
  69543. * This represents the required contract to create a new type of texture loader.
  69544. */
  69545. export interface IInternalTextureLoader {
  69546. /**
  69547. * Defines wether the loader supports cascade loading the different faces.
  69548. */
  69549. supportCascades: boolean;
  69550. /**
  69551. * This returns if the loader support the current file information.
  69552. * @param extension defines the file extension of the file being loaded
  69553. * @param textureFormatInUse defines the current compressed format in use iun the engine
  69554. * @param fallback defines the fallback internal texture if any
  69555. * @param isBase64 defines whether the texture is encoded as a base64
  69556. * @param isBuffer defines whether the texture data are stored as a buffer
  69557. * @returns true if the loader can load the specified file
  69558. */
  69559. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  69560. /**
  69561. * Transform the url before loading if required.
  69562. * @param rootUrl the url of the texture
  69563. * @param textureFormatInUse defines the current compressed format in use iun the engine
  69564. * @returns the transformed texture
  69565. */
  69566. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  69567. /**
  69568. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  69569. * @param rootUrl the url of the texture
  69570. * @param textureFormatInUse defines the current compressed format in use iun the engine
  69571. * @returns the fallback texture
  69572. */
  69573. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  69574. /**
  69575. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  69576. * @param data contains the texture data
  69577. * @param texture defines the BabylonJS internal texture
  69578. * @param createPolynomials will be true if polynomials have been requested
  69579. * @param onLoad defines the callback to trigger once the texture is ready
  69580. * @param onError defines the callback to trigger in case of error
  69581. */
  69582. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  69583. /**
  69584. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  69585. * @param data contains the texture data
  69586. * @param texture defines the BabylonJS internal texture
  69587. * @param callback defines the method to call once ready to upload
  69588. */
  69589. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  69590. }
  69591. }
  69592. declare module BABYLON {
  69593. /**
  69594. * Class used to store and describe the pipeline context associated with an effect
  69595. */
  69596. export interface IPipelineContext {
  69597. /**
  69598. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  69599. */
  69600. isAsync: boolean;
  69601. /**
  69602. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  69603. */
  69604. isReady: boolean;
  69605. /** @hidden */
  69606. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  69607. }
  69608. }
  69609. declare module BABYLON {
  69610. /**
  69611. * Class used to store gfx data (like WebGLBuffer)
  69612. */
  69613. export class DataBuffer {
  69614. /**
  69615. * Gets or sets the number of objects referencing this buffer
  69616. */
  69617. references: number;
  69618. /** Gets or sets the size of the underlying buffer */
  69619. capacity: number;
  69620. /**
  69621. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  69622. */
  69623. is32Bits: boolean;
  69624. /**
  69625. * Gets the underlying buffer
  69626. */
  69627. readonly underlyingResource: any;
  69628. }
  69629. }
  69630. declare module BABYLON {
  69631. /** @hidden */
  69632. export interface IShaderProcessor {
  69633. attributeProcessor?: (attribute: string) => string;
  69634. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  69635. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  69636. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  69637. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  69638. lineProcessor?: (line: string, isFragment: boolean) => string;
  69639. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  69640. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  69641. }
  69642. }
  69643. declare module BABYLON {
  69644. /** @hidden */
  69645. export interface ProcessingOptions {
  69646. defines: string[];
  69647. indexParameters: any;
  69648. isFragment: boolean;
  69649. shouldUseHighPrecisionShader: boolean;
  69650. supportsUniformBuffers: boolean;
  69651. shadersRepository: string;
  69652. includesShadersStore: {
  69653. [key: string]: string;
  69654. };
  69655. processor?: IShaderProcessor;
  69656. version: string;
  69657. platformName: string;
  69658. lookForClosingBracketForUniformBuffer?: boolean;
  69659. }
  69660. }
  69661. declare module BABYLON {
  69662. /** @hidden */
  69663. export class ShaderCodeNode {
  69664. line: string;
  69665. children: ShaderCodeNode[];
  69666. additionalDefineKey?: string;
  69667. additionalDefineValue?: string;
  69668. isValid(preprocessors: {
  69669. [key: string]: string;
  69670. }): boolean;
  69671. process(preprocessors: {
  69672. [key: string]: string;
  69673. }, options: ProcessingOptions): string;
  69674. }
  69675. }
  69676. declare module BABYLON {
  69677. /** @hidden */
  69678. export class ShaderCodeCursor {
  69679. private _lines;
  69680. lineIndex: number;
  69681. readonly currentLine: string;
  69682. readonly canRead: boolean;
  69683. lines: string[];
  69684. }
  69685. }
  69686. declare module BABYLON {
  69687. /** @hidden */
  69688. export class ShaderCodeConditionNode extends ShaderCodeNode {
  69689. process(preprocessors: {
  69690. [key: string]: string;
  69691. }, options: ProcessingOptions): string;
  69692. }
  69693. }
  69694. declare module BABYLON {
  69695. /** @hidden */
  69696. export class ShaderDefineExpression {
  69697. isTrue(preprocessors: {
  69698. [key: string]: string;
  69699. }): boolean;
  69700. }
  69701. }
  69702. declare module BABYLON {
  69703. /** @hidden */
  69704. export class ShaderCodeTestNode extends ShaderCodeNode {
  69705. testExpression: ShaderDefineExpression;
  69706. isValid(preprocessors: {
  69707. [key: string]: string;
  69708. }): boolean;
  69709. }
  69710. }
  69711. declare module BABYLON {
  69712. /** @hidden */
  69713. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  69714. define: string;
  69715. not: boolean;
  69716. constructor(define: string, not?: boolean);
  69717. isTrue(preprocessors: {
  69718. [key: string]: string;
  69719. }): boolean;
  69720. }
  69721. }
  69722. declare module BABYLON {
  69723. /** @hidden */
  69724. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  69725. leftOperand: ShaderDefineExpression;
  69726. rightOperand: ShaderDefineExpression;
  69727. isTrue(preprocessors: {
  69728. [key: string]: string;
  69729. }): boolean;
  69730. }
  69731. }
  69732. declare module BABYLON {
  69733. /** @hidden */
  69734. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  69735. leftOperand: ShaderDefineExpression;
  69736. rightOperand: ShaderDefineExpression;
  69737. isTrue(preprocessors: {
  69738. [key: string]: string;
  69739. }): boolean;
  69740. }
  69741. }
  69742. declare module BABYLON {
  69743. /** @hidden */
  69744. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  69745. define: string;
  69746. operand: string;
  69747. testValue: string;
  69748. constructor(define: string, operand: string, testValue: string);
  69749. isTrue(preprocessors: {
  69750. [key: string]: string;
  69751. }): boolean;
  69752. }
  69753. }
  69754. declare module BABYLON {
  69755. /**
  69756. * Class used to enable access to offline support
  69757. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  69758. */
  69759. export interface IOfflineProvider {
  69760. /**
  69761. * Gets a boolean indicating if scene must be saved in the database
  69762. */
  69763. enableSceneOffline: boolean;
  69764. /**
  69765. * Gets a boolean indicating if textures must be saved in the database
  69766. */
  69767. enableTexturesOffline: boolean;
  69768. /**
  69769. * Open the offline support and make it available
  69770. * @param successCallback defines the callback to call on success
  69771. * @param errorCallback defines the callback to call on error
  69772. */
  69773. open(successCallback: () => void, errorCallback: () => void): void;
  69774. /**
  69775. * Loads an image from the offline support
  69776. * @param url defines the url to load from
  69777. * @param image defines the target DOM image
  69778. */
  69779. loadImage(url: string, image: HTMLImageElement): void;
  69780. /**
  69781. * Loads a file from offline support
  69782. * @param url defines the URL to load from
  69783. * @param sceneLoaded defines a callback to call on success
  69784. * @param progressCallBack defines a callback to call when progress changed
  69785. * @param errorCallback defines a callback to call on error
  69786. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  69787. */
  69788. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  69789. }
  69790. }
  69791. declare module BABYLON {
  69792. /**
  69793. * Class used to help managing file picking and drag'n'drop
  69794. * File Storage
  69795. */
  69796. export class FilesInputStore {
  69797. /**
  69798. * List of files ready to be loaded
  69799. */
  69800. static FilesToLoad: {
  69801. [key: string]: File;
  69802. };
  69803. }
  69804. }
  69805. declare module BABYLON {
  69806. /**
  69807. * Class used to define a retry strategy when error happens while loading assets
  69808. */
  69809. export class RetryStrategy {
  69810. /**
  69811. * Function used to defines an exponential back off strategy
  69812. * @param maxRetries defines the maximum number of retries (3 by default)
  69813. * @param baseInterval defines the interval between retries
  69814. * @returns the strategy function to use
  69815. */
  69816. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  69817. }
  69818. }
  69819. declare module BABYLON {
  69820. /**
  69821. * @ignore
  69822. * Application error to support additional information when loading a file
  69823. */
  69824. export abstract class BaseError extends Error {
  69825. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  69826. }
  69827. }
  69828. declare module BABYLON {
  69829. /** @ignore */
  69830. export class LoadFileError extends BaseError {
  69831. request?: WebRequest;
  69832. file?: File;
  69833. /**
  69834. * Creates a new LoadFileError
  69835. * @param message defines the message of the error
  69836. * @param request defines the optional web request
  69837. * @param file defines the optional file
  69838. */
  69839. constructor(message: string, object?: WebRequest | File);
  69840. }
  69841. /** @ignore */
  69842. export class RequestFileError extends BaseError {
  69843. request: WebRequest;
  69844. /**
  69845. * Creates a new LoadFileError
  69846. * @param message defines the message of the error
  69847. * @param request defines the optional web request
  69848. */
  69849. constructor(message: string, request: WebRequest);
  69850. }
  69851. /** @ignore */
  69852. export class ReadFileError extends BaseError {
  69853. file: File;
  69854. /**
  69855. * Creates a new ReadFileError
  69856. * @param message defines the message of the error
  69857. * @param file defines the optional file
  69858. */
  69859. constructor(message: string, file: File);
  69860. }
  69861. /**
  69862. * @hidden
  69863. */
  69864. export class FileTools {
  69865. /**
  69866. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  69867. */
  69868. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  69869. /**
  69870. * Gets or sets the base URL to use to load assets
  69871. */
  69872. static BaseUrl: string;
  69873. /**
  69874. * Default behaviour for cors in the application.
  69875. * It can be a string if the expected behavior is identical in the entire app.
  69876. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  69877. */
  69878. static CorsBehavior: string | ((url: string | string[]) => string);
  69879. /**
  69880. * Gets or sets a function used to pre-process url before using them to load assets
  69881. */
  69882. static PreprocessUrl: (url: string) => string;
  69883. /**
  69884. * Removes unwanted characters from an url
  69885. * @param url defines the url to clean
  69886. * @returns the cleaned url
  69887. */
  69888. private static _CleanUrl;
  69889. /**
  69890. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  69891. * @param url define the url we are trying
  69892. * @param element define the dom element where to configure the cors policy
  69893. */
  69894. static SetCorsBehavior(url: string | string[], element: {
  69895. crossOrigin: string | null;
  69896. }): void;
  69897. /**
  69898. * Loads an image as an HTMLImageElement.
  69899. * @param input url string, ArrayBuffer, or Blob to load
  69900. * @param onLoad callback called when the image successfully loads
  69901. * @param onError callback called when the image fails to load
  69902. * @param offlineProvider offline provider for caching
  69903. * @param mimeType optional mime type
  69904. * @returns the HTMLImageElement of the loaded image
  69905. */
  69906. 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>;
  69907. /**
  69908. * Reads a file from a File object
  69909. * @param file defines the file to load
  69910. * @param onSuccess defines the callback to call when data is loaded
  69911. * @param onProgress defines the callback to call during loading process
  69912. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  69913. * @param onError defines the callback to call when an error occurs
  69914. * @returns a file request object
  69915. */
  69916. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  69917. /**
  69918. * Loads a file from a url
  69919. * @param url url to load
  69920. * @param onSuccess callback called when the file successfully loads
  69921. * @param onProgress callback called while file is loading (if the server supports this mode)
  69922. * @param offlineProvider defines the offline provider for caching
  69923. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  69924. * @param onError callback called when the file fails to load
  69925. * @returns a file request object
  69926. */
  69927. 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;
  69928. /**
  69929. * Loads a file
  69930. * @param url url to load
  69931. * @param onSuccess callback called when the file successfully loads
  69932. * @param onProgress callback called while file is loading (if the server supports this mode)
  69933. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  69934. * @param onError callback called when the file fails to load
  69935. * @param onOpened callback called when the web request is opened
  69936. * @returns a file request object
  69937. */
  69938. 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;
  69939. /**
  69940. * Checks if the loaded document was accessed via `file:`-Protocol.
  69941. * @returns boolean
  69942. */
  69943. static IsFileURL(): boolean;
  69944. }
  69945. }
  69946. declare module BABYLON {
  69947. /** @hidden */
  69948. export class ShaderProcessor {
  69949. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  69950. private static _ProcessPrecision;
  69951. private static _ExtractOperation;
  69952. private static _BuildSubExpression;
  69953. private static _BuildExpression;
  69954. private static _MoveCursorWithinIf;
  69955. private static _MoveCursor;
  69956. private static _EvaluatePreProcessors;
  69957. private static _PreparePreProcessors;
  69958. private static _ProcessShaderConversion;
  69959. private static _ProcessIncludes;
  69960. }
  69961. }
  69962. declare module BABYLON {
  69963. /**
  69964. * @hidden
  69965. */
  69966. export interface IColor4Like {
  69967. r: float;
  69968. g: float;
  69969. b: float;
  69970. a: float;
  69971. }
  69972. /**
  69973. * @hidden
  69974. */
  69975. export interface IColor3Like {
  69976. r: float;
  69977. g: float;
  69978. b: float;
  69979. }
  69980. /**
  69981. * @hidden
  69982. */
  69983. export interface IVector4Like {
  69984. x: float;
  69985. y: float;
  69986. z: float;
  69987. w: float;
  69988. }
  69989. /**
  69990. * @hidden
  69991. */
  69992. export interface IVector3Like {
  69993. x: float;
  69994. y: float;
  69995. z: float;
  69996. }
  69997. /**
  69998. * @hidden
  69999. */
  70000. export interface IVector2Like {
  70001. x: float;
  70002. y: float;
  70003. }
  70004. /**
  70005. * @hidden
  70006. */
  70007. export interface IMatrixLike {
  70008. toArray(): DeepImmutable<Float32Array>;
  70009. updateFlag: int;
  70010. }
  70011. /**
  70012. * @hidden
  70013. */
  70014. export interface IViewportLike {
  70015. x: float;
  70016. y: float;
  70017. width: float;
  70018. height: float;
  70019. }
  70020. /**
  70021. * @hidden
  70022. */
  70023. export interface IPlaneLike {
  70024. normal: IVector3Like;
  70025. d: float;
  70026. normalize(): void;
  70027. }
  70028. }
  70029. declare module BABYLON {
  70030. /**
  70031. * Interface used to define common properties for effect fallbacks
  70032. */
  70033. export interface IEffectFallbacks {
  70034. /**
  70035. * Removes the defines that should be removed when falling back.
  70036. * @param currentDefines defines the current define statements for the shader.
  70037. * @param effect defines the current effect we try to compile
  70038. * @returns The resulting defines with defines of the current rank removed.
  70039. */
  70040. reduce(currentDefines: string, effect: Effect): string;
  70041. /**
  70042. * Removes the fallback from the bound mesh.
  70043. */
  70044. unBindMesh(): void;
  70045. /**
  70046. * Checks to see if more fallbacks are still availible.
  70047. */
  70048. hasMoreFallbacks: boolean;
  70049. }
  70050. }
  70051. declare module BABYLON {
  70052. /**
  70053. * Class used to evalaute queries containing `and` and `or` operators
  70054. */
  70055. export class AndOrNotEvaluator {
  70056. /**
  70057. * Evaluate a query
  70058. * @param query defines the query to evaluate
  70059. * @param evaluateCallback defines the callback used to filter result
  70060. * @returns true if the query matches
  70061. */
  70062. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  70063. private static _HandleParenthesisContent;
  70064. private static _SimplifyNegation;
  70065. }
  70066. }
  70067. declare module BABYLON {
  70068. /**
  70069. * Class used to store custom tags
  70070. */
  70071. export class Tags {
  70072. /**
  70073. * Adds support for tags on the given object
  70074. * @param obj defines the object to use
  70075. */
  70076. static EnableFor(obj: any): void;
  70077. /**
  70078. * Removes tags support
  70079. * @param obj defines the object to use
  70080. */
  70081. static DisableFor(obj: any): void;
  70082. /**
  70083. * Gets a boolean indicating if the given object has tags
  70084. * @param obj defines the object to use
  70085. * @returns a boolean
  70086. */
  70087. static HasTags(obj: any): boolean;
  70088. /**
  70089. * Gets the tags available on a given object
  70090. * @param obj defines the object to use
  70091. * @param asString defines if the tags must be returned as a string instead of an array of strings
  70092. * @returns the tags
  70093. */
  70094. static GetTags(obj: any, asString?: boolean): any;
  70095. /**
  70096. * Adds tags to an object
  70097. * @param obj defines the object to use
  70098. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  70099. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  70100. */
  70101. static AddTagsTo(obj: any, tagsString: string): void;
  70102. /**
  70103. * @hidden
  70104. */
  70105. static _AddTagTo(obj: any, tag: string): void;
  70106. /**
  70107. * Removes specific tags from a specific object
  70108. * @param obj defines the object to use
  70109. * @param tagsString defines the tags to remove
  70110. */
  70111. static RemoveTagsFrom(obj: any, tagsString: string): void;
  70112. /**
  70113. * @hidden
  70114. */
  70115. static _RemoveTagFrom(obj: any, tag: string): void;
  70116. /**
  70117. * Defines if tags hosted on an object match a given query
  70118. * @param obj defines the object to use
  70119. * @param tagsQuery defines the tag query
  70120. * @returns a boolean
  70121. */
  70122. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  70123. }
  70124. }
  70125. declare module BABYLON {
  70126. /**
  70127. * Scalar computation library
  70128. */
  70129. export class Scalar {
  70130. /**
  70131. * Two pi constants convenient for computation.
  70132. */
  70133. static TwoPi: number;
  70134. /**
  70135. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  70136. * @param a number
  70137. * @param b number
  70138. * @param epsilon (default = 1.401298E-45)
  70139. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  70140. */
  70141. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  70142. /**
  70143. * Returns a string : the upper case translation of the number i to hexadecimal.
  70144. * @param i number
  70145. * @returns the upper case translation of the number i to hexadecimal.
  70146. */
  70147. static ToHex(i: number): string;
  70148. /**
  70149. * Returns -1 if value is negative and +1 is value is positive.
  70150. * @param value the value
  70151. * @returns the value itself if it's equal to zero.
  70152. */
  70153. static Sign(value: number): number;
  70154. /**
  70155. * Returns the value itself if it's between min and max.
  70156. * Returns min if the value is lower than min.
  70157. * Returns max if the value is greater than max.
  70158. * @param value the value to clmap
  70159. * @param min the min value to clamp to (default: 0)
  70160. * @param max the max value to clamp to (default: 1)
  70161. * @returns the clamped value
  70162. */
  70163. static Clamp(value: number, min?: number, max?: number): number;
  70164. /**
  70165. * the log2 of value.
  70166. * @param value the value to compute log2 of
  70167. * @returns the log2 of value.
  70168. */
  70169. static Log2(value: number): number;
  70170. /**
  70171. * Loops the value, so that it is never larger than length and never smaller than 0.
  70172. *
  70173. * This is similar to the modulo operator but it works with floating point numbers.
  70174. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  70175. * With t = 5 and length = 2.5, the result would be 0.0.
  70176. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  70177. * @param value the value
  70178. * @param length the length
  70179. * @returns the looped value
  70180. */
  70181. static Repeat(value: number, length: number): number;
  70182. /**
  70183. * Normalize the value between 0.0 and 1.0 using min and max values
  70184. * @param value value to normalize
  70185. * @param min max to normalize between
  70186. * @param max min to normalize between
  70187. * @returns the normalized value
  70188. */
  70189. static Normalize(value: number, min: number, max: number): number;
  70190. /**
  70191. * Denormalize the value from 0.0 and 1.0 using min and max values
  70192. * @param normalized value to denormalize
  70193. * @param min max to denormalize between
  70194. * @param max min to denormalize between
  70195. * @returns the denormalized value
  70196. */
  70197. static Denormalize(normalized: number, min: number, max: number): number;
  70198. /**
  70199. * Calculates the shortest difference between two given angles given in degrees.
  70200. * @param current current angle in degrees
  70201. * @param target target angle in degrees
  70202. * @returns the delta
  70203. */
  70204. static DeltaAngle(current: number, target: number): number;
  70205. /**
  70206. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  70207. * @param tx value
  70208. * @param length length
  70209. * @returns The returned value will move back and forth between 0 and length
  70210. */
  70211. static PingPong(tx: number, length: number): number;
  70212. /**
  70213. * Interpolates between min and max with smoothing at the limits.
  70214. *
  70215. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  70216. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  70217. * @param from from
  70218. * @param to to
  70219. * @param tx value
  70220. * @returns the smooth stepped value
  70221. */
  70222. static SmoothStep(from: number, to: number, tx: number): number;
  70223. /**
  70224. * Moves a value current towards target.
  70225. *
  70226. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  70227. * Negative values of maxDelta pushes the value away from target.
  70228. * @param current current value
  70229. * @param target target value
  70230. * @param maxDelta max distance to move
  70231. * @returns resulting value
  70232. */
  70233. static MoveTowards(current: number, target: number, maxDelta: number): number;
  70234. /**
  70235. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  70236. *
  70237. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  70238. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  70239. * @param current current value
  70240. * @param target target value
  70241. * @param maxDelta max distance to move
  70242. * @returns resulting angle
  70243. */
  70244. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  70245. /**
  70246. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  70247. * @param start start value
  70248. * @param end target value
  70249. * @param amount amount to lerp between
  70250. * @returns the lerped value
  70251. */
  70252. static Lerp(start: number, end: number, amount: number): number;
  70253. /**
  70254. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  70255. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  70256. * @param start start value
  70257. * @param end target value
  70258. * @param amount amount to lerp between
  70259. * @returns the lerped value
  70260. */
  70261. static LerpAngle(start: number, end: number, amount: number): number;
  70262. /**
  70263. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  70264. * @param a start value
  70265. * @param b target value
  70266. * @param value value between a and b
  70267. * @returns the inverseLerp value
  70268. */
  70269. static InverseLerp(a: number, b: number, value: number): number;
  70270. /**
  70271. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  70272. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  70273. * @param value1 spline value
  70274. * @param tangent1 spline value
  70275. * @param value2 spline value
  70276. * @param tangent2 spline value
  70277. * @param amount input value
  70278. * @returns hermite result
  70279. */
  70280. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  70281. /**
  70282. * Returns a random float number between and min and max values
  70283. * @param min min value of random
  70284. * @param max max value of random
  70285. * @returns random value
  70286. */
  70287. static RandomRange(min: number, max: number): number;
  70288. /**
  70289. * This function returns percentage of a number in a given range.
  70290. *
  70291. * RangeToPercent(40,20,60) will return 0.5 (50%)
  70292. * RangeToPercent(34,0,100) will return 0.34 (34%)
  70293. * @param number to convert to percentage
  70294. * @param min min range
  70295. * @param max max range
  70296. * @returns the percentage
  70297. */
  70298. static RangeToPercent(number: number, min: number, max: number): number;
  70299. /**
  70300. * This function returns number that corresponds to the percentage in a given range.
  70301. *
  70302. * PercentToRange(0.34,0,100) will return 34.
  70303. * @param percent to convert to number
  70304. * @param min min range
  70305. * @param max max range
  70306. * @returns the number
  70307. */
  70308. static PercentToRange(percent: number, min: number, max: number): number;
  70309. /**
  70310. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  70311. * @param angle The angle to normalize in radian.
  70312. * @return The converted angle.
  70313. */
  70314. static NormalizeRadians(angle: number): number;
  70315. }
  70316. }
  70317. declare module BABYLON {
  70318. /**
  70319. * Constant used to convert a value to gamma space
  70320. * @ignorenaming
  70321. */
  70322. export const ToGammaSpace: number;
  70323. /**
  70324. * Constant used to convert a value to linear space
  70325. * @ignorenaming
  70326. */
  70327. export const ToLinearSpace = 2.2;
  70328. /**
  70329. * Constant used to define the minimal number value in Babylon.js
  70330. * @ignorenaming
  70331. */
  70332. let Epsilon: number;
  70333. }
  70334. declare module BABYLON {
  70335. /**
  70336. * Class used to represent a viewport on screen
  70337. */
  70338. export class Viewport {
  70339. /** viewport left coordinate */
  70340. x: number;
  70341. /** viewport top coordinate */
  70342. y: number;
  70343. /**viewport width */
  70344. width: number;
  70345. /** viewport height */
  70346. height: number;
  70347. /**
  70348. * Creates a Viewport object located at (x, y) and sized (width, height)
  70349. * @param x defines viewport left coordinate
  70350. * @param y defines viewport top coordinate
  70351. * @param width defines the viewport width
  70352. * @param height defines the viewport height
  70353. */
  70354. constructor(
  70355. /** viewport left coordinate */
  70356. x: number,
  70357. /** viewport top coordinate */
  70358. y: number,
  70359. /**viewport width */
  70360. width: number,
  70361. /** viewport height */
  70362. height: number);
  70363. /**
  70364. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  70365. * @param renderWidth defines the rendering width
  70366. * @param renderHeight defines the rendering height
  70367. * @returns a new Viewport
  70368. */
  70369. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  70370. /**
  70371. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  70372. * @param renderWidth defines the rendering width
  70373. * @param renderHeight defines the rendering height
  70374. * @param ref defines the target viewport
  70375. * @returns the current viewport
  70376. */
  70377. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  70378. /**
  70379. * Returns a new Viewport copied from the current one
  70380. * @returns a new Viewport
  70381. */
  70382. clone(): Viewport;
  70383. }
  70384. }
  70385. declare module BABYLON {
  70386. /**
  70387. * Class containing a set of static utilities functions for arrays.
  70388. */
  70389. export class ArrayTools {
  70390. /**
  70391. * Returns an array of the given size filled with element built from the given constructor and the paramters
  70392. * @param size the number of element to construct and put in the array
  70393. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  70394. * @returns a new array filled with new objects
  70395. */
  70396. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  70397. }
  70398. }
  70399. declare module BABYLON {
  70400. /**
  70401. * Class representing a vector containing 2 coordinates
  70402. */
  70403. export class Vector2 {
  70404. /** defines the first coordinate */
  70405. x: number;
  70406. /** defines the second coordinate */
  70407. y: number;
  70408. /**
  70409. * Creates a new Vector2 from the given x and y coordinates
  70410. * @param x defines the first coordinate
  70411. * @param y defines the second coordinate
  70412. */
  70413. constructor(
  70414. /** defines the first coordinate */
  70415. x?: number,
  70416. /** defines the second coordinate */
  70417. y?: number);
  70418. /**
  70419. * Gets a string with the Vector2 coordinates
  70420. * @returns a string with the Vector2 coordinates
  70421. */
  70422. toString(): string;
  70423. /**
  70424. * Gets class name
  70425. * @returns the string "Vector2"
  70426. */
  70427. getClassName(): string;
  70428. /**
  70429. * Gets current vector hash code
  70430. * @returns the Vector2 hash code as a number
  70431. */
  70432. getHashCode(): number;
  70433. /**
  70434. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  70435. * @param array defines the source array
  70436. * @param index defines the offset in source array
  70437. * @returns the current Vector2
  70438. */
  70439. toArray(array: FloatArray, index?: number): Vector2;
  70440. /**
  70441. * Copy the current vector to an array
  70442. * @returns a new array with 2 elements: the Vector2 coordinates.
  70443. */
  70444. asArray(): number[];
  70445. /**
  70446. * Sets the Vector2 coordinates with the given Vector2 coordinates
  70447. * @param source defines the source Vector2
  70448. * @returns the current updated Vector2
  70449. */
  70450. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  70451. /**
  70452. * Sets the Vector2 coordinates with the given floats
  70453. * @param x defines the first coordinate
  70454. * @param y defines the second coordinate
  70455. * @returns the current updated Vector2
  70456. */
  70457. copyFromFloats(x: number, y: number): Vector2;
  70458. /**
  70459. * Sets the Vector2 coordinates with the given floats
  70460. * @param x defines the first coordinate
  70461. * @param y defines the second coordinate
  70462. * @returns the current updated Vector2
  70463. */
  70464. set(x: number, y: number): Vector2;
  70465. /**
  70466. * Add another vector with the current one
  70467. * @param otherVector defines the other vector
  70468. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  70469. */
  70470. add(otherVector: DeepImmutable<Vector2>): Vector2;
  70471. /**
  70472. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  70473. * @param otherVector defines the other vector
  70474. * @param result defines the target vector
  70475. * @returns the unmodified current Vector2
  70476. */
  70477. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  70478. /**
  70479. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  70480. * @param otherVector defines the other vector
  70481. * @returns the current updated Vector2
  70482. */
  70483. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  70484. /**
  70485. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  70486. * @param otherVector defines the other vector
  70487. * @returns a new Vector2
  70488. */
  70489. addVector3(otherVector: Vector3): Vector2;
  70490. /**
  70491. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  70492. * @param otherVector defines the other vector
  70493. * @returns a new Vector2
  70494. */
  70495. subtract(otherVector: Vector2): Vector2;
  70496. /**
  70497. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  70498. * @param otherVector defines the other vector
  70499. * @param result defines the target vector
  70500. * @returns the unmodified current Vector2
  70501. */
  70502. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  70503. /**
  70504. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  70505. * @param otherVector defines the other vector
  70506. * @returns the current updated Vector2
  70507. */
  70508. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  70509. /**
  70510. * Multiplies in place the current Vector2 coordinates by the given ones
  70511. * @param otherVector defines the other vector
  70512. * @returns the current updated Vector2
  70513. */
  70514. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  70515. /**
  70516. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  70517. * @param otherVector defines the other vector
  70518. * @returns a new Vector2
  70519. */
  70520. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  70521. /**
  70522. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  70523. * @param otherVector defines the other vector
  70524. * @param result defines the target vector
  70525. * @returns the unmodified current Vector2
  70526. */
  70527. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  70528. /**
  70529. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  70530. * @param x defines the first coordinate
  70531. * @param y defines the second coordinate
  70532. * @returns a new Vector2
  70533. */
  70534. multiplyByFloats(x: number, y: number): Vector2;
  70535. /**
  70536. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  70537. * @param otherVector defines the other vector
  70538. * @returns a new Vector2
  70539. */
  70540. divide(otherVector: Vector2): Vector2;
  70541. /**
  70542. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  70543. * @param otherVector defines the other vector
  70544. * @param result defines the target vector
  70545. * @returns the unmodified current Vector2
  70546. */
  70547. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  70548. /**
  70549. * Divides the current Vector2 coordinates by the given ones
  70550. * @param otherVector defines the other vector
  70551. * @returns the current updated Vector2
  70552. */
  70553. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  70554. /**
  70555. * Gets a new Vector2 with current Vector2 negated coordinates
  70556. * @returns a new Vector2
  70557. */
  70558. negate(): Vector2;
  70559. /**
  70560. * Multiply the Vector2 coordinates by scale
  70561. * @param scale defines the scaling factor
  70562. * @returns the current updated Vector2
  70563. */
  70564. scaleInPlace(scale: number): Vector2;
  70565. /**
  70566. * Returns a new Vector2 scaled by "scale" from the current Vector2
  70567. * @param scale defines the scaling factor
  70568. * @returns a new Vector2
  70569. */
  70570. scale(scale: number): Vector2;
  70571. /**
  70572. * Scale the current Vector2 values by a factor to a given Vector2
  70573. * @param scale defines the scale factor
  70574. * @param result defines the Vector2 object where to store the result
  70575. * @returns the unmodified current Vector2
  70576. */
  70577. scaleToRef(scale: number, result: Vector2): Vector2;
  70578. /**
  70579. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  70580. * @param scale defines the scale factor
  70581. * @param result defines the Vector2 object where to store the result
  70582. * @returns the unmodified current Vector2
  70583. */
  70584. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  70585. /**
  70586. * Gets a boolean if two vectors are equals
  70587. * @param otherVector defines the other vector
  70588. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  70589. */
  70590. equals(otherVector: DeepImmutable<Vector2>): boolean;
  70591. /**
  70592. * Gets a boolean if two vectors are equals (using an epsilon value)
  70593. * @param otherVector defines the other vector
  70594. * @param epsilon defines the minimal distance to consider equality
  70595. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  70596. */
  70597. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  70598. /**
  70599. * Gets a new Vector2 from current Vector2 floored values
  70600. * @returns a new Vector2
  70601. */
  70602. floor(): Vector2;
  70603. /**
  70604. * Gets a new Vector2 from current Vector2 floored values
  70605. * @returns a new Vector2
  70606. */
  70607. fract(): Vector2;
  70608. /**
  70609. * Gets the length of the vector
  70610. * @returns the vector length (float)
  70611. */
  70612. length(): number;
  70613. /**
  70614. * Gets the vector squared length
  70615. * @returns the vector squared length (float)
  70616. */
  70617. lengthSquared(): number;
  70618. /**
  70619. * Normalize the vector
  70620. * @returns the current updated Vector2
  70621. */
  70622. normalize(): Vector2;
  70623. /**
  70624. * Gets a new Vector2 copied from the Vector2
  70625. * @returns a new Vector2
  70626. */
  70627. clone(): Vector2;
  70628. /**
  70629. * Gets a new Vector2(0, 0)
  70630. * @returns a new Vector2
  70631. */
  70632. static Zero(): Vector2;
  70633. /**
  70634. * Gets a new Vector2(1, 1)
  70635. * @returns a new Vector2
  70636. */
  70637. static One(): Vector2;
  70638. /**
  70639. * Gets a new Vector2 set from the given index element of the given array
  70640. * @param array defines the data source
  70641. * @param offset defines the offset in the data source
  70642. * @returns a new Vector2
  70643. */
  70644. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  70645. /**
  70646. * Sets "result" from the given index element of the given array
  70647. * @param array defines the data source
  70648. * @param offset defines the offset in the data source
  70649. * @param result defines the target vector
  70650. */
  70651. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  70652. /**
  70653. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  70654. * @param value1 defines 1st point of control
  70655. * @param value2 defines 2nd point of control
  70656. * @param value3 defines 3rd point of control
  70657. * @param value4 defines 4th point of control
  70658. * @param amount defines the interpolation factor
  70659. * @returns a new Vector2
  70660. */
  70661. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  70662. /**
  70663. * 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".
  70664. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  70665. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  70666. * @param value defines the value to clamp
  70667. * @param min defines the lower limit
  70668. * @param max defines the upper limit
  70669. * @returns a new Vector2
  70670. */
  70671. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  70672. /**
  70673. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  70674. * @param value1 defines the 1st control point
  70675. * @param tangent1 defines the outgoing tangent
  70676. * @param value2 defines the 2nd control point
  70677. * @param tangent2 defines the incoming tangent
  70678. * @param amount defines the interpolation factor
  70679. * @returns a new Vector2
  70680. */
  70681. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  70682. /**
  70683. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  70684. * @param start defines the start vector
  70685. * @param end defines the end vector
  70686. * @param amount defines the interpolation factor
  70687. * @returns a new Vector2
  70688. */
  70689. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  70690. /**
  70691. * Gets the dot product of the vector "left" and the vector "right"
  70692. * @param left defines first vector
  70693. * @param right defines second vector
  70694. * @returns the dot product (float)
  70695. */
  70696. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  70697. /**
  70698. * Returns a new Vector2 equal to the normalized given vector
  70699. * @param vector defines the vector to normalize
  70700. * @returns a new Vector2
  70701. */
  70702. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  70703. /**
  70704. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  70705. * @param left defines 1st vector
  70706. * @param right defines 2nd vector
  70707. * @returns a new Vector2
  70708. */
  70709. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  70710. /**
  70711. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  70712. * @param left defines 1st vector
  70713. * @param right defines 2nd vector
  70714. * @returns a new Vector2
  70715. */
  70716. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  70717. /**
  70718. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  70719. * @param vector defines the vector to transform
  70720. * @param transformation defines the matrix to apply
  70721. * @returns a new Vector2
  70722. */
  70723. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  70724. /**
  70725. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  70726. * @param vector defines the vector to transform
  70727. * @param transformation defines the matrix to apply
  70728. * @param result defines the target vector
  70729. */
  70730. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  70731. /**
  70732. * Determines if a given vector is included in a triangle
  70733. * @param p defines the vector to test
  70734. * @param p0 defines 1st triangle point
  70735. * @param p1 defines 2nd triangle point
  70736. * @param p2 defines 3rd triangle point
  70737. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  70738. */
  70739. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  70740. /**
  70741. * Gets the distance between the vectors "value1" and "value2"
  70742. * @param value1 defines first vector
  70743. * @param value2 defines second vector
  70744. * @returns the distance between vectors
  70745. */
  70746. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  70747. /**
  70748. * Returns the squared distance between the vectors "value1" and "value2"
  70749. * @param value1 defines first vector
  70750. * @param value2 defines second vector
  70751. * @returns the squared distance between vectors
  70752. */
  70753. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  70754. /**
  70755. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  70756. * @param value1 defines first vector
  70757. * @param value2 defines second vector
  70758. * @returns a new Vector2
  70759. */
  70760. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  70761. /**
  70762. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  70763. * @param p defines the middle point
  70764. * @param segA defines one point of the segment
  70765. * @param segB defines the other point of the segment
  70766. * @returns the shortest distance
  70767. */
  70768. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  70769. }
  70770. /**
  70771. * Classed used to store (x,y,z) vector representation
  70772. * A Vector3 is the main object used in 3D geometry
  70773. * It can represent etiher the coordinates of a point the space, either a direction
  70774. * Reminder: js uses a left handed forward facing system
  70775. */
  70776. export class Vector3 {
  70777. /**
  70778. * Defines the first coordinates (on X axis)
  70779. */
  70780. x: number;
  70781. /**
  70782. * Defines the second coordinates (on Y axis)
  70783. */
  70784. y: number;
  70785. /**
  70786. * Defines the third coordinates (on Z axis)
  70787. */
  70788. z: number;
  70789. private static _UpReadOnly;
  70790. private static _ZeroReadOnly;
  70791. /**
  70792. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  70793. * @param x defines the first coordinates (on X axis)
  70794. * @param y defines the second coordinates (on Y axis)
  70795. * @param z defines the third coordinates (on Z axis)
  70796. */
  70797. constructor(
  70798. /**
  70799. * Defines the first coordinates (on X axis)
  70800. */
  70801. x?: number,
  70802. /**
  70803. * Defines the second coordinates (on Y axis)
  70804. */
  70805. y?: number,
  70806. /**
  70807. * Defines the third coordinates (on Z axis)
  70808. */
  70809. z?: number);
  70810. /**
  70811. * Creates a string representation of the Vector3
  70812. * @returns a string with the Vector3 coordinates.
  70813. */
  70814. toString(): string;
  70815. /**
  70816. * Gets the class name
  70817. * @returns the string "Vector3"
  70818. */
  70819. getClassName(): string;
  70820. /**
  70821. * Creates the Vector3 hash code
  70822. * @returns a number which tends to be unique between Vector3 instances
  70823. */
  70824. getHashCode(): number;
  70825. /**
  70826. * Creates an array containing three elements : the coordinates of the Vector3
  70827. * @returns a new array of numbers
  70828. */
  70829. asArray(): number[];
  70830. /**
  70831. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  70832. * @param array defines the destination array
  70833. * @param index defines the offset in the destination array
  70834. * @returns the current Vector3
  70835. */
  70836. toArray(array: FloatArray, index?: number): Vector3;
  70837. /**
  70838. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  70839. * @returns a new Quaternion object, computed from the Vector3 coordinates
  70840. */
  70841. toQuaternion(): Quaternion;
  70842. /**
  70843. * Adds the given vector to the current Vector3
  70844. * @param otherVector defines the second operand
  70845. * @returns the current updated Vector3
  70846. */
  70847. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  70848. /**
  70849. * Adds the given coordinates to the current Vector3
  70850. * @param x defines the x coordinate of the operand
  70851. * @param y defines the y coordinate of the operand
  70852. * @param z defines the z coordinate of the operand
  70853. * @returns the current updated Vector3
  70854. */
  70855. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  70856. /**
  70857. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  70858. * @param otherVector defines the second operand
  70859. * @returns the resulting Vector3
  70860. */
  70861. add(otherVector: DeepImmutable<Vector3>): Vector3;
  70862. /**
  70863. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  70864. * @param otherVector defines the second operand
  70865. * @param result defines the Vector3 object where to store the result
  70866. * @returns the current Vector3
  70867. */
  70868. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  70869. /**
  70870. * Subtract the given vector from the current Vector3
  70871. * @param otherVector defines the second operand
  70872. * @returns the current updated Vector3
  70873. */
  70874. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  70875. /**
  70876. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  70877. * @param otherVector defines the second operand
  70878. * @returns the resulting Vector3
  70879. */
  70880. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  70881. /**
  70882. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  70883. * @param otherVector defines the second operand
  70884. * @param result defines the Vector3 object where to store the result
  70885. * @returns the current Vector3
  70886. */
  70887. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  70888. /**
  70889. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  70890. * @param x defines the x coordinate of the operand
  70891. * @param y defines the y coordinate of the operand
  70892. * @param z defines the z coordinate of the operand
  70893. * @returns the resulting Vector3
  70894. */
  70895. subtractFromFloats(x: number, y: number, z: number): Vector3;
  70896. /**
  70897. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  70898. * @param x defines the x coordinate of the operand
  70899. * @param y defines the y coordinate of the operand
  70900. * @param z defines the z coordinate of the operand
  70901. * @param result defines the Vector3 object where to store the result
  70902. * @returns the current Vector3
  70903. */
  70904. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  70905. /**
  70906. * Gets a new Vector3 set with the current Vector3 negated coordinates
  70907. * @returns a new Vector3
  70908. */
  70909. negate(): Vector3;
  70910. /**
  70911. * Multiplies the Vector3 coordinates by the float "scale"
  70912. * @param scale defines the multiplier factor
  70913. * @returns the current updated Vector3
  70914. */
  70915. scaleInPlace(scale: number): Vector3;
  70916. /**
  70917. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  70918. * @param scale defines the multiplier factor
  70919. * @returns a new Vector3
  70920. */
  70921. scale(scale: number): Vector3;
  70922. /**
  70923. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  70924. * @param scale defines the multiplier factor
  70925. * @param result defines the Vector3 object where to store the result
  70926. * @returns the current Vector3
  70927. */
  70928. scaleToRef(scale: number, result: Vector3): Vector3;
  70929. /**
  70930. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  70931. * @param scale defines the scale factor
  70932. * @param result defines the Vector3 object where to store the result
  70933. * @returns the unmodified current Vector3
  70934. */
  70935. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  70936. /**
  70937. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  70938. * @param otherVector defines the second operand
  70939. * @returns true if both vectors are equals
  70940. */
  70941. equals(otherVector: DeepImmutable<Vector3>): boolean;
  70942. /**
  70943. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  70944. * @param otherVector defines the second operand
  70945. * @param epsilon defines the minimal distance to define values as equals
  70946. * @returns true if both vectors are distant less than epsilon
  70947. */
  70948. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  70949. /**
  70950. * Returns true if the current Vector3 coordinates equals the given floats
  70951. * @param x defines the x coordinate of the operand
  70952. * @param y defines the y coordinate of the operand
  70953. * @param z defines the z coordinate of the operand
  70954. * @returns true if both vectors are equals
  70955. */
  70956. equalsToFloats(x: number, y: number, z: number): boolean;
  70957. /**
  70958. * Multiplies the current Vector3 coordinates by the given ones
  70959. * @param otherVector defines the second operand
  70960. * @returns the current updated Vector3
  70961. */
  70962. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  70963. /**
  70964. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  70965. * @param otherVector defines the second operand
  70966. * @returns the new Vector3
  70967. */
  70968. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  70969. /**
  70970. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  70971. * @param otherVector defines the second operand
  70972. * @param result defines the Vector3 object where to store the result
  70973. * @returns the current Vector3
  70974. */
  70975. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  70976. /**
  70977. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  70978. * @param x defines the x coordinate of the operand
  70979. * @param y defines the y coordinate of the operand
  70980. * @param z defines the z coordinate of the operand
  70981. * @returns the new Vector3
  70982. */
  70983. multiplyByFloats(x: number, y: number, z: number): Vector3;
  70984. /**
  70985. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  70986. * @param otherVector defines the second operand
  70987. * @returns the new Vector3
  70988. */
  70989. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  70990. /**
  70991. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  70992. * @param otherVector defines the second operand
  70993. * @param result defines the Vector3 object where to store the result
  70994. * @returns the current Vector3
  70995. */
  70996. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  70997. /**
  70998. * Divides the current Vector3 coordinates by the given ones.
  70999. * @param otherVector defines the second operand
  71000. * @returns the current updated Vector3
  71001. */
  71002. divideInPlace(otherVector: Vector3): Vector3;
  71003. /**
  71004. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  71005. * @param other defines the second operand
  71006. * @returns the current updated Vector3
  71007. */
  71008. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  71009. /**
  71010. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  71011. * @param other defines the second operand
  71012. * @returns the current updated Vector3
  71013. */
  71014. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  71015. /**
  71016. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  71017. * @param x defines the x coordinate of the operand
  71018. * @param y defines the y coordinate of the operand
  71019. * @param z defines the z coordinate of the operand
  71020. * @returns the current updated Vector3
  71021. */
  71022. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  71023. /**
  71024. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  71025. * @param x defines the x coordinate of the operand
  71026. * @param y defines the y coordinate of the operand
  71027. * @param z defines the z coordinate of the operand
  71028. * @returns the current updated Vector3
  71029. */
  71030. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  71031. /**
  71032. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  71033. * Check if is non uniform within a certain amount of decimal places to account for this
  71034. * @param epsilon the amount the values can differ
  71035. * @returns if the the vector is non uniform to a certain number of decimal places
  71036. */
  71037. isNonUniformWithinEpsilon(epsilon: number): boolean;
  71038. /**
  71039. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  71040. */
  71041. readonly isNonUniform: boolean;
  71042. /**
  71043. * Gets a new Vector3 from current Vector3 floored values
  71044. * @returns a new Vector3
  71045. */
  71046. floor(): Vector3;
  71047. /**
  71048. * Gets a new Vector3 from current Vector3 floored values
  71049. * @returns a new Vector3
  71050. */
  71051. fract(): Vector3;
  71052. /**
  71053. * Gets the length of the Vector3
  71054. * @returns the length of the Vector3
  71055. */
  71056. length(): number;
  71057. /**
  71058. * Gets the squared length of the Vector3
  71059. * @returns squared length of the Vector3
  71060. */
  71061. lengthSquared(): number;
  71062. /**
  71063. * Normalize the current Vector3.
  71064. * Please note that this is an in place operation.
  71065. * @returns the current updated Vector3
  71066. */
  71067. normalize(): Vector3;
  71068. /**
  71069. * Reorders the x y z properties of the vector in place
  71070. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  71071. * @returns the current updated vector
  71072. */
  71073. reorderInPlace(order: string): this;
  71074. /**
  71075. * Rotates the vector around 0,0,0 by a quaternion
  71076. * @param quaternion the rotation quaternion
  71077. * @param result vector to store the result
  71078. * @returns the resulting vector
  71079. */
  71080. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  71081. /**
  71082. * Rotates a vector around a given point
  71083. * @param quaternion the rotation quaternion
  71084. * @param point the point to rotate around
  71085. * @param result vector to store the result
  71086. * @returns the resulting vector
  71087. */
  71088. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  71089. /**
  71090. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  71091. * The cross product is then orthogonal to both current and "other"
  71092. * @param other defines the right operand
  71093. * @returns the cross product
  71094. */
  71095. cross(other: Vector3): Vector3;
  71096. /**
  71097. * Normalize the current Vector3 with the given input length.
  71098. * Please note that this is an in place operation.
  71099. * @param len the length of the vector
  71100. * @returns the current updated Vector3
  71101. */
  71102. normalizeFromLength(len: number): Vector3;
  71103. /**
  71104. * Normalize the current Vector3 to a new vector
  71105. * @returns the new Vector3
  71106. */
  71107. normalizeToNew(): Vector3;
  71108. /**
  71109. * Normalize the current Vector3 to the reference
  71110. * @param reference define the Vector3 to update
  71111. * @returns the updated Vector3
  71112. */
  71113. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  71114. /**
  71115. * Creates a new Vector3 copied from the current Vector3
  71116. * @returns the new Vector3
  71117. */
  71118. clone(): Vector3;
  71119. /**
  71120. * Copies the given vector coordinates to the current Vector3 ones
  71121. * @param source defines the source Vector3
  71122. * @returns the current updated Vector3
  71123. */
  71124. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  71125. /**
  71126. * Copies the given floats to the current Vector3 coordinates
  71127. * @param x defines the x coordinate of the operand
  71128. * @param y defines the y coordinate of the operand
  71129. * @param z defines the z coordinate of the operand
  71130. * @returns the current updated Vector3
  71131. */
  71132. copyFromFloats(x: number, y: number, z: number): Vector3;
  71133. /**
  71134. * Copies the given floats to the current Vector3 coordinates
  71135. * @param x defines the x coordinate of the operand
  71136. * @param y defines the y coordinate of the operand
  71137. * @param z defines the z coordinate of the operand
  71138. * @returns the current updated Vector3
  71139. */
  71140. set(x: number, y: number, z: number): Vector3;
  71141. /**
  71142. * Copies the given float to the current Vector3 coordinates
  71143. * @param v defines the x, y and z coordinates of the operand
  71144. * @returns the current updated Vector3
  71145. */
  71146. setAll(v: number): Vector3;
  71147. /**
  71148. * Get the clip factor between two vectors
  71149. * @param vector0 defines the first operand
  71150. * @param vector1 defines the second operand
  71151. * @param axis defines the axis to use
  71152. * @param size defines the size along the axis
  71153. * @returns the clip factor
  71154. */
  71155. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  71156. /**
  71157. * Get angle between two vectors
  71158. * @param vector0 angle between vector0 and vector1
  71159. * @param vector1 angle between vector0 and vector1
  71160. * @param normal direction of the normal
  71161. * @return the angle between vector0 and vector1
  71162. */
  71163. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  71164. /**
  71165. * Returns a new Vector3 set from the index "offset" of the given array
  71166. * @param array defines the source array
  71167. * @param offset defines the offset in the source array
  71168. * @returns the new Vector3
  71169. */
  71170. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  71171. /**
  71172. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  71173. * This function is deprecated. Use FromArray instead
  71174. * @param array defines the source array
  71175. * @param offset defines the offset in the source array
  71176. * @returns the new Vector3
  71177. */
  71178. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  71179. /**
  71180. * Sets the given vector "result" with the element values from the index "offset" of the given array
  71181. * @param array defines the source array
  71182. * @param offset defines the offset in the source array
  71183. * @param result defines the Vector3 where to store the result
  71184. */
  71185. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  71186. /**
  71187. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  71188. * This function is deprecated. Use FromArrayToRef instead.
  71189. * @param array defines the source array
  71190. * @param offset defines the offset in the source array
  71191. * @param result defines the Vector3 where to store the result
  71192. */
  71193. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  71194. /**
  71195. * Sets the given vector "result" with the given floats.
  71196. * @param x defines the x coordinate of the source
  71197. * @param y defines the y coordinate of the source
  71198. * @param z defines the z coordinate of the source
  71199. * @param result defines the Vector3 where to store the result
  71200. */
  71201. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  71202. /**
  71203. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  71204. * @returns a new empty Vector3
  71205. */
  71206. static Zero(): Vector3;
  71207. /**
  71208. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  71209. * @returns a new unit Vector3
  71210. */
  71211. static One(): Vector3;
  71212. /**
  71213. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  71214. * @returns a new up Vector3
  71215. */
  71216. static Up(): Vector3;
  71217. /**
  71218. * Gets a up Vector3 that must not be updated
  71219. */
  71220. static readonly UpReadOnly: DeepImmutable<Vector3>;
  71221. /**
  71222. * Gets a zero Vector3 that must not be updated
  71223. */
  71224. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  71225. /**
  71226. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  71227. * @returns a new down Vector3
  71228. */
  71229. static Down(): Vector3;
  71230. /**
  71231. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  71232. * @returns a new forward Vector3
  71233. */
  71234. static Forward(): Vector3;
  71235. /**
  71236. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  71237. * @returns a new forward Vector3
  71238. */
  71239. static Backward(): Vector3;
  71240. /**
  71241. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  71242. * @returns a new right Vector3
  71243. */
  71244. static Right(): Vector3;
  71245. /**
  71246. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  71247. * @returns a new left Vector3
  71248. */
  71249. static Left(): Vector3;
  71250. /**
  71251. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  71252. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  71253. * @param vector defines the Vector3 to transform
  71254. * @param transformation defines the transformation matrix
  71255. * @returns the transformed Vector3
  71256. */
  71257. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  71258. /**
  71259. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  71260. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  71261. * @param vector defines the Vector3 to transform
  71262. * @param transformation defines the transformation matrix
  71263. * @param result defines the Vector3 where to store the result
  71264. */
  71265. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  71266. /**
  71267. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  71268. * This method computes tranformed coordinates only, not transformed direction vectors
  71269. * @param x define the x coordinate of the source vector
  71270. * @param y define the y coordinate of the source vector
  71271. * @param z define the z coordinate of the source vector
  71272. * @param transformation defines the transformation matrix
  71273. * @param result defines the Vector3 where to store the result
  71274. */
  71275. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  71276. /**
  71277. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  71278. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  71279. * @param vector defines the Vector3 to transform
  71280. * @param transformation defines the transformation matrix
  71281. * @returns the new Vector3
  71282. */
  71283. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  71284. /**
  71285. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  71286. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  71287. * @param vector defines the Vector3 to transform
  71288. * @param transformation defines the transformation matrix
  71289. * @param result defines the Vector3 where to store the result
  71290. */
  71291. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  71292. /**
  71293. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  71294. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  71295. * @param x define the x coordinate of the source vector
  71296. * @param y define the y coordinate of the source vector
  71297. * @param z define the z coordinate of the source vector
  71298. * @param transformation defines the transformation matrix
  71299. * @param result defines the Vector3 where to store the result
  71300. */
  71301. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  71302. /**
  71303. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  71304. * @param value1 defines the first control point
  71305. * @param value2 defines the second control point
  71306. * @param value3 defines the third control point
  71307. * @param value4 defines the fourth control point
  71308. * @param amount defines the amount on the spline to use
  71309. * @returns the new Vector3
  71310. */
  71311. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  71312. /**
  71313. * 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"
  71314. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  71315. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  71316. * @param value defines the current value
  71317. * @param min defines the lower range value
  71318. * @param max defines the upper range value
  71319. * @returns the new Vector3
  71320. */
  71321. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  71322. /**
  71323. * 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"
  71324. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  71325. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  71326. * @param value defines the current value
  71327. * @param min defines the lower range value
  71328. * @param max defines the upper range value
  71329. * @param result defines the Vector3 where to store the result
  71330. */
  71331. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  71332. /**
  71333. * Checks if a given vector is inside a specific range
  71334. * @param v defines the vector to test
  71335. * @param min defines the minimum range
  71336. * @param max defines the maximum range
  71337. */
  71338. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  71339. /**
  71340. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  71341. * @param value1 defines the first control point
  71342. * @param tangent1 defines the first tangent vector
  71343. * @param value2 defines the second control point
  71344. * @param tangent2 defines the second tangent vector
  71345. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  71346. * @returns the new Vector3
  71347. */
  71348. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  71349. /**
  71350. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  71351. * @param start defines the start value
  71352. * @param end defines the end value
  71353. * @param amount max defines amount between both (between 0 and 1)
  71354. * @returns the new Vector3
  71355. */
  71356. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  71357. /**
  71358. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  71359. * @param start defines the start value
  71360. * @param end defines the end value
  71361. * @param amount max defines amount between both (between 0 and 1)
  71362. * @param result defines the Vector3 where to store the result
  71363. */
  71364. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  71365. /**
  71366. * Returns the dot product (float) between the vectors "left" and "right"
  71367. * @param left defines the left operand
  71368. * @param right defines the right operand
  71369. * @returns the dot product
  71370. */
  71371. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  71372. /**
  71373. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  71374. * The cross product is then orthogonal to both "left" and "right"
  71375. * @param left defines the left operand
  71376. * @param right defines the right operand
  71377. * @returns the cross product
  71378. */
  71379. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  71380. /**
  71381. * Sets the given vector "result" with the cross product of "left" and "right"
  71382. * The cross product is then orthogonal to both "left" and "right"
  71383. * @param left defines the left operand
  71384. * @param right defines the right operand
  71385. * @param result defines the Vector3 where to store the result
  71386. */
  71387. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  71388. /**
  71389. * Returns a new Vector3 as the normalization of the given vector
  71390. * @param vector defines the Vector3 to normalize
  71391. * @returns the new Vector3
  71392. */
  71393. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  71394. /**
  71395. * Sets the given vector "result" with the normalization of the given first vector
  71396. * @param vector defines the Vector3 to normalize
  71397. * @param result defines the Vector3 where to store the result
  71398. */
  71399. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  71400. /**
  71401. * Project a Vector3 onto screen space
  71402. * @param vector defines the Vector3 to project
  71403. * @param world defines the world matrix to use
  71404. * @param transform defines the transform (view x projection) matrix to use
  71405. * @param viewport defines the screen viewport to use
  71406. * @returns the new Vector3
  71407. */
  71408. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  71409. /** @hidden */
  71410. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  71411. /**
  71412. * Unproject from screen space to object space
  71413. * @param source defines the screen space Vector3 to use
  71414. * @param viewportWidth defines the current width of the viewport
  71415. * @param viewportHeight defines the current height of the viewport
  71416. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  71417. * @param transform defines the transform (view x projection) matrix to use
  71418. * @returns the new Vector3
  71419. */
  71420. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  71421. /**
  71422. * Unproject from screen space to object space
  71423. * @param source defines the screen space Vector3 to use
  71424. * @param viewportWidth defines the current width of the viewport
  71425. * @param viewportHeight defines the current height of the viewport
  71426. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  71427. * @param view defines the view matrix to use
  71428. * @param projection defines the projection matrix to use
  71429. * @returns the new Vector3
  71430. */
  71431. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  71432. /**
  71433. * Unproject from screen space to object space
  71434. * @param source defines the screen space Vector3 to use
  71435. * @param viewportWidth defines the current width of the viewport
  71436. * @param viewportHeight defines the current height of the viewport
  71437. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  71438. * @param view defines the view matrix to use
  71439. * @param projection defines the projection matrix to use
  71440. * @param result defines the Vector3 where to store the result
  71441. */
  71442. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  71443. /**
  71444. * Unproject from screen space to object space
  71445. * @param sourceX defines the screen space x coordinate to use
  71446. * @param sourceY defines the screen space y coordinate to use
  71447. * @param sourceZ defines the screen space z coordinate to use
  71448. * @param viewportWidth defines the current width of the viewport
  71449. * @param viewportHeight defines the current height of the viewport
  71450. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  71451. * @param view defines the view matrix to use
  71452. * @param projection defines the projection matrix to use
  71453. * @param result defines the Vector3 where to store the result
  71454. */
  71455. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  71456. /**
  71457. * Gets the minimal coordinate values between two Vector3
  71458. * @param left defines the first operand
  71459. * @param right defines the second operand
  71460. * @returns the new Vector3
  71461. */
  71462. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  71463. /**
  71464. * Gets the maximal coordinate values between two Vector3
  71465. * @param left defines the first operand
  71466. * @param right defines the second operand
  71467. * @returns the new Vector3
  71468. */
  71469. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  71470. /**
  71471. * Returns the distance between the vectors "value1" and "value2"
  71472. * @param value1 defines the first operand
  71473. * @param value2 defines the second operand
  71474. * @returns the distance
  71475. */
  71476. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  71477. /**
  71478. * Returns the squared distance between the vectors "value1" and "value2"
  71479. * @param value1 defines the first operand
  71480. * @param value2 defines the second operand
  71481. * @returns the squared distance
  71482. */
  71483. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  71484. /**
  71485. * Returns a new Vector3 located at the center between "value1" and "value2"
  71486. * @param value1 defines the first operand
  71487. * @param value2 defines the second operand
  71488. * @returns the new Vector3
  71489. */
  71490. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  71491. /**
  71492. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  71493. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  71494. * to something in order to rotate it from its local system to the given target system
  71495. * Note: axis1, axis2 and axis3 are normalized during this operation
  71496. * @param axis1 defines the first axis
  71497. * @param axis2 defines the second axis
  71498. * @param axis3 defines the third axis
  71499. * @returns a new Vector3
  71500. */
  71501. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  71502. /**
  71503. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  71504. * @param axis1 defines the first axis
  71505. * @param axis2 defines the second axis
  71506. * @param axis3 defines the third axis
  71507. * @param ref defines the Vector3 where to store the result
  71508. */
  71509. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  71510. }
  71511. /**
  71512. * Vector4 class created for EulerAngle class conversion to Quaternion
  71513. */
  71514. export class Vector4 {
  71515. /** x value of the vector */
  71516. x: number;
  71517. /** y value of the vector */
  71518. y: number;
  71519. /** z value of the vector */
  71520. z: number;
  71521. /** w value of the vector */
  71522. w: number;
  71523. /**
  71524. * Creates a Vector4 object from the given floats.
  71525. * @param x x value of the vector
  71526. * @param y y value of the vector
  71527. * @param z z value of the vector
  71528. * @param w w value of the vector
  71529. */
  71530. constructor(
  71531. /** x value of the vector */
  71532. x: number,
  71533. /** y value of the vector */
  71534. y: number,
  71535. /** z value of the vector */
  71536. z: number,
  71537. /** w value of the vector */
  71538. w: number);
  71539. /**
  71540. * Returns the string with the Vector4 coordinates.
  71541. * @returns a string containing all the vector values
  71542. */
  71543. toString(): string;
  71544. /**
  71545. * Returns the string "Vector4".
  71546. * @returns "Vector4"
  71547. */
  71548. getClassName(): string;
  71549. /**
  71550. * Returns the Vector4 hash code.
  71551. * @returns a unique hash code
  71552. */
  71553. getHashCode(): number;
  71554. /**
  71555. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  71556. * @returns the resulting array
  71557. */
  71558. asArray(): number[];
  71559. /**
  71560. * Populates the given array from the given index with the Vector4 coordinates.
  71561. * @param array array to populate
  71562. * @param index index of the array to start at (default: 0)
  71563. * @returns the Vector4.
  71564. */
  71565. toArray(array: FloatArray, index?: number): Vector4;
  71566. /**
  71567. * Adds the given vector to the current Vector4.
  71568. * @param otherVector the vector to add
  71569. * @returns the updated Vector4.
  71570. */
  71571. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  71572. /**
  71573. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  71574. * @param otherVector the vector to add
  71575. * @returns the resulting vector
  71576. */
  71577. add(otherVector: DeepImmutable<Vector4>): Vector4;
  71578. /**
  71579. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  71580. * @param otherVector the vector to add
  71581. * @param result the vector to store the result
  71582. * @returns the current Vector4.
  71583. */
  71584. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  71585. /**
  71586. * Subtract in place the given vector from the current Vector4.
  71587. * @param otherVector the vector to subtract
  71588. * @returns the updated Vector4.
  71589. */
  71590. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  71591. /**
  71592. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  71593. * @param otherVector the vector to add
  71594. * @returns the new vector with the result
  71595. */
  71596. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  71597. /**
  71598. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  71599. * @param otherVector the vector to subtract
  71600. * @param result the vector to store the result
  71601. * @returns the current Vector4.
  71602. */
  71603. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  71604. /**
  71605. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  71606. */
  71607. /**
  71608. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  71609. * @param x value to subtract
  71610. * @param y value to subtract
  71611. * @param z value to subtract
  71612. * @param w value to subtract
  71613. * @returns new vector containing the result
  71614. */
  71615. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  71616. /**
  71617. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  71618. * @param x value to subtract
  71619. * @param y value to subtract
  71620. * @param z value to subtract
  71621. * @param w value to subtract
  71622. * @param result the vector to store the result in
  71623. * @returns the current Vector4.
  71624. */
  71625. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  71626. /**
  71627. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  71628. * @returns a new vector with the negated values
  71629. */
  71630. negate(): Vector4;
  71631. /**
  71632. * Multiplies the current Vector4 coordinates by scale (float).
  71633. * @param scale the number to scale with
  71634. * @returns the updated Vector4.
  71635. */
  71636. scaleInPlace(scale: number): Vector4;
  71637. /**
  71638. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  71639. * @param scale the number to scale with
  71640. * @returns a new vector with the result
  71641. */
  71642. scale(scale: number): Vector4;
  71643. /**
  71644. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  71645. * @param scale the number to scale with
  71646. * @param result a vector to store the result in
  71647. * @returns the current Vector4.
  71648. */
  71649. scaleToRef(scale: number, result: Vector4): Vector4;
  71650. /**
  71651. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  71652. * @param scale defines the scale factor
  71653. * @param result defines the Vector4 object where to store the result
  71654. * @returns the unmodified current Vector4
  71655. */
  71656. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  71657. /**
  71658. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  71659. * @param otherVector the vector to compare against
  71660. * @returns true if they are equal
  71661. */
  71662. equals(otherVector: DeepImmutable<Vector4>): boolean;
  71663. /**
  71664. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  71665. * @param otherVector vector to compare against
  71666. * @param epsilon (Default: very small number)
  71667. * @returns true if they are equal
  71668. */
  71669. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  71670. /**
  71671. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  71672. * @param x x value to compare against
  71673. * @param y y value to compare against
  71674. * @param z z value to compare against
  71675. * @param w w value to compare against
  71676. * @returns true if equal
  71677. */
  71678. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  71679. /**
  71680. * Multiplies in place the current Vector4 by the given one.
  71681. * @param otherVector vector to multiple with
  71682. * @returns the updated Vector4.
  71683. */
  71684. multiplyInPlace(otherVector: Vector4): Vector4;
  71685. /**
  71686. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  71687. * @param otherVector vector to multiple with
  71688. * @returns resulting new vector
  71689. */
  71690. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  71691. /**
  71692. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  71693. * @param otherVector vector to multiple with
  71694. * @param result vector to store the result
  71695. * @returns the current Vector4.
  71696. */
  71697. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  71698. /**
  71699. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  71700. * @param x x value multiply with
  71701. * @param y y value multiply with
  71702. * @param z z value multiply with
  71703. * @param w w value multiply with
  71704. * @returns resulting new vector
  71705. */
  71706. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  71707. /**
  71708. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  71709. * @param otherVector vector to devide with
  71710. * @returns resulting new vector
  71711. */
  71712. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  71713. /**
  71714. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  71715. * @param otherVector vector to devide with
  71716. * @param result vector to store the result
  71717. * @returns the current Vector4.
  71718. */
  71719. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  71720. /**
  71721. * Divides the current Vector3 coordinates by the given ones.
  71722. * @param otherVector vector to devide with
  71723. * @returns the updated Vector3.
  71724. */
  71725. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  71726. /**
  71727. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  71728. * @param other defines the second operand
  71729. * @returns the current updated Vector4
  71730. */
  71731. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  71732. /**
  71733. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  71734. * @param other defines the second operand
  71735. * @returns the current updated Vector4
  71736. */
  71737. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  71738. /**
  71739. * Gets a new Vector4 from current Vector4 floored values
  71740. * @returns a new Vector4
  71741. */
  71742. floor(): Vector4;
  71743. /**
  71744. * Gets a new Vector4 from current Vector3 floored values
  71745. * @returns a new Vector4
  71746. */
  71747. fract(): Vector4;
  71748. /**
  71749. * Returns the Vector4 length (float).
  71750. * @returns the length
  71751. */
  71752. length(): number;
  71753. /**
  71754. * Returns the Vector4 squared length (float).
  71755. * @returns the length squared
  71756. */
  71757. lengthSquared(): number;
  71758. /**
  71759. * Normalizes in place the Vector4.
  71760. * @returns the updated Vector4.
  71761. */
  71762. normalize(): Vector4;
  71763. /**
  71764. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  71765. * @returns this converted to a new vector3
  71766. */
  71767. toVector3(): Vector3;
  71768. /**
  71769. * Returns a new Vector4 copied from the current one.
  71770. * @returns the new cloned vector
  71771. */
  71772. clone(): Vector4;
  71773. /**
  71774. * Updates the current Vector4 with the given one coordinates.
  71775. * @param source the source vector to copy from
  71776. * @returns the updated Vector4.
  71777. */
  71778. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  71779. /**
  71780. * Updates the current Vector4 coordinates with the given floats.
  71781. * @param x float to copy from
  71782. * @param y float to copy from
  71783. * @param z float to copy from
  71784. * @param w float to copy from
  71785. * @returns the updated Vector4.
  71786. */
  71787. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  71788. /**
  71789. * Updates the current Vector4 coordinates with the given floats.
  71790. * @param x float to set from
  71791. * @param y float to set from
  71792. * @param z float to set from
  71793. * @param w float to set from
  71794. * @returns the updated Vector4.
  71795. */
  71796. set(x: number, y: number, z: number, w: number): Vector4;
  71797. /**
  71798. * Copies the given float to the current Vector3 coordinates
  71799. * @param v defines the x, y, z and w coordinates of the operand
  71800. * @returns the current updated Vector3
  71801. */
  71802. setAll(v: number): Vector4;
  71803. /**
  71804. * Returns a new Vector4 set from the starting index of the given array.
  71805. * @param array the array to pull values from
  71806. * @param offset the offset into the array to start at
  71807. * @returns the new vector
  71808. */
  71809. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  71810. /**
  71811. * Updates the given vector "result" from the starting index of the given array.
  71812. * @param array the array to pull values from
  71813. * @param offset the offset into the array to start at
  71814. * @param result the vector to store the result in
  71815. */
  71816. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  71817. /**
  71818. * Updates the given vector "result" from the starting index of the given Float32Array.
  71819. * @param array the array to pull values from
  71820. * @param offset the offset into the array to start at
  71821. * @param result the vector to store the result in
  71822. */
  71823. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  71824. /**
  71825. * Updates the given vector "result" coordinates from the given floats.
  71826. * @param x float to set from
  71827. * @param y float to set from
  71828. * @param z float to set from
  71829. * @param w float to set from
  71830. * @param result the vector to the floats in
  71831. */
  71832. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  71833. /**
  71834. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  71835. * @returns the new vector
  71836. */
  71837. static Zero(): Vector4;
  71838. /**
  71839. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  71840. * @returns the new vector
  71841. */
  71842. static One(): Vector4;
  71843. /**
  71844. * Returns a new normalized Vector4 from the given one.
  71845. * @param vector the vector to normalize
  71846. * @returns the vector
  71847. */
  71848. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  71849. /**
  71850. * Updates the given vector "result" from the normalization of the given one.
  71851. * @param vector the vector to normalize
  71852. * @param result the vector to store the result in
  71853. */
  71854. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  71855. /**
  71856. * Returns a vector with the minimum values from the left and right vectors
  71857. * @param left left vector to minimize
  71858. * @param right right vector to minimize
  71859. * @returns a new vector with the minimum of the left and right vector values
  71860. */
  71861. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  71862. /**
  71863. * Returns a vector with the maximum values from the left and right vectors
  71864. * @param left left vector to maximize
  71865. * @param right right vector to maximize
  71866. * @returns a new vector with the maximum of the left and right vector values
  71867. */
  71868. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  71869. /**
  71870. * Returns the distance (float) between the vectors "value1" and "value2".
  71871. * @param value1 value to calulate the distance between
  71872. * @param value2 value to calulate the distance between
  71873. * @return the distance between the two vectors
  71874. */
  71875. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  71876. /**
  71877. * Returns the squared distance (float) between the vectors "value1" and "value2".
  71878. * @param value1 value to calulate the distance between
  71879. * @param value2 value to calulate the distance between
  71880. * @return the distance between the two vectors squared
  71881. */
  71882. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  71883. /**
  71884. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  71885. * @param value1 value to calulate the center between
  71886. * @param value2 value to calulate the center between
  71887. * @return the center between the two vectors
  71888. */
  71889. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  71890. /**
  71891. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  71892. * This methods computes transformed normalized direction vectors only.
  71893. * @param vector the vector to transform
  71894. * @param transformation the transformation matrix to apply
  71895. * @returns the new vector
  71896. */
  71897. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  71898. /**
  71899. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  71900. * This methods computes transformed normalized direction vectors only.
  71901. * @param vector the vector to transform
  71902. * @param transformation the transformation matrix to apply
  71903. * @param result the vector to store the result in
  71904. */
  71905. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  71906. /**
  71907. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  71908. * This methods computes transformed normalized direction vectors only.
  71909. * @param x value to transform
  71910. * @param y value to transform
  71911. * @param z value to transform
  71912. * @param w value to transform
  71913. * @param transformation the transformation matrix to apply
  71914. * @param result the vector to store the results in
  71915. */
  71916. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  71917. /**
  71918. * Creates a new Vector4 from a Vector3
  71919. * @param source defines the source data
  71920. * @param w defines the 4th component (default is 0)
  71921. * @returns a new Vector4
  71922. */
  71923. static FromVector3(source: Vector3, w?: number): Vector4;
  71924. }
  71925. /**
  71926. * Class used to store quaternion data
  71927. * @see https://en.wikipedia.org/wiki/Quaternion
  71928. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  71929. */
  71930. export class Quaternion {
  71931. /** defines the first component (0 by default) */
  71932. x: number;
  71933. /** defines the second component (0 by default) */
  71934. y: number;
  71935. /** defines the third component (0 by default) */
  71936. z: number;
  71937. /** defines the fourth component (1.0 by default) */
  71938. w: number;
  71939. /**
  71940. * Creates a new Quaternion from the given floats
  71941. * @param x defines the first component (0 by default)
  71942. * @param y defines the second component (0 by default)
  71943. * @param z defines the third component (0 by default)
  71944. * @param w defines the fourth component (1.0 by default)
  71945. */
  71946. constructor(
  71947. /** defines the first component (0 by default) */
  71948. x?: number,
  71949. /** defines the second component (0 by default) */
  71950. y?: number,
  71951. /** defines the third component (0 by default) */
  71952. z?: number,
  71953. /** defines the fourth component (1.0 by default) */
  71954. w?: number);
  71955. /**
  71956. * Gets a string representation for the current quaternion
  71957. * @returns a string with the Quaternion coordinates
  71958. */
  71959. toString(): string;
  71960. /**
  71961. * Gets the class name of the quaternion
  71962. * @returns the string "Quaternion"
  71963. */
  71964. getClassName(): string;
  71965. /**
  71966. * Gets a hash code for this quaternion
  71967. * @returns the quaternion hash code
  71968. */
  71969. getHashCode(): number;
  71970. /**
  71971. * Copy the quaternion to an array
  71972. * @returns a new array populated with 4 elements from the quaternion coordinates
  71973. */
  71974. asArray(): number[];
  71975. /**
  71976. * Check if two quaternions are equals
  71977. * @param otherQuaternion defines the second operand
  71978. * @return true if the current quaternion and the given one coordinates are strictly equals
  71979. */
  71980. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  71981. /**
  71982. * Clone the current quaternion
  71983. * @returns a new quaternion copied from the current one
  71984. */
  71985. clone(): Quaternion;
  71986. /**
  71987. * Copy a quaternion to the current one
  71988. * @param other defines the other quaternion
  71989. * @returns the updated current quaternion
  71990. */
  71991. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  71992. /**
  71993. * Updates the current quaternion with the given float coordinates
  71994. * @param x defines the x coordinate
  71995. * @param y defines the y coordinate
  71996. * @param z defines the z coordinate
  71997. * @param w defines the w coordinate
  71998. * @returns the updated current quaternion
  71999. */
  72000. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  72001. /**
  72002. * Updates the current quaternion from the given float coordinates
  72003. * @param x defines the x coordinate
  72004. * @param y defines the y coordinate
  72005. * @param z defines the z coordinate
  72006. * @param w defines the w coordinate
  72007. * @returns the updated current quaternion
  72008. */
  72009. set(x: number, y: number, z: number, w: number): Quaternion;
  72010. /**
  72011. * Adds two quaternions
  72012. * @param other defines the second operand
  72013. * @returns a new quaternion as the addition result of the given one and the current quaternion
  72014. */
  72015. add(other: DeepImmutable<Quaternion>): Quaternion;
  72016. /**
  72017. * Add a quaternion to the current one
  72018. * @param other defines the quaternion to add
  72019. * @returns the current quaternion
  72020. */
  72021. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  72022. /**
  72023. * Subtract two quaternions
  72024. * @param other defines the second operand
  72025. * @returns a new quaternion as the subtraction result of the given one from the current one
  72026. */
  72027. subtract(other: Quaternion): Quaternion;
  72028. /**
  72029. * Multiplies the current quaternion by a scale factor
  72030. * @param value defines the scale factor
  72031. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  72032. */
  72033. scale(value: number): Quaternion;
  72034. /**
  72035. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  72036. * @param scale defines the scale factor
  72037. * @param result defines the Quaternion object where to store the result
  72038. * @returns the unmodified current quaternion
  72039. */
  72040. scaleToRef(scale: number, result: Quaternion): Quaternion;
  72041. /**
  72042. * Multiplies in place the current quaternion by a scale factor
  72043. * @param value defines the scale factor
  72044. * @returns the current modified quaternion
  72045. */
  72046. scaleInPlace(value: number): Quaternion;
  72047. /**
  72048. * Scale the current quaternion values by a factor and add the result to a given quaternion
  72049. * @param scale defines the scale factor
  72050. * @param result defines the Quaternion object where to store the result
  72051. * @returns the unmodified current quaternion
  72052. */
  72053. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  72054. /**
  72055. * Multiplies two quaternions
  72056. * @param q1 defines the second operand
  72057. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  72058. */
  72059. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  72060. /**
  72061. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  72062. * @param q1 defines the second operand
  72063. * @param result defines the target quaternion
  72064. * @returns the current quaternion
  72065. */
  72066. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  72067. /**
  72068. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  72069. * @param q1 defines the second operand
  72070. * @returns the currentupdated quaternion
  72071. */
  72072. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  72073. /**
  72074. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  72075. * @param ref defines the target quaternion
  72076. * @returns the current quaternion
  72077. */
  72078. conjugateToRef(ref: Quaternion): Quaternion;
  72079. /**
  72080. * Conjugates in place (1-q) the current quaternion
  72081. * @returns the current updated quaternion
  72082. */
  72083. conjugateInPlace(): Quaternion;
  72084. /**
  72085. * Conjugates in place (1-q) the current quaternion
  72086. * @returns a new quaternion
  72087. */
  72088. conjugate(): Quaternion;
  72089. /**
  72090. * Gets length of current quaternion
  72091. * @returns the quaternion length (float)
  72092. */
  72093. length(): number;
  72094. /**
  72095. * Normalize in place the current quaternion
  72096. * @returns the current updated quaternion
  72097. */
  72098. normalize(): Quaternion;
  72099. /**
  72100. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  72101. * @param order is a reserved parameter and is ignore for now
  72102. * @returns a new Vector3 containing the Euler angles
  72103. */
  72104. toEulerAngles(order?: string): Vector3;
  72105. /**
  72106. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  72107. * @param result defines the vector which will be filled with the Euler angles
  72108. * @param order is a reserved parameter and is ignore for now
  72109. * @returns the current unchanged quaternion
  72110. */
  72111. toEulerAnglesToRef(result: Vector3): Quaternion;
  72112. /**
  72113. * Updates the given rotation matrix with the current quaternion values
  72114. * @param result defines the target matrix
  72115. * @returns the current unchanged quaternion
  72116. */
  72117. toRotationMatrix(result: Matrix): Quaternion;
  72118. /**
  72119. * Updates the current quaternion from the given rotation matrix values
  72120. * @param matrix defines the source matrix
  72121. * @returns the current updated quaternion
  72122. */
  72123. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  72124. /**
  72125. * Creates a new quaternion from a rotation matrix
  72126. * @param matrix defines the source matrix
  72127. * @returns a new quaternion created from the given rotation matrix values
  72128. */
  72129. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  72130. /**
  72131. * Updates the given quaternion with the given rotation matrix values
  72132. * @param matrix defines the source matrix
  72133. * @param result defines the target quaternion
  72134. */
  72135. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  72136. /**
  72137. * Returns the dot product (float) between the quaternions "left" and "right"
  72138. * @param left defines the left operand
  72139. * @param right defines the right operand
  72140. * @returns the dot product
  72141. */
  72142. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  72143. /**
  72144. * Checks if the two quaternions are close to each other
  72145. * @param quat0 defines the first quaternion to check
  72146. * @param quat1 defines the second quaternion to check
  72147. * @returns true if the two quaternions are close to each other
  72148. */
  72149. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  72150. /**
  72151. * Creates an empty quaternion
  72152. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  72153. */
  72154. static Zero(): Quaternion;
  72155. /**
  72156. * Inverse a given quaternion
  72157. * @param q defines the source quaternion
  72158. * @returns a new quaternion as the inverted current quaternion
  72159. */
  72160. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  72161. /**
  72162. * Inverse a given quaternion
  72163. * @param q defines the source quaternion
  72164. * @param result the quaternion the result will be stored in
  72165. * @returns the result quaternion
  72166. */
  72167. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  72168. /**
  72169. * Creates an identity quaternion
  72170. * @returns the identity quaternion
  72171. */
  72172. static Identity(): Quaternion;
  72173. /**
  72174. * Gets a boolean indicating if the given quaternion is identity
  72175. * @param quaternion defines the quaternion to check
  72176. * @returns true if the quaternion is identity
  72177. */
  72178. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  72179. /**
  72180. * Creates a quaternion from a rotation around an axis
  72181. * @param axis defines the axis to use
  72182. * @param angle defines the angle to use
  72183. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  72184. */
  72185. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  72186. /**
  72187. * Creates a rotation around an axis and stores it into the given quaternion
  72188. * @param axis defines the axis to use
  72189. * @param angle defines the angle to use
  72190. * @param result defines the target quaternion
  72191. * @returns the target quaternion
  72192. */
  72193. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  72194. /**
  72195. * Creates a new quaternion from data stored into an array
  72196. * @param array defines the data source
  72197. * @param offset defines the offset in the source array where the data starts
  72198. * @returns a new quaternion
  72199. */
  72200. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  72201. /**
  72202. * Create a quaternion from Euler rotation angles
  72203. * @param x Pitch
  72204. * @param y Yaw
  72205. * @param z Roll
  72206. * @returns the new Quaternion
  72207. */
  72208. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  72209. /**
  72210. * Updates a quaternion from Euler rotation angles
  72211. * @param x Pitch
  72212. * @param y Yaw
  72213. * @param z Roll
  72214. * @param result the quaternion to store the result
  72215. * @returns the updated quaternion
  72216. */
  72217. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  72218. /**
  72219. * Create a quaternion from Euler rotation vector
  72220. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  72221. * @returns the new Quaternion
  72222. */
  72223. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  72224. /**
  72225. * Updates a quaternion from Euler rotation vector
  72226. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  72227. * @param result the quaternion to store the result
  72228. * @returns the updated quaternion
  72229. */
  72230. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  72231. /**
  72232. * Creates a new quaternion from the given Euler float angles (y, x, z)
  72233. * @param yaw defines the rotation around Y axis
  72234. * @param pitch defines the rotation around X axis
  72235. * @param roll defines the rotation around Z axis
  72236. * @returns the new quaternion
  72237. */
  72238. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  72239. /**
  72240. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  72241. * @param yaw defines the rotation around Y axis
  72242. * @param pitch defines the rotation around X axis
  72243. * @param roll defines the rotation around Z axis
  72244. * @param result defines the target quaternion
  72245. */
  72246. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  72247. /**
  72248. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  72249. * @param alpha defines the rotation around first axis
  72250. * @param beta defines the rotation around second axis
  72251. * @param gamma defines the rotation around third axis
  72252. * @returns the new quaternion
  72253. */
  72254. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  72255. /**
  72256. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  72257. * @param alpha defines the rotation around first axis
  72258. * @param beta defines the rotation around second axis
  72259. * @param gamma defines the rotation around third axis
  72260. * @param result defines the target quaternion
  72261. */
  72262. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  72263. /**
  72264. * 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)
  72265. * @param axis1 defines the first axis
  72266. * @param axis2 defines the second axis
  72267. * @param axis3 defines the third axis
  72268. * @returns the new quaternion
  72269. */
  72270. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  72271. /**
  72272. * 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
  72273. * @param axis1 defines the first axis
  72274. * @param axis2 defines the second axis
  72275. * @param axis3 defines the third axis
  72276. * @param ref defines the target quaternion
  72277. */
  72278. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  72279. /**
  72280. * Interpolates between two quaternions
  72281. * @param left defines first quaternion
  72282. * @param right defines second quaternion
  72283. * @param amount defines the gradient to use
  72284. * @returns the new interpolated quaternion
  72285. */
  72286. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  72287. /**
  72288. * Interpolates between two quaternions and stores it into a target quaternion
  72289. * @param left defines first quaternion
  72290. * @param right defines second quaternion
  72291. * @param amount defines the gradient to use
  72292. * @param result defines the target quaternion
  72293. */
  72294. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  72295. /**
  72296. * Interpolate between two quaternions using Hermite interpolation
  72297. * @param value1 defines first quaternion
  72298. * @param tangent1 defines the incoming tangent
  72299. * @param value2 defines second quaternion
  72300. * @param tangent2 defines the outgoing tangent
  72301. * @param amount defines the target quaternion
  72302. * @returns the new interpolated quaternion
  72303. */
  72304. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  72305. }
  72306. /**
  72307. * Class used to store matrix data (4x4)
  72308. */
  72309. export class Matrix {
  72310. private static _updateFlagSeed;
  72311. private static _identityReadOnly;
  72312. private _isIdentity;
  72313. private _isIdentityDirty;
  72314. private _isIdentity3x2;
  72315. private _isIdentity3x2Dirty;
  72316. /**
  72317. * Gets the update flag of the matrix which is an unique number for the matrix.
  72318. * It will be incremented every time the matrix data change.
  72319. * You can use it to speed the comparison between two versions of the same matrix.
  72320. */
  72321. updateFlag: number;
  72322. private readonly _m;
  72323. /**
  72324. * Gets the internal data of the matrix
  72325. */
  72326. readonly m: DeepImmutable<Float32Array>;
  72327. /** @hidden */
  72328. _markAsUpdated(): void;
  72329. /** @hidden */
  72330. private _updateIdentityStatus;
  72331. /**
  72332. * Creates an empty matrix (filled with zeros)
  72333. */
  72334. constructor();
  72335. /**
  72336. * Check if the current matrix is identity
  72337. * @returns true is the matrix is the identity matrix
  72338. */
  72339. isIdentity(): boolean;
  72340. /**
  72341. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  72342. * @returns true is the matrix is the identity matrix
  72343. */
  72344. isIdentityAs3x2(): boolean;
  72345. /**
  72346. * Gets the determinant of the matrix
  72347. * @returns the matrix determinant
  72348. */
  72349. determinant(): number;
  72350. /**
  72351. * Returns the matrix as a Float32Array
  72352. * @returns the matrix underlying array
  72353. */
  72354. toArray(): DeepImmutable<Float32Array>;
  72355. /**
  72356. * Returns the matrix as a Float32Array
  72357. * @returns the matrix underlying array.
  72358. */
  72359. asArray(): DeepImmutable<Float32Array>;
  72360. /**
  72361. * Inverts the current matrix in place
  72362. * @returns the current inverted matrix
  72363. */
  72364. invert(): Matrix;
  72365. /**
  72366. * Sets all the matrix elements to zero
  72367. * @returns the current matrix
  72368. */
  72369. reset(): Matrix;
  72370. /**
  72371. * Adds the current matrix with a second one
  72372. * @param other defines the matrix to add
  72373. * @returns a new matrix as the addition of the current matrix and the given one
  72374. */
  72375. add(other: DeepImmutable<Matrix>): Matrix;
  72376. /**
  72377. * Sets the given matrix "result" to the addition of the current matrix and the given one
  72378. * @param other defines the matrix to add
  72379. * @param result defines the target matrix
  72380. * @returns the current matrix
  72381. */
  72382. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  72383. /**
  72384. * Adds in place the given matrix to the current matrix
  72385. * @param other defines the second operand
  72386. * @returns the current updated matrix
  72387. */
  72388. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  72389. /**
  72390. * Sets the given matrix to the current inverted Matrix
  72391. * @param other defines the target matrix
  72392. * @returns the unmodified current matrix
  72393. */
  72394. invertToRef(other: Matrix): Matrix;
  72395. /**
  72396. * add a value at the specified position in the current Matrix
  72397. * @param index the index of the value within the matrix. between 0 and 15.
  72398. * @param value the value to be added
  72399. * @returns the current updated matrix
  72400. */
  72401. addAtIndex(index: number, value: number): Matrix;
  72402. /**
  72403. * mutiply the specified position in the current Matrix by a value
  72404. * @param index the index of the value within the matrix. between 0 and 15.
  72405. * @param value the value to be added
  72406. * @returns the current updated matrix
  72407. */
  72408. multiplyAtIndex(index: number, value: number): Matrix;
  72409. /**
  72410. * Inserts the translation vector (using 3 floats) in the current matrix
  72411. * @param x defines the 1st component of the translation
  72412. * @param y defines the 2nd component of the translation
  72413. * @param z defines the 3rd component of the translation
  72414. * @returns the current updated matrix
  72415. */
  72416. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  72417. /**
  72418. * Adds the translation vector (using 3 floats) in the current matrix
  72419. * @param x defines the 1st component of the translation
  72420. * @param y defines the 2nd component of the translation
  72421. * @param z defines the 3rd component of the translation
  72422. * @returns the current updated matrix
  72423. */
  72424. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  72425. /**
  72426. * Inserts the translation vector in the current matrix
  72427. * @param vector3 defines the translation to insert
  72428. * @returns the current updated matrix
  72429. */
  72430. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  72431. /**
  72432. * Gets the translation value of the current matrix
  72433. * @returns a new Vector3 as the extracted translation from the matrix
  72434. */
  72435. getTranslation(): Vector3;
  72436. /**
  72437. * Fill a Vector3 with the extracted translation from the matrix
  72438. * @param result defines the Vector3 where to store the translation
  72439. * @returns the current matrix
  72440. */
  72441. getTranslationToRef(result: Vector3): Matrix;
  72442. /**
  72443. * Remove rotation and scaling part from the matrix
  72444. * @returns the updated matrix
  72445. */
  72446. removeRotationAndScaling(): Matrix;
  72447. /**
  72448. * Multiply two matrices
  72449. * @param other defines the second operand
  72450. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  72451. */
  72452. multiply(other: DeepImmutable<Matrix>): Matrix;
  72453. /**
  72454. * Copy the current matrix from the given one
  72455. * @param other defines the source matrix
  72456. * @returns the current updated matrix
  72457. */
  72458. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  72459. /**
  72460. * Populates the given array from the starting index with the current matrix values
  72461. * @param array defines the target array
  72462. * @param offset defines the offset in the target array where to start storing values
  72463. * @returns the current matrix
  72464. */
  72465. copyToArray(array: Float32Array, offset?: number): Matrix;
  72466. /**
  72467. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  72468. * @param other defines the second operand
  72469. * @param result defines the matrix where to store the multiplication
  72470. * @returns the current matrix
  72471. */
  72472. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  72473. /**
  72474. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  72475. * @param other defines the second operand
  72476. * @param result defines the array where to store the multiplication
  72477. * @param offset defines the offset in the target array where to start storing values
  72478. * @returns the current matrix
  72479. */
  72480. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  72481. /**
  72482. * Check equality between this matrix and a second one
  72483. * @param value defines the second matrix to compare
  72484. * @returns true is the current matrix and the given one values are strictly equal
  72485. */
  72486. equals(value: DeepImmutable<Matrix>): boolean;
  72487. /**
  72488. * Clone the current matrix
  72489. * @returns a new matrix from the current matrix
  72490. */
  72491. clone(): Matrix;
  72492. /**
  72493. * Returns the name of the current matrix class
  72494. * @returns the string "Matrix"
  72495. */
  72496. getClassName(): string;
  72497. /**
  72498. * Gets the hash code of the current matrix
  72499. * @returns the hash code
  72500. */
  72501. getHashCode(): number;
  72502. /**
  72503. * Decomposes the current Matrix into a translation, rotation and scaling components
  72504. * @param scale defines the scale vector3 given as a reference to update
  72505. * @param rotation defines the rotation quaternion given as a reference to update
  72506. * @param translation defines the translation vector3 given as a reference to update
  72507. * @returns true if operation was successful
  72508. */
  72509. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  72510. /**
  72511. * Gets specific row of the matrix
  72512. * @param index defines the number of the row to get
  72513. * @returns the index-th row of the current matrix as a new Vector4
  72514. */
  72515. getRow(index: number): Nullable<Vector4>;
  72516. /**
  72517. * Sets the index-th row of the current matrix to the vector4 values
  72518. * @param index defines the number of the row to set
  72519. * @param row defines the target vector4
  72520. * @returns the updated current matrix
  72521. */
  72522. setRow(index: number, row: Vector4): Matrix;
  72523. /**
  72524. * Compute the transpose of the matrix
  72525. * @returns the new transposed matrix
  72526. */
  72527. transpose(): Matrix;
  72528. /**
  72529. * Compute the transpose of the matrix and store it in a given matrix
  72530. * @param result defines the target matrix
  72531. * @returns the current matrix
  72532. */
  72533. transposeToRef(result: Matrix): Matrix;
  72534. /**
  72535. * Sets the index-th row of the current matrix with the given 4 x float values
  72536. * @param index defines the row index
  72537. * @param x defines the x component to set
  72538. * @param y defines the y component to set
  72539. * @param z defines the z component to set
  72540. * @param w defines the w component to set
  72541. * @returns the updated current matrix
  72542. */
  72543. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  72544. /**
  72545. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  72546. * @param scale defines the scale factor
  72547. * @returns a new matrix
  72548. */
  72549. scale(scale: number): Matrix;
  72550. /**
  72551. * Scale the current matrix values by a factor to a given result matrix
  72552. * @param scale defines the scale factor
  72553. * @param result defines the matrix to store the result
  72554. * @returns the current matrix
  72555. */
  72556. scaleToRef(scale: number, result: Matrix): Matrix;
  72557. /**
  72558. * Scale the current matrix values by a factor and add the result to a given matrix
  72559. * @param scale defines the scale factor
  72560. * @param result defines the Matrix to store the result
  72561. * @returns the current matrix
  72562. */
  72563. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  72564. /**
  72565. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  72566. * @param ref matrix to store the result
  72567. */
  72568. toNormalMatrix(ref: Matrix): void;
  72569. /**
  72570. * Gets only rotation part of the current matrix
  72571. * @returns a new matrix sets to the extracted rotation matrix from the current one
  72572. */
  72573. getRotationMatrix(): Matrix;
  72574. /**
  72575. * Extracts the rotation matrix from the current one and sets it as the given "result"
  72576. * @param result defines the target matrix to store data to
  72577. * @returns the current matrix
  72578. */
  72579. getRotationMatrixToRef(result: Matrix): Matrix;
  72580. /**
  72581. * Toggles model matrix from being right handed to left handed in place and vice versa
  72582. */
  72583. toggleModelMatrixHandInPlace(): void;
  72584. /**
  72585. * Toggles projection matrix from being right handed to left handed in place and vice versa
  72586. */
  72587. toggleProjectionMatrixHandInPlace(): void;
  72588. /**
  72589. * Creates a matrix from an array
  72590. * @param array defines the source array
  72591. * @param offset defines an offset in the source array
  72592. * @returns a new Matrix set from the starting index of the given array
  72593. */
  72594. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  72595. /**
  72596. * Copy the content of an array into a given matrix
  72597. * @param array defines the source array
  72598. * @param offset defines an offset in the source array
  72599. * @param result defines the target matrix
  72600. */
  72601. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  72602. /**
  72603. * Stores an array into a matrix after having multiplied each component by a given factor
  72604. * @param array defines the source array
  72605. * @param offset defines the offset in the source array
  72606. * @param scale defines the scaling factor
  72607. * @param result defines the target matrix
  72608. */
  72609. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  72610. /**
  72611. * Gets an identity matrix that must not be updated
  72612. */
  72613. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  72614. /**
  72615. * Stores a list of values (16) inside a given matrix
  72616. * @param initialM11 defines 1st value of 1st row
  72617. * @param initialM12 defines 2nd value of 1st row
  72618. * @param initialM13 defines 3rd value of 1st row
  72619. * @param initialM14 defines 4th value of 1st row
  72620. * @param initialM21 defines 1st value of 2nd row
  72621. * @param initialM22 defines 2nd value of 2nd row
  72622. * @param initialM23 defines 3rd value of 2nd row
  72623. * @param initialM24 defines 4th value of 2nd row
  72624. * @param initialM31 defines 1st value of 3rd row
  72625. * @param initialM32 defines 2nd value of 3rd row
  72626. * @param initialM33 defines 3rd value of 3rd row
  72627. * @param initialM34 defines 4th value of 3rd row
  72628. * @param initialM41 defines 1st value of 4th row
  72629. * @param initialM42 defines 2nd value of 4th row
  72630. * @param initialM43 defines 3rd value of 4th row
  72631. * @param initialM44 defines 4th value of 4th row
  72632. * @param result defines the target matrix
  72633. */
  72634. 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;
  72635. /**
  72636. * Creates new matrix from a list of values (16)
  72637. * @param initialM11 defines 1st value of 1st row
  72638. * @param initialM12 defines 2nd value of 1st row
  72639. * @param initialM13 defines 3rd value of 1st row
  72640. * @param initialM14 defines 4th value of 1st row
  72641. * @param initialM21 defines 1st value of 2nd row
  72642. * @param initialM22 defines 2nd value of 2nd row
  72643. * @param initialM23 defines 3rd value of 2nd row
  72644. * @param initialM24 defines 4th value of 2nd row
  72645. * @param initialM31 defines 1st value of 3rd row
  72646. * @param initialM32 defines 2nd value of 3rd row
  72647. * @param initialM33 defines 3rd value of 3rd row
  72648. * @param initialM34 defines 4th value of 3rd row
  72649. * @param initialM41 defines 1st value of 4th row
  72650. * @param initialM42 defines 2nd value of 4th row
  72651. * @param initialM43 defines 3rd value of 4th row
  72652. * @param initialM44 defines 4th value of 4th row
  72653. * @returns the new matrix
  72654. */
  72655. 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;
  72656. /**
  72657. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  72658. * @param scale defines the scale vector3
  72659. * @param rotation defines the rotation quaternion
  72660. * @param translation defines the translation vector3
  72661. * @returns a new matrix
  72662. */
  72663. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  72664. /**
  72665. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  72666. * @param scale defines the scale vector3
  72667. * @param rotation defines the rotation quaternion
  72668. * @param translation defines the translation vector3
  72669. * @param result defines the target matrix
  72670. */
  72671. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  72672. /**
  72673. * Creates a new identity matrix
  72674. * @returns a new identity matrix
  72675. */
  72676. static Identity(): Matrix;
  72677. /**
  72678. * Creates a new identity matrix and stores the result in a given matrix
  72679. * @param result defines the target matrix
  72680. */
  72681. static IdentityToRef(result: Matrix): void;
  72682. /**
  72683. * Creates a new zero matrix
  72684. * @returns a new zero matrix
  72685. */
  72686. static Zero(): Matrix;
  72687. /**
  72688. * Creates a new rotation matrix for "angle" radians around the X axis
  72689. * @param angle defines the angle (in radians) to use
  72690. * @return the new matrix
  72691. */
  72692. static RotationX(angle: number): Matrix;
  72693. /**
  72694. * Creates a new matrix as the invert of a given matrix
  72695. * @param source defines the source matrix
  72696. * @returns the new matrix
  72697. */
  72698. static Invert(source: DeepImmutable<Matrix>): Matrix;
  72699. /**
  72700. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  72701. * @param angle defines the angle (in radians) to use
  72702. * @param result defines the target matrix
  72703. */
  72704. static RotationXToRef(angle: number, result: Matrix): void;
  72705. /**
  72706. * Creates a new rotation matrix for "angle" radians around the Y axis
  72707. * @param angle defines the angle (in radians) to use
  72708. * @return the new matrix
  72709. */
  72710. static RotationY(angle: number): Matrix;
  72711. /**
  72712. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  72713. * @param angle defines the angle (in radians) to use
  72714. * @param result defines the target matrix
  72715. */
  72716. static RotationYToRef(angle: number, result: Matrix): void;
  72717. /**
  72718. * Creates a new rotation matrix for "angle" radians around the Z axis
  72719. * @param angle defines the angle (in radians) to use
  72720. * @return the new matrix
  72721. */
  72722. static RotationZ(angle: number): Matrix;
  72723. /**
  72724. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  72725. * @param angle defines the angle (in radians) to use
  72726. * @param result defines the target matrix
  72727. */
  72728. static RotationZToRef(angle: number, result: Matrix): void;
  72729. /**
  72730. * Creates a new rotation matrix for "angle" radians around the given axis
  72731. * @param axis defines the axis to use
  72732. * @param angle defines the angle (in radians) to use
  72733. * @return the new matrix
  72734. */
  72735. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  72736. /**
  72737. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  72738. * @param axis defines the axis to use
  72739. * @param angle defines the angle (in radians) to use
  72740. * @param result defines the target matrix
  72741. */
  72742. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  72743. /**
  72744. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  72745. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  72746. * @param from defines the vector to align
  72747. * @param to defines the vector to align to
  72748. * @param result defines the target matrix
  72749. */
  72750. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  72751. /**
  72752. * Creates a rotation matrix
  72753. * @param yaw defines the yaw angle in radians (Y axis)
  72754. * @param pitch defines the pitch angle in radians (X axis)
  72755. * @param roll defines the roll angle in radians (X axis)
  72756. * @returns the new rotation matrix
  72757. */
  72758. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  72759. /**
  72760. * Creates a rotation matrix and stores it in a given matrix
  72761. * @param yaw defines the yaw angle in radians (Y axis)
  72762. * @param pitch defines the pitch angle in radians (X axis)
  72763. * @param roll defines the roll angle in radians (X axis)
  72764. * @param result defines the target matrix
  72765. */
  72766. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  72767. /**
  72768. * Creates a scaling matrix
  72769. * @param x defines the scale factor on X axis
  72770. * @param y defines the scale factor on Y axis
  72771. * @param z defines the scale factor on Z axis
  72772. * @returns the new matrix
  72773. */
  72774. static Scaling(x: number, y: number, z: number): Matrix;
  72775. /**
  72776. * Creates a scaling matrix and stores it in a given matrix
  72777. * @param x defines the scale factor on X axis
  72778. * @param y defines the scale factor on Y axis
  72779. * @param z defines the scale factor on Z axis
  72780. * @param result defines the target matrix
  72781. */
  72782. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  72783. /**
  72784. * Creates a translation matrix
  72785. * @param x defines the translation on X axis
  72786. * @param y defines the translation on Y axis
  72787. * @param z defines the translationon Z axis
  72788. * @returns the new matrix
  72789. */
  72790. static Translation(x: number, y: number, z: number): Matrix;
  72791. /**
  72792. * Creates a translation matrix and stores it in a given matrix
  72793. * @param x defines the translation on X axis
  72794. * @param y defines the translation on Y axis
  72795. * @param z defines the translationon Z axis
  72796. * @param result defines the target matrix
  72797. */
  72798. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  72799. /**
  72800. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  72801. * @param startValue defines the start value
  72802. * @param endValue defines the end value
  72803. * @param gradient defines the gradient factor
  72804. * @returns the new matrix
  72805. */
  72806. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  72807. /**
  72808. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  72809. * @param startValue defines the start value
  72810. * @param endValue defines the end value
  72811. * @param gradient defines the gradient factor
  72812. * @param result defines the Matrix object where to store data
  72813. */
  72814. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  72815. /**
  72816. * Builds a new matrix whose values are computed by:
  72817. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  72818. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  72819. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  72820. * @param startValue defines the first matrix
  72821. * @param endValue defines the second matrix
  72822. * @param gradient defines the gradient between the two matrices
  72823. * @returns the new matrix
  72824. */
  72825. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  72826. /**
  72827. * Update a matrix to values which are computed by:
  72828. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  72829. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  72830. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  72831. * @param startValue defines the first matrix
  72832. * @param endValue defines the second matrix
  72833. * @param gradient defines the gradient between the two matrices
  72834. * @param result defines the target matrix
  72835. */
  72836. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  72837. /**
  72838. * 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"
  72839. * This function works in left handed mode
  72840. * @param eye defines the final position of the entity
  72841. * @param target defines where the entity should look at
  72842. * @param up defines the up vector for the entity
  72843. * @returns the new matrix
  72844. */
  72845. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  72846. /**
  72847. * 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".
  72848. * This function works in left handed mode
  72849. * @param eye defines the final position of the entity
  72850. * @param target defines where the entity should look at
  72851. * @param up defines the up vector for the entity
  72852. * @param result defines the target matrix
  72853. */
  72854. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  72855. /**
  72856. * 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"
  72857. * This function works in right handed mode
  72858. * @param eye defines the final position of the entity
  72859. * @param target defines where the entity should look at
  72860. * @param up defines the up vector for the entity
  72861. * @returns the new matrix
  72862. */
  72863. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  72864. /**
  72865. * 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".
  72866. * This function works in right handed mode
  72867. * @param eye defines the final position of the entity
  72868. * @param target defines where the entity should look at
  72869. * @param up defines the up vector for the entity
  72870. * @param result defines the target matrix
  72871. */
  72872. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  72873. /**
  72874. * Create a left-handed orthographic projection matrix
  72875. * @param width defines the viewport width
  72876. * @param height defines the viewport height
  72877. * @param znear defines the near clip plane
  72878. * @param zfar defines the far clip plane
  72879. * @returns a new matrix as a left-handed orthographic projection matrix
  72880. */
  72881. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  72882. /**
  72883. * Store a left-handed orthographic projection to a given matrix
  72884. * @param width defines the viewport width
  72885. * @param height defines the viewport height
  72886. * @param znear defines the near clip plane
  72887. * @param zfar defines the far clip plane
  72888. * @param result defines the target matrix
  72889. */
  72890. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  72891. /**
  72892. * Create a left-handed orthographic projection matrix
  72893. * @param left defines the viewport left coordinate
  72894. * @param right defines the viewport right coordinate
  72895. * @param bottom defines the viewport bottom coordinate
  72896. * @param top defines the viewport top coordinate
  72897. * @param znear defines the near clip plane
  72898. * @param zfar defines the far clip plane
  72899. * @returns a new matrix as a left-handed orthographic projection matrix
  72900. */
  72901. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  72902. /**
  72903. * Stores a left-handed orthographic projection into a given matrix
  72904. * @param left defines the viewport left coordinate
  72905. * @param right defines the viewport right coordinate
  72906. * @param bottom defines the viewport bottom coordinate
  72907. * @param top defines the viewport top coordinate
  72908. * @param znear defines the near clip plane
  72909. * @param zfar defines the far clip plane
  72910. * @param result defines the target matrix
  72911. */
  72912. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  72913. /**
  72914. * Creates a right-handed orthographic projection matrix
  72915. * @param left defines the viewport left coordinate
  72916. * @param right defines the viewport right coordinate
  72917. * @param bottom defines the viewport bottom coordinate
  72918. * @param top defines the viewport top coordinate
  72919. * @param znear defines the near clip plane
  72920. * @param zfar defines the far clip plane
  72921. * @returns a new matrix as a right-handed orthographic projection matrix
  72922. */
  72923. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  72924. /**
  72925. * Stores a right-handed orthographic projection into a given matrix
  72926. * @param left defines the viewport left coordinate
  72927. * @param right defines the viewport right coordinate
  72928. * @param bottom defines the viewport bottom coordinate
  72929. * @param top defines the viewport top coordinate
  72930. * @param znear defines the near clip plane
  72931. * @param zfar defines the far clip plane
  72932. * @param result defines the target matrix
  72933. */
  72934. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  72935. /**
  72936. * Creates a left-handed perspective projection matrix
  72937. * @param width defines the viewport width
  72938. * @param height defines the viewport height
  72939. * @param znear defines the near clip plane
  72940. * @param zfar defines the far clip plane
  72941. * @returns a new matrix as a left-handed perspective projection matrix
  72942. */
  72943. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  72944. /**
  72945. * Creates a left-handed perspective projection matrix
  72946. * @param fov defines the horizontal field of view
  72947. * @param aspect defines the aspect ratio
  72948. * @param znear defines the near clip plane
  72949. * @param zfar defines the far clip plane
  72950. * @returns a new matrix as a left-handed perspective projection matrix
  72951. */
  72952. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  72953. /**
  72954. * Stores a left-handed perspective projection into a given matrix
  72955. * @param fov defines the horizontal field of view
  72956. * @param aspect defines the aspect ratio
  72957. * @param znear defines the near clip plane
  72958. * @param zfar defines the far clip plane
  72959. * @param result defines the target matrix
  72960. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  72961. */
  72962. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  72963. /**
  72964. * Stores a left-handed perspective projection into a given matrix with depth reversed
  72965. * @param fov defines the horizontal field of view
  72966. * @param aspect defines the aspect ratio
  72967. * @param znear defines the near clip plane
  72968. * @param zfar not used as infinity is used as far clip
  72969. * @param result defines the target matrix
  72970. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  72971. */
  72972. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  72973. /**
  72974. * Creates a right-handed perspective projection matrix
  72975. * @param fov defines the horizontal field of view
  72976. * @param aspect defines the aspect ratio
  72977. * @param znear defines the near clip plane
  72978. * @param zfar defines the far clip plane
  72979. * @returns a new matrix as a right-handed perspective projection matrix
  72980. */
  72981. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  72982. /**
  72983. * Stores a right-handed perspective projection into a given matrix
  72984. * @param fov defines the horizontal field of view
  72985. * @param aspect defines the aspect ratio
  72986. * @param znear defines the near clip plane
  72987. * @param zfar defines the far clip plane
  72988. * @param result defines the target matrix
  72989. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  72990. */
  72991. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  72992. /**
  72993. * Stores a right-handed perspective projection into a given matrix
  72994. * @param fov defines the horizontal field of view
  72995. * @param aspect defines the aspect ratio
  72996. * @param znear defines the near clip plane
  72997. * @param zfar not used as infinity is used as far clip
  72998. * @param result defines the target matrix
  72999. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  73000. */
  73001. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  73002. /**
  73003. * Stores a perspective projection for WebVR info a given matrix
  73004. * @param fov defines the field of view
  73005. * @param znear defines the near clip plane
  73006. * @param zfar defines the far clip plane
  73007. * @param result defines the target matrix
  73008. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  73009. */
  73010. static PerspectiveFovWebVRToRef(fov: {
  73011. upDegrees: number;
  73012. downDegrees: number;
  73013. leftDegrees: number;
  73014. rightDegrees: number;
  73015. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  73016. /**
  73017. * Computes a complete transformation matrix
  73018. * @param viewport defines the viewport to use
  73019. * @param world defines the world matrix
  73020. * @param view defines the view matrix
  73021. * @param projection defines the projection matrix
  73022. * @param zmin defines the near clip plane
  73023. * @param zmax defines the far clip plane
  73024. * @returns the transformation matrix
  73025. */
  73026. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  73027. /**
  73028. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  73029. * @param matrix defines the matrix to use
  73030. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  73031. */
  73032. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  73033. /**
  73034. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  73035. * @param matrix defines the matrix to use
  73036. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  73037. */
  73038. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  73039. /**
  73040. * Compute the transpose of a given matrix
  73041. * @param matrix defines the matrix to transpose
  73042. * @returns the new matrix
  73043. */
  73044. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  73045. /**
  73046. * Compute the transpose of a matrix and store it in a target matrix
  73047. * @param matrix defines the matrix to transpose
  73048. * @param result defines the target matrix
  73049. */
  73050. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  73051. /**
  73052. * Computes a reflection matrix from a plane
  73053. * @param plane defines the reflection plane
  73054. * @returns a new matrix
  73055. */
  73056. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  73057. /**
  73058. * Computes a reflection matrix from a plane
  73059. * @param plane defines the reflection plane
  73060. * @param result defines the target matrix
  73061. */
  73062. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  73063. /**
  73064. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  73065. * @param xaxis defines the value of the 1st axis
  73066. * @param yaxis defines the value of the 2nd axis
  73067. * @param zaxis defines the value of the 3rd axis
  73068. * @param result defines the target matrix
  73069. */
  73070. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  73071. /**
  73072. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  73073. * @param quat defines the quaternion to use
  73074. * @param result defines the target matrix
  73075. */
  73076. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  73077. }
  73078. /**
  73079. * @hidden
  73080. */
  73081. export class TmpVectors {
  73082. static Vector2: Vector2[];
  73083. static Vector3: Vector3[];
  73084. static Vector4: Vector4[];
  73085. static Quaternion: Quaternion[];
  73086. static Matrix: Matrix[];
  73087. }
  73088. }
  73089. declare module BABYLON {
  73090. /**
  73091. * Defines potential orientation for back face culling
  73092. */
  73093. export enum Orientation {
  73094. /**
  73095. * Clockwise
  73096. */
  73097. CW = 0,
  73098. /** Counter clockwise */
  73099. CCW = 1
  73100. }
  73101. /** Class used to represent a Bezier curve */
  73102. export class BezierCurve {
  73103. /**
  73104. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  73105. * @param t defines the time
  73106. * @param x1 defines the left coordinate on X axis
  73107. * @param y1 defines the left coordinate on Y axis
  73108. * @param x2 defines the right coordinate on X axis
  73109. * @param y2 defines the right coordinate on Y axis
  73110. * @returns the interpolated value
  73111. */
  73112. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  73113. }
  73114. /**
  73115. * Defines angle representation
  73116. */
  73117. export class Angle {
  73118. private _radians;
  73119. /**
  73120. * Creates an Angle object of "radians" radians (float).
  73121. * @param radians the angle in radians
  73122. */
  73123. constructor(radians: number);
  73124. /**
  73125. * Get value in degrees
  73126. * @returns the Angle value in degrees (float)
  73127. */
  73128. degrees(): number;
  73129. /**
  73130. * Get value in radians
  73131. * @returns the Angle value in radians (float)
  73132. */
  73133. radians(): number;
  73134. /**
  73135. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  73136. * @param a defines first vector
  73137. * @param b defines second vector
  73138. * @returns a new Angle
  73139. */
  73140. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  73141. /**
  73142. * Gets a new Angle object from the given float in radians
  73143. * @param radians defines the angle value in radians
  73144. * @returns a new Angle
  73145. */
  73146. static FromRadians(radians: number): Angle;
  73147. /**
  73148. * Gets a new Angle object from the given float in degrees
  73149. * @param degrees defines the angle value in degrees
  73150. * @returns a new Angle
  73151. */
  73152. static FromDegrees(degrees: number): Angle;
  73153. }
  73154. /**
  73155. * This represents an arc in a 2d space.
  73156. */
  73157. export class Arc2 {
  73158. /** Defines the start point of the arc */
  73159. startPoint: Vector2;
  73160. /** Defines the mid point of the arc */
  73161. midPoint: Vector2;
  73162. /** Defines the end point of the arc */
  73163. endPoint: Vector2;
  73164. /**
  73165. * Defines the center point of the arc.
  73166. */
  73167. centerPoint: Vector2;
  73168. /**
  73169. * Defines the radius of the arc.
  73170. */
  73171. radius: number;
  73172. /**
  73173. * Defines the angle of the arc (from mid point to end point).
  73174. */
  73175. angle: Angle;
  73176. /**
  73177. * Defines the start angle of the arc (from start point to middle point).
  73178. */
  73179. startAngle: Angle;
  73180. /**
  73181. * Defines the orientation of the arc (clock wise/counter clock wise).
  73182. */
  73183. orientation: Orientation;
  73184. /**
  73185. * Creates an Arc object from the three given points : start, middle and end.
  73186. * @param startPoint Defines the start point of the arc
  73187. * @param midPoint Defines the midlle point of the arc
  73188. * @param endPoint Defines the end point of the arc
  73189. */
  73190. constructor(
  73191. /** Defines the start point of the arc */
  73192. startPoint: Vector2,
  73193. /** Defines the mid point of the arc */
  73194. midPoint: Vector2,
  73195. /** Defines the end point of the arc */
  73196. endPoint: Vector2);
  73197. }
  73198. /**
  73199. * Represents a 2D path made up of multiple 2D points
  73200. */
  73201. export class Path2 {
  73202. private _points;
  73203. private _length;
  73204. /**
  73205. * If the path start and end point are the same
  73206. */
  73207. closed: boolean;
  73208. /**
  73209. * Creates a Path2 object from the starting 2D coordinates x and y.
  73210. * @param x the starting points x value
  73211. * @param y the starting points y value
  73212. */
  73213. constructor(x: number, y: number);
  73214. /**
  73215. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  73216. * @param x the added points x value
  73217. * @param y the added points y value
  73218. * @returns the updated Path2.
  73219. */
  73220. addLineTo(x: number, y: number): Path2;
  73221. /**
  73222. * 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.
  73223. * @param midX middle point x value
  73224. * @param midY middle point y value
  73225. * @param endX end point x value
  73226. * @param endY end point y value
  73227. * @param numberOfSegments (default: 36)
  73228. * @returns the updated Path2.
  73229. */
  73230. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  73231. /**
  73232. * Closes the Path2.
  73233. * @returns the Path2.
  73234. */
  73235. close(): Path2;
  73236. /**
  73237. * Gets the sum of the distance between each sequential point in the path
  73238. * @returns the Path2 total length (float).
  73239. */
  73240. length(): number;
  73241. /**
  73242. * Gets the points which construct the path
  73243. * @returns the Path2 internal array of points.
  73244. */
  73245. getPoints(): Vector2[];
  73246. /**
  73247. * Retreives the point at the distance aways from the starting point
  73248. * @param normalizedLengthPosition the length along the path to retreive the point from
  73249. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  73250. */
  73251. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  73252. /**
  73253. * Creates a new path starting from an x and y position
  73254. * @param x starting x value
  73255. * @param y starting y value
  73256. * @returns a new Path2 starting at the coordinates (x, y).
  73257. */
  73258. static StartingAt(x: number, y: number): Path2;
  73259. }
  73260. /**
  73261. * Represents a 3D path made up of multiple 3D points
  73262. */
  73263. export class Path3D {
  73264. /**
  73265. * an array of Vector3, the curve axis of the Path3D
  73266. */
  73267. path: Vector3[];
  73268. private _curve;
  73269. private _distances;
  73270. private _tangents;
  73271. private _normals;
  73272. private _binormals;
  73273. private _raw;
  73274. private _alignTangentsWithPath;
  73275. private readonly _pointAtData;
  73276. /**
  73277. * new Path3D(path, normal, raw)
  73278. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  73279. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  73280. * @param path an array of Vector3, the curve axis of the Path3D
  73281. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  73282. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  73283. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  73284. */
  73285. constructor(
  73286. /**
  73287. * an array of Vector3, the curve axis of the Path3D
  73288. */
  73289. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  73290. /**
  73291. * Returns the Path3D array of successive Vector3 designing its curve.
  73292. * @returns the Path3D array of successive Vector3 designing its curve.
  73293. */
  73294. getCurve(): Vector3[];
  73295. /**
  73296. * Returns the Path3D array of successive Vector3 designing its curve.
  73297. * @returns the Path3D array of successive Vector3 designing its curve.
  73298. */
  73299. getPoints(): Vector3[];
  73300. /**
  73301. * @returns the computed length (float) of the path.
  73302. */
  73303. length(): number;
  73304. /**
  73305. * Returns an array populated with tangent vectors on each Path3D curve point.
  73306. * @returns an array populated with tangent vectors on each Path3D curve point.
  73307. */
  73308. getTangents(): Vector3[];
  73309. /**
  73310. * Returns an array populated with normal vectors on each Path3D curve point.
  73311. * @returns an array populated with normal vectors on each Path3D curve point.
  73312. */
  73313. getNormals(): Vector3[];
  73314. /**
  73315. * Returns an array populated with binormal vectors on each Path3D curve point.
  73316. * @returns an array populated with binormal vectors on each Path3D curve point.
  73317. */
  73318. getBinormals(): Vector3[];
  73319. /**
  73320. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  73321. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  73322. */
  73323. getDistances(): number[];
  73324. /**
  73325. * Returns an interpolated point along this path
  73326. * @param position the position of the point along this path, from 0.0 to 1.0
  73327. * @returns a new Vector3 as the point
  73328. */
  73329. getPointAt(position: number): Vector3;
  73330. /**
  73331. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  73332. * @param position the position of the point along this path, from 0.0 to 1.0
  73333. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  73334. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  73335. */
  73336. getTangentAt(position: number, interpolated?: boolean): Vector3;
  73337. /**
  73338. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  73339. * @param position the position of the point along this path, from 0.0 to 1.0
  73340. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  73341. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  73342. */
  73343. getNormalAt(position: number, interpolated?: boolean): Vector3;
  73344. /**
  73345. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  73346. * @param position the position of the point along this path, from 0.0 to 1.0
  73347. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  73348. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  73349. */
  73350. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  73351. /**
  73352. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  73353. * @param position the position of the point along this path, from 0.0 to 1.0
  73354. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  73355. */
  73356. getDistanceAt(position: number): number;
  73357. /**
  73358. * Returns the array index of the previous point of an interpolated point along this path
  73359. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  73360. * @returns the array index
  73361. */
  73362. getPreviousPointIndexAt(position: number): number;
  73363. /**
  73364. * 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)
  73365. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  73366. * @returns the sub position
  73367. */
  73368. getSubPositionAt(position: number): number;
  73369. /**
  73370. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  73371. * @param target the vector of which to get the closest position to
  73372. * @returns the position of the closest virtual point on this path to the target vector
  73373. */
  73374. getClosestPositionTo(target: Vector3): number;
  73375. /**
  73376. * Returns a sub path (slice) of this path
  73377. * @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
  73378. * @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
  73379. * @returns a sub path (slice) of this path
  73380. */
  73381. slice(start?: number, end?: number): Path3D;
  73382. /**
  73383. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  73384. * @param path path which all values are copied into the curves points
  73385. * @param firstNormal which should be projected onto the curve
  73386. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  73387. * @returns the same object updated.
  73388. */
  73389. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  73390. private _compute;
  73391. private _getFirstNonNullVector;
  73392. private _getLastNonNullVector;
  73393. private _normalVector;
  73394. /**
  73395. * Updates the point at data for an interpolated point along this curve
  73396. * @param position the position of the point along this curve, from 0.0 to 1.0
  73397. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  73398. * @returns the (updated) point at data
  73399. */
  73400. private _updatePointAtData;
  73401. /**
  73402. * Updates the point at data from the specified parameters
  73403. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  73404. * @param point the interpolated point
  73405. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  73406. */
  73407. private _setPointAtData;
  73408. /**
  73409. * Updates the point at interpolation matrix for the tangents, normals and binormals
  73410. */
  73411. private _updateInterpolationMatrix;
  73412. }
  73413. /**
  73414. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  73415. * A Curve3 is designed from a series of successive Vector3.
  73416. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  73417. */
  73418. export class Curve3 {
  73419. private _points;
  73420. private _length;
  73421. /**
  73422. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  73423. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  73424. * @param v1 (Vector3) the control point
  73425. * @param v2 (Vector3) the end point of the Quadratic Bezier
  73426. * @param nbPoints (integer) the wanted number of points in the curve
  73427. * @returns the created Curve3
  73428. */
  73429. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  73430. /**
  73431. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  73432. * @param v0 (Vector3) the origin point of the Cubic Bezier
  73433. * @param v1 (Vector3) the first control point
  73434. * @param v2 (Vector3) the second control point
  73435. * @param v3 (Vector3) the end point of the Cubic Bezier
  73436. * @param nbPoints (integer) the wanted number of points in the curve
  73437. * @returns the created Curve3
  73438. */
  73439. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  73440. /**
  73441. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  73442. * @param p1 (Vector3) the origin point of the Hermite Spline
  73443. * @param t1 (Vector3) the tangent vector at the origin point
  73444. * @param p2 (Vector3) the end point of the Hermite Spline
  73445. * @param t2 (Vector3) the tangent vector at the end point
  73446. * @param nbPoints (integer) the wanted number of points in the curve
  73447. * @returns the created Curve3
  73448. */
  73449. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  73450. /**
  73451. * Returns a Curve3 object along a CatmullRom Spline curve :
  73452. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  73453. * @param nbPoints (integer) the wanted number of points between each curve control points
  73454. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  73455. * @returns the created Curve3
  73456. */
  73457. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  73458. /**
  73459. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  73460. * A Curve3 is designed from a series of successive Vector3.
  73461. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  73462. * @param points points which make up the curve
  73463. */
  73464. constructor(points: Vector3[]);
  73465. /**
  73466. * @returns the Curve3 stored array of successive Vector3
  73467. */
  73468. getPoints(): Vector3[];
  73469. /**
  73470. * @returns the computed length (float) of the curve.
  73471. */
  73472. length(): number;
  73473. /**
  73474. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  73475. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  73476. * curveA and curveB keep unchanged.
  73477. * @param curve the curve to continue from this curve
  73478. * @returns the newly constructed curve
  73479. */
  73480. continue(curve: DeepImmutable<Curve3>): Curve3;
  73481. private _computeLength;
  73482. }
  73483. }
  73484. declare module BABYLON {
  73485. /**
  73486. * This represents the main contract an easing function should follow.
  73487. * Easing functions are used throughout the animation system.
  73488. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  73489. */
  73490. export interface IEasingFunction {
  73491. /**
  73492. * Given an input gradient between 0 and 1, this returns the corrseponding value
  73493. * of the easing function.
  73494. * The link below provides some of the most common examples of easing functions.
  73495. * @see https://easings.net/
  73496. * @param gradient Defines the value between 0 and 1 we want the easing value for
  73497. * @returns the corresponding value on the curve defined by the easing function
  73498. */
  73499. ease(gradient: number): number;
  73500. }
  73501. /**
  73502. * Base class used for every default easing function.
  73503. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  73504. */
  73505. export class EasingFunction implements IEasingFunction {
  73506. /**
  73507. * Interpolation follows the mathematical formula associated with the easing function.
  73508. */
  73509. static readonly EASINGMODE_EASEIN: number;
  73510. /**
  73511. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  73512. */
  73513. static readonly EASINGMODE_EASEOUT: number;
  73514. /**
  73515. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  73516. */
  73517. static readonly EASINGMODE_EASEINOUT: number;
  73518. private _easingMode;
  73519. /**
  73520. * Sets the easing mode of the current function.
  73521. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  73522. */
  73523. setEasingMode(easingMode: number): void;
  73524. /**
  73525. * Gets the current easing mode.
  73526. * @returns the easing mode
  73527. */
  73528. getEasingMode(): number;
  73529. /**
  73530. * @hidden
  73531. */
  73532. easeInCore(gradient: number): number;
  73533. /**
  73534. * Given an input gradient between 0 and 1, this returns the corresponding value
  73535. * of the easing function.
  73536. * @param gradient Defines the value between 0 and 1 we want the easing value for
  73537. * @returns the corresponding value on the curve defined by the easing function
  73538. */
  73539. ease(gradient: number): number;
  73540. }
  73541. /**
  73542. * Easing function with a circle shape (see link below).
  73543. * @see https://easings.net/#easeInCirc
  73544. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  73545. */
  73546. export class CircleEase extends EasingFunction implements IEasingFunction {
  73547. /** @hidden */
  73548. easeInCore(gradient: number): number;
  73549. }
  73550. /**
  73551. * Easing function with a ease back shape (see link below).
  73552. * @see https://easings.net/#easeInBack
  73553. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  73554. */
  73555. export class BackEase extends EasingFunction implements IEasingFunction {
  73556. /** Defines the amplitude of the function */
  73557. amplitude: number;
  73558. /**
  73559. * Instantiates a back ease easing
  73560. * @see https://easings.net/#easeInBack
  73561. * @param amplitude Defines the amplitude of the function
  73562. */
  73563. constructor(
  73564. /** Defines the amplitude of the function */
  73565. amplitude?: number);
  73566. /** @hidden */
  73567. easeInCore(gradient: number): number;
  73568. }
  73569. /**
  73570. * Easing function with a bouncing shape (see link below).
  73571. * @see https://easings.net/#easeInBounce
  73572. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  73573. */
  73574. export class BounceEase extends EasingFunction implements IEasingFunction {
  73575. /** Defines the number of bounces */
  73576. bounces: number;
  73577. /** Defines the amplitude of the bounce */
  73578. bounciness: number;
  73579. /**
  73580. * Instantiates a bounce easing
  73581. * @see https://easings.net/#easeInBounce
  73582. * @param bounces Defines the number of bounces
  73583. * @param bounciness Defines the amplitude of the bounce
  73584. */
  73585. constructor(
  73586. /** Defines the number of bounces */
  73587. bounces?: number,
  73588. /** Defines the amplitude of the bounce */
  73589. bounciness?: number);
  73590. /** @hidden */
  73591. easeInCore(gradient: number): number;
  73592. }
  73593. /**
  73594. * Easing function with a power of 3 shape (see link below).
  73595. * @see https://easings.net/#easeInCubic
  73596. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  73597. */
  73598. export class CubicEase extends EasingFunction implements IEasingFunction {
  73599. /** @hidden */
  73600. easeInCore(gradient: number): number;
  73601. }
  73602. /**
  73603. * Easing function with an elastic shape (see link below).
  73604. * @see https://easings.net/#easeInElastic
  73605. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  73606. */
  73607. export class ElasticEase extends EasingFunction implements IEasingFunction {
  73608. /** Defines the number of oscillations*/
  73609. oscillations: number;
  73610. /** Defines the amplitude of the oscillations*/
  73611. springiness: number;
  73612. /**
  73613. * Instantiates an elastic easing function
  73614. * @see https://easings.net/#easeInElastic
  73615. * @param oscillations Defines the number of oscillations
  73616. * @param springiness Defines the amplitude of the oscillations
  73617. */
  73618. constructor(
  73619. /** Defines the number of oscillations*/
  73620. oscillations?: number,
  73621. /** Defines the amplitude of the oscillations*/
  73622. springiness?: number);
  73623. /** @hidden */
  73624. easeInCore(gradient: number): number;
  73625. }
  73626. /**
  73627. * Easing function with an exponential shape (see link below).
  73628. * @see https://easings.net/#easeInExpo
  73629. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  73630. */
  73631. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  73632. /** Defines the exponent of the function */
  73633. exponent: number;
  73634. /**
  73635. * Instantiates an exponential easing function
  73636. * @see https://easings.net/#easeInExpo
  73637. * @param exponent Defines the exponent of the function
  73638. */
  73639. constructor(
  73640. /** Defines the exponent of the function */
  73641. exponent?: number);
  73642. /** @hidden */
  73643. easeInCore(gradient: number): number;
  73644. }
  73645. /**
  73646. * Easing function with a power shape (see link below).
  73647. * @see https://easings.net/#easeInQuad
  73648. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  73649. */
  73650. export class PowerEase extends EasingFunction implements IEasingFunction {
  73651. /** Defines the power of the function */
  73652. power: number;
  73653. /**
  73654. * Instantiates an power base easing function
  73655. * @see https://easings.net/#easeInQuad
  73656. * @param power Defines the power of the function
  73657. */
  73658. constructor(
  73659. /** Defines the power of the function */
  73660. power?: number);
  73661. /** @hidden */
  73662. easeInCore(gradient: number): number;
  73663. }
  73664. /**
  73665. * Easing function with a power of 2 shape (see link below).
  73666. * @see https://easings.net/#easeInQuad
  73667. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  73668. */
  73669. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  73670. /** @hidden */
  73671. easeInCore(gradient: number): number;
  73672. }
  73673. /**
  73674. * Easing function with a power of 4 shape (see link below).
  73675. * @see https://easings.net/#easeInQuart
  73676. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  73677. */
  73678. export class QuarticEase extends EasingFunction implements IEasingFunction {
  73679. /** @hidden */
  73680. easeInCore(gradient: number): number;
  73681. }
  73682. /**
  73683. * Easing function with a power of 5 shape (see link below).
  73684. * @see https://easings.net/#easeInQuint
  73685. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  73686. */
  73687. export class QuinticEase extends EasingFunction implements IEasingFunction {
  73688. /** @hidden */
  73689. easeInCore(gradient: number): number;
  73690. }
  73691. /**
  73692. * Easing function with a sin shape (see link below).
  73693. * @see https://easings.net/#easeInSine
  73694. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  73695. */
  73696. export class SineEase extends EasingFunction implements IEasingFunction {
  73697. /** @hidden */
  73698. easeInCore(gradient: number): number;
  73699. }
  73700. /**
  73701. * Easing function with a bezier shape (see link below).
  73702. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  73703. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  73704. */
  73705. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  73706. /** Defines the x component of the start tangent in the bezier curve */
  73707. x1: number;
  73708. /** Defines the y component of the start tangent in the bezier curve */
  73709. y1: number;
  73710. /** Defines the x component of the end tangent in the bezier curve */
  73711. x2: number;
  73712. /** Defines the y component of the end tangent in the bezier curve */
  73713. y2: number;
  73714. /**
  73715. * Instantiates a bezier function
  73716. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  73717. * @param x1 Defines the x component of the start tangent in the bezier curve
  73718. * @param y1 Defines the y component of the start tangent in the bezier curve
  73719. * @param x2 Defines the x component of the end tangent in the bezier curve
  73720. * @param y2 Defines the y component of the end tangent in the bezier curve
  73721. */
  73722. constructor(
  73723. /** Defines the x component of the start tangent in the bezier curve */
  73724. x1?: number,
  73725. /** Defines the y component of the start tangent in the bezier curve */
  73726. y1?: number,
  73727. /** Defines the x component of the end tangent in the bezier curve */
  73728. x2?: number,
  73729. /** Defines the y component of the end tangent in the bezier curve */
  73730. y2?: number);
  73731. /** @hidden */
  73732. easeInCore(gradient: number): number;
  73733. }
  73734. }
  73735. declare module BABYLON {
  73736. /**
  73737. * Class used to hold a RBG color
  73738. */
  73739. export class Color3 {
  73740. /**
  73741. * Defines the red component (between 0 and 1, default is 0)
  73742. */
  73743. r: number;
  73744. /**
  73745. * Defines the green component (between 0 and 1, default is 0)
  73746. */
  73747. g: number;
  73748. /**
  73749. * Defines the blue component (between 0 and 1, default is 0)
  73750. */
  73751. b: number;
  73752. /**
  73753. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  73754. * @param r defines the red component (between 0 and 1, default is 0)
  73755. * @param g defines the green component (between 0 and 1, default is 0)
  73756. * @param b defines the blue component (between 0 and 1, default is 0)
  73757. */
  73758. constructor(
  73759. /**
  73760. * Defines the red component (between 0 and 1, default is 0)
  73761. */
  73762. r?: number,
  73763. /**
  73764. * Defines the green component (between 0 and 1, default is 0)
  73765. */
  73766. g?: number,
  73767. /**
  73768. * Defines the blue component (between 0 and 1, default is 0)
  73769. */
  73770. b?: number);
  73771. /**
  73772. * Creates a string with the Color3 current values
  73773. * @returns the string representation of the Color3 object
  73774. */
  73775. toString(): string;
  73776. /**
  73777. * Returns the string "Color3"
  73778. * @returns "Color3"
  73779. */
  73780. getClassName(): string;
  73781. /**
  73782. * Compute the Color3 hash code
  73783. * @returns an unique number that can be used to hash Color3 objects
  73784. */
  73785. getHashCode(): number;
  73786. /**
  73787. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  73788. * @param array defines the array where to store the r,g,b components
  73789. * @param index defines an optional index in the target array to define where to start storing values
  73790. * @returns the current Color3 object
  73791. */
  73792. toArray(array: FloatArray, index?: number): Color3;
  73793. /**
  73794. * Returns a new Color4 object from the current Color3 and the given alpha
  73795. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  73796. * @returns a new Color4 object
  73797. */
  73798. toColor4(alpha?: number): Color4;
  73799. /**
  73800. * Returns a new array populated with 3 numeric elements : red, green and blue values
  73801. * @returns the new array
  73802. */
  73803. asArray(): number[];
  73804. /**
  73805. * Returns the luminance value
  73806. * @returns a float value
  73807. */
  73808. toLuminance(): number;
  73809. /**
  73810. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  73811. * @param otherColor defines the second operand
  73812. * @returns the new Color3 object
  73813. */
  73814. multiply(otherColor: DeepImmutable<Color3>): Color3;
  73815. /**
  73816. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  73817. * @param otherColor defines the second operand
  73818. * @param result defines the Color3 object where to store the result
  73819. * @returns the current Color3
  73820. */
  73821. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  73822. /**
  73823. * Determines equality between Color3 objects
  73824. * @param otherColor defines the second operand
  73825. * @returns true if the rgb values are equal to the given ones
  73826. */
  73827. equals(otherColor: DeepImmutable<Color3>): boolean;
  73828. /**
  73829. * Determines equality between the current Color3 object and a set of r,b,g values
  73830. * @param r defines the red component to check
  73831. * @param g defines the green component to check
  73832. * @param b defines the blue component to check
  73833. * @returns true if the rgb values are equal to the given ones
  73834. */
  73835. equalsFloats(r: number, g: number, b: number): boolean;
  73836. /**
  73837. * Multiplies in place each rgb value by scale
  73838. * @param scale defines the scaling factor
  73839. * @returns the updated Color3
  73840. */
  73841. scale(scale: number): Color3;
  73842. /**
  73843. * Multiplies the rgb values by scale and stores the result into "result"
  73844. * @param scale defines the scaling factor
  73845. * @param result defines the Color3 object where to store the result
  73846. * @returns the unmodified current Color3
  73847. */
  73848. scaleToRef(scale: number, result: Color3): Color3;
  73849. /**
  73850. * Scale the current Color3 values by a factor and add the result to a given Color3
  73851. * @param scale defines the scale factor
  73852. * @param result defines color to store the result into
  73853. * @returns the unmodified current Color3
  73854. */
  73855. scaleAndAddToRef(scale: number, result: Color3): Color3;
  73856. /**
  73857. * Clamps the rgb values by the min and max values and stores the result into "result"
  73858. * @param min defines minimum clamping value (default is 0)
  73859. * @param max defines maximum clamping value (default is 1)
  73860. * @param result defines color to store the result into
  73861. * @returns the original Color3
  73862. */
  73863. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  73864. /**
  73865. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  73866. * @param otherColor defines the second operand
  73867. * @returns the new Color3
  73868. */
  73869. add(otherColor: DeepImmutable<Color3>): Color3;
  73870. /**
  73871. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  73872. * @param otherColor defines the second operand
  73873. * @param result defines Color3 object to store the result into
  73874. * @returns the unmodified current Color3
  73875. */
  73876. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  73877. /**
  73878. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  73879. * @param otherColor defines the second operand
  73880. * @returns the new Color3
  73881. */
  73882. subtract(otherColor: DeepImmutable<Color3>): Color3;
  73883. /**
  73884. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  73885. * @param otherColor defines the second operand
  73886. * @param result defines Color3 object to store the result into
  73887. * @returns the unmodified current Color3
  73888. */
  73889. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  73890. /**
  73891. * Copy the current object
  73892. * @returns a new Color3 copied the current one
  73893. */
  73894. clone(): Color3;
  73895. /**
  73896. * Copies the rgb values from the source in the current Color3
  73897. * @param source defines the source Color3 object
  73898. * @returns the updated Color3 object
  73899. */
  73900. copyFrom(source: DeepImmutable<Color3>): Color3;
  73901. /**
  73902. * Updates the Color3 rgb values from the given floats
  73903. * @param r defines the red component to read from
  73904. * @param g defines the green component to read from
  73905. * @param b defines the blue component to read from
  73906. * @returns the current Color3 object
  73907. */
  73908. copyFromFloats(r: number, g: number, b: number): Color3;
  73909. /**
  73910. * Updates the Color3 rgb values from the given floats
  73911. * @param r defines the red component to read from
  73912. * @param g defines the green component to read from
  73913. * @param b defines the blue component to read from
  73914. * @returns the current Color3 object
  73915. */
  73916. set(r: number, g: number, b: number): Color3;
  73917. /**
  73918. * Compute the Color3 hexadecimal code as a string
  73919. * @returns a string containing the hexadecimal representation of the Color3 object
  73920. */
  73921. toHexString(): string;
  73922. /**
  73923. * Computes a new Color3 converted from the current one to linear space
  73924. * @returns a new Color3 object
  73925. */
  73926. toLinearSpace(): Color3;
  73927. /**
  73928. * Converts current color in rgb space to HSV values
  73929. * @returns a new color3 representing the HSV values
  73930. */
  73931. toHSV(): Color3;
  73932. /**
  73933. * Converts current color in rgb space to HSV values
  73934. * @param result defines the Color3 where to store the HSV values
  73935. */
  73936. toHSVToRef(result: Color3): void;
  73937. /**
  73938. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  73939. * @param convertedColor defines the Color3 object where to store the linear space version
  73940. * @returns the unmodified Color3
  73941. */
  73942. toLinearSpaceToRef(convertedColor: Color3): Color3;
  73943. /**
  73944. * Computes a new Color3 converted from the current one to gamma space
  73945. * @returns a new Color3 object
  73946. */
  73947. toGammaSpace(): Color3;
  73948. /**
  73949. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  73950. * @param convertedColor defines the Color3 object where to store the gamma space version
  73951. * @returns the unmodified Color3
  73952. */
  73953. toGammaSpaceToRef(convertedColor: Color3): Color3;
  73954. private static _BlackReadOnly;
  73955. /**
  73956. * Convert Hue, saturation and value to a Color3 (RGB)
  73957. * @param hue defines the hue
  73958. * @param saturation defines the saturation
  73959. * @param value defines the value
  73960. * @param result defines the Color3 where to store the RGB values
  73961. */
  73962. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  73963. /**
  73964. * Creates a new Color3 from the string containing valid hexadecimal values
  73965. * @param hex defines a string containing valid hexadecimal values
  73966. * @returns a new Color3 object
  73967. */
  73968. static FromHexString(hex: string): Color3;
  73969. /**
  73970. * Creates a new Color3 from the starting index of the given array
  73971. * @param array defines the source array
  73972. * @param offset defines an offset in the source array
  73973. * @returns a new Color3 object
  73974. */
  73975. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  73976. /**
  73977. * Creates a new Color3 from integer values (< 256)
  73978. * @param r defines the red component to read from (value between 0 and 255)
  73979. * @param g defines the green component to read from (value between 0 and 255)
  73980. * @param b defines the blue component to read from (value between 0 and 255)
  73981. * @returns a new Color3 object
  73982. */
  73983. static FromInts(r: number, g: number, b: number): Color3;
  73984. /**
  73985. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  73986. * @param start defines the start Color3 value
  73987. * @param end defines the end Color3 value
  73988. * @param amount defines the gradient value between start and end
  73989. * @returns a new Color3 object
  73990. */
  73991. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  73992. /**
  73993. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  73994. * @param left defines the start value
  73995. * @param right defines the end value
  73996. * @param amount defines the gradient factor
  73997. * @param result defines the Color3 object where to store the result
  73998. */
  73999. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  74000. /**
  74001. * Returns a Color3 value containing a red color
  74002. * @returns a new Color3 object
  74003. */
  74004. static Red(): Color3;
  74005. /**
  74006. * Returns a Color3 value containing a green color
  74007. * @returns a new Color3 object
  74008. */
  74009. static Green(): Color3;
  74010. /**
  74011. * Returns a Color3 value containing a blue color
  74012. * @returns a new Color3 object
  74013. */
  74014. static Blue(): Color3;
  74015. /**
  74016. * Returns a Color3 value containing a black color
  74017. * @returns a new Color3 object
  74018. */
  74019. static Black(): Color3;
  74020. /**
  74021. * Gets a Color3 value containing a black color that must not be updated
  74022. */
  74023. static readonly BlackReadOnly: DeepImmutable<Color3>;
  74024. /**
  74025. * Returns a Color3 value containing a white color
  74026. * @returns a new Color3 object
  74027. */
  74028. static White(): Color3;
  74029. /**
  74030. * Returns a Color3 value containing a purple color
  74031. * @returns a new Color3 object
  74032. */
  74033. static Purple(): Color3;
  74034. /**
  74035. * Returns a Color3 value containing a magenta color
  74036. * @returns a new Color3 object
  74037. */
  74038. static Magenta(): Color3;
  74039. /**
  74040. * Returns a Color3 value containing a yellow color
  74041. * @returns a new Color3 object
  74042. */
  74043. static Yellow(): Color3;
  74044. /**
  74045. * Returns a Color3 value containing a gray color
  74046. * @returns a new Color3 object
  74047. */
  74048. static Gray(): Color3;
  74049. /**
  74050. * Returns a Color3 value containing a teal color
  74051. * @returns a new Color3 object
  74052. */
  74053. static Teal(): Color3;
  74054. /**
  74055. * Returns a Color3 value containing a random color
  74056. * @returns a new Color3 object
  74057. */
  74058. static Random(): Color3;
  74059. }
  74060. /**
  74061. * Class used to hold a RBGA color
  74062. */
  74063. export class Color4 {
  74064. /**
  74065. * Defines the red component (between 0 and 1, default is 0)
  74066. */
  74067. r: number;
  74068. /**
  74069. * Defines the green component (between 0 and 1, default is 0)
  74070. */
  74071. g: number;
  74072. /**
  74073. * Defines the blue component (between 0 and 1, default is 0)
  74074. */
  74075. b: number;
  74076. /**
  74077. * Defines the alpha component (between 0 and 1, default is 1)
  74078. */
  74079. a: number;
  74080. /**
  74081. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  74082. * @param r defines the red component (between 0 and 1, default is 0)
  74083. * @param g defines the green component (between 0 and 1, default is 0)
  74084. * @param b defines the blue component (between 0 and 1, default is 0)
  74085. * @param a defines the alpha component (between 0 and 1, default is 1)
  74086. */
  74087. constructor(
  74088. /**
  74089. * Defines the red component (between 0 and 1, default is 0)
  74090. */
  74091. r?: number,
  74092. /**
  74093. * Defines the green component (between 0 and 1, default is 0)
  74094. */
  74095. g?: number,
  74096. /**
  74097. * Defines the blue component (between 0 and 1, default is 0)
  74098. */
  74099. b?: number,
  74100. /**
  74101. * Defines the alpha component (between 0 and 1, default is 1)
  74102. */
  74103. a?: number);
  74104. /**
  74105. * Adds in place the given Color4 values to the current Color4 object
  74106. * @param right defines the second operand
  74107. * @returns the current updated Color4 object
  74108. */
  74109. addInPlace(right: DeepImmutable<Color4>): Color4;
  74110. /**
  74111. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  74112. * @returns the new array
  74113. */
  74114. asArray(): number[];
  74115. /**
  74116. * Stores from the starting index in the given array the Color4 successive values
  74117. * @param array defines the array where to store the r,g,b components
  74118. * @param index defines an optional index in the target array to define where to start storing values
  74119. * @returns the current Color4 object
  74120. */
  74121. toArray(array: number[], index?: number): Color4;
  74122. /**
  74123. * Determines equality between Color4 objects
  74124. * @param otherColor defines the second operand
  74125. * @returns true if the rgba values are equal to the given ones
  74126. */
  74127. equals(otherColor: DeepImmutable<Color4>): boolean;
  74128. /**
  74129. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  74130. * @param right defines the second operand
  74131. * @returns a new Color4 object
  74132. */
  74133. add(right: DeepImmutable<Color4>): Color4;
  74134. /**
  74135. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  74136. * @param right defines the second operand
  74137. * @returns a new Color4 object
  74138. */
  74139. subtract(right: DeepImmutable<Color4>): Color4;
  74140. /**
  74141. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  74142. * @param right defines the second operand
  74143. * @param result defines the Color4 object where to store the result
  74144. * @returns the current Color4 object
  74145. */
  74146. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  74147. /**
  74148. * Creates a new Color4 with the current Color4 values multiplied by scale
  74149. * @param scale defines the scaling factor to apply
  74150. * @returns a new Color4 object
  74151. */
  74152. scale(scale: number): Color4;
  74153. /**
  74154. * Multiplies the current Color4 values by scale and stores the result in "result"
  74155. * @param scale defines the scaling factor to apply
  74156. * @param result defines the Color4 object where to store the result
  74157. * @returns the current unmodified Color4
  74158. */
  74159. scaleToRef(scale: number, result: Color4): Color4;
  74160. /**
  74161. * Scale the current Color4 values by a factor and add the result to a given Color4
  74162. * @param scale defines the scale factor
  74163. * @param result defines the Color4 object where to store the result
  74164. * @returns the unmodified current Color4
  74165. */
  74166. scaleAndAddToRef(scale: number, result: Color4): Color4;
  74167. /**
  74168. * Clamps the rgb values by the min and max values and stores the result into "result"
  74169. * @param min defines minimum clamping value (default is 0)
  74170. * @param max defines maximum clamping value (default is 1)
  74171. * @param result defines color to store the result into.
  74172. * @returns the cuurent Color4
  74173. */
  74174. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  74175. /**
  74176. * Multipy an Color4 value by another and return a new Color4 object
  74177. * @param color defines the Color4 value to multiply by
  74178. * @returns a new Color4 object
  74179. */
  74180. multiply(color: Color4): Color4;
  74181. /**
  74182. * Multipy a Color4 value by another and push the result in a reference value
  74183. * @param color defines the Color4 value to multiply by
  74184. * @param result defines the Color4 to fill the result in
  74185. * @returns the result Color4
  74186. */
  74187. multiplyToRef(color: Color4, result: Color4): Color4;
  74188. /**
  74189. * Creates a string with the Color4 current values
  74190. * @returns the string representation of the Color4 object
  74191. */
  74192. toString(): string;
  74193. /**
  74194. * Returns the string "Color4"
  74195. * @returns "Color4"
  74196. */
  74197. getClassName(): string;
  74198. /**
  74199. * Compute the Color4 hash code
  74200. * @returns an unique number that can be used to hash Color4 objects
  74201. */
  74202. getHashCode(): number;
  74203. /**
  74204. * Creates a new Color4 copied from the current one
  74205. * @returns a new Color4 object
  74206. */
  74207. clone(): Color4;
  74208. /**
  74209. * Copies the given Color4 values into the current one
  74210. * @param source defines the source Color4 object
  74211. * @returns the current updated Color4 object
  74212. */
  74213. copyFrom(source: Color4): Color4;
  74214. /**
  74215. * Copies the given float values into the current one
  74216. * @param r defines the red component to read from
  74217. * @param g defines the green component to read from
  74218. * @param b defines the blue component to read from
  74219. * @param a defines the alpha component to read from
  74220. * @returns the current updated Color4 object
  74221. */
  74222. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  74223. /**
  74224. * Copies the given float values into the current one
  74225. * @param r defines the red component to read from
  74226. * @param g defines the green component to read from
  74227. * @param b defines the blue component to read from
  74228. * @param a defines the alpha component to read from
  74229. * @returns the current updated Color4 object
  74230. */
  74231. set(r: number, g: number, b: number, a: number): Color4;
  74232. /**
  74233. * Compute the Color4 hexadecimal code as a string
  74234. * @returns a string containing the hexadecimal representation of the Color4 object
  74235. */
  74236. toHexString(): string;
  74237. /**
  74238. * Computes a new Color4 converted from the current one to linear space
  74239. * @returns a new Color4 object
  74240. */
  74241. toLinearSpace(): Color4;
  74242. /**
  74243. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  74244. * @param convertedColor defines the Color4 object where to store the linear space version
  74245. * @returns the unmodified Color4
  74246. */
  74247. toLinearSpaceToRef(convertedColor: Color4): Color4;
  74248. /**
  74249. * Computes a new Color4 converted from the current one to gamma space
  74250. * @returns a new Color4 object
  74251. */
  74252. toGammaSpace(): Color4;
  74253. /**
  74254. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  74255. * @param convertedColor defines the Color4 object where to store the gamma space version
  74256. * @returns the unmodified Color4
  74257. */
  74258. toGammaSpaceToRef(convertedColor: Color4): Color4;
  74259. /**
  74260. * Creates a new Color4 from the string containing valid hexadecimal values
  74261. * @param hex defines a string containing valid hexadecimal values
  74262. * @returns a new Color4 object
  74263. */
  74264. static FromHexString(hex: string): Color4;
  74265. /**
  74266. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  74267. * @param left defines the start value
  74268. * @param right defines the end value
  74269. * @param amount defines the gradient factor
  74270. * @returns a new Color4 object
  74271. */
  74272. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  74273. /**
  74274. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  74275. * @param left defines the start value
  74276. * @param right defines the end value
  74277. * @param amount defines the gradient factor
  74278. * @param result defines the Color4 object where to store data
  74279. */
  74280. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  74281. /**
  74282. * Creates a new Color4 from a Color3 and an alpha value
  74283. * @param color3 defines the source Color3 to read from
  74284. * @param alpha defines the alpha component (1.0 by default)
  74285. * @returns a new Color4 object
  74286. */
  74287. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  74288. /**
  74289. * Creates a new Color4 from the starting index element of the given array
  74290. * @param array defines the source array to read from
  74291. * @param offset defines the offset in the source array
  74292. * @returns a new Color4 object
  74293. */
  74294. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  74295. /**
  74296. * Creates a new Color3 from integer values (< 256)
  74297. * @param r defines the red component to read from (value between 0 and 255)
  74298. * @param g defines the green component to read from (value between 0 and 255)
  74299. * @param b defines the blue component to read from (value between 0 and 255)
  74300. * @param a defines the alpha component to read from (value between 0 and 255)
  74301. * @returns a new Color3 object
  74302. */
  74303. static FromInts(r: number, g: number, b: number, a: number): Color4;
  74304. /**
  74305. * Check the content of a given array and convert it to an array containing RGBA data
  74306. * If the original array was already containing count * 4 values then it is returned directly
  74307. * @param colors defines the array to check
  74308. * @param count defines the number of RGBA data to expect
  74309. * @returns an array containing count * 4 values (RGBA)
  74310. */
  74311. static CheckColors4(colors: number[], count: number): number[];
  74312. }
  74313. /**
  74314. * @hidden
  74315. */
  74316. export class TmpColors {
  74317. static Color3: Color3[];
  74318. static Color4: Color4[];
  74319. }
  74320. }
  74321. declare module BABYLON {
  74322. /**
  74323. * Defines an interface which represents an animation key frame
  74324. */
  74325. export interface IAnimationKey {
  74326. /**
  74327. * Frame of the key frame
  74328. */
  74329. frame: number;
  74330. /**
  74331. * Value at the specifies key frame
  74332. */
  74333. value: any;
  74334. /**
  74335. * The input tangent for the cubic hermite spline
  74336. */
  74337. inTangent?: any;
  74338. /**
  74339. * The output tangent for the cubic hermite spline
  74340. */
  74341. outTangent?: any;
  74342. /**
  74343. * The animation interpolation type
  74344. */
  74345. interpolation?: AnimationKeyInterpolation;
  74346. }
  74347. /**
  74348. * Enum for the animation key frame interpolation type
  74349. */
  74350. export enum AnimationKeyInterpolation {
  74351. /**
  74352. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  74353. */
  74354. STEP = 1
  74355. }
  74356. }
  74357. declare module BABYLON {
  74358. /**
  74359. * Represents the range of an animation
  74360. */
  74361. export class AnimationRange {
  74362. /**The name of the animation range**/
  74363. name: string;
  74364. /**The starting frame of the animation */
  74365. from: number;
  74366. /**The ending frame of the animation*/
  74367. to: number;
  74368. /**
  74369. * Initializes the range of an animation
  74370. * @param name The name of the animation range
  74371. * @param from The starting frame of the animation
  74372. * @param to The ending frame of the animation
  74373. */
  74374. constructor(
  74375. /**The name of the animation range**/
  74376. name: string,
  74377. /**The starting frame of the animation */
  74378. from: number,
  74379. /**The ending frame of the animation*/
  74380. to: number);
  74381. /**
  74382. * Makes a copy of the animation range
  74383. * @returns A copy of the animation range
  74384. */
  74385. clone(): AnimationRange;
  74386. }
  74387. }
  74388. declare module BABYLON {
  74389. /**
  74390. * Composed of a frame, and an action function
  74391. */
  74392. export class AnimationEvent {
  74393. /** The frame for which the event is triggered **/
  74394. frame: number;
  74395. /** The event to perform when triggered **/
  74396. action: (currentFrame: number) => void;
  74397. /** Specifies if the event should be triggered only once**/
  74398. onlyOnce?: boolean | undefined;
  74399. /**
  74400. * Specifies if the animation event is done
  74401. */
  74402. isDone: boolean;
  74403. /**
  74404. * Initializes the animation event
  74405. * @param frame The frame for which the event is triggered
  74406. * @param action The event to perform when triggered
  74407. * @param onlyOnce Specifies if the event should be triggered only once
  74408. */
  74409. constructor(
  74410. /** The frame for which the event is triggered **/
  74411. frame: number,
  74412. /** The event to perform when triggered **/
  74413. action: (currentFrame: number) => void,
  74414. /** Specifies if the event should be triggered only once**/
  74415. onlyOnce?: boolean | undefined);
  74416. /** @hidden */
  74417. _clone(): AnimationEvent;
  74418. }
  74419. }
  74420. declare module BABYLON {
  74421. /**
  74422. * Interface used to define a behavior
  74423. */
  74424. export interface Behavior<T> {
  74425. /** gets or sets behavior's name */
  74426. name: string;
  74427. /**
  74428. * Function called when the behavior needs to be initialized (after attaching it to a target)
  74429. */
  74430. init(): void;
  74431. /**
  74432. * Called when the behavior is attached to a target
  74433. * @param target defines the target where the behavior is attached to
  74434. */
  74435. attach(target: T): void;
  74436. /**
  74437. * Called when the behavior is detached from its target
  74438. */
  74439. detach(): void;
  74440. }
  74441. /**
  74442. * Interface implemented by classes supporting behaviors
  74443. */
  74444. export interface IBehaviorAware<T> {
  74445. /**
  74446. * Attach a behavior
  74447. * @param behavior defines the behavior to attach
  74448. * @returns the current host
  74449. */
  74450. addBehavior(behavior: Behavior<T>): T;
  74451. /**
  74452. * Remove a behavior from the current object
  74453. * @param behavior defines the behavior to detach
  74454. * @returns the current host
  74455. */
  74456. removeBehavior(behavior: Behavior<T>): T;
  74457. /**
  74458. * Gets a behavior using its name to search
  74459. * @param name defines the name to search
  74460. * @returns the behavior or null if not found
  74461. */
  74462. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  74463. }
  74464. }
  74465. declare module BABYLON {
  74466. /**
  74467. * Defines an array and its length.
  74468. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  74469. */
  74470. export interface ISmartArrayLike<T> {
  74471. /**
  74472. * The data of the array.
  74473. */
  74474. data: Array<T>;
  74475. /**
  74476. * The active length of the array.
  74477. */
  74478. length: number;
  74479. }
  74480. /**
  74481. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  74482. */
  74483. export class SmartArray<T> implements ISmartArrayLike<T> {
  74484. /**
  74485. * The full set of data from the array.
  74486. */
  74487. data: Array<T>;
  74488. /**
  74489. * The active length of the array.
  74490. */
  74491. length: number;
  74492. protected _id: number;
  74493. /**
  74494. * Instantiates a Smart Array.
  74495. * @param capacity defines the default capacity of the array.
  74496. */
  74497. constructor(capacity: number);
  74498. /**
  74499. * Pushes a value at the end of the active data.
  74500. * @param value defines the object to push in the array.
  74501. */
  74502. push(value: T): void;
  74503. /**
  74504. * Iterates over the active data and apply the lambda to them.
  74505. * @param func defines the action to apply on each value.
  74506. */
  74507. forEach(func: (content: T) => void): void;
  74508. /**
  74509. * Sorts the full sets of data.
  74510. * @param compareFn defines the comparison function to apply.
  74511. */
  74512. sort(compareFn: (a: T, b: T) => number): void;
  74513. /**
  74514. * Resets the active data to an empty array.
  74515. */
  74516. reset(): void;
  74517. /**
  74518. * Releases all the data from the array as well as the array.
  74519. */
  74520. dispose(): void;
  74521. /**
  74522. * Concats the active data with a given array.
  74523. * @param array defines the data to concatenate with.
  74524. */
  74525. concat(array: any): void;
  74526. /**
  74527. * Returns the position of a value in the active data.
  74528. * @param value defines the value to find the index for
  74529. * @returns the index if found in the active data otherwise -1
  74530. */
  74531. indexOf(value: T): number;
  74532. /**
  74533. * Returns whether an element is part of the active data.
  74534. * @param value defines the value to look for
  74535. * @returns true if found in the active data otherwise false
  74536. */
  74537. contains(value: T): boolean;
  74538. private static _GlobalId;
  74539. }
  74540. /**
  74541. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  74542. * The data in this array can only be present once
  74543. */
  74544. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  74545. private _duplicateId;
  74546. /**
  74547. * Pushes a value at the end of the active data.
  74548. * THIS DOES NOT PREVENT DUPPLICATE DATA
  74549. * @param value defines the object to push in the array.
  74550. */
  74551. push(value: T): void;
  74552. /**
  74553. * Pushes a value at the end of the active data.
  74554. * If the data is already present, it won t be added again
  74555. * @param value defines the object to push in the array.
  74556. * @returns true if added false if it was already present
  74557. */
  74558. pushNoDuplicate(value: T): boolean;
  74559. /**
  74560. * Resets the active data to an empty array.
  74561. */
  74562. reset(): void;
  74563. /**
  74564. * Concats the active data with a given array.
  74565. * This ensures no dupplicate will be present in the result.
  74566. * @param array defines the data to concatenate with.
  74567. */
  74568. concatWithNoDuplicate(array: any): void;
  74569. }
  74570. }
  74571. declare module BABYLON {
  74572. /**
  74573. * @ignore
  74574. * This is a list of all the different input types that are available in the application.
  74575. * Fo instance: ArcRotateCameraGamepadInput...
  74576. */
  74577. export var CameraInputTypes: {};
  74578. /**
  74579. * This is the contract to implement in order to create a new input class.
  74580. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  74581. */
  74582. export interface ICameraInput<TCamera extends Camera> {
  74583. /**
  74584. * Defines the camera the input is attached to.
  74585. */
  74586. camera: Nullable<TCamera>;
  74587. /**
  74588. * Gets the class name of the current intput.
  74589. * @returns the class name
  74590. */
  74591. getClassName(): string;
  74592. /**
  74593. * Get the friendly name associated with the input class.
  74594. * @returns the input friendly name
  74595. */
  74596. getSimpleName(): string;
  74597. /**
  74598. * Attach the input controls to a specific dom element to get the input from.
  74599. * @param element Defines the element the controls should be listened from
  74600. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  74601. */
  74602. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  74603. /**
  74604. * Detach the current controls from the specified dom element.
  74605. * @param element Defines the element to stop listening the inputs from
  74606. */
  74607. detachControl(element: Nullable<HTMLElement>): void;
  74608. /**
  74609. * Update the current camera state depending on the inputs that have been used this frame.
  74610. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  74611. */
  74612. checkInputs?: () => void;
  74613. }
  74614. /**
  74615. * Represents a map of input types to input instance or input index to input instance.
  74616. */
  74617. export interface CameraInputsMap<TCamera extends Camera> {
  74618. /**
  74619. * Accessor to the input by input type.
  74620. */
  74621. [name: string]: ICameraInput<TCamera>;
  74622. /**
  74623. * Accessor to the input by input index.
  74624. */
  74625. [idx: number]: ICameraInput<TCamera>;
  74626. }
  74627. /**
  74628. * This represents the input manager used within a camera.
  74629. * It helps dealing with all the different kind of input attached to a camera.
  74630. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  74631. */
  74632. export class CameraInputsManager<TCamera extends Camera> {
  74633. /**
  74634. * Defines the list of inputs attahed to the camera.
  74635. */
  74636. attached: CameraInputsMap<TCamera>;
  74637. /**
  74638. * Defines the dom element the camera is collecting inputs from.
  74639. * This is null if the controls have not been attached.
  74640. */
  74641. attachedElement: Nullable<HTMLElement>;
  74642. /**
  74643. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  74644. */
  74645. noPreventDefault: boolean;
  74646. /**
  74647. * Defined the camera the input manager belongs to.
  74648. */
  74649. camera: TCamera;
  74650. /**
  74651. * Update the current camera state depending on the inputs that have been used this frame.
  74652. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  74653. */
  74654. checkInputs: () => void;
  74655. /**
  74656. * Instantiate a new Camera Input Manager.
  74657. * @param camera Defines the camera the input manager blongs to
  74658. */
  74659. constructor(camera: TCamera);
  74660. /**
  74661. * Add an input method to a camera
  74662. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  74663. * @param input camera input method
  74664. */
  74665. add(input: ICameraInput<TCamera>): void;
  74666. /**
  74667. * Remove a specific input method from a camera
  74668. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  74669. * @param inputToRemove camera input method
  74670. */
  74671. remove(inputToRemove: ICameraInput<TCamera>): void;
  74672. /**
  74673. * Remove a specific input type from a camera
  74674. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  74675. * @param inputType the type of the input to remove
  74676. */
  74677. removeByType(inputType: string): void;
  74678. private _addCheckInputs;
  74679. /**
  74680. * Attach the input controls to the currently attached dom element to listen the events from.
  74681. * @param input Defines the input to attach
  74682. */
  74683. attachInput(input: ICameraInput<TCamera>): void;
  74684. /**
  74685. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  74686. * @param element Defines the dom element to collect the events from
  74687. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  74688. */
  74689. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  74690. /**
  74691. * Detach the current manager inputs controls from a specific dom element.
  74692. * @param element Defines the dom element to collect the events from
  74693. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  74694. */
  74695. detachElement(element: HTMLElement, disconnect?: boolean): void;
  74696. /**
  74697. * Rebuild the dynamic inputCheck function from the current list of
  74698. * defined inputs in the manager.
  74699. */
  74700. rebuildInputCheck(): void;
  74701. /**
  74702. * Remove all attached input methods from a camera
  74703. */
  74704. clear(): void;
  74705. /**
  74706. * Serialize the current input manager attached to a camera.
  74707. * This ensures than once parsed,
  74708. * the input associated to the camera will be identical to the current ones
  74709. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  74710. */
  74711. serialize(serializedCamera: any): void;
  74712. /**
  74713. * Parses an input manager serialized JSON to restore the previous list of inputs
  74714. * and states associated to a camera.
  74715. * @param parsedCamera Defines the JSON to parse
  74716. */
  74717. parse(parsedCamera: any): void;
  74718. }
  74719. }
  74720. declare module BABYLON {
  74721. /**
  74722. * Class used to store data that will be store in GPU memory
  74723. */
  74724. export class Buffer {
  74725. private _engine;
  74726. private _buffer;
  74727. /** @hidden */
  74728. _data: Nullable<DataArray>;
  74729. private _updatable;
  74730. private _instanced;
  74731. private _divisor;
  74732. /**
  74733. * Gets the byte stride.
  74734. */
  74735. readonly byteStride: number;
  74736. /**
  74737. * Constructor
  74738. * @param engine the engine
  74739. * @param data the data to use for this buffer
  74740. * @param updatable whether the data is updatable
  74741. * @param stride the stride (optional)
  74742. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  74743. * @param instanced whether the buffer is instanced (optional)
  74744. * @param useBytes set to true if the stride in in bytes (optional)
  74745. * @param divisor sets an optional divisor for instances (1 by default)
  74746. */
  74747. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  74748. /**
  74749. * Create a new VertexBuffer based on the current buffer
  74750. * @param kind defines the vertex buffer kind (position, normal, etc.)
  74751. * @param offset defines offset in the buffer (0 by default)
  74752. * @param size defines the size in floats of attributes (position is 3 for instance)
  74753. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  74754. * @param instanced defines if the vertex buffer contains indexed data
  74755. * @param useBytes defines if the offset and stride are in bytes *
  74756. * @param divisor sets an optional divisor for instances (1 by default)
  74757. * @returns the new vertex buffer
  74758. */
  74759. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  74760. /**
  74761. * Gets a boolean indicating if the Buffer is updatable?
  74762. * @returns true if the buffer is updatable
  74763. */
  74764. isUpdatable(): boolean;
  74765. /**
  74766. * Gets current buffer's data
  74767. * @returns a DataArray or null
  74768. */
  74769. getData(): Nullable<DataArray>;
  74770. /**
  74771. * Gets underlying native buffer
  74772. * @returns underlying native buffer
  74773. */
  74774. getBuffer(): Nullable<DataBuffer>;
  74775. /**
  74776. * Gets the stride in float32 units (i.e. byte stride / 4).
  74777. * May not be an integer if the byte stride is not divisible by 4.
  74778. * DEPRECATED. Use byteStride instead.
  74779. * @returns the stride in float32 units
  74780. */
  74781. getStrideSize(): number;
  74782. /**
  74783. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  74784. * @param data defines the data to store
  74785. */
  74786. create(data?: Nullable<DataArray>): void;
  74787. /** @hidden */
  74788. _rebuild(): void;
  74789. /**
  74790. * Update current buffer data
  74791. * @param data defines the data to store
  74792. */
  74793. update(data: DataArray): void;
  74794. /**
  74795. * Updates the data directly.
  74796. * @param data the new data
  74797. * @param offset the new offset
  74798. * @param vertexCount the vertex count (optional)
  74799. * @param useBytes set to true if the offset is in bytes
  74800. */
  74801. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  74802. /**
  74803. * Release all resources
  74804. */
  74805. dispose(): void;
  74806. }
  74807. /**
  74808. * Specialized buffer used to store vertex data
  74809. */
  74810. export class VertexBuffer {
  74811. /** @hidden */
  74812. _buffer: Buffer;
  74813. private _kind;
  74814. private _size;
  74815. private _ownsBuffer;
  74816. private _instanced;
  74817. private _instanceDivisor;
  74818. /**
  74819. * The byte type.
  74820. */
  74821. static readonly BYTE: number;
  74822. /**
  74823. * The unsigned byte type.
  74824. */
  74825. static readonly UNSIGNED_BYTE: number;
  74826. /**
  74827. * The short type.
  74828. */
  74829. static readonly SHORT: number;
  74830. /**
  74831. * The unsigned short type.
  74832. */
  74833. static readonly UNSIGNED_SHORT: number;
  74834. /**
  74835. * The integer type.
  74836. */
  74837. static readonly INT: number;
  74838. /**
  74839. * The unsigned integer type.
  74840. */
  74841. static readonly UNSIGNED_INT: number;
  74842. /**
  74843. * The float type.
  74844. */
  74845. static readonly FLOAT: number;
  74846. /**
  74847. * Gets or sets the instance divisor when in instanced mode
  74848. */
  74849. instanceDivisor: number;
  74850. /**
  74851. * Gets the byte stride.
  74852. */
  74853. readonly byteStride: number;
  74854. /**
  74855. * Gets the byte offset.
  74856. */
  74857. readonly byteOffset: number;
  74858. /**
  74859. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  74860. */
  74861. readonly normalized: boolean;
  74862. /**
  74863. * Gets the data type of each component in the array.
  74864. */
  74865. readonly type: number;
  74866. /**
  74867. * Constructor
  74868. * @param engine the engine
  74869. * @param data the data to use for this vertex buffer
  74870. * @param kind the vertex buffer kind
  74871. * @param updatable whether the data is updatable
  74872. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  74873. * @param stride the stride (optional)
  74874. * @param instanced whether the buffer is instanced (optional)
  74875. * @param offset the offset of the data (optional)
  74876. * @param size the number of components (optional)
  74877. * @param type the type of the component (optional)
  74878. * @param normalized whether the data contains normalized data (optional)
  74879. * @param useBytes set to true if stride and offset are in bytes (optional)
  74880. * @param divisor defines the instance divisor to use (1 by default)
  74881. */
  74882. 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);
  74883. /** @hidden */
  74884. _rebuild(): void;
  74885. /**
  74886. * Returns the kind of the VertexBuffer (string)
  74887. * @returns a string
  74888. */
  74889. getKind(): string;
  74890. /**
  74891. * Gets a boolean indicating if the VertexBuffer is updatable?
  74892. * @returns true if the buffer is updatable
  74893. */
  74894. isUpdatable(): boolean;
  74895. /**
  74896. * Gets current buffer's data
  74897. * @returns a DataArray or null
  74898. */
  74899. getData(): Nullable<DataArray>;
  74900. /**
  74901. * Gets underlying native buffer
  74902. * @returns underlying native buffer
  74903. */
  74904. getBuffer(): Nullable<DataBuffer>;
  74905. /**
  74906. * Gets the stride in float32 units (i.e. byte stride / 4).
  74907. * May not be an integer if the byte stride is not divisible by 4.
  74908. * DEPRECATED. Use byteStride instead.
  74909. * @returns the stride in float32 units
  74910. */
  74911. getStrideSize(): number;
  74912. /**
  74913. * Returns the offset as a multiple of the type byte length.
  74914. * DEPRECATED. Use byteOffset instead.
  74915. * @returns the offset in bytes
  74916. */
  74917. getOffset(): number;
  74918. /**
  74919. * Returns the number of components per vertex attribute (integer)
  74920. * @returns the size in float
  74921. */
  74922. getSize(): number;
  74923. /**
  74924. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  74925. * @returns true if this buffer is instanced
  74926. */
  74927. getIsInstanced(): boolean;
  74928. /**
  74929. * Returns the instancing divisor, zero for non-instanced (integer).
  74930. * @returns a number
  74931. */
  74932. getInstanceDivisor(): number;
  74933. /**
  74934. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  74935. * @param data defines the data to store
  74936. */
  74937. create(data?: DataArray): void;
  74938. /**
  74939. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  74940. * This function will create a new buffer if the current one is not updatable
  74941. * @param data defines the data to store
  74942. */
  74943. update(data: DataArray): void;
  74944. /**
  74945. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  74946. * Returns the directly updated WebGLBuffer.
  74947. * @param data the new data
  74948. * @param offset the new offset
  74949. * @param useBytes set to true if the offset is in bytes
  74950. */
  74951. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  74952. /**
  74953. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  74954. */
  74955. dispose(): void;
  74956. /**
  74957. * Enumerates each value of this vertex buffer as numbers.
  74958. * @param count the number of values to enumerate
  74959. * @param callback the callback function called for each value
  74960. */
  74961. forEach(count: number, callback: (value: number, index: number) => void): void;
  74962. /**
  74963. * Positions
  74964. */
  74965. static readonly PositionKind: string;
  74966. /**
  74967. * Normals
  74968. */
  74969. static readonly NormalKind: string;
  74970. /**
  74971. * Tangents
  74972. */
  74973. static readonly TangentKind: string;
  74974. /**
  74975. * Texture coordinates
  74976. */
  74977. static readonly UVKind: string;
  74978. /**
  74979. * Texture coordinates 2
  74980. */
  74981. static readonly UV2Kind: string;
  74982. /**
  74983. * Texture coordinates 3
  74984. */
  74985. static readonly UV3Kind: string;
  74986. /**
  74987. * Texture coordinates 4
  74988. */
  74989. static readonly UV4Kind: string;
  74990. /**
  74991. * Texture coordinates 5
  74992. */
  74993. static readonly UV5Kind: string;
  74994. /**
  74995. * Texture coordinates 6
  74996. */
  74997. static readonly UV6Kind: string;
  74998. /**
  74999. * Colors
  75000. */
  75001. static readonly ColorKind: string;
  75002. /**
  75003. * Matrix indices (for bones)
  75004. */
  75005. static readonly MatricesIndicesKind: string;
  75006. /**
  75007. * Matrix weights (for bones)
  75008. */
  75009. static readonly MatricesWeightsKind: string;
  75010. /**
  75011. * Additional matrix indices (for bones)
  75012. */
  75013. static readonly MatricesIndicesExtraKind: string;
  75014. /**
  75015. * Additional matrix weights (for bones)
  75016. */
  75017. static readonly MatricesWeightsExtraKind: string;
  75018. /**
  75019. * Deduces the stride given a kind.
  75020. * @param kind The kind string to deduce
  75021. * @returns The deduced stride
  75022. */
  75023. static DeduceStride(kind: string): number;
  75024. /**
  75025. * Gets the byte length of the given type.
  75026. * @param type the type
  75027. * @returns the number of bytes
  75028. */
  75029. static GetTypeByteLength(type: number): number;
  75030. /**
  75031. * Enumerates each value of the given parameters as numbers.
  75032. * @param data the data to enumerate
  75033. * @param byteOffset the byte offset of the data
  75034. * @param byteStride the byte stride of the data
  75035. * @param componentCount the number of components per element
  75036. * @param componentType the type of the component
  75037. * @param count the number of values to enumerate
  75038. * @param normalized whether the data is normalized
  75039. * @param callback the callback function called for each value
  75040. */
  75041. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  75042. private static _GetFloatValue;
  75043. }
  75044. }
  75045. declare module BABYLON {
  75046. /**
  75047. * @hidden
  75048. */
  75049. export class IntersectionInfo {
  75050. bu: Nullable<number>;
  75051. bv: Nullable<number>;
  75052. distance: number;
  75053. faceId: number;
  75054. subMeshId: number;
  75055. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  75056. }
  75057. }
  75058. declare module BABYLON {
  75059. /**
  75060. * Represens a plane by the equation ax + by + cz + d = 0
  75061. */
  75062. export class Plane {
  75063. private static _TmpMatrix;
  75064. /**
  75065. * Normal of the plane (a,b,c)
  75066. */
  75067. normal: Vector3;
  75068. /**
  75069. * d component of the plane
  75070. */
  75071. d: number;
  75072. /**
  75073. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  75074. * @param a a component of the plane
  75075. * @param b b component of the plane
  75076. * @param c c component of the plane
  75077. * @param d d component of the plane
  75078. */
  75079. constructor(a: number, b: number, c: number, d: number);
  75080. /**
  75081. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  75082. */
  75083. asArray(): number[];
  75084. /**
  75085. * @returns a new plane copied from the current Plane.
  75086. */
  75087. clone(): Plane;
  75088. /**
  75089. * @returns the string "Plane".
  75090. */
  75091. getClassName(): string;
  75092. /**
  75093. * @returns the Plane hash code.
  75094. */
  75095. getHashCode(): number;
  75096. /**
  75097. * Normalize the current Plane in place.
  75098. * @returns the updated Plane.
  75099. */
  75100. normalize(): Plane;
  75101. /**
  75102. * Applies a transformation the plane and returns the result
  75103. * @param transformation the transformation matrix to be applied to the plane
  75104. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  75105. */
  75106. transform(transformation: DeepImmutable<Matrix>): Plane;
  75107. /**
  75108. * Calcualtte the dot product between the point and the plane normal
  75109. * @param point point to calculate the dot product with
  75110. * @returns the dot product (float) of the point coordinates and the plane normal.
  75111. */
  75112. dotCoordinate(point: DeepImmutable<Vector3>): number;
  75113. /**
  75114. * Updates the current Plane from the plane defined by the three given points.
  75115. * @param point1 one of the points used to contruct the plane
  75116. * @param point2 one of the points used to contruct the plane
  75117. * @param point3 one of the points used to contruct the plane
  75118. * @returns the updated Plane.
  75119. */
  75120. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  75121. /**
  75122. * Checks if the plane is facing a given direction
  75123. * @param direction the direction to check if the plane is facing
  75124. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  75125. * @returns True is the vector "direction" is the same side than the plane normal.
  75126. */
  75127. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  75128. /**
  75129. * Calculates the distance to a point
  75130. * @param point point to calculate distance to
  75131. * @returns the signed distance (float) from the given point to the Plane.
  75132. */
  75133. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  75134. /**
  75135. * Creates a plane from an array
  75136. * @param array the array to create a plane from
  75137. * @returns a new Plane from the given array.
  75138. */
  75139. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  75140. /**
  75141. * Creates a plane from three points
  75142. * @param point1 point used to create the plane
  75143. * @param point2 point used to create the plane
  75144. * @param point3 point used to create the plane
  75145. * @returns a new Plane defined by the three given points.
  75146. */
  75147. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  75148. /**
  75149. * Creates a plane from an origin point and a normal
  75150. * @param origin origin of the plane to be constructed
  75151. * @param normal normal of the plane to be constructed
  75152. * @returns a new Plane the normal vector to this plane at the given origin point.
  75153. * Note : the vector "normal" is updated because normalized.
  75154. */
  75155. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  75156. /**
  75157. * Calculates the distance from a plane and a point
  75158. * @param origin origin of the plane to be constructed
  75159. * @param normal normal of the plane to be constructed
  75160. * @param point point to calculate distance to
  75161. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  75162. */
  75163. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  75164. }
  75165. }
  75166. declare module BABYLON {
  75167. /**
  75168. * Class used to store bounding sphere information
  75169. */
  75170. export class BoundingSphere {
  75171. /**
  75172. * Gets the center of the bounding sphere in local space
  75173. */
  75174. readonly center: Vector3;
  75175. /**
  75176. * Radius of the bounding sphere in local space
  75177. */
  75178. radius: number;
  75179. /**
  75180. * Gets the center of the bounding sphere in world space
  75181. */
  75182. readonly centerWorld: Vector3;
  75183. /**
  75184. * Radius of the bounding sphere in world space
  75185. */
  75186. radiusWorld: number;
  75187. /**
  75188. * Gets the minimum vector in local space
  75189. */
  75190. readonly minimum: Vector3;
  75191. /**
  75192. * Gets the maximum vector in local space
  75193. */
  75194. readonly maximum: Vector3;
  75195. private _worldMatrix;
  75196. private static readonly TmpVector3;
  75197. /**
  75198. * Creates a new bounding sphere
  75199. * @param min defines the minimum vector (in local space)
  75200. * @param max defines the maximum vector (in local space)
  75201. * @param worldMatrix defines the new world matrix
  75202. */
  75203. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  75204. /**
  75205. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  75206. * @param min defines the new minimum vector (in local space)
  75207. * @param max defines the new maximum vector (in local space)
  75208. * @param worldMatrix defines the new world matrix
  75209. */
  75210. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  75211. /**
  75212. * Scale the current bounding sphere by applying a scale factor
  75213. * @param factor defines the scale factor to apply
  75214. * @returns the current bounding box
  75215. */
  75216. scale(factor: number): BoundingSphere;
  75217. /**
  75218. * Gets the world matrix of the bounding box
  75219. * @returns a matrix
  75220. */
  75221. getWorldMatrix(): DeepImmutable<Matrix>;
  75222. /** @hidden */
  75223. _update(worldMatrix: DeepImmutable<Matrix>): void;
  75224. /**
  75225. * Tests if the bounding sphere is intersecting the frustum planes
  75226. * @param frustumPlanes defines the frustum planes to test
  75227. * @returns true if there is an intersection
  75228. */
  75229. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  75230. /**
  75231. * Tests if the bounding sphere center is in between the frustum planes.
  75232. * Used for optimistic fast inclusion.
  75233. * @param frustumPlanes defines the frustum planes to test
  75234. * @returns true if the sphere center is in between the frustum planes
  75235. */
  75236. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  75237. /**
  75238. * Tests if a point is inside the bounding sphere
  75239. * @param point defines the point to test
  75240. * @returns true if the point is inside the bounding sphere
  75241. */
  75242. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  75243. /**
  75244. * Checks if two sphere intersct
  75245. * @param sphere0 sphere 0
  75246. * @param sphere1 sphere 1
  75247. * @returns true if the speres intersect
  75248. */
  75249. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  75250. }
  75251. }
  75252. declare module BABYLON {
  75253. /**
  75254. * Class used to store bounding box information
  75255. */
  75256. export class BoundingBox implements ICullable {
  75257. /**
  75258. * Gets the 8 vectors representing the bounding box in local space
  75259. */
  75260. readonly vectors: Vector3[];
  75261. /**
  75262. * Gets the center of the bounding box in local space
  75263. */
  75264. readonly center: Vector3;
  75265. /**
  75266. * Gets the center of the bounding box in world space
  75267. */
  75268. readonly centerWorld: Vector3;
  75269. /**
  75270. * Gets the extend size in local space
  75271. */
  75272. readonly extendSize: Vector3;
  75273. /**
  75274. * Gets the extend size in world space
  75275. */
  75276. readonly extendSizeWorld: Vector3;
  75277. /**
  75278. * Gets the OBB (object bounding box) directions
  75279. */
  75280. readonly directions: Vector3[];
  75281. /**
  75282. * Gets the 8 vectors representing the bounding box in world space
  75283. */
  75284. readonly vectorsWorld: Vector3[];
  75285. /**
  75286. * Gets the minimum vector in world space
  75287. */
  75288. readonly minimumWorld: Vector3;
  75289. /**
  75290. * Gets the maximum vector in world space
  75291. */
  75292. readonly maximumWorld: Vector3;
  75293. /**
  75294. * Gets the minimum vector in local space
  75295. */
  75296. readonly minimum: Vector3;
  75297. /**
  75298. * Gets the maximum vector in local space
  75299. */
  75300. readonly maximum: Vector3;
  75301. private _worldMatrix;
  75302. private static readonly TmpVector3;
  75303. /**
  75304. * @hidden
  75305. */
  75306. _tag: number;
  75307. /**
  75308. * Creates a new bounding box
  75309. * @param min defines the minimum vector (in local space)
  75310. * @param max defines the maximum vector (in local space)
  75311. * @param worldMatrix defines the new world matrix
  75312. */
  75313. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  75314. /**
  75315. * Recreates the entire bounding box from scratch as if we call the constructor in place
  75316. * @param min defines the new minimum vector (in local space)
  75317. * @param max defines the new maximum vector (in local space)
  75318. * @param worldMatrix defines the new world matrix
  75319. */
  75320. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  75321. /**
  75322. * Scale the current bounding box by applying a scale factor
  75323. * @param factor defines the scale factor to apply
  75324. * @returns the current bounding box
  75325. */
  75326. scale(factor: number): BoundingBox;
  75327. /**
  75328. * Gets the world matrix of the bounding box
  75329. * @returns a matrix
  75330. */
  75331. getWorldMatrix(): DeepImmutable<Matrix>;
  75332. /** @hidden */
  75333. _update(world: DeepImmutable<Matrix>): void;
  75334. /**
  75335. * Tests if the bounding box is intersecting the frustum planes
  75336. * @param frustumPlanes defines the frustum planes to test
  75337. * @returns true if there is an intersection
  75338. */
  75339. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  75340. /**
  75341. * Tests if the bounding box is entirely inside the frustum planes
  75342. * @param frustumPlanes defines the frustum planes to test
  75343. * @returns true if there is an inclusion
  75344. */
  75345. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  75346. /**
  75347. * Tests if a point is inside the bounding box
  75348. * @param point defines the point to test
  75349. * @returns true if the point is inside the bounding box
  75350. */
  75351. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  75352. /**
  75353. * Tests if the bounding box intersects with a bounding sphere
  75354. * @param sphere defines the sphere to test
  75355. * @returns true if there is an intersection
  75356. */
  75357. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  75358. /**
  75359. * Tests if the bounding box intersects with a box defined by a min and max vectors
  75360. * @param min defines the min vector to use
  75361. * @param max defines the max vector to use
  75362. * @returns true if there is an intersection
  75363. */
  75364. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  75365. /**
  75366. * Tests if two bounding boxes are intersections
  75367. * @param box0 defines the first box to test
  75368. * @param box1 defines the second box to test
  75369. * @returns true if there is an intersection
  75370. */
  75371. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  75372. /**
  75373. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  75374. * @param minPoint defines the minimum vector of the bounding box
  75375. * @param maxPoint defines the maximum vector of the bounding box
  75376. * @param sphereCenter defines the sphere center
  75377. * @param sphereRadius defines the sphere radius
  75378. * @returns true if there is an intersection
  75379. */
  75380. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  75381. /**
  75382. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  75383. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  75384. * @param frustumPlanes defines the frustum planes to test
  75385. * @return true if there is an inclusion
  75386. */
  75387. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  75388. /**
  75389. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  75390. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  75391. * @param frustumPlanes defines the frustum planes to test
  75392. * @return true if there is an intersection
  75393. */
  75394. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  75395. }
  75396. }
  75397. declare module BABYLON {
  75398. /** @hidden */
  75399. export class Collider {
  75400. /** Define if a collision was found */
  75401. collisionFound: boolean;
  75402. /**
  75403. * Define last intersection point in local space
  75404. */
  75405. intersectionPoint: Vector3;
  75406. /**
  75407. * Define last collided mesh
  75408. */
  75409. collidedMesh: Nullable<AbstractMesh>;
  75410. private _collisionPoint;
  75411. private _planeIntersectionPoint;
  75412. private _tempVector;
  75413. private _tempVector2;
  75414. private _tempVector3;
  75415. private _tempVector4;
  75416. private _edge;
  75417. private _baseToVertex;
  75418. private _destinationPoint;
  75419. private _slidePlaneNormal;
  75420. private _displacementVector;
  75421. /** @hidden */
  75422. _radius: Vector3;
  75423. /** @hidden */
  75424. _retry: number;
  75425. private _velocity;
  75426. private _basePoint;
  75427. private _epsilon;
  75428. /** @hidden */
  75429. _velocityWorldLength: number;
  75430. /** @hidden */
  75431. _basePointWorld: Vector3;
  75432. private _velocityWorld;
  75433. private _normalizedVelocity;
  75434. /** @hidden */
  75435. _initialVelocity: Vector3;
  75436. /** @hidden */
  75437. _initialPosition: Vector3;
  75438. private _nearestDistance;
  75439. private _collisionMask;
  75440. collisionMask: number;
  75441. /**
  75442. * Gets the plane normal used to compute the sliding response (in local space)
  75443. */
  75444. readonly slidePlaneNormal: Vector3;
  75445. /** @hidden */
  75446. _initialize(source: Vector3, dir: Vector3, e: number): void;
  75447. /** @hidden */
  75448. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  75449. /** @hidden */
  75450. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  75451. /** @hidden */
  75452. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  75453. /** @hidden */
  75454. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  75455. /** @hidden */
  75456. _getResponse(pos: Vector3, vel: Vector3): void;
  75457. }
  75458. }
  75459. declare module BABYLON {
  75460. /**
  75461. * Interface for cullable objects
  75462. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  75463. */
  75464. export interface ICullable {
  75465. /**
  75466. * Checks if the object or part of the object is in the frustum
  75467. * @param frustumPlanes Camera near/planes
  75468. * @returns true if the object is in frustum otherwise false
  75469. */
  75470. isInFrustum(frustumPlanes: Plane[]): boolean;
  75471. /**
  75472. * Checks if a cullable object (mesh...) is in the camera frustum
  75473. * Unlike isInFrustum this cheks the full bounding box
  75474. * @param frustumPlanes Camera near/planes
  75475. * @returns true if the object is in frustum otherwise false
  75476. */
  75477. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  75478. }
  75479. /**
  75480. * Info for a bounding data of a mesh
  75481. */
  75482. export class BoundingInfo implements ICullable {
  75483. /**
  75484. * Bounding box for the mesh
  75485. */
  75486. readonly boundingBox: BoundingBox;
  75487. /**
  75488. * Bounding sphere for the mesh
  75489. */
  75490. readonly boundingSphere: BoundingSphere;
  75491. private _isLocked;
  75492. private static readonly TmpVector3;
  75493. /**
  75494. * Constructs bounding info
  75495. * @param minimum min vector of the bounding box/sphere
  75496. * @param maximum max vector of the bounding box/sphere
  75497. * @param worldMatrix defines the new world matrix
  75498. */
  75499. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  75500. /**
  75501. * Recreates the entire bounding info from scratch as if we call the constructor in place
  75502. * @param min defines the new minimum vector (in local space)
  75503. * @param max defines the new maximum vector (in local space)
  75504. * @param worldMatrix defines the new world matrix
  75505. */
  75506. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  75507. /**
  75508. * min vector of the bounding box/sphere
  75509. */
  75510. readonly minimum: Vector3;
  75511. /**
  75512. * max vector of the bounding box/sphere
  75513. */
  75514. readonly maximum: Vector3;
  75515. /**
  75516. * If the info is locked and won't be updated to avoid perf overhead
  75517. */
  75518. isLocked: boolean;
  75519. /**
  75520. * Updates the bounding sphere and box
  75521. * @param world world matrix to be used to update
  75522. */
  75523. update(world: DeepImmutable<Matrix>): void;
  75524. /**
  75525. * Recreate the bounding info to be centered around a specific point given a specific extend.
  75526. * @param center New center of the bounding info
  75527. * @param extend New extend of the bounding info
  75528. * @returns the current bounding info
  75529. */
  75530. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  75531. /**
  75532. * Scale the current bounding info by applying a scale factor
  75533. * @param factor defines the scale factor to apply
  75534. * @returns the current bounding info
  75535. */
  75536. scale(factor: number): BoundingInfo;
  75537. /**
  75538. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  75539. * @param frustumPlanes defines the frustum to test
  75540. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  75541. * @returns true if the bounding info is in the frustum planes
  75542. */
  75543. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  75544. /**
  75545. * Gets the world distance between the min and max points of the bounding box
  75546. */
  75547. readonly diagonalLength: number;
  75548. /**
  75549. * Checks if a cullable object (mesh...) is in the camera frustum
  75550. * Unlike isInFrustum this cheks the full bounding box
  75551. * @param frustumPlanes Camera near/planes
  75552. * @returns true if the object is in frustum otherwise false
  75553. */
  75554. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  75555. /** @hidden */
  75556. _checkCollision(collider: Collider): boolean;
  75557. /**
  75558. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  75559. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  75560. * @param point the point to check intersection with
  75561. * @returns if the point intersects
  75562. */
  75563. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  75564. /**
  75565. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  75566. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  75567. * @param boundingInfo the bounding info to check intersection with
  75568. * @param precise if the intersection should be done using OBB
  75569. * @returns if the bounding info intersects
  75570. */
  75571. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  75572. }
  75573. }
  75574. declare module BABYLON {
  75575. /**
  75576. * Extracts minimum and maximum values from a list of indexed positions
  75577. * @param positions defines the positions to use
  75578. * @param indices defines the indices to the positions
  75579. * @param indexStart defines the start index
  75580. * @param indexCount defines the end index
  75581. * @param bias defines bias value to add to the result
  75582. * @return minimum and maximum values
  75583. */
  75584. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  75585. minimum: Vector3;
  75586. maximum: Vector3;
  75587. };
  75588. /**
  75589. * Extracts minimum and maximum values from a list of positions
  75590. * @param positions defines the positions to use
  75591. * @param start defines the start index in the positions array
  75592. * @param count defines the number of positions to handle
  75593. * @param bias defines bias value to add to the result
  75594. * @param stride defines the stride size to use (distance between two positions in the positions array)
  75595. * @return minimum and maximum values
  75596. */
  75597. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  75598. minimum: Vector3;
  75599. maximum: Vector3;
  75600. };
  75601. }
  75602. declare module BABYLON {
  75603. /** @hidden */
  75604. export class WebGLDataBuffer extends DataBuffer {
  75605. private _buffer;
  75606. constructor(resource: WebGLBuffer);
  75607. readonly underlyingResource: any;
  75608. }
  75609. }
  75610. declare module BABYLON {
  75611. /** @hidden */
  75612. export class WebGLPipelineContext implements IPipelineContext {
  75613. engine: ThinEngine;
  75614. program: Nullable<WebGLProgram>;
  75615. context?: WebGLRenderingContext;
  75616. vertexShader?: WebGLShader;
  75617. fragmentShader?: WebGLShader;
  75618. isParallelCompiled: boolean;
  75619. onCompiled?: () => void;
  75620. transformFeedback?: WebGLTransformFeedback | null;
  75621. readonly isAsync: boolean;
  75622. readonly isReady: boolean;
  75623. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  75624. }
  75625. }
  75626. declare module BABYLON {
  75627. interface ThinEngine {
  75628. /**
  75629. * Create an uniform buffer
  75630. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  75631. * @param elements defines the content of the uniform buffer
  75632. * @returns the webGL uniform buffer
  75633. */
  75634. createUniformBuffer(elements: FloatArray): DataBuffer;
  75635. /**
  75636. * Create a dynamic uniform buffer
  75637. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  75638. * @param elements defines the content of the uniform buffer
  75639. * @returns the webGL uniform buffer
  75640. */
  75641. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  75642. /**
  75643. * Update an existing uniform buffer
  75644. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  75645. * @param uniformBuffer defines the target uniform buffer
  75646. * @param elements defines the content to update
  75647. * @param offset defines the offset in the uniform buffer where update should start
  75648. * @param count defines the size of the data to update
  75649. */
  75650. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  75651. /**
  75652. * Bind an uniform buffer to the current webGL context
  75653. * @param buffer defines the buffer to bind
  75654. */
  75655. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  75656. /**
  75657. * Bind a buffer to the current webGL context at a given location
  75658. * @param buffer defines the buffer to bind
  75659. * @param location defines the index where to bind the buffer
  75660. */
  75661. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  75662. /**
  75663. * Bind a specific block at a given index in a specific shader program
  75664. * @param pipelineContext defines the pipeline context to use
  75665. * @param blockName defines the block name
  75666. * @param index defines the index where to bind the block
  75667. */
  75668. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  75669. }
  75670. }
  75671. declare module BABYLON {
  75672. /**
  75673. * Uniform buffer objects.
  75674. *
  75675. * Handles blocks of uniform on the GPU.
  75676. *
  75677. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  75678. *
  75679. * For more information, please refer to :
  75680. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  75681. */
  75682. export class UniformBuffer {
  75683. private _engine;
  75684. private _buffer;
  75685. private _data;
  75686. private _bufferData;
  75687. private _dynamic?;
  75688. private _uniformLocations;
  75689. private _uniformSizes;
  75690. private _uniformLocationPointer;
  75691. private _needSync;
  75692. private _noUBO;
  75693. private _currentEffect;
  75694. /** @hidden */
  75695. _alreadyBound: boolean;
  75696. private static _MAX_UNIFORM_SIZE;
  75697. private static _tempBuffer;
  75698. /**
  75699. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  75700. * This is dynamic to allow compat with webgl 1 and 2.
  75701. * You will need to pass the name of the uniform as well as the value.
  75702. */
  75703. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  75704. /**
  75705. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  75706. * This is dynamic to allow compat with webgl 1 and 2.
  75707. * You will need to pass the name of the uniform as well as the value.
  75708. */
  75709. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  75710. /**
  75711. * Lambda to Update a single float in a uniform buffer.
  75712. * This is dynamic to allow compat with webgl 1 and 2.
  75713. * You will need to pass the name of the uniform as well as the value.
  75714. */
  75715. updateFloat: (name: string, x: number) => void;
  75716. /**
  75717. * Lambda to Update a vec2 of float in a uniform buffer.
  75718. * This is dynamic to allow compat with webgl 1 and 2.
  75719. * You will need to pass the name of the uniform as well as the value.
  75720. */
  75721. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  75722. /**
  75723. * Lambda to Update a vec3 of float in a uniform buffer.
  75724. * This is dynamic to allow compat with webgl 1 and 2.
  75725. * You will need to pass the name of the uniform as well as the value.
  75726. */
  75727. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  75728. /**
  75729. * Lambda to Update a vec4 of float in a uniform buffer.
  75730. * This is dynamic to allow compat with webgl 1 and 2.
  75731. * You will need to pass the name of the uniform as well as the value.
  75732. */
  75733. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  75734. /**
  75735. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  75736. * This is dynamic to allow compat with webgl 1 and 2.
  75737. * You will need to pass the name of the uniform as well as the value.
  75738. */
  75739. updateMatrix: (name: string, mat: Matrix) => void;
  75740. /**
  75741. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  75742. * This is dynamic to allow compat with webgl 1 and 2.
  75743. * You will need to pass the name of the uniform as well as the value.
  75744. */
  75745. updateVector3: (name: string, vector: Vector3) => void;
  75746. /**
  75747. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  75748. * This is dynamic to allow compat with webgl 1 and 2.
  75749. * You will need to pass the name of the uniform as well as the value.
  75750. */
  75751. updateVector4: (name: string, vector: Vector4) => void;
  75752. /**
  75753. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  75754. * This is dynamic to allow compat with webgl 1 and 2.
  75755. * You will need to pass the name of the uniform as well as the value.
  75756. */
  75757. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  75758. /**
  75759. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  75760. * This is dynamic to allow compat with webgl 1 and 2.
  75761. * You will need to pass the name of the uniform as well as the value.
  75762. */
  75763. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  75764. /**
  75765. * Instantiates a new Uniform buffer objects.
  75766. *
  75767. * Handles blocks of uniform on the GPU.
  75768. *
  75769. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  75770. *
  75771. * For more information, please refer to :
  75772. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  75773. * @param engine Define the engine the buffer is associated with
  75774. * @param data Define the data contained in the buffer
  75775. * @param dynamic Define if the buffer is updatable
  75776. */
  75777. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  75778. /**
  75779. * Indicates if the buffer is using the WebGL2 UBO implementation,
  75780. * or just falling back on setUniformXXX calls.
  75781. */
  75782. readonly useUbo: boolean;
  75783. /**
  75784. * Indicates if the WebGL underlying uniform buffer is in sync
  75785. * with the javascript cache data.
  75786. */
  75787. readonly isSync: boolean;
  75788. /**
  75789. * Indicates if the WebGL underlying uniform buffer is dynamic.
  75790. * Also, a dynamic UniformBuffer will disable cache verification and always
  75791. * update the underlying WebGL uniform buffer to the GPU.
  75792. * @returns if Dynamic, otherwise false
  75793. */
  75794. isDynamic(): boolean;
  75795. /**
  75796. * The data cache on JS side.
  75797. * @returns the underlying data as a float array
  75798. */
  75799. getData(): Float32Array;
  75800. /**
  75801. * The underlying WebGL Uniform buffer.
  75802. * @returns the webgl buffer
  75803. */
  75804. getBuffer(): Nullable<DataBuffer>;
  75805. /**
  75806. * std140 layout specifies how to align data within an UBO structure.
  75807. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  75808. * for specs.
  75809. */
  75810. private _fillAlignment;
  75811. /**
  75812. * Adds an uniform in the buffer.
  75813. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  75814. * for the layout to be correct !
  75815. * @param name Name of the uniform, as used in the uniform block in the shader.
  75816. * @param size Data size, or data directly.
  75817. */
  75818. addUniform(name: string, size: number | number[]): void;
  75819. /**
  75820. * Adds a Matrix 4x4 to the uniform buffer.
  75821. * @param name Name of the uniform, as used in the uniform block in the shader.
  75822. * @param mat A 4x4 matrix.
  75823. */
  75824. addMatrix(name: string, mat: Matrix): void;
  75825. /**
  75826. * Adds a vec2 to the uniform buffer.
  75827. * @param name Name of the uniform, as used in the uniform block in the shader.
  75828. * @param x Define the x component value of the vec2
  75829. * @param y Define the y component value of the vec2
  75830. */
  75831. addFloat2(name: string, x: number, y: number): void;
  75832. /**
  75833. * Adds a vec3 to the uniform buffer.
  75834. * @param name Name of the uniform, as used in the uniform block in the shader.
  75835. * @param x Define the x component value of the vec3
  75836. * @param y Define the y component value of the vec3
  75837. * @param z Define the z component value of the vec3
  75838. */
  75839. addFloat3(name: string, x: number, y: number, z: number): void;
  75840. /**
  75841. * Adds a vec3 to the uniform buffer.
  75842. * @param name Name of the uniform, as used in the uniform block in the shader.
  75843. * @param color Define the vec3 from a Color
  75844. */
  75845. addColor3(name: string, color: Color3): void;
  75846. /**
  75847. * Adds a vec4 to the uniform buffer.
  75848. * @param name Name of the uniform, as used in the uniform block in the shader.
  75849. * @param color Define the rgb components from a Color
  75850. * @param alpha Define the a component of the vec4
  75851. */
  75852. addColor4(name: string, color: Color3, alpha: number): void;
  75853. /**
  75854. * Adds a vec3 to the uniform buffer.
  75855. * @param name Name of the uniform, as used in the uniform block in the shader.
  75856. * @param vector Define the vec3 components from a Vector
  75857. */
  75858. addVector3(name: string, vector: Vector3): void;
  75859. /**
  75860. * Adds a Matrix 3x3 to the uniform buffer.
  75861. * @param name Name of the uniform, as used in the uniform block in the shader.
  75862. */
  75863. addMatrix3x3(name: string): void;
  75864. /**
  75865. * Adds a Matrix 2x2 to the uniform buffer.
  75866. * @param name Name of the uniform, as used in the uniform block in the shader.
  75867. */
  75868. addMatrix2x2(name: string): void;
  75869. /**
  75870. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  75871. */
  75872. create(): void;
  75873. /** @hidden */
  75874. _rebuild(): void;
  75875. /**
  75876. * Updates the WebGL Uniform Buffer on the GPU.
  75877. * If the `dynamic` flag is set to true, no cache comparison is done.
  75878. * Otherwise, the buffer will be updated only if the cache differs.
  75879. */
  75880. update(): void;
  75881. /**
  75882. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  75883. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  75884. * @param data Define the flattened data
  75885. * @param size Define the size of the data.
  75886. */
  75887. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  75888. private _valueCache;
  75889. private _cacheMatrix;
  75890. private _updateMatrix3x3ForUniform;
  75891. private _updateMatrix3x3ForEffect;
  75892. private _updateMatrix2x2ForEffect;
  75893. private _updateMatrix2x2ForUniform;
  75894. private _updateFloatForEffect;
  75895. private _updateFloatForUniform;
  75896. private _updateFloat2ForEffect;
  75897. private _updateFloat2ForUniform;
  75898. private _updateFloat3ForEffect;
  75899. private _updateFloat3ForUniform;
  75900. private _updateFloat4ForEffect;
  75901. private _updateFloat4ForUniform;
  75902. private _updateMatrixForEffect;
  75903. private _updateMatrixForUniform;
  75904. private _updateVector3ForEffect;
  75905. private _updateVector3ForUniform;
  75906. private _updateVector4ForEffect;
  75907. private _updateVector4ForUniform;
  75908. private _updateColor3ForEffect;
  75909. private _updateColor3ForUniform;
  75910. private _updateColor4ForEffect;
  75911. private _updateColor4ForUniform;
  75912. /**
  75913. * Sets a sampler uniform on the effect.
  75914. * @param name Define the name of the sampler.
  75915. * @param texture Define the texture to set in the sampler
  75916. */
  75917. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  75918. /**
  75919. * Directly updates the value of the uniform in the cache AND on the GPU.
  75920. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  75921. * @param data Define the flattened data
  75922. */
  75923. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  75924. /**
  75925. * Binds this uniform buffer to an effect.
  75926. * @param effect Define the effect to bind the buffer to
  75927. * @param name Name of the uniform block in the shader.
  75928. */
  75929. bindToEffect(effect: Effect, name: string): void;
  75930. /**
  75931. * Disposes the uniform buffer.
  75932. */
  75933. dispose(): void;
  75934. }
  75935. }
  75936. declare module BABYLON {
  75937. /**
  75938. * Enum that determines the text-wrapping mode to use.
  75939. */
  75940. export enum InspectableType {
  75941. /**
  75942. * Checkbox for booleans
  75943. */
  75944. Checkbox = 0,
  75945. /**
  75946. * Sliders for numbers
  75947. */
  75948. Slider = 1,
  75949. /**
  75950. * Vector3
  75951. */
  75952. Vector3 = 2,
  75953. /**
  75954. * Quaternions
  75955. */
  75956. Quaternion = 3,
  75957. /**
  75958. * Color3
  75959. */
  75960. Color3 = 4,
  75961. /**
  75962. * String
  75963. */
  75964. String = 5
  75965. }
  75966. /**
  75967. * Interface used to define custom inspectable properties.
  75968. * This interface is used by the inspector to display custom property grids
  75969. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  75970. */
  75971. export interface IInspectable {
  75972. /**
  75973. * Gets the label to display
  75974. */
  75975. label: string;
  75976. /**
  75977. * Gets the name of the property to edit
  75978. */
  75979. propertyName: string;
  75980. /**
  75981. * Gets the type of the editor to use
  75982. */
  75983. type: InspectableType;
  75984. /**
  75985. * Gets the minimum value of the property when using in "slider" mode
  75986. */
  75987. min?: number;
  75988. /**
  75989. * Gets the maximum value of the property when using in "slider" mode
  75990. */
  75991. max?: number;
  75992. /**
  75993. * Gets the setp to use when using in "slider" mode
  75994. */
  75995. step?: number;
  75996. }
  75997. }
  75998. declare module BABYLON {
  75999. /**
  76000. * Class used to provide helper for timing
  76001. */
  76002. export class TimingTools {
  76003. /**
  76004. * Polyfill for setImmediate
  76005. * @param action defines the action to execute after the current execution block
  76006. */
  76007. static SetImmediate(action: () => void): void;
  76008. }
  76009. }
  76010. declare module BABYLON {
  76011. /**
  76012. * Class used to enable instatition of objects by class name
  76013. */
  76014. export class InstantiationTools {
  76015. /**
  76016. * Use this object to register external classes like custom textures or material
  76017. * to allow the laoders to instantiate them
  76018. */
  76019. static RegisteredExternalClasses: {
  76020. [key: string]: Object;
  76021. };
  76022. /**
  76023. * Tries to instantiate a new object from a given class name
  76024. * @param className defines the class name to instantiate
  76025. * @returns the new object or null if the system was not able to do the instantiation
  76026. */
  76027. static Instantiate(className: string): any;
  76028. }
  76029. }
  76030. declare module BABYLON {
  76031. /**
  76032. * Define options used to create a depth texture
  76033. */
  76034. export class DepthTextureCreationOptions {
  76035. /** Specifies whether or not a stencil should be allocated in the texture */
  76036. generateStencil?: boolean;
  76037. /** Specifies whether or not bilinear filtering is enable on the texture */
  76038. bilinearFiltering?: boolean;
  76039. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  76040. comparisonFunction?: number;
  76041. /** Specifies if the created texture is a cube texture */
  76042. isCube?: boolean;
  76043. }
  76044. }
  76045. declare module BABYLON {
  76046. interface ThinEngine {
  76047. /**
  76048. * Creates a depth stencil cube texture.
  76049. * This is only available in WebGL 2.
  76050. * @param size The size of face edge in the cube texture.
  76051. * @param options The options defining the cube texture.
  76052. * @returns The cube texture
  76053. */
  76054. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  76055. /**
  76056. * Creates a cube texture
  76057. * @param rootUrl defines the url where the files to load is located
  76058. * @param scene defines the current scene
  76059. * @param files defines the list of files to load (1 per face)
  76060. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  76061. * @param onLoad defines an optional callback raised when the texture is loaded
  76062. * @param onError defines an optional callback raised if there is an issue to load the texture
  76063. * @param format defines the format of the data
  76064. * @param forcedExtension defines the extension to use to pick the right loader
  76065. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  76066. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  76067. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  76068. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  76069. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  76070. * @returns the cube texture as an InternalTexture
  76071. */
  76072. 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;
  76073. /**
  76074. * Creates a cube texture
  76075. * @param rootUrl defines the url where the files to load is located
  76076. * @param scene defines the current scene
  76077. * @param files defines the list of files to load (1 per face)
  76078. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  76079. * @param onLoad defines an optional callback raised when the texture is loaded
  76080. * @param onError defines an optional callback raised if there is an issue to load the texture
  76081. * @param format defines the format of the data
  76082. * @param forcedExtension defines the extension to use to pick the right loader
  76083. * @returns the cube texture as an InternalTexture
  76084. */
  76085. 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;
  76086. /**
  76087. * Creates a cube texture
  76088. * @param rootUrl defines the url where the files to load is located
  76089. * @param scene defines the current scene
  76090. * @param files defines the list of files to load (1 per face)
  76091. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  76092. * @param onLoad defines an optional callback raised when the texture is loaded
  76093. * @param onError defines an optional callback raised if there is an issue to load the texture
  76094. * @param format defines the format of the data
  76095. * @param forcedExtension defines the extension to use to pick the right loader
  76096. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  76097. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  76098. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  76099. * @returns the cube texture as an InternalTexture
  76100. */
  76101. 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;
  76102. /** @hidden */
  76103. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  76104. /** @hidden */
  76105. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  76106. /** @hidden */
  76107. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  76108. /** @hidden */
  76109. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  76110. /**
  76111. * @hidden
  76112. */
  76113. _setCubeMapTextureParams(loadMipmap: boolean): void;
  76114. }
  76115. }
  76116. declare module BABYLON {
  76117. /**
  76118. * Class for creating a cube texture
  76119. */
  76120. export class CubeTexture extends BaseTexture {
  76121. private _delayedOnLoad;
  76122. /**
  76123. * The url of the texture
  76124. */
  76125. url: string;
  76126. /**
  76127. * Gets or sets the center of the bounding box associated with the cube texture.
  76128. * It must define where the camera used to render the texture was set
  76129. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  76130. */
  76131. boundingBoxPosition: Vector3;
  76132. private _boundingBoxSize;
  76133. /**
  76134. * Gets or sets the size of the bounding box associated with the cube texture
  76135. * When defined, the cubemap will switch to local mode
  76136. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  76137. * @example https://www.babylonjs-playground.com/#RNASML
  76138. */
  76139. /**
  76140. * Returns the bounding box size
  76141. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  76142. */
  76143. boundingBoxSize: Vector3;
  76144. protected _rotationY: number;
  76145. /**
  76146. * Sets texture matrix rotation angle around Y axis in radians.
  76147. */
  76148. /**
  76149. * Gets texture matrix rotation angle around Y axis radians.
  76150. */
  76151. rotationY: number;
  76152. /**
  76153. * Are mip maps generated for this texture or not.
  76154. */
  76155. readonly noMipmap: boolean;
  76156. private _noMipmap;
  76157. private _files;
  76158. protected _forcedExtension: Nullable<string>;
  76159. private _extensions;
  76160. private _textureMatrix;
  76161. private _format;
  76162. private _createPolynomials;
  76163. /** @hidden */
  76164. _prefiltered: boolean;
  76165. /**
  76166. * Creates a cube texture from an array of image urls
  76167. * @param files defines an array of image urls
  76168. * @param scene defines the hosting scene
  76169. * @param noMipmap specifies if mip maps are not used
  76170. * @returns a cube texture
  76171. */
  76172. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  76173. /**
  76174. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  76175. * @param url defines the url of the prefiltered texture
  76176. * @param scene defines the scene the texture is attached to
  76177. * @param forcedExtension defines the extension of the file if different from the url
  76178. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  76179. * @return the prefiltered texture
  76180. */
  76181. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  76182. /**
  76183. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  76184. * as prefiltered data.
  76185. * @param rootUrl defines the url of the texture or the root name of the six images
  76186. * @param scene defines the scene the texture is attached to
  76187. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  76188. * @param noMipmap defines if mipmaps should be created or not
  76189. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  76190. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  76191. * @param onError defines a callback triggered in case of error during load
  76192. * @param format defines the internal format to use for the texture once loaded
  76193. * @param prefiltered defines whether or not the texture is created from prefiltered data
  76194. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  76195. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  76196. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  76197. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  76198. * @return the cube texture
  76199. */
  76200. 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);
  76201. /**
  76202. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  76203. */
  76204. readonly isPrefiltered: boolean;
  76205. /**
  76206. * Get the current class name of the texture useful for serialization or dynamic coding.
  76207. * @returns "CubeTexture"
  76208. */
  76209. getClassName(): string;
  76210. /**
  76211. * Update the url (and optional buffer) of this texture if url was null during construction.
  76212. * @param url the url of the texture
  76213. * @param forcedExtension defines the extension to use
  76214. * @param onLoad callback called when the texture is loaded (defaults to null)
  76215. */
  76216. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  76217. /**
  76218. * Delays loading of the cube texture
  76219. * @param forcedExtension defines the extension to use
  76220. */
  76221. delayLoad(forcedExtension?: string): void;
  76222. /**
  76223. * Returns the reflection texture matrix
  76224. * @returns the reflection texture matrix
  76225. */
  76226. getReflectionTextureMatrix(): Matrix;
  76227. /**
  76228. * Sets the reflection texture matrix
  76229. * @param value Reflection texture matrix
  76230. */
  76231. setReflectionTextureMatrix(value: Matrix): void;
  76232. /**
  76233. * Parses text to create a cube texture
  76234. * @param parsedTexture define the serialized text to read from
  76235. * @param scene defines the hosting scene
  76236. * @param rootUrl defines the root url of the cube texture
  76237. * @returns a cube texture
  76238. */
  76239. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  76240. /**
  76241. * Makes a clone, or deep copy, of the cube texture
  76242. * @returns a new cube texture
  76243. */
  76244. clone(): CubeTexture;
  76245. }
  76246. }
  76247. declare module BABYLON {
  76248. /**
  76249. * Manages the defines for the Material
  76250. */
  76251. export class MaterialDefines {
  76252. /** @hidden */
  76253. protected _keys: string[];
  76254. private _isDirty;
  76255. /** @hidden */
  76256. _renderId: number;
  76257. /** @hidden */
  76258. _areLightsDirty: boolean;
  76259. /** @hidden */
  76260. _areLightsDisposed: boolean;
  76261. /** @hidden */
  76262. _areAttributesDirty: boolean;
  76263. /** @hidden */
  76264. _areTexturesDirty: boolean;
  76265. /** @hidden */
  76266. _areFresnelDirty: boolean;
  76267. /** @hidden */
  76268. _areMiscDirty: boolean;
  76269. /** @hidden */
  76270. _areImageProcessingDirty: boolean;
  76271. /** @hidden */
  76272. _normals: boolean;
  76273. /** @hidden */
  76274. _uvs: boolean;
  76275. /** @hidden */
  76276. _needNormals: boolean;
  76277. /** @hidden */
  76278. _needUVs: boolean;
  76279. [id: string]: any;
  76280. /**
  76281. * Specifies if the material needs to be re-calculated
  76282. */
  76283. readonly isDirty: boolean;
  76284. /**
  76285. * Marks the material to indicate that it has been re-calculated
  76286. */
  76287. markAsProcessed(): void;
  76288. /**
  76289. * Marks the material to indicate that it needs to be re-calculated
  76290. */
  76291. markAsUnprocessed(): void;
  76292. /**
  76293. * Marks the material to indicate all of its defines need to be re-calculated
  76294. */
  76295. markAllAsDirty(): void;
  76296. /**
  76297. * Marks the material to indicate that image processing needs to be re-calculated
  76298. */
  76299. markAsImageProcessingDirty(): void;
  76300. /**
  76301. * Marks the material to indicate the lights need to be re-calculated
  76302. * @param disposed Defines whether the light is dirty due to dispose or not
  76303. */
  76304. markAsLightDirty(disposed?: boolean): void;
  76305. /**
  76306. * Marks the attribute state as changed
  76307. */
  76308. markAsAttributesDirty(): void;
  76309. /**
  76310. * Marks the texture state as changed
  76311. */
  76312. markAsTexturesDirty(): void;
  76313. /**
  76314. * Marks the fresnel state as changed
  76315. */
  76316. markAsFresnelDirty(): void;
  76317. /**
  76318. * Marks the misc state as changed
  76319. */
  76320. markAsMiscDirty(): void;
  76321. /**
  76322. * Rebuilds the material defines
  76323. */
  76324. rebuild(): void;
  76325. /**
  76326. * Specifies if two material defines are equal
  76327. * @param other - A material define instance to compare to
  76328. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  76329. */
  76330. isEqual(other: MaterialDefines): boolean;
  76331. /**
  76332. * Clones this instance's defines to another instance
  76333. * @param other - material defines to clone values to
  76334. */
  76335. cloneTo(other: MaterialDefines): void;
  76336. /**
  76337. * Resets the material define values
  76338. */
  76339. reset(): void;
  76340. /**
  76341. * Converts the material define values to a string
  76342. * @returns - String of material define information
  76343. */
  76344. toString(): string;
  76345. }
  76346. }
  76347. declare module BABYLON {
  76348. /**
  76349. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  76350. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  76351. * 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;
  76352. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  76353. */
  76354. export class ColorCurves {
  76355. private _dirty;
  76356. private _tempColor;
  76357. private _globalCurve;
  76358. private _highlightsCurve;
  76359. private _midtonesCurve;
  76360. private _shadowsCurve;
  76361. private _positiveCurve;
  76362. private _negativeCurve;
  76363. private _globalHue;
  76364. private _globalDensity;
  76365. private _globalSaturation;
  76366. private _globalExposure;
  76367. /**
  76368. * Gets the global Hue value.
  76369. * 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).
  76370. */
  76371. /**
  76372. * Sets the global Hue value.
  76373. * 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).
  76374. */
  76375. globalHue: number;
  76376. /**
  76377. * Gets the global Density value.
  76378. * 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.
  76379. * Values less than zero provide a filter of opposite hue.
  76380. */
  76381. /**
  76382. * Sets the global Density value.
  76383. * 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.
  76384. * Values less than zero provide a filter of opposite hue.
  76385. */
  76386. globalDensity: number;
  76387. /**
  76388. * Gets the global Saturation value.
  76389. * 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.
  76390. */
  76391. /**
  76392. * Sets the global Saturation value.
  76393. * 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.
  76394. */
  76395. globalSaturation: number;
  76396. /**
  76397. * Gets the global Exposure value.
  76398. * 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.
  76399. */
  76400. /**
  76401. * Sets the global Exposure value.
  76402. * 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.
  76403. */
  76404. globalExposure: number;
  76405. private _highlightsHue;
  76406. private _highlightsDensity;
  76407. private _highlightsSaturation;
  76408. private _highlightsExposure;
  76409. /**
  76410. * Gets the highlights Hue value.
  76411. * 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).
  76412. */
  76413. /**
  76414. * Sets the highlights Hue value.
  76415. * 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).
  76416. */
  76417. highlightsHue: number;
  76418. /**
  76419. * Gets the highlights Density value.
  76420. * 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.
  76421. * Values less than zero provide a filter of opposite hue.
  76422. */
  76423. /**
  76424. * Sets the highlights Density value.
  76425. * 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.
  76426. * Values less than zero provide a filter of opposite hue.
  76427. */
  76428. highlightsDensity: number;
  76429. /**
  76430. * Gets the highlights Saturation value.
  76431. * 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.
  76432. */
  76433. /**
  76434. * Sets the highlights Saturation value.
  76435. * 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.
  76436. */
  76437. highlightsSaturation: number;
  76438. /**
  76439. * Gets the highlights Exposure value.
  76440. * 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.
  76441. */
  76442. /**
  76443. * Sets the highlights Exposure value.
  76444. * 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.
  76445. */
  76446. highlightsExposure: number;
  76447. private _midtonesHue;
  76448. private _midtonesDensity;
  76449. private _midtonesSaturation;
  76450. private _midtonesExposure;
  76451. /**
  76452. * Gets the midtones Hue value.
  76453. * 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).
  76454. */
  76455. /**
  76456. * Sets the midtones Hue value.
  76457. * 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).
  76458. */
  76459. midtonesHue: number;
  76460. /**
  76461. * Gets the midtones Density value.
  76462. * 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.
  76463. * Values less than zero provide a filter of opposite hue.
  76464. */
  76465. /**
  76466. * Sets the midtones Density value.
  76467. * 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.
  76468. * Values less than zero provide a filter of opposite hue.
  76469. */
  76470. midtonesDensity: number;
  76471. /**
  76472. * Gets the midtones Saturation value.
  76473. * 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.
  76474. */
  76475. /**
  76476. * Sets the midtones Saturation value.
  76477. * 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.
  76478. */
  76479. midtonesSaturation: number;
  76480. /**
  76481. * Gets the midtones Exposure value.
  76482. * 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.
  76483. */
  76484. /**
  76485. * Sets the midtones Exposure value.
  76486. * 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.
  76487. */
  76488. midtonesExposure: number;
  76489. private _shadowsHue;
  76490. private _shadowsDensity;
  76491. private _shadowsSaturation;
  76492. private _shadowsExposure;
  76493. /**
  76494. * Gets the shadows Hue value.
  76495. * 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).
  76496. */
  76497. /**
  76498. * Sets the shadows Hue value.
  76499. * 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).
  76500. */
  76501. shadowsHue: number;
  76502. /**
  76503. * Gets the shadows Density value.
  76504. * 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.
  76505. * Values less than zero provide a filter of opposite hue.
  76506. */
  76507. /**
  76508. * Sets the shadows Density value.
  76509. * 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.
  76510. * Values less than zero provide a filter of opposite hue.
  76511. */
  76512. shadowsDensity: number;
  76513. /**
  76514. * Gets the shadows Saturation value.
  76515. * 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.
  76516. */
  76517. /**
  76518. * Sets the shadows Saturation value.
  76519. * 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.
  76520. */
  76521. shadowsSaturation: number;
  76522. /**
  76523. * Gets the shadows Exposure value.
  76524. * 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.
  76525. */
  76526. /**
  76527. * Sets the shadows Exposure value.
  76528. * 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.
  76529. */
  76530. shadowsExposure: number;
  76531. /**
  76532. * Returns the class name
  76533. * @returns The class name
  76534. */
  76535. getClassName(): string;
  76536. /**
  76537. * Binds the color curves to the shader.
  76538. * @param colorCurves The color curve to bind
  76539. * @param effect The effect to bind to
  76540. * @param positiveUniform The positive uniform shader parameter
  76541. * @param neutralUniform The neutral uniform shader parameter
  76542. * @param negativeUniform The negative uniform shader parameter
  76543. */
  76544. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  76545. /**
  76546. * Prepare the list of uniforms associated with the ColorCurves effects.
  76547. * @param uniformsList The list of uniforms used in the effect
  76548. */
  76549. static PrepareUniforms(uniformsList: string[]): void;
  76550. /**
  76551. * Returns color grading data based on a hue, density, saturation and exposure value.
  76552. * @param filterHue The hue of the color filter.
  76553. * @param filterDensity The density of the color filter.
  76554. * @param saturation The saturation.
  76555. * @param exposure The exposure.
  76556. * @param result The result data container.
  76557. */
  76558. private getColorGradingDataToRef;
  76559. /**
  76560. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  76561. * @param value The input slider value in range [-100,100].
  76562. * @returns Adjusted value.
  76563. */
  76564. private static applyColorGradingSliderNonlinear;
  76565. /**
  76566. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  76567. * @param hue The hue (H) input.
  76568. * @param saturation The saturation (S) input.
  76569. * @param brightness The brightness (B) input.
  76570. * @result An RGBA color represented as Vector4.
  76571. */
  76572. private static fromHSBToRef;
  76573. /**
  76574. * Returns a value clamped between min and max
  76575. * @param value The value to clamp
  76576. * @param min The minimum of value
  76577. * @param max The maximum of value
  76578. * @returns The clamped value.
  76579. */
  76580. private static clamp;
  76581. /**
  76582. * Clones the current color curve instance.
  76583. * @return The cloned curves
  76584. */
  76585. clone(): ColorCurves;
  76586. /**
  76587. * Serializes the current color curve instance to a json representation.
  76588. * @return a JSON representation
  76589. */
  76590. serialize(): any;
  76591. /**
  76592. * Parses the color curve from a json representation.
  76593. * @param source the JSON source to parse
  76594. * @return The parsed curves
  76595. */
  76596. static Parse(source: any): ColorCurves;
  76597. }
  76598. }
  76599. declare module BABYLON {
  76600. /**
  76601. * Interface to follow in your material defines to integrate easily the
  76602. * Image proccessing functions.
  76603. * @hidden
  76604. */
  76605. export interface IImageProcessingConfigurationDefines {
  76606. IMAGEPROCESSING: boolean;
  76607. VIGNETTE: boolean;
  76608. VIGNETTEBLENDMODEMULTIPLY: boolean;
  76609. VIGNETTEBLENDMODEOPAQUE: boolean;
  76610. TONEMAPPING: boolean;
  76611. TONEMAPPING_ACES: boolean;
  76612. CONTRAST: boolean;
  76613. EXPOSURE: boolean;
  76614. COLORCURVES: boolean;
  76615. COLORGRADING: boolean;
  76616. COLORGRADING3D: boolean;
  76617. SAMPLER3DGREENDEPTH: boolean;
  76618. SAMPLER3DBGRMAP: boolean;
  76619. IMAGEPROCESSINGPOSTPROCESS: boolean;
  76620. }
  76621. /**
  76622. * @hidden
  76623. */
  76624. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  76625. IMAGEPROCESSING: boolean;
  76626. VIGNETTE: boolean;
  76627. VIGNETTEBLENDMODEMULTIPLY: boolean;
  76628. VIGNETTEBLENDMODEOPAQUE: boolean;
  76629. TONEMAPPING: boolean;
  76630. TONEMAPPING_ACES: boolean;
  76631. CONTRAST: boolean;
  76632. COLORCURVES: boolean;
  76633. COLORGRADING: boolean;
  76634. COLORGRADING3D: boolean;
  76635. SAMPLER3DGREENDEPTH: boolean;
  76636. SAMPLER3DBGRMAP: boolean;
  76637. IMAGEPROCESSINGPOSTPROCESS: boolean;
  76638. EXPOSURE: boolean;
  76639. constructor();
  76640. }
  76641. /**
  76642. * This groups together the common properties used for image processing either in direct forward pass
  76643. * or through post processing effect depending on the use of the image processing pipeline in your scene
  76644. * or not.
  76645. */
  76646. export class ImageProcessingConfiguration {
  76647. /**
  76648. * Default tone mapping applied in BabylonJS.
  76649. */
  76650. static readonly TONEMAPPING_STANDARD: number;
  76651. /**
  76652. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  76653. * to other engines rendering to increase portability.
  76654. */
  76655. static readonly TONEMAPPING_ACES: number;
  76656. /**
  76657. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  76658. */
  76659. colorCurves: Nullable<ColorCurves>;
  76660. private _colorCurvesEnabled;
  76661. /**
  76662. * Gets wether the color curves effect is enabled.
  76663. */
  76664. /**
  76665. * Sets wether the color curves effect is enabled.
  76666. */
  76667. colorCurvesEnabled: boolean;
  76668. private _colorGradingTexture;
  76669. /**
  76670. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  76671. */
  76672. /**
  76673. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  76674. */
  76675. colorGradingTexture: Nullable<BaseTexture>;
  76676. private _colorGradingEnabled;
  76677. /**
  76678. * Gets wether the color grading effect is enabled.
  76679. */
  76680. /**
  76681. * Sets wether the color grading effect is enabled.
  76682. */
  76683. colorGradingEnabled: boolean;
  76684. private _colorGradingWithGreenDepth;
  76685. /**
  76686. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  76687. */
  76688. /**
  76689. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  76690. */
  76691. colorGradingWithGreenDepth: boolean;
  76692. private _colorGradingBGR;
  76693. /**
  76694. * Gets wether the color grading texture contains BGR values.
  76695. */
  76696. /**
  76697. * Sets wether the color grading texture contains BGR values.
  76698. */
  76699. colorGradingBGR: boolean;
  76700. /** @hidden */
  76701. _exposure: number;
  76702. /**
  76703. * Gets the Exposure used in the effect.
  76704. */
  76705. /**
  76706. * Sets the Exposure used in the effect.
  76707. */
  76708. exposure: number;
  76709. private _toneMappingEnabled;
  76710. /**
  76711. * Gets wether the tone mapping effect is enabled.
  76712. */
  76713. /**
  76714. * Sets wether the tone mapping effect is enabled.
  76715. */
  76716. toneMappingEnabled: boolean;
  76717. private _toneMappingType;
  76718. /**
  76719. * Gets the type of tone mapping effect.
  76720. */
  76721. /**
  76722. * Sets the type of tone mapping effect used in BabylonJS.
  76723. */
  76724. toneMappingType: number;
  76725. protected _contrast: number;
  76726. /**
  76727. * Gets the contrast used in the effect.
  76728. */
  76729. /**
  76730. * Sets the contrast used in the effect.
  76731. */
  76732. contrast: number;
  76733. /**
  76734. * Vignette stretch size.
  76735. */
  76736. vignetteStretch: number;
  76737. /**
  76738. * Vignette centre X Offset.
  76739. */
  76740. vignetteCentreX: number;
  76741. /**
  76742. * Vignette centre Y Offset.
  76743. */
  76744. vignetteCentreY: number;
  76745. /**
  76746. * Vignette weight or intensity of the vignette effect.
  76747. */
  76748. vignetteWeight: number;
  76749. /**
  76750. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  76751. * if vignetteEnabled is set to true.
  76752. */
  76753. vignetteColor: Color4;
  76754. /**
  76755. * Camera field of view used by the Vignette effect.
  76756. */
  76757. vignetteCameraFov: number;
  76758. private _vignetteBlendMode;
  76759. /**
  76760. * Gets the vignette blend mode allowing different kind of effect.
  76761. */
  76762. /**
  76763. * Sets the vignette blend mode allowing different kind of effect.
  76764. */
  76765. vignetteBlendMode: number;
  76766. private _vignetteEnabled;
  76767. /**
  76768. * Gets wether the vignette effect is enabled.
  76769. */
  76770. /**
  76771. * Sets wether the vignette effect is enabled.
  76772. */
  76773. vignetteEnabled: boolean;
  76774. private _applyByPostProcess;
  76775. /**
  76776. * Gets wether the image processing is applied through a post process or not.
  76777. */
  76778. /**
  76779. * Sets wether the image processing is applied through a post process or not.
  76780. */
  76781. applyByPostProcess: boolean;
  76782. private _isEnabled;
  76783. /**
  76784. * Gets wether the image processing is enabled or not.
  76785. */
  76786. /**
  76787. * Sets wether the image processing is enabled or not.
  76788. */
  76789. isEnabled: boolean;
  76790. /**
  76791. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  76792. */
  76793. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  76794. /**
  76795. * Method called each time the image processing information changes requires to recompile the effect.
  76796. */
  76797. protected _updateParameters(): void;
  76798. /**
  76799. * Gets the current class name.
  76800. * @return "ImageProcessingConfiguration"
  76801. */
  76802. getClassName(): string;
  76803. /**
  76804. * Prepare the list of uniforms associated with the Image Processing effects.
  76805. * @param uniforms The list of uniforms used in the effect
  76806. * @param defines the list of defines currently in use
  76807. */
  76808. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  76809. /**
  76810. * Prepare the list of samplers associated with the Image Processing effects.
  76811. * @param samplersList The list of uniforms used in the effect
  76812. * @param defines the list of defines currently in use
  76813. */
  76814. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  76815. /**
  76816. * Prepare the list of defines associated to the shader.
  76817. * @param defines the list of defines to complete
  76818. * @param forPostProcess Define if we are currently in post process mode or not
  76819. */
  76820. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  76821. /**
  76822. * Returns true if all the image processing information are ready.
  76823. * @returns True if ready, otherwise, false
  76824. */
  76825. isReady(): boolean;
  76826. /**
  76827. * Binds the image processing to the shader.
  76828. * @param effect The effect to bind to
  76829. * @param overrideAspectRatio Override the aspect ratio of the effect
  76830. */
  76831. bind(effect: Effect, overrideAspectRatio?: number): void;
  76832. /**
  76833. * Clones the current image processing instance.
  76834. * @return The cloned image processing
  76835. */
  76836. clone(): ImageProcessingConfiguration;
  76837. /**
  76838. * Serializes the current image processing instance to a json representation.
  76839. * @return a JSON representation
  76840. */
  76841. serialize(): any;
  76842. /**
  76843. * Parses the image processing from a json representation.
  76844. * @param source the JSON source to parse
  76845. * @return The parsed image processing
  76846. */
  76847. static Parse(source: any): ImageProcessingConfiguration;
  76848. private static _VIGNETTEMODE_MULTIPLY;
  76849. private static _VIGNETTEMODE_OPAQUE;
  76850. /**
  76851. * Used to apply the vignette as a mix with the pixel color.
  76852. */
  76853. static readonly VIGNETTEMODE_MULTIPLY: number;
  76854. /**
  76855. * Used to apply the vignette as a replacement of the pixel color.
  76856. */
  76857. static readonly VIGNETTEMODE_OPAQUE: number;
  76858. }
  76859. }
  76860. declare module BABYLON {
  76861. /** @hidden */
  76862. export var postprocessVertexShader: {
  76863. name: string;
  76864. shader: string;
  76865. };
  76866. }
  76867. declare module BABYLON {
  76868. interface ThinEngine {
  76869. /**
  76870. * Creates a new render target texture
  76871. * @param size defines the size of the texture
  76872. * @param options defines the options used to create the texture
  76873. * @returns a new render target texture stored in an InternalTexture
  76874. */
  76875. createRenderTargetTexture(size: number | {
  76876. width: number;
  76877. height: number;
  76878. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  76879. /**
  76880. * Creates a depth stencil texture.
  76881. * This is only available in WebGL 2 or with the depth texture extension available.
  76882. * @param size The size of face edge in the texture.
  76883. * @param options The options defining the texture.
  76884. * @returns The texture
  76885. */
  76886. createDepthStencilTexture(size: number | {
  76887. width: number;
  76888. height: number;
  76889. }, options: DepthTextureCreationOptions): InternalTexture;
  76890. /** @hidden */
  76891. _createDepthStencilTexture(size: number | {
  76892. width: number;
  76893. height: number;
  76894. }, options: DepthTextureCreationOptions): InternalTexture;
  76895. }
  76896. }
  76897. declare module BABYLON {
  76898. /** Defines supported spaces */
  76899. export enum Space {
  76900. /** Local (object) space */
  76901. LOCAL = 0,
  76902. /** World space */
  76903. WORLD = 1,
  76904. /** Bone space */
  76905. BONE = 2
  76906. }
  76907. /** Defines the 3 main axes */
  76908. export class Axis {
  76909. /** X axis */
  76910. static X: Vector3;
  76911. /** Y axis */
  76912. static Y: Vector3;
  76913. /** Z axis */
  76914. static Z: Vector3;
  76915. }
  76916. }
  76917. declare module BABYLON {
  76918. /**
  76919. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  76920. * This is the base of the follow, arc rotate cameras and Free camera
  76921. * @see http://doc.babylonjs.com/features/cameras
  76922. */
  76923. export class TargetCamera extends Camera {
  76924. private static _RigCamTransformMatrix;
  76925. private static _TargetTransformMatrix;
  76926. private static _TargetFocalPoint;
  76927. /**
  76928. * Define the current direction the camera is moving to
  76929. */
  76930. cameraDirection: Vector3;
  76931. /**
  76932. * Define the current rotation the camera is rotating to
  76933. */
  76934. cameraRotation: Vector2;
  76935. /**
  76936. * When set, the up vector of the camera will be updated by the rotation of the camera
  76937. */
  76938. updateUpVectorFromRotation: boolean;
  76939. private _tmpQuaternion;
  76940. /**
  76941. * Define the current rotation of the camera
  76942. */
  76943. rotation: Vector3;
  76944. /**
  76945. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  76946. */
  76947. rotationQuaternion: Quaternion;
  76948. /**
  76949. * Define the current speed of the camera
  76950. */
  76951. speed: number;
  76952. /**
  76953. * Add constraint to the camera to prevent it to move freely in all directions and
  76954. * around all axis.
  76955. */
  76956. noRotationConstraint: boolean;
  76957. /**
  76958. * Define the current target of the camera as an object or a position.
  76959. */
  76960. lockedTarget: any;
  76961. /** @hidden */
  76962. _currentTarget: Vector3;
  76963. /** @hidden */
  76964. _initialFocalDistance: number;
  76965. /** @hidden */
  76966. _viewMatrix: Matrix;
  76967. /** @hidden */
  76968. _camMatrix: Matrix;
  76969. /** @hidden */
  76970. _cameraTransformMatrix: Matrix;
  76971. /** @hidden */
  76972. _cameraRotationMatrix: Matrix;
  76973. /** @hidden */
  76974. _referencePoint: Vector3;
  76975. /** @hidden */
  76976. _transformedReferencePoint: Vector3;
  76977. protected _globalCurrentTarget: Vector3;
  76978. protected _globalCurrentUpVector: Vector3;
  76979. /** @hidden */
  76980. _reset: () => void;
  76981. private _defaultUp;
  76982. /**
  76983. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  76984. * This is the base of the follow, arc rotate cameras and Free camera
  76985. * @see http://doc.babylonjs.com/features/cameras
  76986. * @param name Defines the name of the camera in the scene
  76987. * @param position Defines the start position of the camera in the scene
  76988. * @param scene Defines the scene the camera belongs to
  76989. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  76990. */
  76991. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  76992. /**
  76993. * Gets the position in front of the camera at a given distance.
  76994. * @param distance The distance from the camera we want the position to be
  76995. * @returns the position
  76996. */
  76997. getFrontPosition(distance: number): Vector3;
  76998. /** @hidden */
  76999. _getLockedTargetPosition(): Nullable<Vector3>;
  77000. private _storedPosition;
  77001. private _storedRotation;
  77002. private _storedRotationQuaternion;
  77003. /**
  77004. * Store current camera state of the camera (fov, position, rotation, etc..)
  77005. * @returns the camera
  77006. */
  77007. storeState(): Camera;
  77008. /**
  77009. * Restored camera state. You must call storeState() first
  77010. * @returns whether it was successful or not
  77011. * @hidden
  77012. */
  77013. _restoreStateValues(): boolean;
  77014. /** @hidden */
  77015. _initCache(): void;
  77016. /** @hidden */
  77017. _updateCache(ignoreParentClass?: boolean): void;
  77018. /** @hidden */
  77019. _isSynchronizedViewMatrix(): boolean;
  77020. /** @hidden */
  77021. _computeLocalCameraSpeed(): number;
  77022. /**
  77023. * Defines the target the camera should look at.
  77024. * @param target Defines the new target as a Vector or a mesh
  77025. */
  77026. setTarget(target: Vector3): void;
  77027. /**
  77028. * Return the current target position of the camera. This value is expressed in local space.
  77029. * @returns the target position
  77030. */
  77031. getTarget(): Vector3;
  77032. /** @hidden */
  77033. _decideIfNeedsToMove(): boolean;
  77034. /** @hidden */
  77035. _updatePosition(): void;
  77036. /** @hidden */
  77037. _checkInputs(): void;
  77038. protected _updateCameraRotationMatrix(): void;
  77039. /**
  77040. * 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)
  77041. * @returns the current camera
  77042. */
  77043. private _rotateUpVectorWithCameraRotationMatrix;
  77044. private _cachedRotationZ;
  77045. private _cachedQuaternionRotationZ;
  77046. /** @hidden */
  77047. _getViewMatrix(): Matrix;
  77048. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  77049. /**
  77050. * @hidden
  77051. */
  77052. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  77053. /**
  77054. * @hidden
  77055. */
  77056. _updateRigCameras(): void;
  77057. private _getRigCamPositionAndTarget;
  77058. /**
  77059. * Gets the current object class name.
  77060. * @return the class name
  77061. */
  77062. getClassName(): string;
  77063. }
  77064. }
  77065. declare module BABYLON {
  77066. /**
  77067. * Gather the list of keyboard event types as constants.
  77068. */
  77069. export class KeyboardEventTypes {
  77070. /**
  77071. * The keydown event is fired when a key becomes active (pressed).
  77072. */
  77073. static readonly KEYDOWN: number;
  77074. /**
  77075. * The keyup event is fired when a key has been released.
  77076. */
  77077. static readonly KEYUP: number;
  77078. }
  77079. /**
  77080. * This class is used to store keyboard related info for the onKeyboardObservable event.
  77081. */
  77082. export class KeyboardInfo {
  77083. /**
  77084. * Defines the type of event (KeyboardEventTypes)
  77085. */
  77086. type: number;
  77087. /**
  77088. * Defines the related dom event
  77089. */
  77090. event: KeyboardEvent;
  77091. /**
  77092. * Instantiates a new keyboard info.
  77093. * This class is used to store keyboard related info for the onKeyboardObservable event.
  77094. * @param type Defines the type of event (KeyboardEventTypes)
  77095. * @param event Defines the related dom event
  77096. */
  77097. constructor(
  77098. /**
  77099. * Defines the type of event (KeyboardEventTypes)
  77100. */
  77101. type: number,
  77102. /**
  77103. * Defines the related dom event
  77104. */
  77105. event: KeyboardEvent);
  77106. }
  77107. /**
  77108. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  77109. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  77110. */
  77111. export class KeyboardInfoPre extends KeyboardInfo {
  77112. /**
  77113. * Defines the type of event (KeyboardEventTypes)
  77114. */
  77115. type: number;
  77116. /**
  77117. * Defines the related dom event
  77118. */
  77119. event: KeyboardEvent;
  77120. /**
  77121. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  77122. */
  77123. skipOnPointerObservable: boolean;
  77124. /**
  77125. * Instantiates a new keyboard pre info.
  77126. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  77127. * @param type Defines the type of event (KeyboardEventTypes)
  77128. * @param event Defines the related dom event
  77129. */
  77130. constructor(
  77131. /**
  77132. * Defines the type of event (KeyboardEventTypes)
  77133. */
  77134. type: number,
  77135. /**
  77136. * Defines the related dom event
  77137. */
  77138. event: KeyboardEvent);
  77139. }
  77140. }
  77141. declare module BABYLON {
  77142. /**
  77143. * Manage the keyboard inputs to control the movement of a free camera.
  77144. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  77145. */
  77146. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  77147. /**
  77148. * Defines the camera the input is attached to.
  77149. */
  77150. camera: FreeCamera;
  77151. /**
  77152. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  77153. */
  77154. keysUp: number[];
  77155. /**
  77156. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  77157. */
  77158. keysDown: number[];
  77159. /**
  77160. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  77161. */
  77162. keysLeft: number[];
  77163. /**
  77164. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  77165. */
  77166. keysRight: number[];
  77167. private _keys;
  77168. private _onCanvasBlurObserver;
  77169. private _onKeyboardObserver;
  77170. private _engine;
  77171. private _scene;
  77172. /**
  77173. * Attach the input controls to a specific dom element to get the input from.
  77174. * @param element Defines the element the controls should be listened from
  77175. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  77176. */
  77177. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  77178. /**
  77179. * Detach the current controls from the specified dom element.
  77180. * @param element Defines the element to stop listening the inputs from
  77181. */
  77182. detachControl(element: Nullable<HTMLElement>): void;
  77183. /**
  77184. * Update the current camera state depending on the inputs that have been used this frame.
  77185. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  77186. */
  77187. checkInputs(): void;
  77188. /**
  77189. * Gets the class name of the current intput.
  77190. * @returns the class name
  77191. */
  77192. getClassName(): string;
  77193. /** @hidden */
  77194. _onLostFocus(): void;
  77195. /**
  77196. * Get the friendly name associated with the input class.
  77197. * @returns the input friendly name
  77198. */
  77199. getSimpleName(): string;
  77200. }
  77201. }
  77202. declare module BABYLON {
  77203. /**
  77204. * Interface describing all the common properties and methods a shadow light needs to implement.
  77205. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  77206. * as well as binding the different shadow properties to the effects.
  77207. */
  77208. export interface IShadowLight extends Light {
  77209. /**
  77210. * The light id in the scene (used in scene.findLighById for instance)
  77211. */
  77212. id: string;
  77213. /**
  77214. * The position the shdow will be casted from.
  77215. */
  77216. position: Vector3;
  77217. /**
  77218. * In 2d mode (needCube being false), the direction used to cast the shadow.
  77219. */
  77220. direction: Vector3;
  77221. /**
  77222. * The transformed position. Position of the light in world space taking parenting in account.
  77223. */
  77224. transformedPosition: Vector3;
  77225. /**
  77226. * The transformed direction. Direction of the light in world space taking parenting in account.
  77227. */
  77228. transformedDirection: Vector3;
  77229. /**
  77230. * The friendly name of the light in the scene.
  77231. */
  77232. name: string;
  77233. /**
  77234. * Defines the shadow projection clipping minimum z value.
  77235. */
  77236. shadowMinZ: number;
  77237. /**
  77238. * Defines the shadow projection clipping maximum z value.
  77239. */
  77240. shadowMaxZ: number;
  77241. /**
  77242. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  77243. * @returns true if the information has been computed, false if it does not need to (no parenting)
  77244. */
  77245. computeTransformedInformation(): boolean;
  77246. /**
  77247. * Gets the scene the light belongs to.
  77248. * @returns The scene
  77249. */
  77250. getScene(): Scene;
  77251. /**
  77252. * Callback defining a custom Projection Matrix Builder.
  77253. * This can be used to override the default projection matrix computation.
  77254. */
  77255. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  77256. /**
  77257. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  77258. * @param matrix The materix to updated with the projection information
  77259. * @param viewMatrix The transform matrix of the light
  77260. * @param renderList The list of mesh to render in the map
  77261. * @returns The current light
  77262. */
  77263. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  77264. /**
  77265. * Gets the current depth scale used in ESM.
  77266. * @returns The scale
  77267. */
  77268. getDepthScale(): number;
  77269. /**
  77270. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  77271. * @returns true if a cube texture needs to be use
  77272. */
  77273. needCube(): boolean;
  77274. /**
  77275. * Detects if the projection matrix requires to be recomputed this frame.
  77276. * @returns true if it requires to be recomputed otherwise, false.
  77277. */
  77278. needProjectionMatrixCompute(): boolean;
  77279. /**
  77280. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  77281. */
  77282. forceProjectionMatrixCompute(): void;
  77283. /**
  77284. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  77285. * @param faceIndex The index of the face we are computed the direction to generate shadow
  77286. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  77287. */
  77288. getShadowDirection(faceIndex?: number): Vector3;
  77289. /**
  77290. * Gets the minZ used for shadow according to both the scene and the light.
  77291. * @param activeCamera The camera we are returning the min for
  77292. * @returns the depth min z
  77293. */
  77294. getDepthMinZ(activeCamera: Camera): number;
  77295. /**
  77296. * Gets the maxZ used for shadow according to both the scene and the light.
  77297. * @param activeCamera The camera we are returning the max for
  77298. * @returns the depth max z
  77299. */
  77300. getDepthMaxZ(activeCamera: Camera): number;
  77301. }
  77302. /**
  77303. * Base implementation IShadowLight
  77304. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  77305. */
  77306. export abstract class ShadowLight extends Light implements IShadowLight {
  77307. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  77308. protected _position: Vector3;
  77309. protected _setPosition(value: Vector3): void;
  77310. /**
  77311. * Sets the position the shadow will be casted from. Also use as the light position for both
  77312. * point and spot lights.
  77313. */
  77314. /**
  77315. * Sets the position the shadow will be casted from. Also use as the light position for both
  77316. * point and spot lights.
  77317. */
  77318. position: Vector3;
  77319. protected _direction: Vector3;
  77320. protected _setDirection(value: Vector3): void;
  77321. /**
  77322. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  77323. * Also use as the light direction on spot and directional lights.
  77324. */
  77325. /**
  77326. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  77327. * Also use as the light direction on spot and directional lights.
  77328. */
  77329. direction: Vector3;
  77330. private _shadowMinZ;
  77331. /**
  77332. * Gets the shadow projection clipping minimum z value.
  77333. */
  77334. /**
  77335. * Sets the shadow projection clipping minimum z value.
  77336. */
  77337. shadowMinZ: number;
  77338. private _shadowMaxZ;
  77339. /**
  77340. * Sets the shadow projection clipping maximum z value.
  77341. */
  77342. /**
  77343. * Gets the shadow projection clipping maximum z value.
  77344. */
  77345. shadowMaxZ: number;
  77346. /**
  77347. * Callback defining a custom Projection Matrix Builder.
  77348. * This can be used to override the default projection matrix computation.
  77349. */
  77350. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  77351. /**
  77352. * The transformed position. Position of the light in world space taking parenting in account.
  77353. */
  77354. transformedPosition: Vector3;
  77355. /**
  77356. * The transformed direction. Direction of the light in world space taking parenting in account.
  77357. */
  77358. transformedDirection: Vector3;
  77359. private _needProjectionMatrixCompute;
  77360. /**
  77361. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  77362. * @returns true if the information has been computed, false if it does not need to (no parenting)
  77363. */
  77364. computeTransformedInformation(): boolean;
  77365. /**
  77366. * Return the depth scale used for the shadow map.
  77367. * @returns the depth scale.
  77368. */
  77369. getDepthScale(): number;
  77370. /**
  77371. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  77372. * @param faceIndex The index of the face we are computed the direction to generate shadow
  77373. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  77374. */
  77375. getShadowDirection(faceIndex?: number): Vector3;
  77376. /**
  77377. * Returns the ShadowLight absolute position in the World.
  77378. * @returns the position vector in world space
  77379. */
  77380. getAbsolutePosition(): Vector3;
  77381. /**
  77382. * Sets the ShadowLight direction toward the passed target.
  77383. * @param target The point to target in local space
  77384. * @returns the updated ShadowLight direction
  77385. */
  77386. setDirectionToTarget(target: Vector3): Vector3;
  77387. /**
  77388. * Returns the light rotation in euler definition.
  77389. * @returns the x y z rotation in local space.
  77390. */
  77391. getRotation(): Vector3;
  77392. /**
  77393. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  77394. * @returns true if a cube texture needs to be use
  77395. */
  77396. needCube(): boolean;
  77397. /**
  77398. * Detects if the projection matrix requires to be recomputed this frame.
  77399. * @returns true if it requires to be recomputed otherwise, false.
  77400. */
  77401. needProjectionMatrixCompute(): boolean;
  77402. /**
  77403. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  77404. */
  77405. forceProjectionMatrixCompute(): void;
  77406. /** @hidden */
  77407. _initCache(): void;
  77408. /** @hidden */
  77409. _isSynchronized(): boolean;
  77410. /**
  77411. * Computes the world matrix of the node
  77412. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  77413. * @returns the world matrix
  77414. */
  77415. computeWorldMatrix(force?: boolean): Matrix;
  77416. /**
  77417. * Gets the minZ used for shadow according to both the scene and the light.
  77418. * @param activeCamera The camera we are returning the min for
  77419. * @returns the depth min z
  77420. */
  77421. getDepthMinZ(activeCamera: Camera): number;
  77422. /**
  77423. * Gets the maxZ used for shadow according to both the scene and the light.
  77424. * @param activeCamera The camera we are returning the max for
  77425. * @returns the depth max z
  77426. */
  77427. getDepthMaxZ(activeCamera: Camera): number;
  77428. /**
  77429. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  77430. * @param matrix The materix to updated with the projection information
  77431. * @param viewMatrix The transform matrix of the light
  77432. * @param renderList The list of mesh to render in the map
  77433. * @returns The current light
  77434. */
  77435. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  77436. }
  77437. }
  77438. declare module BABYLON {
  77439. /**
  77440. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  77441. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  77442. */
  77443. export class EffectFallbacks implements IEffectFallbacks {
  77444. private _defines;
  77445. private _currentRank;
  77446. private _maxRank;
  77447. private _mesh;
  77448. /**
  77449. * Removes the fallback from the bound mesh.
  77450. */
  77451. unBindMesh(): void;
  77452. /**
  77453. * Adds a fallback on the specified property.
  77454. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  77455. * @param define The name of the define in the shader
  77456. */
  77457. addFallback(rank: number, define: string): void;
  77458. /**
  77459. * Sets the mesh to use CPU skinning when needing to fallback.
  77460. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  77461. * @param mesh The mesh to use the fallbacks.
  77462. */
  77463. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  77464. /**
  77465. * Checks to see if more fallbacks are still availible.
  77466. */
  77467. readonly hasMoreFallbacks: boolean;
  77468. /**
  77469. * Removes the defines that should be removed when falling back.
  77470. * @param currentDefines defines the current define statements for the shader.
  77471. * @param effect defines the current effect we try to compile
  77472. * @returns The resulting defines with defines of the current rank removed.
  77473. */
  77474. reduce(currentDefines: string, effect: Effect): string;
  77475. }
  77476. }
  77477. declare module BABYLON {
  77478. /**
  77479. * "Static Class" containing the most commonly used helper while dealing with material for
  77480. * rendering purpose.
  77481. *
  77482. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  77483. *
  77484. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  77485. */
  77486. export class MaterialHelper {
  77487. /**
  77488. * Bind the current view position to an effect.
  77489. * @param effect The effect to be bound
  77490. * @param scene The scene the eyes position is used from
  77491. */
  77492. static BindEyePosition(effect: Effect, scene: Scene): void;
  77493. /**
  77494. * Helps preparing the defines values about the UVs in used in the effect.
  77495. * UVs are shared as much as we can accross channels in the shaders.
  77496. * @param texture The texture we are preparing the UVs for
  77497. * @param defines The defines to update
  77498. * @param key The channel key "diffuse", "specular"... used in the shader
  77499. */
  77500. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  77501. /**
  77502. * Binds a texture matrix value to its corrsponding uniform
  77503. * @param texture The texture to bind the matrix for
  77504. * @param uniformBuffer The uniform buffer receivin the data
  77505. * @param key The channel key "diffuse", "specular"... used in the shader
  77506. */
  77507. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  77508. /**
  77509. * Gets the current status of the fog (should it be enabled?)
  77510. * @param mesh defines the mesh to evaluate for fog support
  77511. * @param scene defines the hosting scene
  77512. * @returns true if fog must be enabled
  77513. */
  77514. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  77515. /**
  77516. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  77517. * @param mesh defines the current mesh
  77518. * @param scene defines the current scene
  77519. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  77520. * @param pointsCloud defines if point cloud rendering has to be turned on
  77521. * @param fogEnabled defines if fog has to be turned on
  77522. * @param alphaTest defines if alpha testing has to be turned on
  77523. * @param defines defines the current list of defines
  77524. */
  77525. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  77526. /**
  77527. * Helper used to prepare the list of defines associated with frame values for shader compilation
  77528. * @param scene defines the current scene
  77529. * @param engine defines the current engine
  77530. * @param defines specifies the list of active defines
  77531. * @param useInstances defines if instances have to be turned on
  77532. * @param useClipPlane defines if clip plane have to be turned on
  77533. */
  77534. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  77535. /**
  77536. * Prepares the defines for bones
  77537. * @param mesh The mesh containing the geometry data we will draw
  77538. * @param defines The defines to update
  77539. */
  77540. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  77541. /**
  77542. * Prepares the defines for morph targets
  77543. * @param mesh The mesh containing the geometry data we will draw
  77544. * @param defines The defines to update
  77545. */
  77546. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  77547. /**
  77548. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  77549. * @param mesh The mesh containing the geometry data we will draw
  77550. * @param defines The defines to update
  77551. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  77552. * @param useBones Precise whether bones should be used or not (override mesh info)
  77553. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  77554. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  77555. * @returns false if defines are considered not dirty and have not been checked
  77556. */
  77557. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  77558. /**
  77559. * Prepares the defines related to multiview
  77560. * @param scene The scene we are intending to draw
  77561. * @param defines The defines to update
  77562. */
  77563. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  77564. /**
  77565. * Prepares the defines related to the light information passed in parameter
  77566. * @param scene The scene we are intending to draw
  77567. * @param mesh The mesh the effect is compiling for
  77568. * @param light The light the effect is compiling for
  77569. * @param lightIndex The index of the light
  77570. * @param defines The defines to update
  77571. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  77572. * @param state Defines the current state regarding what is needed (normals, etc...)
  77573. */
  77574. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  77575. needNormals: boolean;
  77576. needRebuild: boolean;
  77577. shadowEnabled: boolean;
  77578. specularEnabled: boolean;
  77579. lightmapMode: boolean;
  77580. }): void;
  77581. /**
  77582. * Prepares the defines related to the light information passed in parameter
  77583. * @param scene The scene we are intending to draw
  77584. * @param mesh The mesh the effect is compiling for
  77585. * @param defines The defines to update
  77586. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  77587. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  77588. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  77589. * @returns true if normals will be required for the rest of the effect
  77590. */
  77591. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  77592. /**
  77593. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  77594. * @param lightIndex defines the light index
  77595. * @param uniformsList The uniform list
  77596. * @param samplersList The sampler list
  77597. * @param projectedLightTexture defines if projected texture must be used
  77598. * @param uniformBuffersList defines an optional list of uniform buffers
  77599. */
  77600. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  77601. /**
  77602. * Prepares the uniforms and samplers list to be used in the effect
  77603. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  77604. * @param samplersList The sampler list
  77605. * @param defines The defines helping in the list generation
  77606. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  77607. */
  77608. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  77609. /**
  77610. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  77611. * @param defines The defines to update while falling back
  77612. * @param fallbacks The authorized effect fallbacks
  77613. * @param maxSimultaneousLights The maximum number of lights allowed
  77614. * @param rank the current rank of the Effect
  77615. * @returns The newly affected rank
  77616. */
  77617. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  77618. private static _TmpMorphInfluencers;
  77619. /**
  77620. * Prepares the list of attributes required for morph targets according to the effect defines.
  77621. * @param attribs The current list of supported attribs
  77622. * @param mesh The mesh to prepare the morph targets attributes for
  77623. * @param influencers The number of influencers
  77624. */
  77625. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  77626. /**
  77627. * Prepares the list of attributes required for morph targets according to the effect defines.
  77628. * @param attribs The current list of supported attribs
  77629. * @param mesh The mesh to prepare the morph targets attributes for
  77630. * @param defines The current Defines of the effect
  77631. */
  77632. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  77633. /**
  77634. * Prepares the list of attributes required for bones according to the effect defines.
  77635. * @param attribs The current list of supported attribs
  77636. * @param mesh The mesh to prepare the bones attributes for
  77637. * @param defines The current Defines of the effect
  77638. * @param fallbacks The current efffect fallback strategy
  77639. */
  77640. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  77641. /**
  77642. * Check and prepare the list of attributes required for instances according to the effect defines.
  77643. * @param attribs The current list of supported attribs
  77644. * @param defines The current MaterialDefines of the effect
  77645. */
  77646. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  77647. /**
  77648. * Add the list of attributes required for instances to the attribs array.
  77649. * @param attribs The current list of supported attribs
  77650. */
  77651. static PushAttributesForInstances(attribs: string[]): void;
  77652. /**
  77653. * Binds the light information to the effect.
  77654. * @param light The light containing the generator
  77655. * @param effect The effect we are binding the data to
  77656. * @param lightIndex The light index in the effect used to render
  77657. */
  77658. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  77659. /**
  77660. * Binds the lights information from the scene to the effect for the given mesh.
  77661. * @param light Light to bind
  77662. * @param lightIndex Light index
  77663. * @param scene The scene where the light belongs to
  77664. * @param effect The effect we are binding the data to
  77665. * @param useSpecular Defines if specular is supported
  77666. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  77667. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  77668. */
  77669. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  77670. /**
  77671. * Binds the lights information from the scene to the effect for the given mesh.
  77672. * @param scene The scene the lights belongs to
  77673. * @param mesh The mesh we are binding the information to render
  77674. * @param effect The effect we are binding the data to
  77675. * @param defines The generated defines for the effect
  77676. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  77677. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  77678. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  77679. */
  77680. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  77681. private static _tempFogColor;
  77682. /**
  77683. * Binds the fog information from the scene to the effect for the given mesh.
  77684. * @param scene The scene the lights belongs to
  77685. * @param mesh The mesh we are binding the information to render
  77686. * @param effect The effect we are binding the data to
  77687. * @param linearSpace Defines if the fog effect is applied in linear space
  77688. */
  77689. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  77690. /**
  77691. * Binds the bones information from the mesh to the effect.
  77692. * @param mesh The mesh we are binding the information to render
  77693. * @param effect The effect we are binding the data to
  77694. */
  77695. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  77696. /**
  77697. * Binds the morph targets information from the mesh to the effect.
  77698. * @param abstractMesh The mesh we are binding the information to render
  77699. * @param effect The effect we are binding the data to
  77700. */
  77701. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  77702. /**
  77703. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  77704. * @param defines The generated defines used in the effect
  77705. * @param effect The effect we are binding the data to
  77706. * @param scene The scene we are willing to render with logarithmic scale for
  77707. */
  77708. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  77709. /**
  77710. * Binds the clip plane information from the scene to the effect.
  77711. * @param scene The scene the clip plane information are extracted from
  77712. * @param effect The effect we are binding the data to
  77713. */
  77714. static BindClipPlane(effect: Effect, scene: Scene): void;
  77715. }
  77716. }
  77717. declare module BABYLON {
  77718. /** @hidden */
  77719. export var packingFunctions: {
  77720. name: string;
  77721. shader: string;
  77722. };
  77723. }
  77724. declare module BABYLON {
  77725. /** @hidden */
  77726. export var shadowMapPixelShader: {
  77727. name: string;
  77728. shader: string;
  77729. };
  77730. }
  77731. declare module BABYLON {
  77732. /** @hidden */
  77733. export var bonesDeclaration: {
  77734. name: string;
  77735. shader: string;
  77736. };
  77737. }
  77738. declare module BABYLON {
  77739. /** @hidden */
  77740. export var morphTargetsVertexGlobalDeclaration: {
  77741. name: string;
  77742. shader: string;
  77743. };
  77744. }
  77745. declare module BABYLON {
  77746. /** @hidden */
  77747. export var morphTargetsVertexDeclaration: {
  77748. name: string;
  77749. shader: string;
  77750. };
  77751. }
  77752. declare module BABYLON {
  77753. /** @hidden */
  77754. export var instancesDeclaration: {
  77755. name: string;
  77756. shader: string;
  77757. };
  77758. }
  77759. declare module BABYLON {
  77760. /** @hidden */
  77761. export var helperFunctions: {
  77762. name: string;
  77763. shader: string;
  77764. };
  77765. }
  77766. declare module BABYLON {
  77767. /** @hidden */
  77768. export var morphTargetsVertex: {
  77769. name: string;
  77770. shader: string;
  77771. };
  77772. }
  77773. declare module BABYLON {
  77774. /** @hidden */
  77775. export var instancesVertex: {
  77776. name: string;
  77777. shader: string;
  77778. };
  77779. }
  77780. declare module BABYLON {
  77781. /** @hidden */
  77782. export var bonesVertex: {
  77783. name: string;
  77784. shader: string;
  77785. };
  77786. }
  77787. declare module BABYLON {
  77788. /** @hidden */
  77789. export var shadowMapVertexShader: {
  77790. name: string;
  77791. shader: string;
  77792. };
  77793. }
  77794. declare module BABYLON {
  77795. /** @hidden */
  77796. export var depthBoxBlurPixelShader: {
  77797. name: string;
  77798. shader: string;
  77799. };
  77800. }
  77801. declare module BABYLON {
  77802. /**
  77803. * Defines the options associated with the creation of a custom shader for a shadow generator.
  77804. */
  77805. export interface ICustomShaderOptions {
  77806. /**
  77807. * Gets or sets the custom shader name to use
  77808. */
  77809. shaderName: string;
  77810. /**
  77811. * The list of attribute names used in the shader
  77812. */
  77813. attributes?: string[];
  77814. /**
  77815. * The list of unifrom names used in the shader
  77816. */
  77817. uniforms?: string[];
  77818. /**
  77819. * The list of sampler names used in the shader
  77820. */
  77821. samplers?: string[];
  77822. /**
  77823. * The list of defines used in the shader
  77824. */
  77825. defines?: string[];
  77826. }
  77827. /**
  77828. * Interface to implement to create a shadow generator compatible with BJS.
  77829. */
  77830. export interface IShadowGenerator {
  77831. /**
  77832. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  77833. * @returns The render target texture if present otherwise, null
  77834. */
  77835. getShadowMap(): Nullable<RenderTargetTexture>;
  77836. /**
  77837. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  77838. * @returns The render target texture if the shadow map is present otherwise, null
  77839. */
  77840. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  77841. /**
  77842. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  77843. * @param subMesh The submesh we want to render in the shadow map
  77844. * @param useInstances Defines wether will draw in the map using instances
  77845. * @returns true if ready otherwise, false
  77846. */
  77847. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  77848. /**
  77849. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  77850. * @param defines Defines of the material we want to update
  77851. * @param lightIndex Index of the light in the enabled light list of the material
  77852. */
  77853. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  77854. /**
  77855. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  77856. * defined in the generator but impacting the effect).
  77857. * It implies the unifroms available on the materials are the standard BJS ones.
  77858. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  77859. * @param effect The effect we are binfing the information for
  77860. */
  77861. bindShadowLight(lightIndex: string, effect: Effect): void;
  77862. /**
  77863. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  77864. * (eq to shadow prjection matrix * light transform matrix)
  77865. * @returns The transform matrix used to create the shadow map
  77866. */
  77867. getTransformMatrix(): Matrix;
  77868. /**
  77869. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  77870. * Cube and 2D textures for instance.
  77871. */
  77872. recreateShadowMap(): void;
  77873. /**
  77874. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  77875. * @param onCompiled Callback triggered at the and of the effects compilation
  77876. * @param options Sets of optional options forcing the compilation with different modes
  77877. */
  77878. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  77879. useInstances: boolean;
  77880. }>): void;
  77881. /**
  77882. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  77883. * @param options Sets of optional options forcing the compilation with different modes
  77884. * @returns A promise that resolves when the compilation completes
  77885. */
  77886. forceCompilationAsync(options?: Partial<{
  77887. useInstances: boolean;
  77888. }>): Promise<void>;
  77889. /**
  77890. * Serializes the shadow generator setup to a json object.
  77891. * @returns The serialized JSON object
  77892. */
  77893. serialize(): any;
  77894. /**
  77895. * Disposes the Shadow map and related Textures and effects.
  77896. */
  77897. dispose(): void;
  77898. }
  77899. /**
  77900. * Default implementation IShadowGenerator.
  77901. * This is the main object responsible of generating shadows in the framework.
  77902. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  77903. */
  77904. export class ShadowGenerator implements IShadowGenerator {
  77905. /**
  77906. * Shadow generator mode None: no filtering applied.
  77907. */
  77908. static readonly FILTER_NONE: number;
  77909. /**
  77910. * Shadow generator mode ESM: Exponential Shadow Mapping.
  77911. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  77912. */
  77913. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  77914. /**
  77915. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  77916. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  77917. */
  77918. static readonly FILTER_POISSONSAMPLING: number;
  77919. /**
  77920. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  77921. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  77922. */
  77923. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  77924. /**
  77925. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  77926. * edge artifacts on steep falloff.
  77927. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  77928. */
  77929. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  77930. /**
  77931. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  77932. * edge artifacts on steep falloff.
  77933. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  77934. */
  77935. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  77936. /**
  77937. * Shadow generator mode PCF: Percentage Closer Filtering
  77938. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  77939. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  77940. */
  77941. static readonly FILTER_PCF: number;
  77942. /**
  77943. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  77944. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  77945. * Contact Hardening
  77946. */
  77947. static readonly FILTER_PCSS: number;
  77948. /**
  77949. * Reserved for PCF and PCSS
  77950. * Highest Quality.
  77951. *
  77952. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  77953. *
  77954. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  77955. */
  77956. static readonly QUALITY_HIGH: number;
  77957. /**
  77958. * Reserved for PCF and PCSS
  77959. * Good tradeoff for quality/perf cross devices
  77960. *
  77961. * Execute PCF on a 3*3 kernel.
  77962. *
  77963. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  77964. */
  77965. static readonly QUALITY_MEDIUM: number;
  77966. /**
  77967. * Reserved for PCF and PCSS
  77968. * The lowest quality but the fastest.
  77969. *
  77970. * Execute PCF on a 1*1 kernel.
  77971. *
  77972. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  77973. */
  77974. static readonly QUALITY_LOW: number;
  77975. /** Gets or sets the custom shader name to use */
  77976. customShaderOptions: ICustomShaderOptions;
  77977. /**
  77978. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  77979. */
  77980. onBeforeShadowMapRenderObservable: Observable<Effect>;
  77981. /**
  77982. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  77983. */
  77984. onAfterShadowMapRenderObservable: Observable<Effect>;
  77985. /**
  77986. * Observable triggered before a mesh is rendered in the shadow map.
  77987. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  77988. */
  77989. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  77990. /**
  77991. * Observable triggered after a mesh is rendered in the shadow map.
  77992. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  77993. */
  77994. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  77995. private _bias;
  77996. /**
  77997. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  77998. */
  77999. /**
  78000. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  78001. */
  78002. bias: number;
  78003. private _normalBias;
  78004. /**
  78005. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  78006. */
  78007. /**
  78008. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  78009. */
  78010. normalBias: number;
  78011. private _blurBoxOffset;
  78012. /**
  78013. * Gets the blur box offset: offset applied during the blur pass.
  78014. * Only useful if useKernelBlur = false
  78015. */
  78016. /**
  78017. * Sets the blur box offset: offset applied during the blur pass.
  78018. * Only useful if useKernelBlur = false
  78019. */
  78020. blurBoxOffset: number;
  78021. private _blurScale;
  78022. /**
  78023. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  78024. * 2 means half of the size.
  78025. */
  78026. /**
  78027. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  78028. * 2 means half of the size.
  78029. */
  78030. blurScale: number;
  78031. private _blurKernel;
  78032. /**
  78033. * Gets the blur kernel: kernel size of the blur pass.
  78034. * Only useful if useKernelBlur = true
  78035. */
  78036. /**
  78037. * Sets the blur kernel: kernel size of the blur pass.
  78038. * Only useful if useKernelBlur = true
  78039. */
  78040. blurKernel: number;
  78041. private _useKernelBlur;
  78042. /**
  78043. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  78044. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  78045. */
  78046. /**
  78047. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  78048. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  78049. */
  78050. useKernelBlur: boolean;
  78051. private _depthScale;
  78052. /**
  78053. * Gets the depth scale used in ESM mode.
  78054. */
  78055. /**
  78056. * Sets the depth scale used in ESM mode.
  78057. * This can override the scale stored on the light.
  78058. */
  78059. depthScale: number;
  78060. private _filter;
  78061. /**
  78062. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  78063. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  78064. */
  78065. /**
  78066. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  78067. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  78068. */
  78069. filter: number;
  78070. /**
  78071. * Gets if the current filter is set to Poisson Sampling.
  78072. */
  78073. /**
  78074. * Sets the current filter to Poisson Sampling.
  78075. */
  78076. usePoissonSampling: boolean;
  78077. /**
  78078. * Gets if the current filter is set to ESM.
  78079. */
  78080. /**
  78081. * Sets the current filter is to ESM.
  78082. */
  78083. useExponentialShadowMap: boolean;
  78084. /**
  78085. * Gets if the current filter is set to filtered ESM.
  78086. */
  78087. /**
  78088. * Gets if the current filter is set to filtered ESM.
  78089. */
  78090. useBlurExponentialShadowMap: boolean;
  78091. /**
  78092. * Gets if the current filter is set to "close ESM" (using the inverse of the
  78093. * exponential to prevent steep falloff artifacts).
  78094. */
  78095. /**
  78096. * Sets the current filter to "close ESM" (using the inverse of the
  78097. * exponential to prevent steep falloff artifacts).
  78098. */
  78099. useCloseExponentialShadowMap: boolean;
  78100. /**
  78101. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  78102. * exponential to prevent steep falloff artifacts).
  78103. */
  78104. /**
  78105. * Sets the current filter to filtered "close ESM" (using the inverse of the
  78106. * exponential to prevent steep falloff artifacts).
  78107. */
  78108. useBlurCloseExponentialShadowMap: boolean;
  78109. /**
  78110. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  78111. */
  78112. /**
  78113. * Sets the current filter to "PCF" (percentage closer filtering).
  78114. */
  78115. usePercentageCloserFiltering: boolean;
  78116. private _filteringQuality;
  78117. /**
  78118. * Gets the PCF or PCSS Quality.
  78119. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  78120. */
  78121. /**
  78122. * Sets the PCF or PCSS Quality.
  78123. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  78124. */
  78125. filteringQuality: number;
  78126. /**
  78127. * Gets if the current filter is set to "PCSS" (contact hardening).
  78128. */
  78129. /**
  78130. * Sets the current filter to "PCSS" (contact hardening).
  78131. */
  78132. useContactHardeningShadow: boolean;
  78133. private _contactHardeningLightSizeUVRatio;
  78134. /**
  78135. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  78136. * Using a ratio helps keeping shape stability independently of the map size.
  78137. *
  78138. * It does not account for the light projection as it was having too much
  78139. * instability during the light setup or during light position changes.
  78140. *
  78141. * Only valid if useContactHardeningShadow is true.
  78142. */
  78143. /**
  78144. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  78145. * Using a ratio helps keeping shape stability independently of the map size.
  78146. *
  78147. * It does not account for the light projection as it was having too much
  78148. * instability during the light setup or during light position changes.
  78149. *
  78150. * Only valid if useContactHardeningShadow is true.
  78151. */
  78152. contactHardeningLightSizeUVRatio: number;
  78153. private _darkness;
  78154. /** Gets or sets the actual darkness of a shadow */
  78155. darkness: number;
  78156. /**
  78157. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  78158. * 0 means strongest and 1 would means no shadow.
  78159. * @returns the darkness.
  78160. */
  78161. getDarkness(): number;
  78162. /**
  78163. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  78164. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  78165. * @returns the shadow generator allowing fluent coding.
  78166. */
  78167. setDarkness(darkness: number): ShadowGenerator;
  78168. private _transparencyShadow;
  78169. /** Gets or sets the ability to have transparent shadow */
  78170. transparencyShadow: boolean;
  78171. /**
  78172. * Sets the ability to have transparent shadow (boolean).
  78173. * @param transparent True if transparent else False
  78174. * @returns the shadow generator allowing fluent coding
  78175. */
  78176. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  78177. private _shadowMap;
  78178. private _shadowMap2;
  78179. /**
  78180. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  78181. * @returns The render target texture if present otherwise, null
  78182. */
  78183. getShadowMap(): Nullable<RenderTargetTexture>;
  78184. /**
  78185. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  78186. * @returns The render target texture if the shadow map is present otherwise, null
  78187. */
  78188. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  78189. /**
  78190. * Gets the class name of that object
  78191. * @returns "ShadowGenerator"
  78192. */
  78193. getClassName(): string;
  78194. /**
  78195. * Helper function to add a mesh and its descendants to the list of shadow casters.
  78196. * @param mesh Mesh to add
  78197. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  78198. * @returns the Shadow Generator itself
  78199. */
  78200. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  78201. /**
  78202. * Helper function to remove a mesh and its descendants from the list of shadow casters
  78203. * @param mesh Mesh to remove
  78204. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  78205. * @returns the Shadow Generator itself
  78206. */
  78207. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  78208. /**
  78209. * Controls the extent to which the shadows fade out at the edge of the frustum
  78210. * Used only by directionals and spots
  78211. */
  78212. frustumEdgeFalloff: number;
  78213. private _light;
  78214. /**
  78215. * Returns the associated light object.
  78216. * @returns the light generating the shadow
  78217. */
  78218. getLight(): IShadowLight;
  78219. /**
  78220. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  78221. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  78222. * It might on the other hand introduce peter panning.
  78223. */
  78224. forceBackFacesOnly: boolean;
  78225. private _scene;
  78226. private _lightDirection;
  78227. private _effect;
  78228. private _viewMatrix;
  78229. private _projectionMatrix;
  78230. private _transformMatrix;
  78231. private _cachedPosition;
  78232. private _cachedDirection;
  78233. private _cachedDefines;
  78234. private _currentRenderID;
  78235. private _boxBlurPostprocess;
  78236. private _kernelBlurXPostprocess;
  78237. private _kernelBlurYPostprocess;
  78238. private _blurPostProcesses;
  78239. private _mapSize;
  78240. private _currentFaceIndex;
  78241. private _currentFaceIndexCache;
  78242. private _textureType;
  78243. private _defaultTextureMatrix;
  78244. private _storedUniqueId;
  78245. /** @hidden */
  78246. static _SceneComponentInitialization: (scene: Scene) => void;
  78247. /**
  78248. * Creates a ShadowGenerator object.
  78249. * A ShadowGenerator is the required tool to use the shadows.
  78250. * Each light casting shadows needs to use its own ShadowGenerator.
  78251. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  78252. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  78253. * @param light The light object generating the shadows.
  78254. * @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.
  78255. */
  78256. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  78257. private _initializeGenerator;
  78258. private _initializeShadowMap;
  78259. private _initializeBlurRTTAndPostProcesses;
  78260. private _renderForShadowMap;
  78261. private _renderSubMeshForShadowMap;
  78262. private _applyFilterValues;
  78263. /**
  78264. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  78265. * @param onCompiled Callback triggered at the and of the effects compilation
  78266. * @param options Sets of optional options forcing the compilation with different modes
  78267. */
  78268. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  78269. useInstances: boolean;
  78270. }>): void;
  78271. /**
  78272. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  78273. * @param options Sets of optional options forcing the compilation with different modes
  78274. * @returns A promise that resolves when the compilation completes
  78275. */
  78276. forceCompilationAsync(options?: Partial<{
  78277. useInstances: boolean;
  78278. }>): Promise<void>;
  78279. /**
  78280. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  78281. * @param subMesh The submesh we want to render in the shadow map
  78282. * @param useInstances Defines wether will draw in the map using instances
  78283. * @returns true if ready otherwise, false
  78284. */
  78285. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  78286. /**
  78287. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  78288. * @param defines Defines of the material we want to update
  78289. * @param lightIndex Index of the light in the enabled light list of the material
  78290. */
  78291. prepareDefines(defines: any, lightIndex: number): void;
  78292. /**
  78293. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  78294. * defined in the generator but impacting the effect).
  78295. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  78296. * @param effect The effect we are binfing the information for
  78297. */
  78298. bindShadowLight(lightIndex: string, effect: Effect): void;
  78299. /**
  78300. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  78301. * (eq to shadow prjection matrix * light transform matrix)
  78302. * @returns The transform matrix used to create the shadow map
  78303. */
  78304. getTransformMatrix(): Matrix;
  78305. /**
  78306. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  78307. * Cube and 2D textures for instance.
  78308. */
  78309. recreateShadowMap(): void;
  78310. private _disposeBlurPostProcesses;
  78311. private _disposeRTTandPostProcesses;
  78312. /**
  78313. * Disposes the ShadowGenerator.
  78314. * Returns nothing.
  78315. */
  78316. dispose(): void;
  78317. /**
  78318. * Serializes the shadow generator setup to a json object.
  78319. * @returns The serialized JSON object
  78320. */
  78321. serialize(): any;
  78322. /**
  78323. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  78324. * @param parsedShadowGenerator The JSON object to parse
  78325. * @param scene The scene to create the shadow map for
  78326. * @returns The parsed shadow generator
  78327. */
  78328. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  78329. }
  78330. }
  78331. declare module BABYLON {
  78332. /**
  78333. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  78334. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  78335. * 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.
  78336. */
  78337. export abstract class Light extends Node {
  78338. /**
  78339. * Falloff Default: light is falling off following the material specification:
  78340. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  78341. */
  78342. static readonly FALLOFF_DEFAULT: number;
  78343. /**
  78344. * Falloff Physical: light is falling off following the inverse squared distance law.
  78345. */
  78346. static readonly FALLOFF_PHYSICAL: number;
  78347. /**
  78348. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  78349. * to enhance interoperability with other engines.
  78350. */
  78351. static readonly FALLOFF_GLTF: number;
  78352. /**
  78353. * Falloff Standard: light is falling off like in the standard material
  78354. * to enhance interoperability with other materials.
  78355. */
  78356. static readonly FALLOFF_STANDARD: number;
  78357. /**
  78358. * If every light affecting the material is in this lightmapMode,
  78359. * material.lightmapTexture adds or multiplies
  78360. * (depends on material.useLightmapAsShadowmap)
  78361. * after every other light calculations.
  78362. */
  78363. static readonly LIGHTMAP_DEFAULT: number;
  78364. /**
  78365. * material.lightmapTexture as only diffuse lighting from this light
  78366. * adds only specular lighting from this light
  78367. * adds dynamic shadows
  78368. */
  78369. static readonly LIGHTMAP_SPECULAR: number;
  78370. /**
  78371. * material.lightmapTexture as only lighting
  78372. * no light calculation from this light
  78373. * only adds dynamic shadows from this light
  78374. */
  78375. static readonly LIGHTMAP_SHADOWSONLY: number;
  78376. /**
  78377. * Each light type uses the default quantity according to its type:
  78378. * point/spot lights use luminous intensity
  78379. * directional lights use illuminance
  78380. */
  78381. static readonly INTENSITYMODE_AUTOMATIC: number;
  78382. /**
  78383. * lumen (lm)
  78384. */
  78385. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  78386. /**
  78387. * candela (lm/sr)
  78388. */
  78389. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  78390. /**
  78391. * lux (lm/m^2)
  78392. */
  78393. static readonly INTENSITYMODE_ILLUMINANCE: number;
  78394. /**
  78395. * nit (cd/m^2)
  78396. */
  78397. static readonly INTENSITYMODE_LUMINANCE: number;
  78398. /**
  78399. * Light type const id of the point light.
  78400. */
  78401. static readonly LIGHTTYPEID_POINTLIGHT: number;
  78402. /**
  78403. * Light type const id of the directional light.
  78404. */
  78405. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  78406. /**
  78407. * Light type const id of the spot light.
  78408. */
  78409. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  78410. /**
  78411. * Light type const id of the hemispheric light.
  78412. */
  78413. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  78414. /**
  78415. * Diffuse gives the basic color to an object.
  78416. */
  78417. diffuse: Color3;
  78418. /**
  78419. * Specular produces a highlight color on an object.
  78420. * Note: This is note affecting PBR materials.
  78421. */
  78422. specular: Color3;
  78423. /**
  78424. * Defines the falloff type for this light. This lets overrriding how punctual light are
  78425. * falling off base on range or angle.
  78426. * This can be set to any values in Light.FALLOFF_x.
  78427. *
  78428. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  78429. * other types of materials.
  78430. */
  78431. falloffType: number;
  78432. /**
  78433. * Strength of the light.
  78434. * Note: By default it is define in the framework own unit.
  78435. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  78436. */
  78437. intensity: number;
  78438. private _range;
  78439. protected _inverseSquaredRange: number;
  78440. /**
  78441. * Defines how far from the source the light is impacting in scene units.
  78442. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  78443. */
  78444. /**
  78445. * Defines how far from the source the light is impacting in scene units.
  78446. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  78447. */
  78448. range: number;
  78449. /**
  78450. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  78451. * of light.
  78452. */
  78453. private _photometricScale;
  78454. private _intensityMode;
  78455. /**
  78456. * Gets the photometric scale used to interpret the intensity.
  78457. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  78458. */
  78459. /**
  78460. * Sets the photometric scale used to interpret the intensity.
  78461. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  78462. */
  78463. intensityMode: number;
  78464. private _radius;
  78465. /**
  78466. * Gets the light radius used by PBR Materials to simulate soft area lights.
  78467. */
  78468. /**
  78469. * sets the light radius used by PBR Materials to simulate soft area lights.
  78470. */
  78471. radius: number;
  78472. private _renderPriority;
  78473. /**
  78474. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  78475. * exceeding the number allowed of the materials.
  78476. */
  78477. renderPriority: number;
  78478. private _shadowEnabled;
  78479. /**
  78480. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  78481. * the current shadow generator.
  78482. */
  78483. /**
  78484. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  78485. * the current shadow generator.
  78486. */
  78487. shadowEnabled: boolean;
  78488. private _includedOnlyMeshes;
  78489. /**
  78490. * Gets the only meshes impacted by this light.
  78491. */
  78492. /**
  78493. * Sets the only meshes impacted by this light.
  78494. */
  78495. includedOnlyMeshes: AbstractMesh[];
  78496. private _excludedMeshes;
  78497. /**
  78498. * Gets the meshes not impacted by this light.
  78499. */
  78500. /**
  78501. * Sets the meshes not impacted by this light.
  78502. */
  78503. excludedMeshes: AbstractMesh[];
  78504. private _excludeWithLayerMask;
  78505. /**
  78506. * Gets the layer id use to find what meshes are not impacted by the light.
  78507. * Inactive if 0
  78508. */
  78509. /**
  78510. * Sets the layer id use to find what meshes are not impacted by the light.
  78511. * Inactive if 0
  78512. */
  78513. excludeWithLayerMask: number;
  78514. private _includeOnlyWithLayerMask;
  78515. /**
  78516. * Gets the layer id use to find what meshes are impacted by the light.
  78517. * Inactive if 0
  78518. */
  78519. /**
  78520. * Sets the layer id use to find what meshes are impacted by the light.
  78521. * Inactive if 0
  78522. */
  78523. includeOnlyWithLayerMask: number;
  78524. private _lightmapMode;
  78525. /**
  78526. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  78527. */
  78528. /**
  78529. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  78530. */
  78531. lightmapMode: number;
  78532. /**
  78533. * Shadow generator associted to the light.
  78534. * @hidden Internal use only.
  78535. */
  78536. _shadowGenerator: Nullable<IShadowGenerator>;
  78537. /**
  78538. * @hidden Internal use only.
  78539. */
  78540. _excludedMeshesIds: string[];
  78541. /**
  78542. * @hidden Internal use only.
  78543. */
  78544. _includedOnlyMeshesIds: string[];
  78545. /**
  78546. * The current light unifom buffer.
  78547. * @hidden Internal use only.
  78548. */
  78549. _uniformBuffer: UniformBuffer;
  78550. /** @hidden */
  78551. _renderId: number;
  78552. /**
  78553. * Creates a Light object in the scene.
  78554. * Documentation : https://doc.babylonjs.com/babylon101/lights
  78555. * @param name The firendly name of the light
  78556. * @param scene The scene the light belongs too
  78557. */
  78558. constructor(name: string, scene: Scene);
  78559. protected abstract _buildUniformLayout(): void;
  78560. /**
  78561. * Sets the passed Effect "effect" with the Light information.
  78562. * @param effect The effect to update
  78563. * @param lightIndex The index of the light in the effect to update
  78564. * @returns The light
  78565. */
  78566. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  78567. /**
  78568. * Sets the passed Effect "effect" with the Light information.
  78569. * @param effect The effect to update
  78570. * @param lightDataUniformName The uniform used to store light data (position or direction)
  78571. * @returns The light
  78572. */
  78573. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  78574. /**
  78575. * Returns the string "Light".
  78576. * @returns the class name
  78577. */
  78578. getClassName(): string;
  78579. /** @hidden */
  78580. readonly _isLight: boolean;
  78581. /**
  78582. * Converts the light information to a readable string for debug purpose.
  78583. * @param fullDetails Supports for multiple levels of logging within scene loading
  78584. * @returns the human readable light info
  78585. */
  78586. toString(fullDetails?: boolean): string;
  78587. /** @hidden */
  78588. protected _syncParentEnabledState(): void;
  78589. /**
  78590. * Set the enabled state of this node.
  78591. * @param value - the new enabled state
  78592. */
  78593. setEnabled(value: boolean): void;
  78594. /**
  78595. * Returns the Light associated shadow generator if any.
  78596. * @return the associated shadow generator.
  78597. */
  78598. getShadowGenerator(): Nullable<IShadowGenerator>;
  78599. /**
  78600. * Returns a Vector3, the absolute light position in the World.
  78601. * @returns the world space position of the light
  78602. */
  78603. getAbsolutePosition(): Vector3;
  78604. /**
  78605. * Specifies if the light will affect the passed mesh.
  78606. * @param mesh The mesh to test against the light
  78607. * @return true the mesh is affected otherwise, false.
  78608. */
  78609. canAffectMesh(mesh: AbstractMesh): boolean;
  78610. /**
  78611. * Sort function to order lights for rendering.
  78612. * @param a First Light object to compare to second.
  78613. * @param b Second Light object to compare first.
  78614. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  78615. */
  78616. static CompareLightsPriority(a: Light, b: Light): number;
  78617. /**
  78618. * Releases resources associated with this node.
  78619. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  78620. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  78621. */
  78622. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  78623. /**
  78624. * Returns the light type ID (integer).
  78625. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  78626. */
  78627. getTypeID(): number;
  78628. /**
  78629. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  78630. * @returns the scaled intensity in intensity mode unit
  78631. */
  78632. getScaledIntensity(): number;
  78633. /**
  78634. * Returns a new Light object, named "name", from the current one.
  78635. * @param name The name of the cloned light
  78636. * @returns the new created light
  78637. */
  78638. clone(name: string): Nullable<Light>;
  78639. /**
  78640. * Serializes the current light into a Serialization object.
  78641. * @returns the serialized object.
  78642. */
  78643. serialize(): any;
  78644. /**
  78645. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  78646. * This new light is named "name" and added to the passed scene.
  78647. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  78648. * @param name The friendly name of the light
  78649. * @param scene The scene the new light will belong to
  78650. * @returns the constructor function
  78651. */
  78652. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  78653. /**
  78654. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  78655. * @param parsedLight The JSON representation of the light
  78656. * @param scene The scene to create the parsed light in
  78657. * @returns the created light after parsing
  78658. */
  78659. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  78660. private _hookArrayForExcluded;
  78661. private _hookArrayForIncludedOnly;
  78662. private _resyncMeshes;
  78663. /**
  78664. * Forces the meshes to update their light related information in their rendering used effects
  78665. * @hidden Internal Use Only
  78666. */
  78667. _markMeshesAsLightDirty(): void;
  78668. /**
  78669. * Recomputes the cached photometric scale if needed.
  78670. */
  78671. private _computePhotometricScale;
  78672. /**
  78673. * Returns the Photometric Scale according to the light type and intensity mode.
  78674. */
  78675. private _getPhotometricScale;
  78676. /**
  78677. * Reorder the light in the scene according to their defined priority.
  78678. * @hidden Internal Use Only
  78679. */
  78680. _reorderLightsInScene(): void;
  78681. /**
  78682. * Prepares the list of defines specific to the light type.
  78683. * @param defines the list of defines
  78684. * @param lightIndex defines the index of the light for the effect
  78685. */
  78686. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  78687. }
  78688. }
  78689. declare module BABYLON {
  78690. /**
  78691. * Interface used to define Action
  78692. */
  78693. export interface IAction {
  78694. /**
  78695. * Trigger for the action
  78696. */
  78697. trigger: number;
  78698. /** Options of the trigger */
  78699. triggerOptions: any;
  78700. /**
  78701. * Gets the trigger parameters
  78702. * @returns the trigger parameters
  78703. */
  78704. getTriggerParameter(): any;
  78705. /**
  78706. * Internal only - executes current action event
  78707. * @hidden
  78708. */
  78709. _executeCurrent(evt?: ActionEvent): void;
  78710. /**
  78711. * Serialize placeholder for child classes
  78712. * @param parent of child
  78713. * @returns the serialized object
  78714. */
  78715. serialize(parent: any): any;
  78716. /**
  78717. * Internal only
  78718. * @hidden
  78719. */
  78720. _prepare(): void;
  78721. /**
  78722. * Internal only - manager for action
  78723. * @hidden
  78724. */
  78725. _actionManager: AbstractActionManager;
  78726. /**
  78727. * Adds action to chain of actions, may be a DoNothingAction
  78728. * @param action defines the next action to execute
  78729. * @returns The action passed in
  78730. * @see https://www.babylonjs-playground.com/#1T30HR#0
  78731. */
  78732. then(action: IAction): IAction;
  78733. }
  78734. /**
  78735. * The action to be carried out following a trigger
  78736. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  78737. */
  78738. export class Action implements IAction {
  78739. /** the trigger, with or without parameters, for the action */
  78740. triggerOptions: any;
  78741. /**
  78742. * Trigger for the action
  78743. */
  78744. trigger: number;
  78745. /**
  78746. * Internal only - manager for action
  78747. * @hidden
  78748. */
  78749. _actionManager: ActionManager;
  78750. private _nextActiveAction;
  78751. private _child;
  78752. private _condition?;
  78753. private _triggerParameter;
  78754. /**
  78755. * An event triggered prior to action being executed.
  78756. */
  78757. onBeforeExecuteObservable: Observable<Action>;
  78758. /**
  78759. * Creates a new Action
  78760. * @param triggerOptions the trigger, with or without parameters, for the action
  78761. * @param condition an optional determinant of action
  78762. */
  78763. constructor(
  78764. /** the trigger, with or without parameters, for the action */
  78765. triggerOptions: any, condition?: Condition);
  78766. /**
  78767. * Internal only
  78768. * @hidden
  78769. */
  78770. _prepare(): void;
  78771. /**
  78772. * Gets the trigger parameters
  78773. * @returns the trigger parameters
  78774. */
  78775. getTriggerParameter(): any;
  78776. /**
  78777. * Internal only - executes current action event
  78778. * @hidden
  78779. */
  78780. _executeCurrent(evt?: ActionEvent): void;
  78781. /**
  78782. * Execute placeholder for child classes
  78783. * @param evt optional action event
  78784. */
  78785. execute(evt?: ActionEvent): void;
  78786. /**
  78787. * Skips to next active action
  78788. */
  78789. skipToNextActiveAction(): void;
  78790. /**
  78791. * Adds action to chain of actions, may be a DoNothingAction
  78792. * @param action defines the next action to execute
  78793. * @returns The action passed in
  78794. * @see https://www.babylonjs-playground.com/#1T30HR#0
  78795. */
  78796. then(action: Action): Action;
  78797. /**
  78798. * Internal only
  78799. * @hidden
  78800. */
  78801. _getProperty(propertyPath: string): string;
  78802. /**
  78803. * Internal only
  78804. * @hidden
  78805. */
  78806. _getEffectiveTarget(target: any, propertyPath: string): any;
  78807. /**
  78808. * Serialize placeholder for child classes
  78809. * @param parent of child
  78810. * @returns the serialized object
  78811. */
  78812. serialize(parent: any): any;
  78813. /**
  78814. * Internal only called by serialize
  78815. * @hidden
  78816. */
  78817. protected _serialize(serializedAction: any, parent?: any): any;
  78818. /**
  78819. * Internal only
  78820. * @hidden
  78821. */
  78822. static _SerializeValueAsString: (value: any) => string;
  78823. /**
  78824. * Internal only
  78825. * @hidden
  78826. */
  78827. static _GetTargetProperty: (target: Node | Scene) => {
  78828. name: string;
  78829. targetType: string;
  78830. value: string;
  78831. };
  78832. }
  78833. }
  78834. declare module BABYLON {
  78835. /**
  78836. * A Condition applied to an Action
  78837. */
  78838. export class Condition {
  78839. /**
  78840. * Internal only - manager for action
  78841. * @hidden
  78842. */
  78843. _actionManager: ActionManager;
  78844. /**
  78845. * Internal only
  78846. * @hidden
  78847. */
  78848. _evaluationId: number;
  78849. /**
  78850. * Internal only
  78851. * @hidden
  78852. */
  78853. _currentResult: boolean;
  78854. /**
  78855. * Creates a new Condition
  78856. * @param actionManager the manager of the action the condition is applied to
  78857. */
  78858. constructor(actionManager: ActionManager);
  78859. /**
  78860. * Check if the current condition is valid
  78861. * @returns a boolean
  78862. */
  78863. isValid(): boolean;
  78864. /**
  78865. * Internal only
  78866. * @hidden
  78867. */
  78868. _getProperty(propertyPath: string): string;
  78869. /**
  78870. * Internal only
  78871. * @hidden
  78872. */
  78873. _getEffectiveTarget(target: any, propertyPath: string): any;
  78874. /**
  78875. * Serialize placeholder for child classes
  78876. * @returns the serialized object
  78877. */
  78878. serialize(): any;
  78879. /**
  78880. * Internal only
  78881. * @hidden
  78882. */
  78883. protected _serialize(serializedCondition: any): any;
  78884. }
  78885. /**
  78886. * Defines specific conditional operators as extensions of Condition
  78887. */
  78888. export class ValueCondition extends Condition {
  78889. /** path to specify the property of the target the conditional operator uses */
  78890. propertyPath: string;
  78891. /** the value compared by the conditional operator against the current value of the property */
  78892. value: any;
  78893. /** the conditional operator, default ValueCondition.IsEqual */
  78894. operator: number;
  78895. /**
  78896. * Internal only
  78897. * @hidden
  78898. */
  78899. private static _IsEqual;
  78900. /**
  78901. * Internal only
  78902. * @hidden
  78903. */
  78904. private static _IsDifferent;
  78905. /**
  78906. * Internal only
  78907. * @hidden
  78908. */
  78909. private static _IsGreater;
  78910. /**
  78911. * Internal only
  78912. * @hidden
  78913. */
  78914. private static _IsLesser;
  78915. /**
  78916. * returns the number for IsEqual
  78917. */
  78918. static readonly IsEqual: number;
  78919. /**
  78920. * Returns the number for IsDifferent
  78921. */
  78922. static readonly IsDifferent: number;
  78923. /**
  78924. * Returns the number for IsGreater
  78925. */
  78926. static readonly IsGreater: number;
  78927. /**
  78928. * Returns the number for IsLesser
  78929. */
  78930. static readonly IsLesser: number;
  78931. /**
  78932. * Internal only The action manager for the condition
  78933. * @hidden
  78934. */
  78935. _actionManager: ActionManager;
  78936. /**
  78937. * Internal only
  78938. * @hidden
  78939. */
  78940. private _target;
  78941. /**
  78942. * Internal only
  78943. * @hidden
  78944. */
  78945. private _effectiveTarget;
  78946. /**
  78947. * Internal only
  78948. * @hidden
  78949. */
  78950. private _property;
  78951. /**
  78952. * Creates a new ValueCondition
  78953. * @param actionManager manager for the action the condition applies to
  78954. * @param target for the action
  78955. * @param propertyPath path to specify the property of the target the conditional operator uses
  78956. * @param value the value compared by the conditional operator against the current value of the property
  78957. * @param operator the conditional operator, default ValueCondition.IsEqual
  78958. */
  78959. constructor(actionManager: ActionManager, target: any,
  78960. /** path to specify the property of the target the conditional operator uses */
  78961. propertyPath: string,
  78962. /** the value compared by the conditional operator against the current value of the property */
  78963. value: any,
  78964. /** the conditional operator, default ValueCondition.IsEqual */
  78965. operator?: number);
  78966. /**
  78967. * Compares the given value with the property value for the specified conditional operator
  78968. * @returns the result of the comparison
  78969. */
  78970. isValid(): boolean;
  78971. /**
  78972. * Serialize the ValueCondition into a JSON compatible object
  78973. * @returns serialization object
  78974. */
  78975. serialize(): any;
  78976. /**
  78977. * Gets the name of the conditional operator for the ValueCondition
  78978. * @param operator the conditional operator
  78979. * @returns the name
  78980. */
  78981. static GetOperatorName(operator: number): string;
  78982. }
  78983. /**
  78984. * Defines a predicate condition as an extension of Condition
  78985. */
  78986. export class PredicateCondition extends Condition {
  78987. /** defines the predicate function used to validate the condition */
  78988. predicate: () => boolean;
  78989. /**
  78990. * Internal only - manager for action
  78991. * @hidden
  78992. */
  78993. _actionManager: ActionManager;
  78994. /**
  78995. * Creates a new PredicateCondition
  78996. * @param actionManager manager for the action the condition applies to
  78997. * @param predicate defines the predicate function used to validate the condition
  78998. */
  78999. constructor(actionManager: ActionManager,
  79000. /** defines the predicate function used to validate the condition */
  79001. predicate: () => boolean);
  79002. /**
  79003. * @returns the validity of the predicate condition
  79004. */
  79005. isValid(): boolean;
  79006. }
  79007. /**
  79008. * Defines a state condition as an extension of Condition
  79009. */
  79010. export class StateCondition extends Condition {
  79011. /** Value to compare with target state */
  79012. value: string;
  79013. /**
  79014. * Internal only - manager for action
  79015. * @hidden
  79016. */
  79017. _actionManager: ActionManager;
  79018. /**
  79019. * Internal only
  79020. * @hidden
  79021. */
  79022. private _target;
  79023. /**
  79024. * Creates a new StateCondition
  79025. * @param actionManager manager for the action the condition applies to
  79026. * @param target of the condition
  79027. * @param value to compare with target state
  79028. */
  79029. constructor(actionManager: ActionManager, target: any,
  79030. /** Value to compare with target state */
  79031. value: string);
  79032. /**
  79033. * Gets a boolean indicating if the current condition is met
  79034. * @returns the validity of the state
  79035. */
  79036. isValid(): boolean;
  79037. /**
  79038. * Serialize the StateCondition into a JSON compatible object
  79039. * @returns serialization object
  79040. */
  79041. serialize(): any;
  79042. }
  79043. }
  79044. declare module BABYLON {
  79045. /**
  79046. * This defines an action responsible to toggle a boolean once triggered.
  79047. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  79048. */
  79049. export class SwitchBooleanAction extends Action {
  79050. /**
  79051. * The path to the boolean property in the target object
  79052. */
  79053. propertyPath: string;
  79054. private _target;
  79055. private _effectiveTarget;
  79056. private _property;
  79057. /**
  79058. * Instantiate the action
  79059. * @param triggerOptions defines the trigger options
  79060. * @param target defines the object containing the boolean
  79061. * @param propertyPath defines the path to the boolean property in the target object
  79062. * @param condition defines the trigger related conditions
  79063. */
  79064. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  79065. /** @hidden */
  79066. _prepare(): void;
  79067. /**
  79068. * Execute the action toggle the boolean value.
  79069. */
  79070. execute(): void;
  79071. /**
  79072. * Serializes the actions and its related information.
  79073. * @param parent defines the object to serialize in
  79074. * @returns the serialized object
  79075. */
  79076. serialize(parent: any): any;
  79077. }
  79078. /**
  79079. * This defines an action responsible to set a the state field of the target
  79080. * to a desired value once triggered.
  79081. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  79082. */
  79083. export class SetStateAction extends Action {
  79084. /**
  79085. * The value to store in the state field.
  79086. */
  79087. value: string;
  79088. private _target;
  79089. /**
  79090. * Instantiate the action
  79091. * @param triggerOptions defines the trigger options
  79092. * @param target defines the object containing the state property
  79093. * @param value defines the value to store in the state field
  79094. * @param condition defines the trigger related conditions
  79095. */
  79096. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  79097. /**
  79098. * Execute the action and store the value on the target state property.
  79099. */
  79100. execute(): void;
  79101. /**
  79102. * Serializes the actions and its related information.
  79103. * @param parent defines the object to serialize in
  79104. * @returns the serialized object
  79105. */
  79106. serialize(parent: any): any;
  79107. }
  79108. /**
  79109. * This defines an action responsible to set a property of the target
  79110. * to a desired value once triggered.
  79111. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  79112. */
  79113. export class SetValueAction extends Action {
  79114. /**
  79115. * The path of the property to set in the target.
  79116. */
  79117. propertyPath: string;
  79118. /**
  79119. * The value to set in the property
  79120. */
  79121. value: any;
  79122. private _target;
  79123. private _effectiveTarget;
  79124. private _property;
  79125. /**
  79126. * Instantiate the action
  79127. * @param triggerOptions defines the trigger options
  79128. * @param target defines the object containing the property
  79129. * @param propertyPath defines the path of the property to set in the target
  79130. * @param value defines the value to set in the property
  79131. * @param condition defines the trigger related conditions
  79132. */
  79133. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  79134. /** @hidden */
  79135. _prepare(): void;
  79136. /**
  79137. * Execute the action and set the targetted property to the desired value.
  79138. */
  79139. execute(): void;
  79140. /**
  79141. * Serializes the actions and its related information.
  79142. * @param parent defines the object to serialize in
  79143. * @returns the serialized object
  79144. */
  79145. serialize(parent: any): any;
  79146. }
  79147. /**
  79148. * This defines an action responsible to increment the target value
  79149. * to a desired value once triggered.
  79150. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  79151. */
  79152. export class IncrementValueAction extends Action {
  79153. /**
  79154. * The path of the property to increment in the target.
  79155. */
  79156. propertyPath: string;
  79157. /**
  79158. * The value we should increment the property by.
  79159. */
  79160. value: any;
  79161. private _target;
  79162. private _effectiveTarget;
  79163. private _property;
  79164. /**
  79165. * Instantiate the action
  79166. * @param triggerOptions defines the trigger options
  79167. * @param target defines the object containing the property
  79168. * @param propertyPath defines the path of the property to increment in the target
  79169. * @param value defines the value value we should increment the property by
  79170. * @param condition defines the trigger related conditions
  79171. */
  79172. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  79173. /** @hidden */
  79174. _prepare(): void;
  79175. /**
  79176. * Execute the action and increment the target of the value amount.
  79177. */
  79178. execute(): void;
  79179. /**
  79180. * Serializes the actions and its related information.
  79181. * @param parent defines the object to serialize in
  79182. * @returns the serialized object
  79183. */
  79184. serialize(parent: any): any;
  79185. }
  79186. /**
  79187. * This defines an action responsible to start an animation once triggered.
  79188. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  79189. */
  79190. export class PlayAnimationAction extends Action {
  79191. /**
  79192. * Where the animation should start (animation frame)
  79193. */
  79194. from: number;
  79195. /**
  79196. * Where the animation should stop (animation frame)
  79197. */
  79198. to: number;
  79199. /**
  79200. * Define if the animation should loop or stop after the first play.
  79201. */
  79202. loop?: boolean;
  79203. private _target;
  79204. /**
  79205. * Instantiate the action
  79206. * @param triggerOptions defines the trigger options
  79207. * @param target defines the target animation or animation name
  79208. * @param from defines from where the animation should start (animation frame)
  79209. * @param end defines where the animation should stop (animation frame)
  79210. * @param loop defines if the animation should loop or stop after the first play
  79211. * @param condition defines the trigger related conditions
  79212. */
  79213. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  79214. /** @hidden */
  79215. _prepare(): void;
  79216. /**
  79217. * Execute the action and play the animation.
  79218. */
  79219. execute(): void;
  79220. /**
  79221. * Serializes the actions and its related information.
  79222. * @param parent defines the object to serialize in
  79223. * @returns the serialized object
  79224. */
  79225. serialize(parent: any): any;
  79226. }
  79227. /**
  79228. * This defines an action responsible to stop an animation once triggered.
  79229. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  79230. */
  79231. export class StopAnimationAction extends Action {
  79232. private _target;
  79233. /**
  79234. * Instantiate the action
  79235. * @param triggerOptions defines the trigger options
  79236. * @param target defines the target animation or animation name
  79237. * @param condition defines the trigger related conditions
  79238. */
  79239. constructor(triggerOptions: any, target: any, condition?: Condition);
  79240. /** @hidden */
  79241. _prepare(): void;
  79242. /**
  79243. * Execute the action and stop the animation.
  79244. */
  79245. execute(): void;
  79246. /**
  79247. * Serializes the actions and its related information.
  79248. * @param parent defines the object to serialize in
  79249. * @returns the serialized object
  79250. */
  79251. serialize(parent: any): any;
  79252. }
  79253. /**
  79254. * This defines an action responsible that does nothing once triggered.
  79255. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  79256. */
  79257. export class DoNothingAction extends Action {
  79258. /**
  79259. * Instantiate the action
  79260. * @param triggerOptions defines the trigger options
  79261. * @param condition defines the trigger related conditions
  79262. */
  79263. constructor(triggerOptions?: any, condition?: Condition);
  79264. /**
  79265. * Execute the action and do nothing.
  79266. */
  79267. execute(): void;
  79268. /**
  79269. * Serializes the actions and its related information.
  79270. * @param parent defines the object to serialize in
  79271. * @returns the serialized object
  79272. */
  79273. serialize(parent: any): any;
  79274. }
  79275. /**
  79276. * This defines an action responsible to trigger several actions once triggered.
  79277. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  79278. */
  79279. export class CombineAction extends Action {
  79280. /**
  79281. * The list of aggregated animations to run.
  79282. */
  79283. children: Action[];
  79284. /**
  79285. * Instantiate the action
  79286. * @param triggerOptions defines the trigger options
  79287. * @param children defines the list of aggregated animations to run
  79288. * @param condition defines the trigger related conditions
  79289. */
  79290. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  79291. /** @hidden */
  79292. _prepare(): void;
  79293. /**
  79294. * Execute the action and executes all the aggregated actions.
  79295. */
  79296. execute(evt: ActionEvent): void;
  79297. /**
  79298. * Serializes the actions and its related information.
  79299. * @param parent defines the object to serialize in
  79300. * @returns the serialized object
  79301. */
  79302. serialize(parent: any): any;
  79303. }
  79304. /**
  79305. * This defines an action responsible to run code (external event) once triggered.
  79306. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  79307. */
  79308. export class ExecuteCodeAction extends Action {
  79309. /**
  79310. * The callback function to run.
  79311. */
  79312. func: (evt: ActionEvent) => void;
  79313. /**
  79314. * Instantiate the action
  79315. * @param triggerOptions defines the trigger options
  79316. * @param func defines the callback function to run
  79317. * @param condition defines the trigger related conditions
  79318. */
  79319. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  79320. /**
  79321. * Execute the action and run the attached code.
  79322. */
  79323. execute(evt: ActionEvent): void;
  79324. }
  79325. /**
  79326. * This defines an action responsible to set the parent property of the target once triggered.
  79327. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  79328. */
  79329. export class SetParentAction extends Action {
  79330. private _parent;
  79331. private _target;
  79332. /**
  79333. * Instantiate the action
  79334. * @param triggerOptions defines the trigger options
  79335. * @param target defines the target containing the parent property
  79336. * @param parent defines from where the animation should start (animation frame)
  79337. * @param condition defines the trigger related conditions
  79338. */
  79339. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  79340. /** @hidden */
  79341. _prepare(): void;
  79342. /**
  79343. * Execute the action and set the parent property.
  79344. */
  79345. execute(): void;
  79346. /**
  79347. * Serializes the actions and its related information.
  79348. * @param parent defines the object to serialize in
  79349. * @returns the serialized object
  79350. */
  79351. serialize(parent: any): any;
  79352. }
  79353. }
  79354. declare module BABYLON {
  79355. /**
  79356. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  79357. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  79358. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  79359. */
  79360. export class ActionManager extends AbstractActionManager {
  79361. /**
  79362. * Nothing
  79363. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79364. */
  79365. static readonly NothingTrigger: number;
  79366. /**
  79367. * On pick
  79368. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79369. */
  79370. static readonly OnPickTrigger: number;
  79371. /**
  79372. * On left pick
  79373. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79374. */
  79375. static readonly OnLeftPickTrigger: number;
  79376. /**
  79377. * On right pick
  79378. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79379. */
  79380. static readonly OnRightPickTrigger: number;
  79381. /**
  79382. * On center pick
  79383. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79384. */
  79385. static readonly OnCenterPickTrigger: number;
  79386. /**
  79387. * On pick down
  79388. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79389. */
  79390. static readonly OnPickDownTrigger: number;
  79391. /**
  79392. * On double pick
  79393. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79394. */
  79395. static readonly OnDoublePickTrigger: number;
  79396. /**
  79397. * On pick up
  79398. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79399. */
  79400. static readonly OnPickUpTrigger: number;
  79401. /**
  79402. * On pick out.
  79403. * This trigger will only be raised if you also declared a OnPickDown
  79404. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79405. */
  79406. static readonly OnPickOutTrigger: number;
  79407. /**
  79408. * On long press
  79409. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79410. */
  79411. static readonly OnLongPressTrigger: number;
  79412. /**
  79413. * On pointer over
  79414. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79415. */
  79416. static readonly OnPointerOverTrigger: number;
  79417. /**
  79418. * On pointer out
  79419. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79420. */
  79421. static readonly OnPointerOutTrigger: number;
  79422. /**
  79423. * On every frame
  79424. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79425. */
  79426. static readonly OnEveryFrameTrigger: number;
  79427. /**
  79428. * On intersection enter
  79429. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79430. */
  79431. static readonly OnIntersectionEnterTrigger: number;
  79432. /**
  79433. * On intersection exit
  79434. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79435. */
  79436. static readonly OnIntersectionExitTrigger: number;
  79437. /**
  79438. * On key down
  79439. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79440. */
  79441. static readonly OnKeyDownTrigger: number;
  79442. /**
  79443. * On key up
  79444. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79445. */
  79446. static readonly OnKeyUpTrigger: number;
  79447. private _scene;
  79448. /**
  79449. * Creates a new action manager
  79450. * @param scene defines the hosting scene
  79451. */
  79452. constructor(scene: Scene);
  79453. /**
  79454. * Releases all associated resources
  79455. */
  79456. dispose(): void;
  79457. /**
  79458. * Gets hosting scene
  79459. * @returns the hosting scene
  79460. */
  79461. getScene(): Scene;
  79462. /**
  79463. * Does this action manager handles actions of any of the given triggers
  79464. * @param triggers defines the triggers to be tested
  79465. * @return a boolean indicating whether one (or more) of the triggers is handled
  79466. */
  79467. hasSpecificTriggers(triggers: number[]): boolean;
  79468. /**
  79469. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  79470. * speed.
  79471. * @param triggerA defines the trigger to be tested
  79472. * @param triggerB defines the trigger to be tested
  79473. * @return a boolean indicating whether one (or more) of the triggers is handled
  79474. */
  79475. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  79476. /**
  79477. * Does this action manager handles actions of a given trigger
  79478. * @param trigger defines the trigger to be tested
  79479. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  79480. * @return whether the trigger is handled
  79481. */
  79482. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  79483. /**
  79484. * Does this action manager has pointer triggers
  79485. */
  79486. readonly hasPointerTriggers: boolean;
  79487. /**
  79488. * Does this action manager has pick triggers
  79489. */
  79490. readonly hasPickTriggers: boolean;
  79491. /**
  79492. * Registers an action to this action manager
  79493. * @param action defines the action to be registered
  79494. * @return the action amended (prepared) after registration
  79495. */
  79496. registerAction(action: IAction): Nullable<IAction>;
  79497. /**
  79498. * Unregisters an action to this action manager
  79499. * @param action defines the action to be unregistered
  79500. * @return a boolean indicating whether the action has been unregistered
  79501. */
  79502. unregisterAction(action: IAction): Boolean;
  79503. /**
  79504. * Process a specific trigger
  79505. * @param trigger defines the trigger to process
  79506. * @param evt defines the event details to be processed
  79507. */
  79508. processTrigger(trigger: number, evt?: IActionEvent): void;
  79509. /** @hidden */
  79510. _getEffectiveTarget(target: any, propertyPath: string): any;
  79511. /** @hidden */
  79512. _getProperty(propertyPath: string): string;
  79513. /**
  79514. * Serialize this manager to a JSON object
  79515. * @param name defines the property name to store this manager
  79516. * @returns a JSON representation of this manager
  79517. */
  79518. serialize(name: string): any;
  79519. /**
  79520. * Creates a new ActionManager from a JSON data
  79521. * @param parsedActions defines the JSON data to read from
  79522. * @param object defines the hosting mesh
  79523. * @param scene defines the hosting scene
  79524. */
  79525. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  79526. /**
  79527. * Get a trigger name by index
  79528. * @param trigger defines the trigger index
  79529. * @returns a trigger name
  79530. */
  79531. static GetTriggerName(trigger: number): string;
  79532. }
  79533. }
  79534. declare module BABYLON {
  79535. /**
  79536. * Class representing a ray with position and direction
  79537. */
  79538. export class Ray {
  79539. /** origin point */
  79540. origin: Vector3;
  79541. /** direction */
  79542. direction: Vector3;
  79543. /** length of the ray */
  79544. length: number;
  79545. private static readonly TmpVector3;
  79546. private _tmpRay;
  79547. /**
  79548. * Creates a new ray
  79549. * @param origin origin point
  79550. * @param direction direction
  79551. * @param length length of the ray
  79552. */
  79553. constructor(
  79554. /** origin point */
  79555. origin: Vector3,
  79556. /** direction */
  79557. direction: Vector3,
  79558. /** length of the ray */
  79559. length?: number);
  79560. /**
  79561. * Checks if the ray intersects a box
  79562. * @param minimum bound of the box
  79563. * @param maximum bound of the box
  79564. * @param intersectionTreshold extra extend to be added to the box in all direction
  79565. * @returns if the box was hit
  79566. */
  79567. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  79568. /**
  79569. * Checks if the ray intersects a box
  79570. * @param box the bounding box to check
  79571. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  79572. * @returns if the box was hit
  79573. */
  79574. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  79575. /**
  79576. * If the ray hits a sphere
  79577. * @param sphere the bounding sphere to check
  79578. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  79579. * @returns true if it hits the sphere
  79580. */
  79581. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  79582. /**
  79583. * If the ray hits a triange
  79584. * @param vertex0 triangle vertex
  79585. * @param vertex1 triangle vertex
  79586. * @param vertex2 triangle vertex
  79587. * @returns intersection information if hit
  79588. */
  79589. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  79590. /**
  79591. * Checks if ray intersects a plane
  79592. * @param plane the plane to check
  79593. * @returns the distance away it was hit
  79594. */
  79595. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  79596. /**
  79597. * Calculate the intercept of a ray on a given axis
  79598. * @param axis to check 'x' | 'y' | 'z'
  79599. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  79600. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  79601. */
  79602. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  79603. /**
  79604. * Checks if ray intersects a mesh
  79605. * @param mesh the mesh to check
  79606. * @param fastCheck if only the bounding box should checked
  79607. * @returns picking info of the intersecton
  79608. */
  79609. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  79610. /**
  79611. * Checks if ray intersects a mesh
  79612. * @param meshes the meshes to check
  79613. * @param fastCheck if only the bounding box should checked
  79614. * @param results array to store result in
  79615. * @returns Array of picking infos
  79616. */
  79617. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  79618. private _comparePickingInfo;
  79619. private static smallnum;
  79620. private static rayl;
  79621. /**
  79622. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  79623. * @param sega the first point of the segment to test the intersection against
  79624. * @param segb the second point of the segment to test the intersection against
  79625. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  79626. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  79627. */
  79628. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  79629. /**
  79630. * Update the ray from viewport position
  79631. * @param x position
  79632. * @param y y position
  79633. * @param viewportWidth viewport width
  79634. * @param viewportHeight viewport height
  79635. * @param world world matrix
  79636. * @param view view matrix
  79637. * @param projection projection matrix
  79638. * @returns this ray updated
  79639. */
  79640. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  79641. /**
  79642. * Creates a ray with origin and direction of 0,0,0
  79643. * @returns the new ray
  79644. */
  79645. static Zero(): Ray;
  79646. /**
  79647. * Creates a new ray from screen space and viewport
  79648. * @param x position
  79649. * @param y y position
  79650. * @param viewportWidth viewport width
  79651. * @param viewportHeight viewport height
  79652. * @param world world matrix
  79653. * @param view view matrix
  79654. * @param projection projection matrix
  79655. * @returns new ray
  79656. */
  79657. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  79658. /**
  79659. * 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
  79660. * transformed to the given world matrix.
  79661. * @param origin The origin point
  79662. * @param end The end point
  79663. * @param world a matrix to transform the ray to. Default is the identity matrix.
  79664. * @returns the new ray
  79665. */
  79666. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  79667. /**
  79668. * Transforms a ray by a matrix
  79669. * @param ray ray to transform
  79670. * @param matrix matrix to apply
  79671. * @returns the resulting new ray
  79672. */
  79673. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  79674. /**
  79675. * Transforms a ray by a matrix
  79676. * @param ray ray to transform
  79677. * @param matrix matrix to apply
  79678. * @param result ray to store result in
  79679. */
  79680. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  79681. /**
  79682. * Unproject a ray from screen space to object space
  79683. * @param sourceX defines the screen space x coordinate to use
  79684. * @param sourceY defines the screen space y coordinate to use
  79685. * @param viewportWidth defines the current width of the viewport
  79686. * @param viewportHeight defines the current height of the viewport
  79687. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  79688. * @param view defines the view matrix to use
  79689. * @param projection defines the projection matrix to use
  79690. */
  79691. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  79692. }
  79693. /**
  79694. * Type used to define predicate used to select faces when a mesh intersection is detected
  79695. */
  79696. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  79697. interface Scene {
  79698. /** @hidden */
  79699. _tempPickingRay: Nullable<Ray>;
  79700. /** @hidden */
  79701. _cachedRayForTransform: Ray;
  79702. /** @hidden */
  79703. _pickWithRayInverseMatrix: Matrix;
  79704. /** @hidden */
  79705. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  79706. /** @hidden */
  79707. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  79708. }
  79709. }
  79710. declare module BABYLON {
  79711. /**
  79712. * Groups all the scene component constants in one place to ease maintenance.
  79713. * @hidden
  79714. */
  79715. export class SceneComponentConstants {
  79716. static readonly NAME_EFFECTLAYER: string;
  79717. static readonly NAME_LAYER: string;
  79718. static readonly NAME_LENSFLARESYSTEM: string;
  79719. static readonly NAME_BOUNDINGBOXRENDERER: string;
  79720. static readonly NAME_PARTICLESYSTEM: string;
  79721. static readonly NAME_GAMEPAD: string;
  79722. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  79723. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  79724. static readonly NAME_DEPTHRENDERER: string;
  79725. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  79726. static readonly NAME_SPRITE: string;
  79727. static readonly NAME_OUTLINERENDERER: string;
  79728. static readonly NAME_PROCEDURALTEXTURE: string;
  79729. static readonly NAME_SHADOWGENERATOR: string;
  79730. static readonly NAME_OCTREE: string;
  79731. static readonly NAME_PHYSICSENGINE: string;
  79732. static readonly NAME_AUDIO: string;
  79733. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  79734. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  79735. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  79736. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  79737. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  79738. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  79739. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  79740. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  79741. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  79742. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  79743. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  79744. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  79745. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  79746. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  79747. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  79748. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  79749. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  79750. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  79751. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  79752. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  79753. static readonly STEP_AFTERRENDER_AUDIO: number;
  79754. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  79755. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  79756. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  79757. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  79758. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  79759. static readonly STEP_POINTERMOVE_SPRITE: number;
  79760. static readonly STEP_POINTERDOWN_SPRITE: number;
  79761. static readonly STEP_POINTERUP_SPRITE: number;
  79762. }
  79763. /**
  79764. * This represents a scene component.
  79765. *
  79766. * This is used to decouple the dependency the scene is having on the different workloads like
  79767. * layers, post processes...
  79768. */
  79769. export interface ISceneComponent {
  79770. /**
  79771. * The name of the component. Each component must have a unique name.
  79772. */
  79773. name: string;
  79774. /**
  79775. * The scene the component belongs to.
  79776. */
  79777. scene: Scene;
  79778. /**
  79779. * Register the component to one instance of a scene.
  79780. */
  79781. register(): void;
  79782. /**
  79783. * Rebuilds the elements related to this component in case of
  79784. * context lost for instance.
  79785. */
  79786. rebuild(): void;
  79787. /**
  79788. * Disposes the component and the associated ressources.
  79789. */
  79790. dispose(): void;
  79791. }
  79792. /**
  79793. * This represents a SERIALIZABLE scene component.
  79794. *
  79795. * This extends Scene Component to add Serialization methods on top.
  79796. */
  79797. export interface ISceneSerializableComponent extends ISceneComponent {
  79798. /**
  79799. * Adds all the elements from the container to the scene
  79800. * @param container the container holding the elements
  79801. */
  79802. addFromContainer(container: AbstractScene): void;
  79803. /**
  79804. * Removes all the elements in the container from the scene
  79805. * @param container contains the elements to remove
  79806. * @param dispose if the removed element should be disposed (default: false)
  79807. */
  79808. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  79809. /**
  79810. * Serializes the component data to the specified json object
  79811. * @param serializationObject The object to serialize to
  79812. */
  79813. serialize(serializationObject: any): void;
  79814. }
  79815. /**
  79816. * Strong typing of a Mesh related stage step action
  79817. */
  79818. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  79819. /**
  79820. * Strong typing of a Evaluate Sub Mesh related stage step action
  79821. */
  79822. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  79823. /**
  79824. * Strong typing of a Active Mesh related stage step action
  79825. */
  79826. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  79827. /**
  79828. * Strong typing of a Camera related stage step action
  79829. */
  79830. export type CameraStageAction = (camera: Camera) => void;
  79831. /**
  79832. * Strong typing of a Camera Frame buffer related stage step action
  79833. */
  79834. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  79835. /**
  79836. * Strong typing of a Render Target related stage step action
  79837. */
  79838. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  79839. /**
  79840. * Strong typing of a RenderingGroup related stage step action
  79841. */
  79842. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  79843. /**
  79844. * Strong typing of a Mesh Render related stage step action
  79845. */
  79846. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  79847. /**
  79848. * Strong typing of a simple stage step action
  79849. */
  79850. export type SimpleStageAction = () => void;
  79851. /**
  79852. * Strong typing of a render target action.
  79853. */
  79854. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  79855. /**
  79856. * Strong typing of a pointer move action.
  79857. */
  79858. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  79859. /**
  79860. * Strong typing of a pointer up/down action.
  79861. */
  79862. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  79863. /**
  79864. * Representation of a stage in the scene (Basically a list of ordered steps)
  79865. * @hidden
  79866. */
  79867. export class Stage<T extends Function> extends Array<{
  79868. index: number;
  79869. component: ISceneComponent;
  79870. action: T;
  79871. }> {
  79872. /**
  79873. * Hide ctor from the rest of the world.
  79874. * @param items The items to add.
  79875. */
  79876. private constructor();
  79877. /**
  79878. * Creates a new Stage.
  79879. * @returns A new instance of a Stage
  79880. */
  79881. static Create<T extends Function>(): Stage<T>;
  79882. /**
  79883. * Registers a step in an ordered way in the targeted stage.
  79884. * @param index Defines the position to register the step in
  79885. * @param component Defines the component attached to the step
  79886. * @param action Defines the action to launch during the step
  79887. */
  79888. registerStep(index: number, component: ISceneComponent, action: T): void;
  79889. /**
  79890. * Clears all the steps from the stage.
  79891. */
  79892. clear(): void;
  79893. }
  79894. }
  79895. declare module BABYLON {
  79896. interface Scene {
  79897. /** @hidden */
  79898. _pointerOverSprite: Nullable<Sprite>;
  79899. /** @hidden */
  79900. _pickedDownSprite: Nullable<Sprite>;
  79901. /** @hidden */
  79902. _tempSpritePickingRay: Nullable<Ray>;
  79903. /**
  79904. * All of the sprite managers added to this scene
  79905. * @see http://doc.babylonjs.com/babylon101/sprites
  79906. */
  79907. spriteManagers: Array<ISpriteManager>;
  79908. /**
  79909. * An event triggered when sprites rendering is about to start
  79910. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  79911. */
  79912. onBeforeSpritesRenderingObservable: Observable<Scene>;
  79913. /**
  79914. * An event triggered when sprites rendering is done
  79915. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  79916. */
  79917. onAfterSpritesRenderingObservable: Observable<Scene>;
  79918. /** @hidden */
  79919. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  79920. /** Launch a ray to try to pick a sprite in the scene
  79921. * @param x position on screen
  79922. * @param y position on screen
  79923. * @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
  79924. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  79925. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  79926. * @returns a PickingInfo
  79927. */
  79928. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  79929. /** Use the given ray to pick a sprite in the scene
  79930. * @param ray The ray (in world space) to use to pick meshes
  79931. * @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
  79932. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  79933. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  79934. * @returns a PickingInfo
  79935. */
  79936. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  79937. /** @hidden */
  79938. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  79939. /** Launch a ray to try to pick sprites in the scene
  79940. * @param x position on screen
  79941. * @param y position on screen
  79942. * @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
  79943. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  79944. * @returns a PickingInfo array
  79945. */
  79946. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  79947. /** Use the given ray to pick sprites in the scene
  79948. * @param ray The ray (in world space) to use to pick meshes
  79949. * @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
  79950. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  79951. * @returns a PickingInfo array
  79952. */
  79953. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  79954. /**
  79955. * Force the sprite under the pointer
  79956. * @param sprite defines the sprite to use
  79957. */
  79958. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  79959. /**
  79960. * Gets the sprite under the pointer
  79961. * @returns a Sprite or null if no sprite is under the pointer
  79962. */
  79963. getPointerOverSprite(): Nullable<Sprite>;
  79964. }
  79965. /**
  79966. * Defines the sprite scene component responsible to manage sprites
  79967. * in a given scene.
  79968. */
  79969. export class SpriteSceneComponent implements ISceneComponent {
  79970. /**
  79971. * The component name helpfull to identify the component in the list of scene components.
  79972. */
  79973. readonly name: string;
  79974. /**
  79975. * The scene the component belongs to.
  79976. */
  79977. scene: Scene;
  79978. /** @hidden */
  79979. private _spritePredicate;
  79980. /**
  79981. * Creates a new instance of the component for the given scene
  79982. * @param scene Defines the scene to register the component in
  79983. */
  79984. constructor(scene: Scene);
  79985. /**
  79986. * Registers the component in a given scene
  79987. */
  79988. register(): void;
  79989. /**
  79990. * Rebuilds the elements related to this component in case of
  79991. * context lost for instance.
  79992. */
  79993. rebuild(): void;
  79994. /**
  79995. * Disposes the component and the associated ressources.
  79996. */
  79997. dispose(): void;
  79998. private _pickSpriteButKeepRay;
  79999. private _pointerMove;
  80000. private _pointerDown;
  80001. private _pointerUp;
  80002. }
  80003. }
  80004. declare module BABYLON {
  80005. /** @hidden */
  80006. export var fogFragmentDeclaration: {
  80007. name: string;
  80008. shader: string;
  80009. };
  80010. }
  80011. declare module BABYLON {
  80012. /** @hidden */
  80013. export var fogFragment: {
  80014. name: string;
  80015. shader: string;
  80016. };
  80017. }
  80018. declare module BABYLON {
  80019. /** @hidden */
  80020. export var spritesPixelShader: {
  80021. name: string;
  80022. shader: string;
  80023. };
  80024. }
  80025. declare module BABYLON {
  80026. /** @hidden */
  80027. export var fogVertexDeclaration: {
  80028. name: string;
  80029. shader: string;
  80030. };
  80031. }
  80032. declare module BABYLON {
  80033. /** @hidden */
  80034. export var spritesVertexShader: {
  80035. name: string;
  80036. shader: string;
  80037. };
  80038. }
  80039. declare module BABYLON {
  80040. /**
  80041. * Defines the minimum interface to fullfil in order to be a sprite manager.
  80042. */
  80043. export interface ISpriteManager extends IDisposable {
  80044. /**
  80045. * Restricts the camera to viewing objects with the same layerMask.
  80046. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  80047. */
  80048. layerMask: number;
  80049. /**
  80050. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  80051. */
  80052. isPickable: boolean;
  80053. /**
  80054. * Specifies the rendering group id for this mesh (0 by default)
  80055. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  80056. */
  80057. renderingGroupId: number;
  80058. /**
  80059. * Defines the list of sprites managed by the manager.
  80060. */
  80061. sprites: Array<Sprite>;
  80062. /**
  80063. * Tests the intersection of a sprite with a specific ray.
  80064. * @param ray The ray we are sending to test the collision
  80065. * @param camera The camera space we are sending rays in
  80066. * @param predicate A predicate allowing excluding sprites from the list of object to test
  80067. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  80068. * @returns picking info or null.
  80069. */
  80070. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  80071. /**
  80072. * Intersects the sprites with a ray
  80073. * @param ray defines the ray to intersect with
  80074. * @param camera defines the current active camera
  80075. * @param predicate defines a predicate used to select candidate sprites
  80076. * @returns null if no hit or a PickingInfo array
  80077. */
  80078. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  80079. /**
  80080. * Renders the list of sprites on screen.
  80081. */
  80082. render(): void;
  80083. }
  80084. /**
  80085. * Class used to manage multiple sprites on the same spritesheet
  80086. * @see http://doc.babylonjs.com/babylon101/sprites
  80087. */
  80088. export class SpriteManager implements ISpriteManager {
  80089. /** defines the manager's name */
  80090. name: string;
  80091. /** Gets the list of sprites */
  80092. sprites: Sprite[];
  80093. /** Gets or sets the rendering group id (0 by default) */
  80094. renderingGroupId: number;
  80095. /** Gets or sets camera layer mask */
  80096. layerMask: number;
  80097. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  80098. fogEnabled: boolean;
  80099. /** Gets or sets a boolean indicating if the sprites are pickable */
  80100. isPickable: boolean;
  80101. /** Defines the default width of a cell in the spritesheet */
  80102. cellWidth: number;
  80103. /** Defines the default height of a cell in the spritesheet */
  80104. cellHeight: number;
  80105. /** Associative array from JSON sprite data file */
  80106. private _cellData;
  80107. /** Array of sprite names from JSON sprite data file */
  80108. private _spriteMap;
  80109. /** True when packed cell data from JSON file is ready*/
  80110. private _packedAndReady;
  80111. /**
  80112. * An event triggered when the manager is disposed.
  80113. */
  80114. onDisposeObservable: Observable<SpriteManager>;
  80115. private _onDisposeObserver;
  80116. /**
  80117. * Callback called when the manager is disposed
  80118. */
  80119. onDispose: () => void;
  80120. private _capacity;
  80121. private _fromPacked;
  80122. private _spriteTexture;
  80123. private _epsilon;
  80124. private _scene;
  80125. private _vertexData;
  80126. private _buffer;
  80127. private _vertexBuffers;
  80128. private _indexBuffer;
  80129. private _effectBase;
  80130. private _effectFog;
  80131. /**
  80132. * Gets or sets the spritesheet texture
  80133. */
  80134. texture: Texture;
  80135. /**
  80136. * Creates a new sprite manager
  80137. * @param name defines the manager's name
  80138. * @param imgUrl defines the sprite sheet url
  80139. * @param capacity defines the maximum allowed number of sprites
  80140. * @param cellSize defines the size of a sprite cell
  80141. * @param scene defines the hosting scene
  80142. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  80143. * @param samplingMode defines the smapling mode to use with spritesheet
  80144. * @param fromPacked set to false; do not alter
  80145. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  80146. */
  80147. constructor(
  80148. /** defines the manager's name */
  80149. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: string | null);
  80150. private _makePacked;
  80151. private _appendSpriteVertex;
  80152. /**
  80153. * Intersects the sprites with a ray
  80154. * @param ray defines the ray to intersect with
  80155. * @param camera defines the current active camera
  80156. * @param predicate defines a predicate used to select candidate sprites
  80157. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  80158. * @returns null if no hit or a PickingInfo
  80159. */
  80160. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  80161. /**
  80162. * Intersects the sprites with a ray
  80163. * @param ray defines the ray to intersect with
  80164. * @param camera defines the current active camera
  80165. * @param predicate defines a predicate used to select candidate sprites
  80166. * @returns null if no hit or a PickingInfo array
  80167. */
  80168. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  80169. /**
  80170. * Render all child sprites
  80171. */
  80172. render(): void;
  80173. /**
  80174. * Release associated resources
  80175. */
  80176. dispose(): void;
  80177. }
  80178. }
  80179. declare module BABYLON {
  80180. /**
  80181. * Class used to represent a sprite
  80182. * @see http://doc.babylonjs.com/babylon101/sprites
  80183. */
  80184. export class Sprite {
  80185. /** defines the name */
  80186. name: string;
  80187. /** Gets or sets the current world position */
  80188. position: Vector3;
  80189. /** Gets or sets the main color */
  80190. color: Color4;
  80191. /** Gets or sets the width */
  80192. width: number;
  80193. /** Gets or sets the height */
  80194. height: number;
  80195. /** Gets or sets rotation angle */
  80196. angle: number;
  80197. /** Gets or sets the cell index in the sprite sheet */
  80198. cellIndex: number;
  80199. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  80200. cellRef: string;
  80201. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  80202. invertU: number;
  80203. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  80204. invertV: number;
  80205. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  80206. disposeWhenFinishedAnimating: boolean;
  80207. /** Gets the list of attached animations */
  80208. animations: Animation[];
  80209. /** Gets or sets a boolean indicating if the sprite can be picked */
  80210. isPickable: boolean;
  80211. /**
  80212. * Gets or sets the associated action manager
  80213. */
  80214. actionManager: Nullable<ActionManager>;
  80215. private _animationStarted;
  80216. private _loopAnimation;
  80217. private _fromIndex;
  80218. private _toIndex;
  80219. private _delay;
  80220. private _direction;
  80221. private _manager;
  80222. private _time;
  80223. private _onAnimationEnd;
  80224. /**
  80225. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  80226. */
  80227. isVisible: boolean;
  80228. /**
  80229. * Gets or sets the sprite size
  80230. */
  80231. size: number;
  80232. /**
  80233. * Creates a new Sprite
  80234. * @param name defines the name
  80235. * @param manager defines the manager
  80236. */
  80237. constructor(
  80238. /** defines the name */
  80239. name: string, manager: ISpriteManager);
  80240. /**
  80241. * Starts an animation
  80242. * @param from defines the initial key
  80243. * @param to defines the end key
  80244. * @param loop defines if the animation must loop
  80245. * @param delay defines the start delay (in ms)
  80246. * @param onAnimationEnd defines a callback to call when animation ends
  80247. */
  80248. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  80249. /** Stops current animation (if any) */
  80250. stopAnimation(): void;
  80251. /** @hidden */
  80252. _animate(deltaTime: number): void;
  80253. /** Release associated resources */
  80254. dispose(): void;
  80255. }
  80256. }
  80257. declare module BABYLON {
  80258. /**
  80259. * Information about the result of picking within a scene
  80260. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  80261. */
  80262. export class PickingInfo {
  80263. /** @hidden */
  80264. _pickingUnavailable: boolean;
  80265. /**
  80266. * If the pick collided with an object
  80267. */
  80268. hit: boolean;
  80269. /**
  80270. * Distance away where the pick collided
  80271. */
  80272. distance: number;
  80273. /**
  80274. * The location of pick collision
  80275. */
  80276. pickedPoint: Nullable<Vector3>;
  80277. /**
  80278. * The mesh corresponding the the pick collision
  80279. */
  80280. pickedMesh: Nullable<AbstractMesh>;
  80281. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  80282. bu: number;
  80283. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  80284. bv: number;
  80285. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  80286. faceId: number;
  80287. /** Id of the the submesh that was picked */
  80288. subMeshId: number;
  80289. /** If a sprite was picked, this will be the sprite the pick collided with */
  80290. pickedSprite: Nullable<Sprite>;
  80291. /**
  80292. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  80293. */
  80294. originMesh: Nullable<AbstractMesh>;
  80295. /**
  80296. * The ray that was used to perform the picking.
  80297. */
  80298. ray: Nullable<Ray>;
  80299. /**
  80300. * Gets the normal correspodning to the face the pick collided with
  80301. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  80302. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  80303. * @returns The normal correspodning to the face the pick collided with
  80304. */
  80305. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  80306. /**
  80307. * Gets the texture coordinates of where the pick occured
  80308. * @returns the vector containing the coordnates of the texture
  80309. */
  80310. getTextureCoordinates(): Nullable<Vector2>;
  80311. }
  80312. }
  80313. declare module BABYLON {
  80314. /**
  80315. * Gather the list of pointer event types as constants.
  80316. */
  80317. export class PointerEventTypes {
  80318. /**
  80319. * 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.
  80320. */
  80321. static readonly POINTERDOWN: number;
  80322. /**
  80323. * The pointerup event is fired when a pointer is no longer active.
  80324. */
  80325. static readonly POINTERUP: number;
  80326. /**
  80327. * The pointermove event is fired when a pointer changes coordinates.
  80328. */
  80329. static readonly POINTERMOVE: number;
  80330. /**
  80331. * The pointerwheel event is fired when a mouse wheel has been rotated.
  80332. */
  80333. static readonly POINTERWHEEL: number;
  80334. /**
  80335. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  80336. */
  80337. static readonly POINTERPICK: number;
  80338. /**
  80339. * The pointertap event is fired when a the object has been touched and released without drag.
  80340. */
  80341. static readonly POINTERTAP: number;
  80342. /**
  80343. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  80344. */
  80345. static readonly POINTERDOUBLETAP: number;
  80346. }
  80347. /**
  80348. * Base class of pointer info types.
  80349. */
  80350. export class PointerInfoBase {
  80351. /**
  80352. * Defines the type of event (PointerEventTypes)
  80353. */
  80354. type: number;
  80355. /**
  80356. * Defines the related dom event
  80357. */
  80358. event: PointerEvent | MouseWheelEvent;
  80359. /**
  80360. * Instantiates the base class of pointers info.
  80361. * @param type Defines the type of event (PointerEventTypes)
  80362. * @param event Defines the related dom event
  80363. */
  80364. constructor(
  80365. /**
  80366. * Defines the type of event (PointerEventTypes)
  80367. */
  80368. type: number,
  80369. /**
  80370. * Defines the related dom event
  80371. */
  80372. event: PointerEvent | MouseWheelEvent);
  80373. }
  80374. /**
  80375. * This class is used to store pointer related info for the onPrePointerObservable event.
  80376. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  80377. */
  80378. export class PointerInfoPre extends PointerInfoBase {
  80379. /**
  80380. * Ray from a pointer if availible (eg. 6dof controller)
  80381. */
  80382. ray: Nullable<Ray>;
  80383. /**
  80384. * Defines the local position of the pointer on the canvas.
  80385. */
  80386. localPosition: Vector2;
  80387. /**
  80388. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  80389. */
  80390. skipOnPointerObservable: boolean;
  80391. /**
  80392. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  80393. * @param type Defines the type of event (PointerEventTypes)
  80394. * @param event Defines the related dom event
  80395. * @param localX Defines the local x coordinates of the pointer when the event occured
  80396. * @param localY Defines the local y coordinates of the pointer when the event occured
  80397. */
  80398. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  80399. }
  80400. /**
  80401. * This type contains all the data related to a pointer event in Babylon.js.
  80402. * 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.
  80403. */
  80404. export class PointerInfo extends PointerInfoBase {
  80405. /**
  80406. * Defines the picking info associated to the info (if any)\
  80407. */
  80408. pickInfo: Nullable<PickingInfo>;
  80409. /**
  80410. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  80411. * @param type Defines the type of event (PointerEventTypes)
  80412. * @param event Defines the related dom event
  80413. * @param pickInfo Defines the picking info associated to the info (if any)\
  80414. */
  80415. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  80416. /**
  80417. * Defines the picking info associated to the info (if any)\
  80418. */
  80419. pickInfo: Nullable<PickingInfo>);
  80420. }
  80421. /**
  80422. * Data relating to a touch event on the screen.
  80423. */
  80424. export interface PointerTouch {
  80425. /**
  80426. * X coordinate of touch.
  80427. */
  80428. x: number;
  80429. /**
  80430. * Y coordinate of touch.
  80431. */
  80432. y: number;
  80433. /**
  80434. * Id of touch. Unique for each finger.
  80435. */
  80436. pointerId: number;
  80437. /**
  80438. * Event type passed from DOM.
  80439. */
  80440. type: any;
  80441. }
  80442. }
  80443. declare module BABYLON {
  80444. /**
  80445. * Manage the mouse inputs to control the movement of a free camera.
  80446. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  80447. */
  80448. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  80449. /**
  80450. * Define if touch is enabled in the mouse input
  80451. */
  80452. touchEnabled: boolean;
  80453. /**
  80454. * Defines the camera the input is attached to.
  80455. */
  80456. camera: FreeCamera;
  80457. /**
  80458. * Defines the buttons associated with the input to handle camera move.
  80459. */
  80460. buttons: number[];
  80461. /**
  80462. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  80463. */
  80464. angularSensibility: number;
  80465. private _pointerInput;
  80466. private _onMouseMove;
  80467. private _observer;
  80468. private previousPosition;
  80469. /**
  80470. * Observable for when a pointer move event occurs containing the move offset
  80471. */
  80472. onPointerMovedObservable: Observable<{
  80473. offsetX: number;
  80474. offsetY: number;
  80475. }>;
  80476. /**
  80477. * @hidden
  80478. * If the camera should be rotated automatically based on pointer movement
  80479. */
  80480. _allowCameraRotation: boolean;
  80481. /**
  80482. * Manage the mouse inputs to control the movement of a free camera.
  80483. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  80484. * @param touchEnabled Defines if touch is enabled or not
  80485. */
  80486. constructor(
  80487. /**
  80488. * Define if touch is enabled in the mouse input
  80489. */
  80490. touchEnabled?: boolean);
  80491. /**
  80492. * Attach the input controls to a specific dom element to get the input from.
  80493. * @param element Defines the element the controls should be listened from
  80494. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  80495. */
  80496. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  80497. /**
  80498. * Called on JS contextmenu event.
  80499. * Override this method to provide functionality.
  80500. */
  80501. protected onContextMenu(evt: PointerEvent): void;
  80502. /**
  80503. * Detach the current controls from the specified dom element.
  80504. * @param element Defines the element to stop listening the inputs from
  80505. */
  80506. detachControl(element: Nullable<HTMLElement>): void;
  80507. /**
  80508. * Gets the class name of the current intput.
  80509. * @returns the class name
  80510. */
  80511. getClassName(): string;
  80512. /**
  80513. * Get the friendly name associated with the input class.
  80514. * @returns the input friendly name
  80515. */
  80516. getSimpleName(): string;
  80517. }
  80518. }
  80519. declare module BABYLON {
  80520. /**
  80521. * Manage the touch inputs to control the movement of a free camera.
  80522. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  80523. */
  80524. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  80525. /**
  80526. * Defines the camera the input is attached to.
  80527. */
  80528. camera: FreeCamera;
  80529. /**
  80530. * Defines the touch sensibility for rotation.
  80531. * The higher the faster.
  80532. */
  80533. touchAngularSensibility: number;
  80534. /**
  80535. * Defines the touch sensibility for move.
  80536. * The higher the faster.
  80537. */
  80538. touchMoveSensibility: number;
  80539. private _offsetX;
  80540. private _offsetY;
  80541. private _pointerPressed;
  80542. private _pointerInput;
  80543. private _observer;
  80544. private _onLostFocus;
  80545. /**
  80546. * Attach the input controls to a specific dom element to get the input from.
  80547. * @param element Defines the element the controls should be listened from
  80548. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  80549. */
  80550. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  80551. /**
  80552. * Detach the current controls from the specified dom element.
  80553. * @param element Defines the element to stop listening the inputs from
  80554. */
  80555. detachControl(element: Nullable<HTMLElement>): void;
  80556. /**
  80557. * Update the current camera state depending on the inputs that have been used this frame.
  80558. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  80559. */
  80560. checkInputs(): void;
  80561. /**
  80562. * Gets the class name of the current intput.
  80563. * @returns the class name
  80564. */
  80565. getClassName(): string;
  80566. /**
  80567. * Get the friendly name associated with the input class.
  80568. * @returns the input friendly name
  80569. */
  80570. getSimpleName(): string;
  80571. }
  80572. }
  80573. declare module BABYLON {
  80574. /**
  80575. * Default Inputs manager for the FreeCamera.
  80576. * It groups all the default supported inputs for ease of use.
  80577. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  80578. */
  80579. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  80580. /**
  80581. * @hidden
  80582. */
  80583. _mouseInput: Nullable<FreeCameraMouseInput>;
  80584. /**
  80585. * Instantiates a new FreeCameraInputsManager.
  80586. * @param camera Defines the camera the inputs belong to
  80587. */
  80588. constructor(camera: FreeCamera);
  80589. /**
  80590. * Add keyboard input support to the input manager.
  80591. * @returns the current input manager
  80592. */
  80593. addKeyboard(): FreeCameraInputsManager;
  80594. /**
  80595. * Add mouse input support to the input manager.
  80596. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  80597. * @returns the current input manager
  80598. */
  80599. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  80600. /**
  80601. * Removes the mouse input support from the manager
  80602. * @returns the current input manager
  80603. */
  80604. removeMouse(): FreeCameraInputsManager;
  80605. /**
  80606. * Add touch input support to the input manager.
  80607. * @returns the current input manager
  80608. */
  80609. addTouch(): FreeCameraInputsManager;
  80610. /**
  80611. * Remove all attached input methods from a camera
  80612. */
  80613. clear(): void;
  80614. }
  80615. }
  80616. declare module BABYLON {
  80617. /**
  80618. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  80619. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  80620. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  80621. */
  80622. export class FreeCamera extends TargetCamera {
  80623. /**
  80624. * Define the collision ellipsoid of the camera.
  80625. * This is helpful to simulate a camera body like the player body around the camera
  80626. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  80627. */
  80628. ellipsoid: Vector3;
  80629. /**
  80630. * Define an offset for the position of the ellipsoid around the camera.
  80631. * This can be helpful to determine the center of the body near the gravity center of the body
  80632. * instead of its head.
  80633. */
  80634. ellipsoidOffset: Vector3;
  80635. /**
  80636. * Enable or disable collisions of the camera with the rest of the scene objects.
  80637. */
  80638. checkCollisions: boolean;
  80639. /**
  80640. * Enable or disable gravity on the camera.
  80641. */
  80642. applyGravity: boolean;
  80643. /**
  80644. * Define the input manager associated to the camera.
  80645. */
  80646. inputs: FreeCameraInputsManager;
  80647. /**
  80648. * Gets the input sensibility for a mouse input. (default is 2000.0)
  80649. * Higher values reduce sensitivity.
  80650. */
  80651. /**
  80652. * Sets the input sensibility for a mouse input. (default is 2000.0)
  80653. * Higher values reduce sensitivity.
  80654. */
  80655. angularSensibility: number;
  80656. /**
  80657. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  80658. */
  80659. keysUp: number[];
  80660. /**
  80661. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  80662. */
  80663. keysDown: number[];
  80664. /**
  80665. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  80666. */
  80667. keysLeft: number[];
  80668. /**
  80669. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  80670. */
  80671. keysRight: number[];
  80672. /**
  80673. * Event raised when the camera collide with a mesh in the scene.
  80674. */
  80675. onCollide: (collidedMesh: AbstractMesh) => void;
  80676. private _collider;
  80677. private _needMoveForGravity;
  80678. private _oldPosition;
  80679. private _diffPosition;
  80680. private _newPosition;
  80681. /** @hidden */
  80682. _localDirection: Vector3;
  80683. /** @hidden */
  80684. _transformedDirection: Vector3;
  80685. /**
  80686. * Instantiates a Free Camera.
  80687. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  80688. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  80689. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  80690. * @param name Define the name of the camera in the scene
  80691. * @param position Define the start position of the camera in the scene
  80692. * @param scene Define the scene the camera belongs to
  80693. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  80694. */
  80695. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  80696. /**
  80697. * Attached controls to the current camera.
  80698. * @param element Defines the element the controls should be listened from
  80699. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  80700. */
  80701. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  80702. /**
  80703. * Detach the current controls from the camera.
  80704. * The camera will stop reacting to inputs.
  80705. * @param element Defines the element to stop listening the inputs from
  80706. */
  80707. detachControl(element: HTMLElement): void;
  80708. private _collisionMask;
  80709. /**
  80710. * Define a collision mask to limit the list of object the camera can collide with
  80711. */
  80712. collisionMask: number;
  80713. /** @hidden */
  80714. _collideWithWorld(displacement: Vector3): void;
  80715. private _onCollisionPositionChange;
  80716. /** @hidden */
  80717. _checkInputs(): void;
  80718. /** @hidden */
  80719. _decideIfNeedsToMove(): boolean;
  80720. /** @hidden */
  80721. _updatePosition(): void;
  80722. /**
  80723. * Destroy the camera and release the current resources hold by it.
  80724. */
  80725. dispose(): void;
  80726. /**
  80727. * Gets the current object class name.
  80728. * @return the class name
  80729. */
  80730. getClassName(): string;
  80731. }
  80732. }
  80733. declare module BABYLON {
  80734. /**
  80735. * Represents a gamepad control stick position
  80736. */
  80737. export class StickValues {
  80738. /**
  80739. * The x component of the control stick
  80740. */
  80741. x: number;
  80742. /**
  80743. * The y component of the control stick
  80744. */
  80745. y: number;
  80746. /**
  80747. * Initializes the gamepad x and y control stick values
  80748. * @param x The x component of the gamepad control stick value
  80749. * @param y The y component of the gamepad control stick value
  80750. */
  80751. constructor(
  80752. /**
  80753. * The x component of the control stick
  80754. */
  80755. x: number,
  80756. /**
  80757. * The y component of the control stick
  80758. */
  80759. y: number);
  80760. }
  80761. /**
  80762. * An interface which manages callbacks for gamepad button changes
  80763. */
  80764. export interface GamepadButtonChanges {
  80765. /**
  80766. * Called when a gamepad has been changed
  80767. */
  80768. changed: boolean;
  80769. /**
  80770. * Called when a gamepad press event has been triggered
  80771. */
  80772. pressChanged: boolean;
  80773. /**
  80774. * Called when a touch event has been triggered
  80775. */
  80776. touchChanged: boolean;
  80777. /**
  80778. * Called when a value has changed
  80779. */
  80780. valueChanged: boolean;
  80781. }
  80782. /**
  80783. * Represents a gamepad
  80784. */
  80785. export class Gamepad {
  80786. /**
  80787. * The id of the gamepad
  80788. */
  80789. id: string;
  80790. /**
  80791. * The index of the gamepad
  80792. */
  80793. index: number;
  80794. /**
  80795. * The browser gamepad
  80796. */
  80797. browserGamepad: any;
  80798. /**
  80799. * Specifies what type of gamepad this represents
  80800. */
  80801. type: number;
  80802. private _leftStick;
  80803. private _rightStick;
  80804. /** @hidden */
  80805. _isConnected: boolean;
  80806. private _leftStickAxisX;
  80807. private _leftStickAxisY;
  80808. private _rightStickAxisX;
  80809. private _rightStickAxisY;
  80810. /**
  80811. * Triggered when the left control stick has been changed
  80812. */
  80813. private _onleftstickchanged;
  80814. /**
  80815. * Triggered when the right control stick has been changed
  80816. */
  80817. private _onrightstickchanged;
  80818. /**
  80819. * Represents a gamepad controller
  80820. */
  80821. static GAMEPAD: number;
  80822. /**
  80823. * Represents a generic controller
  80824. */
  80825. static GENERIC: number;
  80826. /**
  80827. * Represents an XBox controller
  80828. */
  80829. static XBOX: number;
  80830. /**
  80831. * Represents a pose-enabled controller
  80832. */
  80833. static POSE_ENABLED: number;
  80834. /**
  80835. * Represents an Dual Shock controller
  80836. */
  80837. static DUALSHOCK: number;
  80838. /**
  80839. * Specifies whether the left control stick should be Y-inverted
  80840. */
  80841. protected _invertLeftStickY: boolean;
  80842. /**
  80843. * Specifies if the gamepad has been connected
  80844. */
  80845. readonly isConnected: boolean;
  80846. /**
  80847. * Initializes the gamepad
  80848. * @param id The id of the gamepad
  80849. * @param index The index of the gamepad
  80850. * @param browserGamepad The browser gamepad
  80851. * @param leftStickX The x component of the left joystick
  80852. * @param leftStickY The y component of the left joystick
  80853. * @param rightStickX The x component of the right joystick
  80854. * @param rightStickY The y component of the right joystick
  80855. */
  80856. constructor(
  80857. /**
  80858. * The id of the gamepad
  80859. */
  80860. id: string,
  80861. /**
  80862. * The index of the gamepad
  80863. */
  80864. index: number,
  80865. /**
  80866. * The browser gamepad
  80867. */
  80868. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  80869. /**
  80870. * Callback triggered when the left joystick has changed
  80871. * @param callback
  80872. */
  80873. onleftstickchanged(callback: (values: StickValues) => void): void;
  80874. /**
  80875. * Callback triggered when the right joystick has changed
  80876. * @param callback
  80877. */
  80878. onrightstickchanged(callback: (values: StickValues) => void): void;
  80879. /**
  80880. * Gets the left joystick
  80881. */
  80882. /**
  80883. * Sets the left joystick values
  80884. */
  80885. leftStick: StickValues;
  80886. /**
  80887. * Gets the right joystick
  80888. */
  80889. /**
  80890. * Sets the right joystick value
  80891. */
  80892. rightStick: StickValues;
  80893. /**
  80894. * Updates the gamepad joystick positions
  80895. */
  80896. update(): void;
  80897. /**
  80898. * Disposes the gamepad
  80899. */
  80900. dispose(): void;
  80901. }
  80902. /**
  80903. * Represents a generic gamepad
  80904. */
  80905. export class GenericPad extends Gamepad {
  80906. private _buttons;
  80907. private _onbuttondown;
  80908. private _onbuttonup;
  80909. /**
  80910. * Observable triggered when a button has been pressed
  80911. */
  80912. onButtonDownObservable: Observable<number>;
  80913. /**
  80914. * Observable triggered when a button has been released
  80915. */
  80916. onButtonUpObservable: Observable<number>;
  80917. /**
  80918. * Callback triggered when a button has been pressed
  80919. * @param callback Called when a button has been pressed
  80920. */
  80921. onbuttondown(callback: (buttonPressed: number) => void): void;
  80922. /**
  80923. * Callback triggered when a button has been released
  80924. * @param callback Called when a button has been released
  80925. */
  80926. onbuttonup(callback: (buttonReleased: number) => void): void;
  80927. /**
  80928. * Initializes the generic gamepad
  80929. * @param id The id of the generic gamepad
  80930. * @param index The index of the generic gamepad
  80931. * @param browserGamepad The browser gamepad
  80932. */
  80933. constructor(id: string, index: number, browserGamepad: any);
  80934. private _setButtonValue;
  80935. /**
  80936. * Updates the generic gamepad
  80937. */
  80938. update(): void;
  80939. /**
  80940. * Disposes the generic gamepad
  80941. */
  80942. dispose(): void;
  80943. }
  80944. }
  80945. declare module BABYLON {
  80946. interface Engine {
  80947. /**
  80948. * Creates a raw texture
  80949. * @param data defines the data to store in the texture
  80950. * @param width defines the width of the texture
  80951. * @param height defines the height of the texture
  80952. * @param format defines the format of the data
  80953. * @param generateMipMaps defines if the engine should generate the mip levels
  80954. * @param invertY defines if data must be stored with Y axis inverted
  80955. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  80956. * @param compression defines the compression used (null by default)
  80957. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  80958. * @returns the raw texture inside an InternalTexture
  80959. */
  80960. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  80961. /**
  80962. * Update a raw texture
  80963. * @param texture defines the texture to update
  80964. * @param data defines the data to store in the texture
  80965. * @param format defines the format of the data
  80966. * @param invertY defines if data must be stored with Y axis inverted
  80967. */
  80968. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  80969. /**
  80970. * Update a raw texture
  80971. * @param texture defines the texture to update
  80972. * @param data defines the data to store in the texture
  80973. * @param format defines the format of the data
  80974. * @param invertY defines if data must be stored with Y axis inverted
  80975. * @param compression defines the compression used (null by default)
  80976. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  80977. */
  80978. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  80979. /**
  80980. * Creates a new raw cube texture
  80981. * @param data defines the array of data to use to create each face
  80982. * @param size defines the size of the textures
  80983. * @param format defines the format of the data
  80984. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  80985. * @param generateMipMaps defines if the engine should generate the mip levels
  80986. * @param invertY defines if data must be stored with Y axis inverted
  80987. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  80988. * @param compression defines the compression used (null by default)
  80989. * @returns the cube texture as an InternalTexture
  80990. */
  80991. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  80992. /**
  80993. * Update a raw cube texture
  80994. * @param texture defines the texture to udpdate
  80995. * @param data defines the data to store
  80996. * @param format defines the data format
  80997. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  80998. * @param invertY defines if data must be stored with Y axis inverted
  80999. */
  81000. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  81001. /**
  81002. * Update a raw cube texture
  81003. * @param texture defines the texture to udpdate
  81004. * @param data defines the data to store
  81005. * @param format defines the data format
  81006. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  81007. * @param invertY defines if data must be stored with Y axis inverted
  81008. * @param compression defines the compression used (null by default)
  81009. */
  81010. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  81011. /**
  81012. * Update a raw cube texture
  81013. * @param texture defines the texture to udpdate
  81014. * @param data defines the data to store
  81015. * @param format defines the data format
  81016. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  81017. * @param invertY defines if data must be stored with Y axis inverted
  81018. * @param compression defines the compression used (null by default)
  81019. * @param level defines which level of the texture to update
  81020. */
  81021. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  81022. /**
  81023. * Creates a new raw cube texture from a specified url
  81024. * @param url defines the url where the data is located
  81025. * @param scene defines the current scene
  81026. * @param size defines the size of the textures
  81027. * @param format defines the format of the data
  81028. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  81029. * @param noMipmap defines if the engine should avoid generating the mip levels
  81030. * @param callback defines a callback used to extract texture data from loaded data
  81031. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  81032. * @param onLoad defines a callback called when texture is loaded
  81033. * @param onError defines a callback called if there is an error
  81034. * @returns the cube texture as an InternalTexture
  81035. */
  81036. 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;
  81037. /**
  81038. * Creates a new raw cube texture from a specified url
  81039. * @param url defines the url where the data is located
  81040. * @param scene defines the current scene
  81041. * @param size defines the size of the textures
  81042. * @param format defines the format of the data
  81043. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  81044. * @param noMipmap defines if the engine should avoid generating the mip levels
  81045. * @param callback defines a callback used to extract texture data from loaded data
  81046. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  81047. * @param onLoad defines a callback called when texture is loaded
  81048. * @param onError defines a callback called if there is an error
  81049. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  81050. * @param invertY defines if data must be stored with Y axis inverted
  81051. * @returns the cube texture as an InternalTexture
  81052. */
  81053. 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;
  81054. /**
  81055. * Creates a new raw 3D texture
  81056. * @param data defines the data used to create the texture
  81057. * @param width defines the width of the texture
  81058. * @param height defines the height of the texture
  81059. * @param depth defines the depth of the texture
  81060. * @param format defines the format of the texture
  81061. * @param generateMipMaps defines if the engine must generate mip levels
  81062. * @param invertY defines if data must be stored with Y axis inverted
  81063. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  81064. * @param compression defines the compressed used (can be null)
  81065. * @param textureType defines the compressed used (can be null)
  81066. * @returns a new raw 3D texture (stored in an InternalTexture)
  81067. */
  81068. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  81069. /**
  81070. * Update a raw 3D texture
  81071. * @param texture defines the texture to update
  81072. * @param data defines the data to store
  81073. * @param format defines the data format
  81074. * @param invertY defines if data must be stored with Y axis inverted
  81075. */
  81076. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  81077. /**
  81078. * Update a raw 3D texture
  81079. * @param texture defines the texture to update
  81080. * @param data defines the data to store
  81081. * @param format defines the data format
  81082. * @param invertY defines if data must be stored with Y axis inverted
  81083. * @param compression defines the used compression (can be null)
  81084. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  81085. */
  81086. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  81087. /**
  81088. * Creates a new raw 2D array texture
  81089. * @param data defines the data used to create the texture
  81090. * @param width defines the width of the texture
  81091. * @param height defines the height of the texture
  81092. * @param depth defines the number of layers of the texture
  81093. * @param format defines the format of the texture
  81094. * @param generateMipMaps defines if the engine must generate mip levels
  81095. * @param invertY defines if data must be stored with Y axis inverted
  81096. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  81097. * @param compression defines the compressed used (can be null)
  81098. * @param textureType defines the compressed used (can be null)
  81099. * @returns a new raw 2D array texture (stored in an InternalTexture)
  81100. */
  81101. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  81102. /**
  81103. * Update a raw 2D array texture
  81104. * @param texture defines the texture to update
  81105. * @param data defines the data to store
  81106. * @param format defines the data format
  81107. * @param invertY defines if data must be stored with Y axis inverted
  81108. */
  81109. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  81110. /**
  81111. * Update a raw 2D array texture
  81112. * @param texture defines the texture to update
  81113. * @param data defines the data to store
  81114. * @param format defines the data format
  81115. * @param invertY defines if data must be stored with Y axis inverted
  81116. * @param compression defines the used compression (can be null)
  81117. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  81118. */
  81119. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  81120. }
  81121. }
  81122. declare module BABYLON {
  81123. /**
  81124. * Raw texture can help creating a texture directly from an array of data.
  81125. * This can be super useful if you either get the data from an uncompressed source or
  81126. * if you wish to create your texture pixel by pixel.
  81127. */
  81128. export class RawTexture extends Texture {
  81129. /**
  81130. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  81131. */
  81132. format: number;
  81133. private _engine;
  81134. /**
  81135. * Instantiates a new RawTexture.
  81136. * Raw texture can help creating a texture directly from an array of data.
  81137. * This can be super useful if you either get the data from an uncompressed source or
  81138. * if you wish to create your texture pixel by pixel.
  81139. * @param data define the array of data to use to create the texture
  81140. * @param width define the width of the texture
  81141. * @param height define the height of the texture
  81142. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  81143. * @param scene define the scene the texture belongs to
  81144. * @param generateMipMaps define whether mip maps should be generated or not
  81145. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  81146. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  81147. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  81148. */
  81149. constructor(data: ArrayBufferView, width: number, height: number,
  81150. /**
  81151. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  81152. */
  81153. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  81154. /**
  81155. * Updates the texture underlying data.
  81156. * @param data Define the new data of the texture
  81157. */
  81158. update(data: ArrayBufferView): void;
  81159. /**
  81160. * Creates a luminance texture from some data.
  81161. * @param data Define the texture data
  81162. * @param width Define the width of the texture
  81163. * @param height Define the height of the texture
  81164. * @param scene Define the scene the texture belongs to
  81165. * @param generateMipMaps Define whether or not to create mip maps for the texture
  81166. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  81167. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  81168. * @returns the luminance texture
  81169. */
  81170. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  81171. /**
  81172. * Creates a luminance alpha texture from some data.
  81173. * @param data Define the texture data
  81174. * @param width Define the width of the texture
  81175. * @param height Define the height of the texture
  81176. * @param scene Define the scene the texture belongs to
  81177. * @param generateMipMaps Define whether or not to create mip maps for the texture
  81178. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  81179. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  81180. * @returns the luminance alpha texture
  81181. */
  81182. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  81183. /**
  81184. * Creates an alpha texture from some data.
  81185. * @param data Define the texture data
  81186. * @param width Define the width of the texture
  81187. * @param height Define the height of the texture
  81188. * @param scene Define the scene the texture belongs to
  81189. * @param generateMipMaps Define whether or not to create mip maps for the texture
  81190. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  81191. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  81192. * @returns the alpha texture
  81193. */
  81194. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  81195. /**
  81196. * Creates a RGB texture from some data.
  81197. * @param data Define the texture data
  81198. * @param width Define the width of the texture
  81199. * @param height Define the height of the texture
  81200. * @param scene Define the scene the texture belongs to
  81201. * @param generateMipMaps Define whether or not to create mip maps for the texture
  81202. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  81203. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  81204. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  81205. * @returns the RGB alpha texture
  81206. */
  81207. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  81208. /**
  81209. * Creates a RGBA texture from some data.
  81210. * @param data Define the texture data
  81211. * @param width Define the width of the texture
  81212. * @param height Define the height of the texture
  81213. * @param scene Define the scene the texture belongs to
  81214. * @param generateMipMaps Define whether or not to create mip maps for the texture
  81215. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  81216. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  81217. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  81218. * @returns the RGBA texture
  81219. */
  81220. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  81221. /**
  81222. * Creates a R texture from some data.
  81223. * @param data Define the texture data
  81224. * @param width Define the width of the texture
  81225. * @param height Define the height of the texture
  81226. * @param scene Define the scene the texture belongs to
  81227. * @param generateMipMaps Define whether or not to create mip maps for the texture
  81228. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  81229. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  81230. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  81231. * @returns the R texture
  81232. */
  81233. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  81234. }
  81235. }
  81236. declare module BABYLON {
  81237. /**
  81238. * Interface for the size containing width and height
  81239. */
  81240. export interface ISize {
  81241. /**
  81242. * Width
  81243. */
  81244. width: number;
  81245. /**
  81246. * Heighht
  81247. */
  81248. height: number;
  81249. }
  81250. /**
  81251. * Size containing widht and height
  81252. */
  81253. export class Size implements ISize {
  81254. /**
  81255. * Width
  81256. */
  81257. width: number;
  81258. /**
  81259. * Height
  81260. */
  81261. height: number;
  81262. /**
  81263. * Creates a Size object from the given width and height (floats).
  81264. * @param width width of the new size
  81265. * @param height height of the new size
  81266. */
  81267. constructor(width: number, height: number);
  81268. /**
  81269. * Returns a string with the Size width and height
  81270. * @returns a string with the Size width and height
  81271. */
  81272. toString(): string;
  81273. /**
  81274. * "Size"
  81275. * @returns the string "Size"
  81276. */
  81277. getClassName(): string;
  81278. /**
  81279. * Returns the Size hash code.
  81280. * @returns a hash code for a unique width and height
  81281. */
  81282. getHashCode(): number;
  81283. /**
  81284. * Updates the current size from the given one.
  81285. * @param src the given size
  81286. */
  81287. copyFrom(src: Size): void;
  81288. /**
  81289. * Updates in place the current Size from the given floats.
  81290. * @param width width of the new size
  81291. * @param height height of the new size
  81292. * @returns the updated Size.
  81293. */
  81294. copyFromFloats(width: number, height: number): Size;
  81295. /**
  81296. * Updates in place the current Size from the given floats.
  81297. * @param width width to set
  81298. * @param height height to set
  81299. * @returns the updated Size.
  81300. */
  81301. set(width: number, height: number): Size;
  81302. /**
  81303. * Multiplies the width and height by numbers
  81304. * @param w factor to multiple the width by
  81305. * @param h factor to multiple the height by
  81306. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  81307. */
  81308. multiplyByFloats(w: number, h: number): Size;
  81309. /**
  81310. * Clones the size
  81311. * @returns a new Size copied from the given one.
  81312. */
  81313. clone(): Size;
  81314. /**
  81315. * True if the current Size and the given one width and height are strictly equal.
  81316. * @param other the other size to compare against
  81317. * @returns True if the current Size and the given one width and height are strictly equal.
  81318. */
  81319. equals(other: Size): boolean;
  81320. /**
  81321. * The surface of the Size : width * height (float).
  81322. */
  81323. readonly surface: number;
  81324. /**
  81325. * Create a new size of zero
  81326. * @returns a new Size set to (0.0, 0.0)
  81327. */
  81328. static Zero(): Size;
  81329. /**
  81330. * Sums the width and height of two sizes
  81331. * @param otherSize size to add to this size
  81332. * @returns a new Size set as the addition result of the current Size and the given one.
  81333. */
  81334. add(otherSize: Size): Size;
  81335. /**
  81336. * Subtracts the width and height of two
  81337. * @param otherSize size to subtract to this size
  81338. * @returns a new Size set as the subtraction result of the given one from the current Size.
  81339. */
  81340. subtract(otherSize: Size): Size;
  81341. /**
  81342. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  81343. * @param start starting size to lerp between
  81344. * @param end end size to lerp between
  81345. * @param amount amount to lerp between the start and end values
  81346. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  81347. */
  81348. static Lerp(start: Size, end: Size, amount: number): Size;
  81349. }
  81350. }
  81351. declare module BABYLON {
  81352. /**
  81353. * Defines a runtime animation
  81354. */
  81355. export class RuntimeAnimation {
  81356. private _events;
  81357. /**
  81358. * The current frame of the runtime animation
  81359. */
  81360. private _currentFrame;
  81361. /**
  81362. * The animation used by the runtime animation
  81363. */
  81364. private _animation;
  81365. /**
  81366. * The target of the runtime animation
  81367. */
  81368. private _target;
  81369. /**
  81370. * The initiating animatable
  81371. */
  81372. private _host;
  81373. /**
  81374. * The original value of the runtime animation
  81375. */
  81376. private _originalValue;
  81377. /**
  81378. * The original blend value of the runtime animation
  81379. */
  81380. private _originalBlendValue;
  81381. /**
  81382. * The offsets cache of the runtime animation
  81383. */
  81384. private _offsetsCache;
  81385. /**
  81386. * The high limits cache of the runtime animation
  81387. */
  81388. private _highLimitsCache;
  81389. /**
  81390. * Specifies if the runtime animation has been stopped
  81391. */
  81392. private _stopped;
  81393. /**
  81394. * The blending factor of the runtime animation
  81395. */
  81396. private _blendingFactor;
  81397. /**
  81398. * The BabylonJS scene
  81399. */
  81400. private _scene;
  81401. /**
  81402. * The current value of the runtime animation
  81403. */
  81404. private _currentValue;
  81405. /** @hidden */
  81406. _animationState: _IAnimationState;
  81407. /**
  81408. * The active target of the runtime animation
  81409. */
  81410. private _activeTargets;
  81411. private _currentActiveTarget;
  81412. private _directTarget;
  81413. /**
  81414. * The target path of the runtime animation
  81415. */
  81416. private _targetPath;
  81417. /**
  81418. * The weight of the runtime animation
  81419. */
  81420. private _weight;
  81421. /**
  81422. * The ratio offset of the runtime animation
  81423. */
  81424. private _ratioOffset;
  81425. /**
  81426. * The previous delay of the runtime animation
  81427. */
  81428. private _previousDelay;
  81429. /**
  81430. * The previous ratio of the runtime animation
  81431. */
  81432. private _previousRatio;
  81433. private _enableBlending;
  81434. private _keys;
  81435. private _minFrame;
  81436. private _maxFrame;
  81437. private _minValue;
  81438. private _maxValue;
  81439. private _targetIsArray;
  81440. /**
  81441. * Gets the current frame of the runtime animation
  81442. */
  81443. readonly currentFrame: number;
  81444. /**
  81445. * Gets the weight of the runtime animation
  81446. */
  81447. readonly weight: number;
  81448. /**
  81449. * Gets the current value of the runtime animation
  81450. */
  81451. readonly currentValue: any;
  81452. /**
  81453. * Gets the target path of the runtime animation
  81454. */
  81455. readonly targetPath: string;
  81456. /**
  81457. * Gets the actual target of the runtime animation
  81458. */
  81459. readonly target: any;
  81460. /** @hidden */
  81461. _onLoop: () => void;
  81462. /**
  81463. * Create a new RuntimeAnimation object
  81464. * @param target defines the target of the animation
  81465. * @param animation defines the source animation object
  81466. * @param scene defines the hosting scene
  81467. * @param host defines the initiating Animatable
  81468. */
  81469. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  81470. private _preparePath;
  81471. /**
  81472. * Gets the animation from the runtime animation
  81473. */
  81474. readonly animation: Animation;
  81475. /**
  81476. * Resets the runtime animation to the beginning
  81477. * @param restoreOriginal defines whether to restore the target property to the original value
  81478. */
  81479. reset(restoreOriginal?: boolean): void;
  81480. /**
  81481. * Specifies if the runtime animation is stopped
  81482. * @returns Boolean specifying if the runtime animation is stopped
  81483. */
  81484. isStopped(): boolean;
  81485. /**
  81486. * Disposes of the runtime animation
  81487. */
  81488. dispose(): void;
  81489. /**
  81490. * Apply the interpolated value to the target
  81491. * @param currentValue defines the value computed by the animation
  81492. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  81493. */
  81494. setValue(currentValue: any, weight: number): void;
  81495. private _getOriginalValues;
  81496. private _setValue;
  81497. /**
  81498. * Gets the loop pmode of the runtime animation
  81499. * @returns Loop Mode
  81500. */
  81501. private _getCorrectLoopMode;
  81502. /**
  81503. * Move the current animation to a given frame
  81504. * @param frame defines the frame to move to
  81505. */
  81506. goToFrame(frame: number): void;
  81507. /**
  81508. * @hidden Internal use only
  81509. */
  81510. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  81511. /**
  81512. * Execute the current animation
  81513. * @param delay defines the delay to add to the current frame
  81514. * @param from defines the lower bound of the animation range
  81515. * @param to defines the upper bound of the animation range
  81516. * @param loop defines if the current animation must loop
  81517. * @param speedRatio defines the current speed ratio
  81518. * @param weight defines the weight of the animation (default is -1 so no weight)
  81519. * @param onLoop optional callback called when animation loops
  81520. * @returns a boolean indicating if the animation is running
  81521. */
  81522. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  81523. }
  81524. }
  81525. declare module BABYLON {
  81526. /**
  81527. * Class used to store an actual running animation
  81528. */
  81529. export class Animatable {
  81530. /** defines the target object */
  81531. target: any;
  81532. /** defines the starting frame number (default is 0) */
  81533. fromFrame: number;
  81534. /** defines the ending frame number (default is 100) */
  81535. toFrame: number;
  81536. /** defines if the animation must loop (default is false) */
  81537. loopAnimation: boolean;
  81538. /** defines a callback to call when animation ends if it is not looping */
  81539. onAnimationEnd?: (() => void) | null | undefined;
  81540. /** defines a callback to call when animation loops */
  81541. onAnimationLoop?: (() => void) | null | undefined;
  81542. private _localDelayOffset;
  81543. private _pausedDelay;
  81544. private _runtimeAnimations;
  81545. private _paused;
  81546. private _scene;
  81547. private _speedRatio;
  81548. private _weight;
  81549. private _syncRoot;
  81550. /**
  81551. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  81552. * This will only apply for non looping animation (default is true)
  81553. */
  81554. disposeOnEnd: boolean;
  81555. /**
  81556. * Gets a boolean indicating if the animation has started
  81557. */
  81558. animationStarted: boolean;
  81559. /**
  81560. * Observer raised when the animation ends
  81561. */
  81562. onAnimationEndObservable: Observable<Animatable>;
  81563. /**
  81564. * Observer raised when the animation loops
  81565. */
  81566. onAnimationLoopObservable: Observable<Animatable>;
  81567. /**
  81568. * Gets the root Animatable used to synchronize and normalize animations
  81569. */
  81570. readonly syncRoot: Nullable<Animatable>;
  81571. /**
  81572. * Gets the current frame of the first RuntimeAnimation
  81573. * Used to synchronize Animatables
  81574. */
  81575. readonly masterFrame: number;
  81576. /**
  81577. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  81578. */
  81579. weight: number;
  81580. /**
  81581. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  81582. */
  81583. speedRatio: number;
  81584. /**
  81585. * Creates a new Animatable
  81586. * @param scene defines the hosting scene
  81587. * @param target defines the target object
  81588. * @param fromFrame defines the starting frame number (default is 0)
  81589. * @param toFrame defines the ending frame number (default is 100)
  81590. * @param loopAnimation defines if the animation must loop (default is false)
  81591. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  81592. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  81593. * @param animations defines a group of animation to add to the new Animatable
  81594. * @param onAnimationLoop defines a callback to call when animation loops
  81595. */
  81596. constructor(scene: Scene,
  81597. /** defines the target object */
  81598. target: any,
  81599. /** defines the starting frame number (default is 0) */
  81600. fromFrame?: number,
  81601. /** defines the ending frame number (default is 100) */
  81602. toFrame?: number,
  81603. /** defines if the animation must loop (default is false) */
  81604. loopAnimation?: boolean, speedRatio?: number,
  81605. /** defines a callback to call when animation ends if it is not looping */
  81606. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  81607. /** defines a callback to call when animation loops */
  81608. onAnimationLoop?: (() => void) | null | undefined);
  81609. /**
  81610. * Synchronize and normalize current Animatable with a source Animatable
  81611. * This is useful when using animation weights and when animations are not of the same length
  81612. * @param root defines the root Animatable to synchronize with
  81613. * @returns the current Animatable
  81614. */
  81615. syncWith(root: Animatable): Animatable;
  81616. /**
  81617. * Gets the list of runtime animations
  81618. * @returns an array of RuntimeAnimation
  81619. */
  81620. getAnimations(): RuntimeAnimation[];
  81621. /**
  81622. * Adds more animations to the current animatable
  81623. * @param target defines the target of the animations
  81624. * @param animations defines the new animations to add
  81625. */
  81626. appendAnimations(target: any, animations: Animation[]): void;
  81627. /**
  81628. * Gets the source animation for a specific property
  81629. * @param property defines the propertyu to look for
  81630. * @returns null or the source animation for the given property
  81631. */
  81632. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  81633. /**
  81634. * Gets the runtime animation for a specific property
  81635. * @param property defines the propertyu to look for
  81636. * @returns null or the runtime animation for the given property
  81637. */
  81638. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  81639. /**
  81640. * Resets the animatable to its original state
  81641. */
  81642. reset(): void;
  81643. /**
  81644. * Allows the animatable to blend with current running animations
  81645. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  81646. * @param blendingSpeed defines the blending speed to use
  81647. */
  81648. enableBlending(blendingSpeed: number): void;
  81649. /**
  81650. * Disable animation blending
  81651. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  81652. */
  81653. disableBlending(): void;
  81654. /**
  81655. * Jump directly to a given frame
  81656. * @param frame defines the frame to jump to
  81657. */
  81658. goToFrame(frame: number): void;
  81659. /**
  81660. * Pause the animation
  81661. */
  81662. pause(): void;
  81663. /**
  81664. * Restart the animation
  81665. */
  81666. restart(): void;
  81667. private _raiseOnAnimationEnd;
  81668. /**
  81669. * Stop and delete the current animation
  81670. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  81671. * @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)
  81672. */
  81673. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  81674. /**
  81675. * Wait asynchronously for the animation to end
  81676. * @returns a promise which will be fullfilled when the animation ends
  81677. */
  81678. waitAsync(): Promise<Animatable>;
  81679. /** @hidden */
  81680. _animate(delay: number): boolean;
  81681. }
  81682. interface Scene {
  81683. /** @hidden */
  81684. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  81685. /** @hidden */
  81686. _processLateAnimationBindingsForMatrices(holder: {
  81687. totalWeight: number;
  81688. animations: RuntimeAnimation[];
  81689. originalValue: Matrix;
  81690. }): any;
  81691. /** @hidden */
  81692. _processLateAnimationBindingsForQuaternions(holder: {
  81693. totalWeight: number;
  81694. animations: RuntimeAnimation[];
  81695. originalValue: Quaternion;
  81696. }, refQuaternion: Quaternion): Quaternion;
  81697. /** @hidden */
  81698. _processLateAnimationBindings(): void;
  81699. /**
  81700. * Will start the animation sequence of a given target
  81701. * @param target defines the target
  81702. * @param from defines from which frame should animation start
  81703. * @param to defines until which frame should animation run.
  81704. * @param weight defines the weight to apply to the animation (1.0 by default)
  81705. * @param loop defines if the animation loops
  81706. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  81707. * @param onAnimationEnd defines the function to be executed when the animation ends
  81708. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  81709. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  81710. * @param onAnimationLoop defines the callback to call when an animation loops
  81711. * @returns the animatable object created for this animation
  81712. */
  81713. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  81714. /**
  81715. * Will start the animation sequence of a given target
  81716. * @param target defines the target
  81717. * @param from defines from which frame should animation start
  81718. * @param to defines until which frame should animation run.
  81719. * @param loop defines if the animation loops
  81720. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  81721. * @param onAnimationEnd defines the function to be executed when the animation ends
  81722. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  81723. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  81724. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  81725. * @param onAnimationLoop defines the callback to call when an animation loops
  81726. * @returns the animatable object created for this animation
  81727. */
  81728. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  81729. /**
  81730. * Will start the animation sequence of a given target and its hierarchy
  81731. * @param target defines the target
  81732. * @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.
  81733. * @param from defines from which frame should animation start
  81734. * @param to defines until which frame should animation run.
  81735. * @param loop defines if the animation loops
  81736. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  81737. * @param onAnimationEnd defines the function to be executed when the animation ends
  81738. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  81739. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  81740. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  81741. * @param onAnimationLoop defines the callback to call when an animation loops
  81742. * @returns the list of created animatables
  81743. */
  81744. 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[];
  81745. /**
  81746. * Begin a new animation on a given node
  81747. * @param target defines the target where the animation will take place
  81748. * @param animations defines the list of animations to start
  81749. * @param from defines the initial value
  81750. * @param to defines the final value
  81751. * @param loop defines if you want animation to loop (off by default)
  81752. * @param speedRatio defines the speed ratio to apply to all animations
  81753. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  81754. * @param onAnimationLoop defines the callback to call when an animation loops
  81755. * @returns the list of created animatables
  81756. */
  81757. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  81758. /**
  81759. * Begin a new animation on a given node and its hierarchy
  81760. * @param target defines the root node where the animation will take place
  81761. * @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.
  81762. * @param animations defines the list of animations to start
  81763. * @param from defines the initial value
  81764. * @param to defines the final value
  81765. * @param loop defines if you want animation to loop (off by default)
  81766. * @param speedRatio defines the speed ratio to apply to all animations
  81767. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  81768. * @param onAnimationLoop defines the callback to call when an animation loops
  81769. * @returns the list of animatables created for all nodes
  81770. */
  81771. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  81772. /**
  81773. * Gets the animatable associated with a specific target
  81774. * @param target defines the target of the animatable
  81775. * @returns the required animatable if found
  81776. */
  81777. getAnimatableByTarget(target: any): Nullable<Animatable>;
  81778. /**
  81779. * Gets all animatables associated with a given target
  81780. * @param target defines the target to look animatables for
  81781. * @returns an array of Animatables
  81782. */
  81783. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  81784. /**
  81785. * Stops and removes all animations that have been applied to the scene
  81786. */
  81787. stopAllAnimations(): void;
  81788. /**
  81789. * Gets the current delta time used by animation engine
  81790. */
  81791. deltaTime: number;
  81792. }
  81793. interface Bone {
  81794. /**
  81795. * Copy an animation range from another bone
  81796. * @param source defines the source bone
  81797. * @param rangeName defines the range name to copy
  81798. * @param frameOffset defines the frame offset
  81799. * @param rescaleAsRequired defines if rescaling must be applied if required
  81800. * @param skelDimensionsRatio defines the scaling ratio
  81801. * @returns true if operation was successful
  81802. */
  81803. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  81804. }
  81805. }
  81806. declare module BABYLON {
  81807. /**
  81808. * Class used to override all child animations of a given target
  81809. */
  81810. export class AnimationPropertiesOverride {
  81811. /**
  81812. * Gets or sets a value indicating if animation blending must be used
  81813. */
  81814. enableBlending: boolean;
  81815. /**
  81816. * Gets or sets the blending speed to use when enableBlending is true
  81817. */
  81818. blendingSpeed: number;
  81819. /**
  81820. * Gets or sets the default loop mode to use
  81821. */
  81822. loopMode: number;
  81823. }
  81824. }
  81825. declare module BABYLON {
  81826. /**
  81827. * Class used to handle skinning animations
  81828. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  81829. */
  81830. export class Skeleton implements IAnimatable {
  81831. /** defines the skeleton name */
  81832. name: string;
  81833. /** defines the skeleton Id */
  81834. id: string;
  81835. /**
  81836. * Defines the list of child bones
  81837. */
  81838. bones: Bone[];
  81839. /**
  81840. * Defines an estimate of the dimension of the skeleton at rest
  81841. */
  81842. dimensionsAtRest: Vector3;
  81843. /**
  81844. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  81845. */
  81846. needInitialSkinMatrix: boolean;
  81847. /**
  81848. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  81849. */
  81850. overrideMesh: Nullable<AbstractMesh>;
  81851. /**
  81852. * Gets the list of animations attached to this skeleton
  81853. */
  81854. animations: Array<Animation>;
  81855. private _scene;
  81856. private _isDirty;
  81857. private _transformMatrices;
  81858. private _transformMatrixTexture;
  81859. private _meshesWithPoseMatrix;
  81860. private _animatables;
  81861. private _identity;
  81862. private _synchronizedWithMesh;
  81863. private _ranges;
  81864. private _lastAbsoluteTransformsUpdateId;
  81865. private _canUseTextureForBones;
  81866. private _uniqueId;
  81867. /** @hidden */
  81868. _numBonesWithLinkedTransformNode: number;
  81869. /** @hidden */
  81870. _hasWaitingData: Nullable<boolean>;
  81871. /**
  81872. * Specifies if the skeleton should be serialized
  81873. */
  81874. doNotSerialize: boolean;
  81875. private _useTextureToStoreBoneMatrices;
  81876. /**
  81877. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  81878. * Please note that this option is not available if the hardware does not support it
  81879. */
  81880. useTextureToStoreBoneMatrices: boolean;
  81881. private _animationPropertiesOverride;
  81882. /**
  81883. * Gets or sets the animation properties override
  81884. */
  81885. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  81886. /**
  81887. * List of inspectable custom properties (used by the Inspector)
  81888. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  81889. */
  81890. inspectableCustomProperties: IInspectable[];
  81891. /**
  81892. * An observable triggered before computing the skeleton's matrices
  81893. */
  81894. onBeforeComputeObservable: Observable<Skeleton>;
  81895. /**
  81896. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  81897. */
  81898. readonly isUsingTextureForMatrices: boolean;
  81899. /**
  81900. * Gets the unique ID of this skeleton
  81901. */
  81902. readonly uniqueId: number;
  81903. /**
  81904. * Creates a new skeleton
  81905. * @param name defines the skeleton name
  81906. * @param id defines the skeleton Id
  81907. * @param scene defines the hosting scene
  81908. */
  81909. constructor(
  81910. /** defines the skeleton name */
  81911. name: string,
  81912. /** defines the skeleton Id */
  81913. id: string, scene: Scene);
  81914. /**
  81915. * Gets the current object class name.
  81916. * @return the class name
  81917. */
  81918. getClassName(): string;
  81919. /**
  81920. * Returns an array containing the root bones
  81921. * @returns an array containing the root bones
  81922. */
  81923. getChildren(): Array<Bone>;
  81924. /**
  81925. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  81926. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  81927. * @returns a Float32Array containing matrices data
  81928. */
  81929. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  81930. /**
  81931. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  81932. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  81933. * @returns a raw texture containing the data
  81934. */
  81935. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  81936. /**
  81937. * Gets the current hosting scene
  81938. * @returns a scene object
  81939. */
  81940. getScene(): Scene;
  81941. /**
  81942. * Gets a string representing the current skeleton data
  81943. * @param fullDetails defines a boolean indicating if we want a verbose version
  81944. * @returns a string representing the current skeleton data
  81945. */
  81946. toString(fullDetails?: boolean): string;
  81947. /**
  81948. * Get bone's index searching by name
  81949. * @param name defines bone's name to search for
  81950. * @return the indice of the bone. Returns -1 if not found
  81951. */
  81952. getBoneIndexByName(name: string): number;
  81953. /**
  81954. * Creater a new animation range
  81955. * @param name defines the name of the range
  81956. * @param from defines the start key
  81957. * @param to defines the end key
  81958. */
  81959. createAnimationRange(name: string, from: number, to: number): void;
  81960. /**
  81961. * Delete a specific animation range
  81962. * @param name defines the name of the range
  81963. * @param deleteFrames defines if frames must be removed as well
  81964. */
  81965. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  81966. /**
  81967. * Gets a specific animation range
  81968. * @param name defines the name of the range to look for
  81969. * @returns the requested animation range or null if not found
  81970. */
  81971. getAnimationRange(name: string): Nullable<AnimationRange>;
  81972. /**
  81973. * Gets the list of all animation ranges defined on this skeleton
  81974. * @returns an array
  81975. */
  81976. getAnimationRanges(): Nullable<AnimationRange>[];
  81977. /**
  81978. * Copy animation range from a source skeleton.
  81979. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  81980. * @param source defines the source skeleton
  81981. * @param name defines the name of the range to copy
  81982. * @param rescaleAsRequired defines if rescaling must be applied if required
  81983. * @returns true if operation was successful
  81984. */
  81985. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  81986. /**
  81987. * Forces the skeleton to go to rest pose
  81988. */
  81989. returnToRest(): void;
  81990. private _getHighestAnimationFrame;
  81991. /**
  81992. * Begin a specific animation range
  81993. * @param name defines the name of the range to start
  81994. * @param loop defines if looping must be turned on (false by default)
  81995. * @param speedRatio defines the speed ratio to apply (1 by default)
  81996. * @param onAnimationEnd defines a callback which will be called when animation will end
  81997. * @returns a new animatable
  81998. */
  81999. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  82000. /** @hidden */
  82001. _markAsDirty(): void;
  82002. /** @hidden */
  82003. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  82004. /** @hidden */
  82005. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  82006. private _computeTransformMatrices;
  82007. /**
  82008. * Build all resources required to render a skeleton
  82009. */
  82010. prepare(): void;
  82011. /**
  82012. * Gets the list of animatables currently running for this skeleton
  82013. * @returns an array of animatables
  82014. */
  82015. getAnimatables(): IAnimatable[];
  82016. /**
  82017. * Clone the current skeleton
  82018. * @param name defines the name of the new skeleton
  82019. * @param id defines the id of the new skeleton
  82020. * @returns the new skeleton
  82021. */
  82022. clone(name: string, id?: string): Skeleton;
  82023. /**
  82024. * Enable animation blending for this skeleton
  82025. * @param blendingSpeed defines the blending speed to apply
  82026. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  82027. */
  82028. enableBlending(blendingSpeed?: number): void;
  82029. /**
  82030. * Releases all resources associated with the current skeleton
  82031. */
  82032. dispose(): void;
  82033. /**
  82034. * Serialize the skeleton in a JSON object
  82035. * @returns a JSON object
  82036. */
  82037. serialize(): any;
  82038. /**
  82039. * Creates a new skeleton from serialized data
  82040. * @param parsedSkeleton defines the serialized data
  82041. * @param scene defines the hosting scene
  82042. * @returns a new skeleton
  82043. */
  82044. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  82045. /**
  82046. * Compute all node absolute transforms
  82047. * @param forceUpdate defines if computation must be done even if cache is up to date
  82048. */
  82049. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  82050. /**
  82051. * Gets the root pose matrix
  82052. * @returns a matrix
  82053. */
  82054. getPoseMatrix(): Nullable<Matrix>;
  82055. /**
  82056. * Sorts bones per internal index
  82057. */
  82058. sortBones(): void;
  82059. private _sortBones;
  82060. }
  82061. }
  82062. declare module BABYLON {
  82063. /**
  82064. * Class used to store bone information
  82065. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  82066. */
  82067. export class Bone extends Node {
  82068. /**
  82069. * defines the bone name
  82070. */
  82071. name: string;
  82072. private static _tmpVecs;
  82073. private static _tmpQuat;
  82074. private static _tmpMats;
  82075. /**
  82076. * Gets the list of child bones
  82077. */
  82078. children: Bone[];
  82079. /** Gets the animations associated with this bone */
  82080. animations: Animation[];
  82081. /**
  82082. * Gets or sets bone length
  82083. */
  82084. length: number;
  82085. /**
  82086. * @hidden Internal only
  82087. * Set this value to map this bone to a different index in the transform matrices
  82088. * Set this value to -1 to exclude the bone from the transform matrices
  82089. */
  82090. _index: Nullable<number>;
  82091. private _skeleton;
  82092. private _localMatrix;
  82093. private _restPose;
  82094. private _baseMatrix;
  82095. private _absoluteTransform;
  82096. private _invertedAbsoluteTransform;
  82097. private _parent;
  82098. private _scalingDeterminant;
  82099. private _worldTransform;
  82100. private _localScaling;
  82101. private _localRotation;
  82102. private _localPosition;
  82103. private _needToDecompose;
  82104. private _needToCompose;
  82105. /** @hidden */
  82106. _linkedTransformNode: Nullable<TransformNode>;
  82107. /** @hidden */
  82108. _waitingTransformNodeId: Nullable<string>;
  82109. /** @hidden */
  82110. /** @hidden */
  82111. _matrix: Matrix;
  82112. /**
  82113. * Create a new bone
  82114. * @param name defines the bone name
  82115. * @param skeleton defines the parent skeleton
  82116. * @param parentBone defines the parent (can be null if the bone is the root)
  82117. * @param localMatrix defines the local matrix
  82118. * @param restPose defines the rest pose matrix
  82119. * @param baseMatrix defines the base matrix
  82120. * @param index defines index of the bone in the hiearchy
  82121. */
  82122. constructor(
  82123. /**
  82124. * defines the bone name
  82125. */
  82126. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  82127. /**
  82128. * Gets the current object class name.
  82129. * @return the class name
  82130. */
  82131. getClassName(): string;
  82132. /**
  82133. * Gets the parent skeleton
  82134. * @returns a skeleton
  82135. */
  82136. getSkeleton(): Skeleton;
  82137. /**
  82138. * Gets parent bone
  82139. * @returns a bone or null if the bone is the root of the bone hierarchy
  82140. */
  82141. getParent(): Nullable<Bone>;
  82142. /**
  82143. * Returns an array containing the root bones
  82144. * @returns an array containing the root bones
  82145. */
  82146. getChildren(): Array<Bone>;
  82147. /**
  82148. * Gets the node index in matrix array generated for rendering
  82149. * @returns the node index
  82150. */
  82151. getIndex(): number;
  82152. /**
  82153. * Sets the parent bone
  82154. * @param parent defines the parent (can be null if the bone is the root)
  82155. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  82156. */
  82157. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  82158. /**
  82159. * Gets the local matrix
  82160. * @returns a matrix
  82161. */
  82162. getLocalMatrix(): Matrix;
  82163. /**
  82164. * Gets the base matrix (initial matrix which remains unchanged)
  82165. * @returns a matrix
  82166. */
  82167. getBaseMatrix(): Matrix;
  82168. /**
  82169. * Gets the rest pose matrix
  82170. * @returns a matrix
  82171. */
  82172. getRestPose(): Matrix;
  82173. /**
  82174. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  82175. */
  82176. getWorldMatrix(): Matrix;
  82177. /**
  82178. * Sets the local matrix to rest pose matrix
  82179. */
  82180. returnToRest(): void;
  82181. /**
  82182. * Gets the inverse of the absolute transform matrix.
  82183. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  82184. * @returns a matrix
  82185. */
  82186. getInvertedAbsoluteTransform(): Matrix;
  82187. /**
  82188. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  82189. * @returns a matrix
  82190. */
  82191. getAbsoluteTransform(): Matrix;
  82192. /**
  82193. * Links with the given transform node.
  82194. * The local matrix of this bone is copied from the transform node every frame.
  82195. * @param transformNode defines the transform node to link to
  82196. */
  82197. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  82198. /**
  82199. * Gets the node used to drive the bone's transformation
  82200. * @returns a transform node or null
  82201. */
  82202. getTransformNode(): Nullable<TransformNode>;
  82203. /** Gets or sets current position (in local space) */
  82204. position: Vector3;
  82205. /** Gets or sets current rotation (in local space) */
  82206. rotation: Vector3;
  82207. /** Gets or sets current rotation quaternion (in local space) */
  82208. rotationQuaternion: Quaternion;
  82209. /** Gets or sets current scaling (in local space) */
  82210. scaling: Vector3;
  82211. /**
  82212. * Gets the animation properties override
  82213. */
  82214. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  82215. private _decompose;
  82216. private _compose;
  82217. /**
  82218. * Update the base and local matrices
  82219. * @param matrix defines the new base or local matrix
  82220. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  82221. * @param updateLocalMatrix defines if the local matrix should be updated
  82222. */
  82223. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  82224. /** @hidden */
  82225. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  82226. /**
  82227. * Flag the bone as dirty (Forcing it to update everything)
  82228. */
  82229. markAsDirty(): void;
  82230. /** @hidden */
  82231. _markAsDirtyAndCompose(): void;
  82232. private _markAsDirtyAndDecompose;
  82233. /**
  82234. * Translate the bone in local or world space
  82235. * @param vec The amount to translate the bone
  82236. * @param space The space that the translation is in
  82237. * @param mesh The mesh that this bone is attached to. This is only used in world space
  82238. */
  82239. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  82240. /**
  82241. * Set the postion of the bone in local or world space
  82242. * @param position The position to set the bone
  82243. * @param space The space that the position is in
  82244. * @param mesh The mesh that this bone is attached to. This is only used in world space
  82245. */
  82246. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  82247. /**
  82248. * Set the absolute position of the bone (world space)
  82249. * @param position The position to set the bone
  82250. * @param mesh The mesh that this bone is attached to
  82251. */
  82252. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  82253. /**
  82254. * Scale the bone on the x, y and z axes (in local space)
  82255. * @param x The amount to scale the bone on the x axis
  82256. * @param y The amount to scale the bone on the y axis
  82257. * @param z The amount to scale the bone on the z axis
  82258. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  82259. */
  82260. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  82261. /**
  82262. * Set the bone scaling in local space
  82263. * @param scale defines the scaling vector
  82264. */
  82265. setScale(scale: Vector3): void;
  82266. /**
  82267. * Gets the current scaling in local space
  82268. * @returns the current scaling vector
  82269. */
  82270. getScale(): Vector3;
  82271. /**
  82272. * Gets the current scaling in local space and stores it in a target vector
  82273. * @param result defines the target vector
  82274. */
  82275. getScaleToRef(result: Vector3): void;
  82276. /**
  82277. * Set the yaw, pitch, and roll of the bone in local or world space
  82278. * @param yaw The rotation of the bone on the y axis
  82279. * @param pitch The rotation of the bone on the x axis
  82280. * @param roll The rotation of the bone on the z axis
  82281. * @param space The space that the axes of rotation are in
  82282. * @param mesh The mesh that this bone is attached to. This is only used in world space
  82283. */
  82284. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  82285. /**
  82286. * Add a rotation to the bone on an axis in local or world space
  82287. * @param axis The axis to rotate the bone on
  82288. * @param amount The amount to rotate the bone
  82289. * @param space The space that the axis is in
  82290. * @param mesh The mesh that this bone is attached to. This is only used in world space
  82291. */
  82292. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  82293. /**
  82294. * Set the rotation of the bone to a particular axis angle in local or world space
  82295. * @param axis The axis to rotate the bone on
  82296. * @param angle The angle that the bone should be rotated to
  82297. * @param space The space that the axis is in
  82298. * @param mesh The mesh that this bone is attached to. This is only used in world space
  82299. */
  82300. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  82301. /**
  82302. * Set the euler rotation of the bone in local of world space
  82303. * @param rotation The euler rotation that the bone should be set to
  82304. * @param space The space that the rotation is in
  82305. * @param mesh The mesh that this bone is attached to. This is only used in world space
  82306. */
  82307. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  82308. /**
  82309. * Set the quaternion rotation of the bone in local of world space
  82310. * @param quat The quaternion rotation that the bone should be set to
  82311. * @param space The space that the rotation is in
  82312. * @param mesh The mesh that this bone is attached to. This is only used in world space
  82313. */
  82314. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  82315. /**
  82316. * Set the rotation matrix of the bone in local of world space
  82317. * @param rotMat The rotation matrix that the bone should be set to
  82318. * @param space The space that the rotation is in
  82319. * @param mesh The mesh that this bone is attached to. This is only used in world space
  82320. */
  82321. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  82322. private _rotateWithMatrix;
  82323. private _getNegativeRotationToRef;
  82324. /**
  82325. * Get the position of the bone in local or world space
  82326. * @param space The space that the returned position is in
  82327. * @param mesh The mesh that this bone is attached to. This is only used in world space
  82328. * @returns The position of the bone
  82329. */
  82330. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  82331. /**
  82332. * Copy the position of the bone to a vector3 in local or world space
  82333. * @param space The space that the returned position is in
  82334. * @param mesh The mesh that this bone is attached to. This is only used in world space
  82335. * @param result The vector3 to copy the position to
  82336. */
  82337. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  82338. /**
  82339. * Get the absolute position of the bone (world space)
  82340. * @param mesh The mesh that this bone is attached to
  82341. * @returns The absolute position of the bone
  82342. */
  82343. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  82344. /**
  82345. * Copy the absolute position of the bone (world space) to the result param
  82346. * @param mesh The mesh that this bone is attached to
  82347. * @param result The vector3 to copy the absolute position to
  82348. */
  82349. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  82350. /**
  82351. * Compute the absolute transforms of this bone and its children
  82352. */
  82353. computeAbsoluteTransforms(): void;
  82354. /**
  82355. * Get the world direction from an axis that is in the local space of the bone
  82356. * @param localAxis The local direction that is used to compute the world direction
  82357. * @param mesh The mesh that this bone is attached to
  82358. * @returns The world direction
  82359. */
  82360. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  82361. /**
  82362. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  82363. * @param localAxis The local direction that is used to compute the world direction
  82364. * @param mesh The mesh that this bone is attached to
  82365. * @param result The vector3 that the world direction will be copied to
  82366. */
  82367. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  82368. /**
  82369. * Get the euler rotation of the bone in local or world space
  82370. * @param space The space that the rotation should be in
  82371. * @param mesh The mesh that this bone is attached to. This is only used in world space
  82372. * @returns The euler rotation
  82373. */
  82374. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  82375. /**
  82376. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  82377. * @param space The space that the rotation should be in
  82378. * @param mesh The mesh that this bone is attached to. This is only used in world space
  82379. * @param result The vector3 that the rotation should be copied to
  82380. */
  82381. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  82382. /**
  82383. * Get the quaternion rotation of the bone in either local or world space
  82384. * @param space The space that the rotation should be in
  82385. * @param mesh The mesh that this bone is attached to. This is only used in world space
  82386. * @returns The quaternion rotation
  82387. */
  82388. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  82389. /**
  82390. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  82391. * @param space The space that the rotation should be in
  82392. * @param mesh The mesh that this bone is attached to. This is only used in world space
  82393. * @param result The quaternion that the rotation should be copied to
  82394. */
  82395. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  82396. /**
  82397. * Get the rotation matrix of the bone in local or world space
  82398. * @param space The space that the rotation should be in
  82399. * @param mesh The mesh that this bone is attached to. This is only used in world space
  82400. * @returns The rotation matrix
  82401. */
  82402. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  82403. /**
  82404. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  82405. * @param space The space that the rotation should be in
  82406. * @param mesh The mesh that this bone is attached to. This is only used in world space
  82407. * @param result The quaternion that the rotation should be copied to
  82408. */
  82409. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  82410. /**
  82411. * Get the world position of a point that is in the local space of the bone
  82412. * @param position The local position
  82413. * @param mesh The mesh that this bone is attached to
  82414. * @returns The world position
  82415. */
  82416. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  82417. /**
  82418. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  82419. * @param position The local position
  82420. * @param mesh The mesh that this bone is attached to
  82421. * @param result The vector3 that the world position should be copied to
  82422. */
  82423. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  82424. /**
  82425. * Get the local position of a point that is in world space
  82426. * @param position The world position
  82427. * @param mesh The mesh that this bone is attached to
  82428. * @returns The local position
  82429. */
  82430. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  82431. /**
  82432. * Get the local position of a point that is in world space and copy it to the result param
  82433. * @param position The world position
  82434. * @param mesh The mesh that this bone is attached to
  82435. * @param result The vector3 that the local position should be copied to
  82436. */
  82437. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  82438. }
  82439. }
  82440. declare module BABYLON {
  82441. /**
  82442. * 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.
  82443. * @see https://doc.babylonjs.com/how_to/transformnode
  82444. */
  82445. export class TransformNode extends Node {
  82446. /**
  82447. * Object will not rotate to face the camera
  82448. */
  82449. static BILLBOARDMODE_NONE: number;
  82450. /**
  82451. * Object will rotate to face the camera but only on the x axis
  82452. */
  82453. static BILLBOARDMODE_X: number;
  82454. /**
  82455. * Object will rotate to face the camera but only on the y axis
  82456. */
  82457. static BILLBOARDMODE_Y: number;
  82458. /**
  82459. * Object will rotate to face the camera but only on the z axis
  82460. */
  82461. static BILLBOARDMODE_Z: number;
  82462. /**
  82463. * Object will rotate to face the camera
  82464. */
  82465. static BILLBOARDMODE_ALL: number;
  82466. /**
  82467. * Object will rotate to face the camera's position instead of orientation
  82468. */
  82469. static BILLBOARDMODE_USE_POSITION: number;
  82470. private _forward;
  82471. private _forwardInverted;
  82472. private _up;
  82473. private _right;
  82474. private _rightInverted;
  82475. private _position;
  82476. private _rotation;
  82477. private _rotationQuaternion;
  82478. protected _scaling: Vector3;
  82479. protected _isDirty: boolean;
  82480. private _transformToBoneReferal;
  82481. private _isAbsoluteSynced;
  82482. private _billboardMode;
  82483. /**
  82484. * Gets or sets the billboard mode. Default is 0.
  82485. *
  82486. * | Value | Type | Description |
  82487. * | --- | --- | --- |
  82488. * | 0 | BILLBOARDMODE_NONE | |
  82489. * | 1 | BILLBOARDMODE_X | |
  82490. * | 2 | BILLBOARDMODE_Y | |
  82491. * | 4 | BILLBOARDMODE_Z | |
  82492. * | 7 | BILLBOARDMODE_ALL | |
  82493. *
  82494. */
  82495. billboardMode: number;
  82496. private _preserveParentRotationForBillboard;
  82497. /**
  82498. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  82499. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  82500. */
  82501. preserveParentRotationForBillboard: boolean;
  82502. /**
  82503. * 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
  82504. */
  82505. scalingDeterminant: number;
  82506. private _infiniteDistance;
  82507. /**
  82508. * Gets or sets the distance of the object to max, often used by skybox
  82509. */
  82510. infiniteDistance: boolean;
  82511. /**
  82512. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  82513. * By default the system will update normals to compensate
  82514. */
  82515. ignoreNonUniformScaling: boolean;
  82516. /**
  82517. * 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
  82518. */
  82519. reIntegrateRotationIntoRotationQuaternion: boolean;
  82520. /** @hidden */
  82521. _poseMatrix: Nullable<Matrix>;
  82522. /** @hidden */
  82523. _localMatrix: Matrix;
  82524. private _usePivotMatrix;
  82525. private _absolutePosition;
  82526. private _absoluteScaling;
  82527. private _absoluteRotationQuaternion;
  82528. private _pivotMatrix;
  82529. private _pivotMatrixInverse;
  82530. protected _postMultiplyPivotMatrix: boolean;
  82531. protected _isWorldMatrixFrozen: boolean;
  82532. /** @hidden */
  82533. _indexInSceneTransformNodesArray: number;
  82534. /**
  82535. * An event triggered after the world matrix is updated
  82536. */
  82537. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  82538. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  82539. /**
  82540. * Gets a string identifying the name of the class
  82541. * @returns "TransformNode" string
  82542. */
  82543. getClassName(): string;
  82544. /**
  82545. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  82546. */
  82547. position: Vector3;
  82548. /**
  82549. * 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)).
  82550. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  82551. */
  82552. rotation: Vector3;
  82553. /**
  82554. * 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)).
  82555. */
  82556. scaling: Vector3;
  82557. /**
  82558. * 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).
  82559. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  82560. */
  82561. rotationQuaternion: Nullable<Quaternion>;
  82562. /**
  82563. * The forward direction of that transform in world space.
  82564. */
  82565. readonly forward: Vector3;
  82566. /**
  82567. * The up direction of that transform in world space.
  82568. */
  82569. readonly up: Vector3;
  82570. /**
  82571. * The right direction of that transform in world space.
  82572. */
  82573. readonly right: Vector3;
  82574. /**
  82575. * Copies the parameter passed Matrix into the mesh Pose matrix.
  82576. * @param matrix the matrix to copy the pose from
  82577. * @returns this TransformNode.
  82578. */
  82579. updatePoseMatrix(matrix: Matrix): TransformNode;
  82580. /**
  82581. * Returns the mesh Pose matrix.
  82582. * @returns the pose matrix
  82583. */
  82584. getPoseMatrix(): Matrix;
  82585. /** @hidden */
  82586. _isSynchronized(): boolean;
  82587. /** @hidden */
  82588. _initCache(): void;
  82589. /**
  82590. * Flag the transform node as dirty (Forcing it to update everything)
  82591. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  82592. * @returns this transform node
  82593. */
  82594. markAsDirty(property: string): TransformNode;
  82595. /**
  82596. * Returns the current mesh absolute position.
  82597. * Returns a Vector3.
  82598. */
  82599. readonly absolutePosition: Vector3;
  82600. /**
  82601. * Returns the current mesh absolute scaling.
  82602. * Returns a Vector3.
  82603. */
  82604. readonly absoluteScaling: Vector3;
  82605. /**
  82606. * Returns the current mesh absolute rotation.
  82607. * Returns a Quaternion.
  82608. */
  82609. readonly absoluteRotationQuaternion: Quaternion;
  82610. /**
  82611. * Sets a new matrix to apply before all other transformation
  82612. * @param matrix defines the transform matrix
  82613. * @returns the current TransformNode
  82614. */
  82615. setPreTransformMatrix(matrix: Matrix): TransformNode;
  82616. /**
  82617. * Sets a new pivot matrix to the current node
  82618. * @param matrix defines the new pivot matrix to use
  82619. * @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
  82620. * @returns the current TransformNode
  82621. */
  82622. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  82623. /**
  82624. * Returns the mesh pivot matrix.
  82625. * Default : Identity.
  82626. * @returns the matrix
  82627. */
  82628. getPivotMatrix(): Matrix;
  82629. /**
  82630. * Instantiate (when possible) or clone that node with its hierarchy
  82631. * @param newParent defines the new parent to use for the instance (or clone)
  82632. * @param options defines options to configure how copy is done
  82633. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  82634. * @returns an instance (or a clone) of the current node with its hiearchy
  82635. */
  82636. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  82637. doNotInstantiate: boolean;
  82638. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  82639. /**
  82640. * Prevents the World matrix to be computed any longer
  82641. * @param newWorldMatrix defines an optional matrix to use as world matrix
  82642. * @returns the TransformNode.
  82643. */
  82644. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  82645. /**
  82646. * Allows back the World matrix computation.
  82647. * @returns the TransformNode.
  82648. */
  82649. unfreezeWorldMatrix(): this;
  82650. /**
  82651. * True if the World matrix has been frozen.
  82652. */
  82653. readonly isWorldMatrixFrozen: boolean;
  82654. /**
  82655. * Retuns the mesh absolute position in the World.
  82656. * @returns a Vector3.
  82657. */
  82658. getAbsolutePosition(): Vector3;
  82659. /**
  82660. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  82661. * @param absolutePosition the absolute position to set
  82662. * @returns the TransformNode.
  82663. */
  82664. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  82665. /**
  82666. * Sets the mesh position in its local space.
  82667. * @param vector3 the position to set in localspace
  82668. * @returns the TransformNode.
  82669. */
  82670. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  82671. /**
  82672. * Returns the mesh position in the local space from the current World matrix values.
  82673. * @returns a new Vector3.
  82674. */
  82675. getPositionExpressedInLocalSpace(): Vector3;
  82676. /**
  82677. * Translates the mesh along the passed Vector3 in its local space.
  82678. * @param vector3 the distance to translate in localspace
  82679. * @returns the TransformNode.
  82680. */
  82681. locallyTranslate(vector3: Vector3): TransformNode;
  82682. private static _lookAtVectorCache;
  82683. /**
  82684. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  82685. * @param targetPoint the position (must be in same space as current mesh) to look at
  82686. * @param yawCor optional yaw (y-axis) correction in radians
  82687. * @param pitchCor optional pitch (x-axis) correction in radians
  82688. * @param rollCor optional roll (z-axis) correction in radians
  82689. * @param space the choosen space of the target
  82690. * @returns the TransformNode.
  82691. */
  82692. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  82693. /**
  82694. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  82695. * This Vector3 is expressed in the World space.
  82696. * @param localAxis axis to rotate
  82697. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  82698. */
  82699. getDirection(localAxis: Vector3): Vector3;
  82700. /**
  82701. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  82702. * localAxis is expressed in the mesh local space.
  82703. * result is computed in the Wordl space from the mesh World matrix.
  82704. * @param localAxis axis to rotate
  82705. * @param result the resulting transformnode
  82706. * @returns this TransformNode.
  82707. */
  82708. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  82709. /**
  82710. * Sets this transform node rotation to the given local axis.
  82711. * @param localAxis the axis in local space
  82712. * @param yawCor optional yaw (y-axis) correction in radians
  82713. * @param pitchCor optional pitch (x-axis) correction in radians
  82714. * @param rollCor optional roll (z-axis) correction in radians
  82715. * @returns this TransformNode
  82716. */
  82717. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  82718. /**
  82719. * Sets a new pivot point to the current node
  82720. * @param point defines the new pivot point to use
  82721. * @param space defines if the point is in world or local space (local by default)
  82722. * @returns the current TransformNode
  82723. */
  82724. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  82725. /**
  82726. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  82727. * @returns the pivot point
  82728. */
  82729. getPivotPoint(): Vector3;
  82730. /**
  82731. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  82732. * @param result the vector3 to store the result
  82733. * @returns this TransformNode.
  82734. */
  82735. getPivotPointToRef(result: Vector3): TransformNode;
  82736. /**
  82737. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  82738. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  82739. */
  82740. getAbsolutePivotPoint(): Vector3;
  82741. /**
  82742. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  82743. * @param result vector3 to store the result
  82744. * @returns this TransformNode.
  82745. */
  82746. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  82747. /**
  82748. * Defines the passed node as the parent of the current node.
  82749. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  82750. * @see https://doc.babylonjs.com/how_to/parenting
  82751. * @param node the node ot set as the parent
  82752. * @returns this TransformNode.
  82753. */
  82754. setParent(node: Nullable<Node>): TransformNode;
  82755. private _nonUniformScaling;
  82756. /**
  82757. * True if the scaling property of this object is non uniform eg. (1,2,1)
  82758. */
  82759. readonly nonUniformScaling: boolean;
  82760. /** @hidden */
  82761. _updateNonUniformScalingState(value: boolean): boolean;
  82762. /**
  82763. * Attach the current TransformNode to another TransformNode associated with a bone
  82764. * @param bone Bone affecting the TransformNode
  82765. * @param affectedTransformNode TransformNode associated with the bone
  82766. * @returns this object
  82767. */
  82768. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  82769. /**
  82770. * Detach the transform node if its associated with a bone
  82771. * @returns this object
  82772. */
  82773. detachFromBone(): TransformNode;
  82774. private static _rotationAxisCache;
  82775. /**
  82776. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  82777. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  82778. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  82779. * The passed axis is also normalized.
  82780. * @param axis the axis to rotate around
  82781. * @param amount the amount to rotate in radians
  82782. * @param space Space to rotate in (Default: local)
  82783. * @returns the TransformNode.
  82784. */
  82785. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  82786. /**
  82787. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  82788. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  82789. * The passed axis is also normalized. .
  82790. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  82791. * @param point the point to rotate around
  82792. * @param axis the axis to rotate around
  82793. * @param amount the amount to rotate in radians
  82794. * @returns the TransformNode
  82795. */
  82796. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  82797. /**
  82798. * Translates the mesh along the axis vector for the passed distance in the given space.
  82799. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  82800. * @param axis the axis to translate in
  82801. * @param distance the distance to translate
  82802. * @param space Space to rotate in (Default: local)
  82803. * @returns the TransformNode.
  82804. */
  82805. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  82806. /**
  82807. * Adds a rotation step to the mesh current rotation.
  82808. * x, y, z are Euler angles expressed in radians.
  82809. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  82810. * This means this rotation is made in the mesh local space only.
  82811. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  82812. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  82813. * ```javascript
  82814. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  82815. * ```
  82816. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  82817. * 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.
  82818. * @param x Rotation to add
  82819. * @param y Rotation to add
  82820. * @param z Rotation to add
  82821. * @returns the TransformNode.
  82822. */
  82823. addRotation(x: number, y: number, z: number): TransformNode;
  82824. /**
  82825. * @hidden
  82826. */
  82827. protected _getEffectiveParent(): Nullable<Node>;
  82828. /**
  82829. * Computes the world matrix of the node
  82830. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  82831. * @returns the world matrix
  82832. */
  82833. computeWorldMatrix(force?: boolean): Matrix;
  82834. protected _afterComputeWorldMatrix(): void;
  82835. /**
  82836. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  82837. * @param func callback function to add
  82838. *
  82839. * @returns the TransformNode.
  82840. */
  82841. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  82842. /**
  82843. * Removes a registered callback function.
  82844. * @param func callback function to remove
  82845. * @returns the TransformNode.
  82846. */
  82847. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  82848. /**
  82849. * Gets the position of the current mesh in camera space
  82850. * @param camera defines the camera to use
  82851. * @returns a position
  82852. */
  82853. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  82854. /**
  82855. * Returns the distance from the mesh to the active camera
  82856. * @param camera defines the camera to use
  82857. * @returns the distance
  82858. */
  82859. getDistanceToCamera(camera?: Nullable<Camera>): number;
  82860. /**
  82861. * Clone the current transform node
  82862. * @param name Name of the new clone
  82863. * @param newParent New parent for the clone
  82864. * @param doNotCloneChildren Do not clone children hierarchy
  82865. * @returns the new transform node
  82866. */
  82867. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  82868. /**
  82869. * Serializes the objects information.
  82870. * @param currentSerializationObject defines the object to serialize in
  82871. * @returns the serialized object
  82872. */
  82873. serialize(currentSerializationObject?: any): any;
  82874. /**
  82875. * Returns a new TransformNode object parsed from the source provided.
  82876. * @param parsedTransformNode is the source.
  82877. * @param scene the scne the object belongs to
  82878. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  82879. * @returns a new TransformNode object parsed from the source provided.
  82880. */
  82881. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  82882. /**
  82883. * Get all child-transformNodes of this node
  82884. * @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
  82885. * @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
  82886. * @returns an array of TransformNode
  82887. */
  82888. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  82889. /**
  82890. * Releases resources associated with this transform node.
  82891. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  82892. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  82893. */
  82894. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  82895. /**
  82896. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  82897. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  82898. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  82899. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  82900. * @returns the current mesh
  82901. */
  82902. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  82903. private _syncAbsoluteScalingAndRotation;
  82904. }
  82905. }
  82906. declare module BABYLON {
  82907. /**
  82908. * Defines the types of pose enabled controllers that are supported
  82909. */
  82910. export enum PoseEnabledControllerType {
  82911. /**
  82912. * HTC Vive
  82913. */
  82914. VIVE = 0,
  82915. /**
  82916. * Oculus Rift
  82917. */
  82918. OCULUS = 1,
  82919. /**
  82920. * Windows mixed reality
  82921. */
  82922. WINDOWS = 2,
  82923. /**
  82924. * Samsung gear VR
  82925. */
  82926. GEAR_VR = 3,
  82927. /**
  82928. * Google Daydream
  82929. */
  82930. DAYDREAM = 4,
  82931. /**
  82932. * Generic
  82933. */
  82934. GENERIC = 5
  82935. }
  82936. /**
  82937. * Defines the MutableGamepadButton interface for the state of a gamepad button
  82938. */
  82939. export interface MutableGamepadButton {
  82940. /**
  82941. * Value of the button/trigger
  82942. */
  82943. value: number;
  82944. /**
  82945. * If the button/trigger is currently touched
  82946. */
  82947. touched: boolean;
  82948. /**
  82949. * If the button/trigger is currently pressed
  82950. */
  82951. pressed: boolean;
  82952. }
  82953. /**
  82954. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  82955. * @hidden
  82956. */
  82957. export interface ExtendedGamepadButton extends GamepadButton {
  82958. /**
  82959. * If the button/trigger is currently pressed
  82960. */
  82961. readonly pressed: boolean;
  82962. /**
  82963. * If the button/trigger is currently touched
  82964. */
  82965. readonly touched: boolean;
  82966. /**
  82967. * Value of the button/trigger
  82968. */
  82969. readonly value: number;
  82970. }
  82971. /** @hidden */
  82972. export interface _GamePadFactory {
  82973. /**
  82974. * Returns wether or not the current gamepad can be created for this type of controller.
  82975. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  82976. * @returns true if it can be created, otherwise false
  82977. */
  82978. canCreate(gamepadInfo: any): boolean;
  82979. /**
  82980. * Creates a new instance of the Gamepad.
  82981. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  82982. * @returns the new gamepad instance
  82983. */
  82984. create(gamepadInfo: any): Gamepad;
  82985. }
  82986. /**
  82987. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  82988. */
  82989. export class PoseEnabledControllerHelper {
  82990. /** @hidden */
  82991. static _ControllerFactories: _GamePadFactory[];
  82992. /** @hidden */
  82993. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  82994. /**
  82995. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  82996. * @param vrGamepad the gamepad to initialized
  82997. * @returns a vr controller of the type the gamepad identified as
  82998. */
  82999. static InitiateController(vrGamepad: any): Gamepad;
  83000. }
  83001. /**
  83002. * Defines the PoseEnabledController object that contains state of a vr capable controller
  83003. */
  83004. export class PoseEnabledController extends Gamepad implements PoseControlled {
  83005. /**
  83006. * If the controller is used in a webXR session
  83007. */
  83008. isXR: boolean;
  83009. private _deviceRoomPosition;
  83010. private _deviceRoomRotationQuaternion;
  83011. /**
  83012. * The device position in babylon space
  83013. */
  83014. devicePosition: Vector3;
  83015. /**
  83016. * The device rotation in babylon space
  83017. */
  83018. deviceRotationQuaternion: Quaternion;
  83019. /**
  83020. * The scale factor of the device in babylon space
  83021. */
  83022. deviceScaleFactor: number;
  83023. /**
  83024. * (Likely devicePosition should be used instead) The device position in its room space
  83025. */
  83026. position: Vector3;
  83027. /**
  83028. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  83029. */
  83030. rotationQuaternion: Quaternion;
  83031. /**
  83032. * The type of controller (Eg. Windows mixed reality)
  83033. */
  83034. controllerType: PoseEnabledControllerType;
  83035. protected _calculatedPosition: Vector3;
  83036. private _calculatedRotation;
  83037. /**
  83038. * The raw pose from the device
  83039. */
  83040. rawPose: DevicePose;
  83041. private _trackPosition;
  83042. private _maxRotationDistFromHeadset;
  83043. private _draggedRoomRotation;
  83044. /**
  83045. * @hidden
  83046. */
  83047. _disableTrackPosition(fixedPosition: Vector3): void;
  83048. /**
  83049. * Internal, the mesh attached to the controller
  83050. * @hidden
  83051. */
  83052. _mesh: Nullable<AbstractMesh>;
  83053. private _poseControlledCamera;
  83054. private _leftHandSystemQuaternion;
  83055. /**
  83056. * Internal, matrix used to convert room space to babylon space
  83057. * @hidden
  83058. */
  83059. _deviceToWorld: Matrix;
  83060. /**
  83061. * Node to be used when casting a ray from the controller
  83062. * @hidden
  83063. */
  83064. _pointingPoseNode: Nullable<TransformNode>;
  83065. /**
  83066. * Name of the child mesh that can be used to cast a ray from the controller
  83067. */
  83068. static readonly POINTING_POSE: string;
  83069. /**
  83070. * Creates a new PoseEnabledController from a gamepad
  83071. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  83072. */
  83073. constructor(browserGamepad: any);
  83074. private _workingMatrix;
  83075. /**
  83076. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  83077. */
  83078. update(): void;
  83079. /**
  83080. * Updates only the pose device and mesh without doing any button event checking
  83081. */
  83082. protected _updatePoseAndMesh(): void;
  83083. /**
  83084. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  83085. * @param poseData raw pose fromthe device
  83086. */
  83087. updateFromDevice(poseData: DevicePose): void;
  83088. /**
  83089. * @hidden
  83090. */
  83091. _meshAttachedObservable: Observable<AbstractMesh>;
  83092. /**
  83093. * Attaches a mesh to the controller
  83094. * @param mesh the mesh to be attached
  83095. */
  83096. attachToMesh(mesh: AbstractMesh): void;
  83097. /**
  83098. * Attaches the controllers mesh to a camera
  83099. * @param camera the camera the mesh should be attached to
  83100. */
  83101. attachToPoseControlledCamera(camera: TargetCamera): void;
  83102. /**
  83103. * Disposes of the controller
  83104. */
  83105. dispose(): void;
  83106. /**
  83107. * The mesh that is attached to the controller
  83108. */
  83109. readonly mesh: Nullable<AbstractMesh>;
  83110. /**
  83111. * Gets the ray of the controller in the direction the controller is pointing
  83112. * @param length the length the resulting ray should be
  83113. * @returns a ray in the direction the controller is pointing
  83114. */
  83115. getForwardRay(length?: number): Ray;
  83116. }
  83117. }
  83118. declare module BABYLON {
  83119. /**
  83120. * Defines the WebVRController object that represents controllers tracked in 3D space
  83121. */
  83122. export abstract class WebVRController extends PoseEnabledController {
  83123. /**
  83124. * Internal, the default controller model for the controller
  83125. */
  83126. protected _defaultModel: Nullable<AbstractMesh>;
  83127. /**
  83128. * Fired when the trigger state has changed
  83129. */
  83130. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  83131. /**
  83132. * Fired when the main button state has changed
  83133. */
  83134. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  83135. /**
  83136. * Fired when the secondary button state has changed
  83137. */
  83138. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  83139. /**
  83140. * Fired when the pad state has changed
  83141. */
  83142. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  83143. /**
  83144. * Fired when controllers stick values have changed
  83145. */
  83146. onPadValuesChangedObservable: Observable<StickValues>;
  83147. /**
  83148. * Array of button availible on the controller
  83149. */
  83150. protected _buttons: Array<MutableGamepadButton>;
  83151. private _onButtonStateChange;
  83152. /**
  83153. * Fired when a controller button's state has changed
  83154. * @param callback the callback containing the button that was modified
  83155. */
  83156. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  83157. /**
  83158. * X and Y axis corresponding to the controllers joystick
  83159. */
  83160. pad: StickValues;
  83161. /**
  83162. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  83163. */
  83164. hand: string;
  83165. /**
  83166. * The default controller model for the controller
  83167. */
  83168. readonly defaultModel: Nullable<AbstractMesh>;
  83169. /**
  83170. * Creates a new WebVRController from a gamepad
  83171. * @param vrGamepad the gamepad that the WebVRController should be created from
  83172. */
  83173. constructor(vrGamepad: any);
  83174. /**
  83175. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  83176. */
  83177. update(): void;
  83178. /**
  83179. * Function to be called when a button is modified
  83180. */
  83181. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  83182. /**
  83183. * Loads a mesh and attaches it to the controller
  83184. * @param scene the scene the mesh should be added to
  83185. * @param meshLoaded callback for when the mesh has been loaded
  83186. */
  83187. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  83188. private _setButtonValue;
  83189. private _changes;
  83190. private _checkChanges;
  83191. /**
  83192. * Disposes of th webVRCOntroller
  83193. */
  83194. dispose(): void;
  83195. }
  83196. }
  83197. declare module BABYLON {
  83198. /**
  83199. * The HemisphericLight simulates the ambient environment light,
  83200. * so the passed direction is the light reflection direction, not the incoming direction.
  83201. */
  83202. export class HemisphericLight extends Light {
  83203. /**
  83204. * The groundColor is the light in the opposite direction to the one specified during creation.
  83205. * 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.
  83206. */
  83207. groundColor: Color3;
  83208. /**
  83209. * The light reflection direction, not the incoming direction.
  83210. */
  83211. direction: Vector3;
  83212. /**
  83213. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  83214. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  83215. * The HemisphericLight can't cast shadows.
  83216. * Documentation : https://doc.babylonjs.com/babylon101/lights
  83217. * @param name The friendly name of the light
  83218. * @param direction The direction of the light reflection
  83219. * @param scene The scene the light belongs to
  83220. */
  83221. constructor(name: string, direction: Vector3, scene: Scene);
  83222. protected _buildUniformLayout(): void;
  83223. /**
  83224. * Returns the string "HemisphericLight".
  83225. * @return The class name
  83226. */
  83227. getClassName(): string;
  83228. /**
  83229. * Sets the HemisphericLight direction towards the passed target (Vector3).
  83230. * Returns the updated direction.
  83231. * @param target The target the direction should point to
  83232. * @return The computed direction
  83233. */
  83234. setDirectionToTarget(target: Vector3): Vector3;
  83235. /**
  83236. * Returns the shadow generator associated to the light.
  83237. * @returns Always null for hemispheric lights because it does not support shadows.
  83238. */
  83239. getShadowGenerator(): Nullable<IShadowGenerator>;
  83240. /**
  83241. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  83242. * @param effect The effect to update
  83243. * @param lightIndex The index of the light in the effect to update
  83244. * @returns The hemispheric light
  83245. */
  83246. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  83247. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  83248. /**
  83249. * Computes the world matrix of the node
  83250. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  83251. * @param useWasUpdatedFlag defines a reserved property
  83252. * @returns the world matrix
  83253. */
  83254. computeWorldMatrix(): Matrix;
  83255. /**
  83256. * Returns the integer 3.
  83257. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  83258. */
  83259. getTypeID(): number;
  83260. /**
  83261. * Prepares the list of defines specific to the light type.
  83262. * @param defines the list of defines
  83263. * @param lightIndex defines the index of the light for the effect
  83264. */
  83265. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  83266. }
  83267. }
  83268. declare module BABYLON {
  83269. /** @hidden */
  83270. export var vrMultiviewToSingleviewPixelShader: {
  83271. name: string;
  83272. shader: string;
  83273. };
  83274. }
  83275. declare module BABYLON {
  83276. /**
  83277. * Renders to multiple views with a single draw call
  83278. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  83279. */
  83280. export class MultiviewRenderTarget extends RenderTargetTexture {
  83281. /**
  83282. * Creates a multiview render target
  83283. * @param scene scene used with the render target
  83284. * @param size the size of the render target (used for each view)
  83285. */
  83286. constructor(scene: Scene, size?: number | {
  83287. width: number;
  83288. height: number;
  83289. } | {
  83290. ratio: number;
  83291. });
  83292. /**
  83293. * @hidden
  83294. * @param faceIndex the face index, if its a cube texture
  83295. */
  83296. _bindFrameBuffer(faceIndex?: number): void;
  83297. /**
  83298. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  83299. * @returns the view count
  83300. */
  83301. getViewCount(): number;
  83302. }
  83303. }
  83304. declare module BABYLON {
  83305. /**
  83306. * Represents a camera frustum
  83307. */
  83308. export class Frustum {
  83309. /**
  83310. * Gets the planes representing the frustum
  83311. * @param transform matrix to be applied to the returned planes
  83312. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  83313. */
  83314. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  83315. /**
  83316. * Gets the near frustum plane transformed by the transform matrix
  83317. * @param transform transformation matrix to be applied to the resulting frustum plane
  83318. * @param frustumPlane the resuling frustum plane
  83319. */
  83320. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  83321. /**
  83322. * Gets the far frustum plane transformed by the transform matrix
  83323. * @param transform transformation matrix to be applied to the resulting frustum plane
  83324. * @param frustumPlane the resuling frustum plane
  83325. */
  83326. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  83327. /**
  83328. * Gets the left frustum plane transformed by the transform matrix
  83329. * @param transform transformation matrix to be applied to the resulting frustum plane
  83330. * @param frustumPlane the resuling frustum plane
  83331. */
  83332. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  83333. /**
  83334. * Gets the right frustum plane transformed by the transform matrix
  83335. * @param transform transformation matrix to be applied to the resulting frustum plane
  83336. * @param frustumPlane the resuling frustum plane
  83337. */
  83338. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  83339. /**
  83340. * Gets the top frustum plane transformed by the transform matrix
  83341. * @param transform transformation matrix to be applied to the resulting frustum plane
  83342. * @param frustumPlane the resuling frustum plane
  83343. */
  83344. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  83345. /**
  83346. * Gets the bottom frustum plane transformed by the transform matrix
  83347. * @param transform transformation matrix to be applied to the resulting frustum plane
  83348. * @param frustumPlane the resuling frustum plane
  83349. */
  83350. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  83351. /**
  83352. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  83353. * @param transform transformation matrix to be applied to the resulting frustum planes
  83354. * @param frustumPlanes the resuling frustum planes
  83355. */
  83356. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  83357. }
  83358. }
  83359. declare module BABYLON {
  83360. interface Engine {
  83361. /**
  83362. * Creates a new multiview render target
  83363. * @param width defines the width of the texture
  83364. * @param height defines the height of the texture
  83365. * @returns the created multiview texture
  83366. */
  83367. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  83368. /**
  83369. * Binds a multiview framebuffer to be drawn to
  83370. * @param multiviewTexture texture to bind
  83371. */
  83372. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  83373. }
  83374. interface Camera {
  83375. /**
  83376. * @hidden
  83377. * 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)
  83378. */
  83379. _useMultiviewToSingleView: boolean;
  83380. /**
  83381. * @hidden
  83382. * 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)
  83383. */
  83384. _multiviewTexture: Nullable<RenderTargetTexture>;
  83385. /**
  83386. * @hidden
  83387. * ensures the multiview texture of the camera exists and has the specified width/height
  83388. * @param width height to set on the multiview texture
  83389. * @param height width to set on the multiview texture
  83390. */
  83391. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  83392. }
  83393. interface Scene {
  83394. /** @hidden */
  83395. _transformMatrixR: Matrix;
  83396. /** @hidden */
  83397. _multiviewSceneUbo: Nullable<UniformBuffer>;
  83398. /** @hidden */
  83399. _createMultiviewUbo(): void;
  83400. /** @hidden */
  83401. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  83402. /** @hidden */
  83403. _renderMultiviewToSingleView(camera: Camera): void;
  83404. }
  83405. }
  83406. declare module BABYLON {
  83407. /**
  83408. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  83409. * This will not be used for webXR as it supports displaying texture arrays directly
  83410. */
  83411. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  83412. /**
  83413. * Initializes a VRMultiviewToSingleview
  83414. * @param name name of the post process
  83415. * @param camera camera to be applied to
  83416. * @param scaleFactor scaling factor to the size of the output texture
  83417. */
  83418. constructor(name: string, camera: Camera, scaleFactor: number);
  83419. }
  83420. }
  83421. declare module BABYLON {
  83422. /**
  83423. * Interface used to define additional presentation attributes
  83424. */
  83425. export interface IVRPresentationAttributes {
  83426. /**
  83427. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  83428. */
  83429. highRefreshRate: boolean;
  83430. /**
  83431. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  83432. */
  83433. foveationLevel: number;
  83434. }
  83435. interface Engine {
  83436. /** @hidden */
  83437. _vrDisplay: any;
  83438. /** @hidden */
  83439. _vrSupported: boolean;
  83440. /** @hidden */
  83441. _oldSize: Size;
  83442. /** @hidden */
  83443. _oldHardwareScaleFactor: number;
  83444. /** @hidden */
  83445. _vrExclusivePointerMode: boolean;
  83446. /** @hidden */
  83447. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  83448. /** @hidden */
  83449. _onVRDisplayPointerRestricted: () => void;
  83450. /** @hidden */
  83451. _onVRDisplayPointerUnrestricted: () => void;
  83452. /** @hidden */
  83453. _onVrDisplayConnect: Nullable<(display: any) => void>;
  83454. /** @hidden */
  83455. _onVrDisplayDisconnect: Nullable<() => void>;
  83456. /** @hidden */
  83457. _onVrDisplayPresentChange: Nullable<() => void>;
  83458. /**
  83459. * Observable signaled when VR display mode changes
  83460. */
  83461. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  83462. /**
  83463. * Observable signaled when VR request present is complete
  83464. */
  83465. onVRRequestPresentComplete: Observable<boolean>;
  83466. /**
  83467. * Observable signaled when VR request present starts
  83468. */
  83469. onVRRequestPresentStart: Observable<Engine>;
  83470. /**
  83471. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  83472. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  83473. */
  83474. isInVRExclusivePointerMode: boolean;
  83475. /**
  83476. * Gets a boolean indicating if a webVR device was detected
  83477. * @returns true if a webVR device was detected
  83478. */
  83479. isVRDevicePresent(): boolean;
  83480. /**
  83481. * Gets the current webVR device
  83482. * @returns the current webVR device (or null)
  83483. */
  83484. getVRDevice(): any;
  83485. /**
  83486. * Initializes a webVR display and starts listening to display change events
  83487. * The onVRDisplayChangedObservable will be notified upon these changes
  83488. * @returns A promise containing a VRDisplay and if vr is supported
  83489. */
  83490. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  83491. /** @hidden */
  83492. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  83493. /**
  83494. * Gets or sets the presentation attributes used to configure VR rendering
  83495. */
  83496. vrPresentationAttributes?: IVRPresentationAttributes;
  83497. /**
  83498. * Call this function to switch to webVR mode
  83499. * Will do nothing if webVR is not supported or if there is no webVR device
  83500. * @param options the webvr options provided to the camera. mainly used for multiview
  83501. * @see http://doc.babylonjs.com/how_to/webvr_camera
  83502. */
  83503. enableVR(options: WebVROptions): void;
  83504. /** @hidden */
  83505. _onVRFullScreenTriggered(): void;
  83506. }
  83507. }
  83508. declare module BABYLON {
  83509. /**
  83510. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  83511. * IMPORTANT!! The data is right-hand data.
  83512. * @export
  83513. * @interface DevicePose
  83514. */
  83515. export interface DevicePose {
  83516. /**
  83517. * The position of the device, values in array are [x,y,z].
  83518. */
  83519. readonly position: Nullable<Float32Array>;
  83520. /**
  83521. * The linearVelocity of the device, values in array are [x,y,z].
  83522. */
  83523. readonly linearVelocity: Nullable<Float32Array>;
  83524. /**
  83525. * The linearAcceleration of the device, values in array are [x,y,z].
  83526. */
  83527. readonly linearAcceleration: Nullable<Float32Array>;
  83528. /**
  83529. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  83530. */
  83531. readonly orientation: Nullable<Float32Array>;
  83532. /**
  83533. * The angularVelocity of the device, values in array are [x,y,z].
  83534. */
  83535. readonly angularVelocity: Nullable<Float32Array>;
  83536. /**
  83537. * The angularAcceleration of the device, values in array are [x,y,z].
  83538. */
  83539. readonly angularAcceleration: Nullable<Float32Array>;
  83540. }
  83541. /**
  83542. * Interface representing a pose controlled object in Babylon.
  83543. * A pose controlled object has both regular pose values as well as pose values
  83544. * from an external device such as a VR head mounted display
  83545. */
  83546. export interface PoseControlled {
  83547. /**
  83548. * The position of the object in babylon space.
  83549. */
  83550. position: Vector3;
  83551. /**
  83552. * The rotation quaternion of the object in babylon space.
  83553. */
  83554. rotationQuaternion: Quaternion;
  83555. /**
  83556. * The position of the device in babylon space.
  83557. */
  83558. devicePosition?: Vector3;
  83559. /**
  83560. * The rotation quaternion of the device in babylon space.
  83561. */
  83562. deviceRotationQuaternion: Quaternion;
  83563. /**
  83564. * The raw pose coming from the device.
  83565. */
  83566. rawPose: Nullable<DevicePose>;
  83567. /**
  83568. * The scale of the device to be used when translating from device space to babylon space.
  83569. */
  83570. deviceScaleFactor: number;
  83571. /**
  83572. * Updates the poseControlled values based on the input device pose.
  83573. * @param poseData the pose data to update the object with
  83574. */
  83575. updateFromDevice(poseData: DevicePose): void;
  83576. }
  83577. /**
  83578. * Set of options to customize the webVRCamera
  83579. */
  83580. export interface WebVROptions {
  83581. /**
  83582. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  83583. */
  83584. trackPosition?: boolean;
  83585. /**
  83586. * Sets the scale of the vrDevice in babylon space. (default: 1)
  83587. */
  83588. positionScale?: number;
  83589. /**
  83590. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  83591. */
  83592. displayName?: string;
  83593. /**
  83594. * Should the native controller meshes be initialized. (default: true)
  83595. */
  83596. controllerMeshes?: boolean;
  83597. /**
  83598. * Creating a default HemiLight only on controllers. (default: true)
  83599. */
  83600. defaultLightingOnControllers?: boolean;
  83601. /**
  83602. * If you don't want to use the default VR button of the helper. (default: false)
  83603. */
  83604. useCustomVRButton?: boolean;
  83605. /**
  83606. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  83607. */
  83608. customVRButton?: HTMLButtonElement;
  83609. /**
  83610. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  83611. */
  83612. rayLength?: number;
  83613. /**
  83614. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  83615. */
  83616. defaultHeight?: number;
  83617. /**
  83618. * If multiview should be used if availible (default: false)
  83619. */
  83620. useMultiview?: boolean;
  83621. }
  83622. /**
  83623. * This represents a WebVR camera.
  83624. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  83625. * @example http://doc.babylonjs.com/how_to/webvr_camera
  83626. */
  83627. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  83628. private webVROptions;
  83629. /**
  83630. * @hidden
  83631. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  83632. */
  83633. _vrDevice: any;
  83634. /**
  83635. * The rawPose of the vrDevice.
  83636. */
  83637. rawPose: Nullable<DevicePose>;
  83638. private _onVREnabled;
  83639. private _specsVersion;
  83640. private _attached;
  83641. private _frameData;
  83642. protected _descendants: Array<Node>;
  83643. private _deviceRoomPosition;
  83644. /** @hidden */
  83645. _deviceRoomRotationQuaternion: Quaternion;
  83646. private _standingMatrix;
  83647. /**
  83648. * Represents device position in babylon space.
  83649. */
  83650. devicePosition: Vector3;
  83651. /**
  83652. * Represents device rotation in babylon space.
  83653. */
  83654. deviceRotationQuaternion: Quaternion;
  83655. /**
  83656. * The scale of the device to be used when translating from device space to babylon space.
  83657. */
  83658. deviceScaleFactor: number;
  83659. private _deviceToWorld;
  83660. private _worldToDevice;
  83661. /**
  83662. * References to the webVR controllers for the vrDevice.
  83663. */
  83664. controllers: Array<WebVRController>;
  83665. /**
  83666. * Emits an event when a controller is attached.
  83667. */
  83668. onControllersAttachedObservable: Observable<WebVRController[]>;
  83669. /**
  83670. * Emits an event when a controller's mesh has been loaded;
  83671. */
  83672. onControllerMeshLoadedObservable: Observable<WebVRController>;
  83673. /**
  83674. * Emits an event when the HMD's pose has been updated.
  83675. */
  83676. onPoseUpdatedFromDeviceObservable: Observable<any>;
  83677. private _poseSet;
  83678. /**
  83679. * If the rig cameras be used as parent instead of this camera.
  83680. */
  83681. rigParenting: boolean;
  83682. private _lightOnControllers;
  83683. private _defaultHeight?;
  83684. /**
  83685. * Instantiates a WebVRFreeCamera.
  83686. * @param name The name of the WebVRFreeCamera
  83687. * @param position The starting anchor position for the camera
  83688. * @param scene The scene the camera belongs to
  83689. * @param webVROptions a set of customizable options for the webVRCamera
  83690. */
  83691. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  83692. /**
  83693. * Gets the device distance from the ground in meters.
  83694. * @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.
  83695. */
  83696. deviceDistanceToRoomGround(): number;
  83697. /**
  83698. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  83699. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  83700. */
  83701. useStandingMatrix(callback?: (bool: boolean) => void): void;
  83702. /**
  83703. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  83704. * @returns A promise with a boolean set to if the standing matrix is supported.
  83705. */
  83706. useStandingMatrixAsync(): Promise<boolean>;
  83707. /**
  83708. * Disposes the camera
  83709. */
  83710. dispose(): void;
  83711. /**
  83712. * Gets a vrController by name.
  83713. * @param name The name of the controller to retreive
  83714. * @returns the controller matching the name specified or null if not found
  83715. */
  83716. getControllerByName(name: string): Nullable<WebVRController>;
  83717. private _leftController;
  83718. /**
  83719. * The controller corresponding to the users left hand.
  83720. */
  83721. readonly leftController: Nullable<WebVRController>;
  83722. private _rightController;
  83723. /**
  83724. * The controller corresponding to the users right hand.
  83725. */
  83726. readonly rightController: Nullable<WebVRController>;
  83727. /**
  83728. * Casts a ray forward from the vrCamera's gaze.
  83729. * @param length Length of the ray (default: 100)
  83730. * @returns the ray corresponding to the gaze
  83731. */
  83732. getForwardRay(length?: number): Ray;
  83733. /**
  83734. * @hidden
  83735. * Updates the camera based on device's frame data
  83736. */
  83737. _checkInputs(): void;
  83738. /**
  83739. * Updates the poseControlled values based on the input device pose.
  83740. * @param poseData Pose coming from the device
  83741. */
  83742. updateFromDevice(poseData: DevicePose): void;
  83743. private _htmlElementAttached;
  83744. private _detachIfAttached;
  83745. /**
  83746. * WebVR's attach control will start broadcasting frames to the device.
  83747. * Note that in certain browsers (chrome for example) this function must be called
  83748. * within a user-interaction callback. Example:
  83749. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  83750. *
  83751. * @param element html element to attach the vrDevice to
  83752. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  83753. */
  83754. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  83755. /**
  83756. * Detaches the camera from the html element and disables VR
  83757. *
  83758. * @param element html element to detach from
  83759. */
  83760. detachControl(element: HTMLElement): void;
  83761. /**
  83762. * @returns the name of this class
  83763. */
  83764. getClassName(): string;
  83765. /**
  83766. * Calls resetPose on the vrDisplay
  83767. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  83768. */
  83769. resetToCurrentRotation(): void;
  83770. /**
  83771. * @hidden
  83772. * Updates the rig cameras (left and right eye)
  83773. */
  83774. _updateRigCameras(): void;
  83775. private _workingVector;
  83776. private _oneVector;
  83777. private _workingMatrix;
  83778. private updateCacheCalled;
  83779. private _correctPositionIfNotTrackPosition;
  83780. /**
  83781. * @hidden
  83782. * Updates the cached values of the camera
  83783. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  83784. */
  83785. _updateCache(ignoreParentClass?: boolean): void;
  83786. /**
  83787. * @hidden
  83788. * Get current device position in babylon world
  83789. */
  83790. _computeDevicePosition(): void;
  83791. /**
  83792. * Updates the current device position and rotation in the babylon world
  83793. */
  83794. update(): void;
  83795. /**
  83796. * @hidden
  83797. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  83798. * @returns an identity matrix
  83799. */
  83800. _getViewMatrix(): Matrix;
  83801. private _tmpMatrix;
  83802. /**
  83803. * This function is called by the two RIG cameras.
  83804. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  83805. * @hidden
  83806. */
  83807. _getWebVRViewMatrix(): Matrix;
  83808. /** @hidden */
  83809. _getWebVRProjectionMatrix(): Matrix;
  83810. private _onGamepadConnectedObserver;
  83811. private _onGamepadDisconnectedObserver;
  83812. private _updateCacheWhenTrackingDisabledObserver;
  83813. /**
  83814. * Initializes the controllers and their meshes
  83815. */
  83816. initControllers(): void;
  83817. }
  83818. }
  83819. declare module BABYLON {
  83820. /**
  83821. * Size options for a post process
  83822. */
  83823. export type PostProcessOptions = {
  83824. width: number;
  83825. height: number;
  83826. };
  83827. /**
  83828. * PostProcess can be used to apply a shader to a texture after it has been rendered
  83829. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  83830. */
  83831. export class PostProcess {
  83832. /** Name of the PostProcess. */
  83833. name: string;
  83834. /**
  83835. * Gets or sets the unique id of the post process
  83836. */
  83837. uniqueId: number;
  83838. /**
  83839. * Width of the texture to apply the post process on
  83840. */
  83841. width: number;
  83842. /**
  83843. * Height of the texture to apply the post process on
  83844. */
  83845. height: number;
  83846. /**
  83847. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  83848. * @hidden
  83849. */
  83850. _outputTexture: Nullable<InternalTexture>;
  83851. /**
  83852. * Sampling mode used by the shader
  83853. * See https://doc.babylonjs.com/classes/3.1/texture
  83854. */
  83855. renderTargetSamplingMode: number;
  83856. /**
  83857. * Clear color to use when screen clearing
  83858. */
  83859. clearColor: Color4;
  83860. /**
  83861. * If the buffer needs to be cleared before applying the post process. (default: true)
  83862. * Should be set to false if shader will overwrite all previous pixels.
  83863. */
  83864. autoClear: boolean;
  83865. /**
  83866. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  83867. */
  83868. alphaMode: number;
  83869. /**
  83870. * Sets the setAlphaBlendConstants of the babylon engine
  83871. */
  83872. alphaConstants: Color4;
  83873. /**
  83874. * Animations to be used for the post processing
  83875. */
  83876. animations: Animation[];
  83877. /**
  83878. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  83879. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  83880. */
  83881. enablePixelPerfectMode: boolean;
  83882. /**
  83883. * Force the postprocess to be applied without taking in account viewport
  83884. */
  83885. forceFullscreenViewport: boolean;
  83886. /**
  83887. * List of inspectable custom properties (used by the Inspector)
  83888. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  83889. */
  83890. inspectableCustomProperties: IInspectable[];
  83891. /**
  83892. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  83893. *
  83894. * | Value | Type | Description |
  83895. * | ----- | ----------------------------------- | ----------- |
  83896. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  83897. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  83898. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  83899. *
  83900. */
  83901. scaleMode: number;
  83902. /**
  83903. * Force textures to be a power of two (default: false)
  83904. */
  83905. alwaysForcePOT: boolean;
  83906. private _samples;
  83907. /**
  83908. * Number of sample textures (default: 1)
  83909. */
  83910. samples: number;
  83911. /**
  83912. * Modify the scale of the post process to be the same as the viewport (default: false)
  83913. */
  83914. adaptScaleToCurrentViewport: boolean;
  83915. private _camera;
  83916. private _scene;
  83917. private _engine;
  83918. private _options;
  83919. private _reusable;
  83920. private _textureType;
  83921. /**
  83922. * Smart array of input and output textures for the post process.
  83923. * @hidden
  83924. */
  83925. _textures: SmartArray<InternalTexture>;
  83926. /**
  83927. * The index in _textures that corresponds to the output texture.
  83928. * @hidden
  83929. */
  83930. _currentRenderTextureInd: number;
  83931. private _effect;
  83932. private _samplers;
  83933. private _fragmentUrl;
  83934. private _vertexUrl;
  83935. private _parameters;
  83936. private _scaleRatio;
  83937. protected _indexParameters: any;
  83938. private _shareOutputWithPostProcess;
  83939. private _texelSize;
  83940. private _forcedOutputTexture;
  83941. /**
  83942. * Returns the fragment url or shader name used in the post process.
  83943. * @returns the fragment url or name in the shader store.
  83944. */
  83945. getEffectName(): string;
  83946. /**
  83947. * An event triggered when the postprocess is activated.
  83948. */
  83949. onActivateObservable: Observable<Camera>;
  83950. private _onActivateObserver;
  83951. /**
  83952. * A function that is added to the onActivateObservable
  83953. */
  83954. onActivate: Nullable<(camera: Camera) => void>;
  83955. /**
  83956. * An event triggered when the postprocess changes its size.
  83957. */
  83958. onSizeChangedObservable: Observable<PostProcess>;
  83959. private _onSizeChangedObserver;
  83960. /**
  83961. * A function that is added to the onSizeChangedObservable
  83962. */
  83963. onSizeChanged: (postProcess: PostProcess) => void;
  83964. /**
  83965. * An event triggered when the postprocess applies its effect.
  83966. */
  83967. onApplyObservable: Observable<Effect>;
  83968. private _onApplyObserver;
  83969. /**
  83970. * A function that is added to the onApplyObservable
  83971. */
  83972. onApply: (effect: Effect) => void;
  83973. /**
  83974. * An event triggered before rendering the postprocess
  83975. */
  83976. onBeforeRenderObservable: Observable<Effect>;
  83977. private _onBeforeRenderObserver;
  83978. /**
  83979. * A function that is added to the onBeforeRenderObservable
  83980. */
  83981. onBeforeRender: (effect: Effect) => void;
  83982. /**
  83983. * An event triggered after rendering the postprocess
  83984. */
  83985. onAfterRenderObservable: Observable<Effect>;
  83986. private _onAfterRenderObserver;
  83987. /**
  83988. * A function that is added to the onAfterRenderObservable
  83989. */
  83990. onAfterRender: (efect: Effect) => void;
  83991. /**
  83992. * 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
  83993. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  83994. */
  83995. inputTexture: InternalTexture;
  83996. /**
  83997. * Gets the camera which post process is applied to.
  83998. * @returns The camera the post process is applied to.
  83999. */
  84000. getCamera(): Camera;
  84001. /**
  84002. * Gets the texel size of the postprocess.
  84003. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  84004. */
  84005. readonly texelSize: Vector2;
  84006. /**
  84007. * Creates a new instance PostProcess
  84008. * @param name The name of the PostProcess.
  84009. * @param fragmentUrl The url of the fragment shader to be used.
  84010. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  84011. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  84012. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  84013. * @param camera The camera to apply the render pass to.
  84014. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  84015. * @param engine The engine which the post process will be applied. (default: current engine)
  84016. * @param reusable If the post process can be reused on the same frame. (default: false)
  84017. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  84018. * @param textureType Type of textures used when performing the post process. (default: 0)
  84019. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  84020. * @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
  84021. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  84022. */
  84023. constructor(
  84024. /** Name of the PostProcess. */
  84025. 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);
  84026. /**
  84027. * Gets a string idenfifying the name of the class
  84028. * @returns "PostProcess" string
  84029. */
  84030. getClassName(): string;
  84031. /**
  84032. * Gets the engine which this post process belongs to.
  84033. * @returns The engine the post process was enabled with.
  84034. */
  84035. getEngine(): Engine;
  84036. /**
  84037. * The effect that is created when initializing the post process.
  84038. * @returns The created effect corresponding the the postprocess.
  84039. */
  84040. getEffect(): Effect;
  84041. /**
  84042. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  84043. * @param postProcess The post process to share the output with.
  84044. * @returns This post process.
  84045. */
  84046. shareOutputWith(postProcess: PostProcess): PostProcess;
  84047. /**
  84048. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  84049. * This should be called if the post process that shares output with this post process is disabled/disposed.
  84050. */
  84051. useOwnOutput(): void;
  84052. /**
  84053. * Updates the effect with the current post process compile time values and recompiles the shader.
  84054. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  84055. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  84056. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  84057. * @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
  84058. * @param onCompiled Called when the shader has been compiled.
  84059. * @param onError Called if there is an error when compiling a shader.
  84060. */
  84061. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  84062. /**
  84063. * The post process is reusable if it can be used multiple times within one frame.
  84064. * @returns If the post process is reusable
  84065. */
  84066. isReusable(): boolean;
  84067. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  84068. markTextureDirty(): void;
  84069. /**
  84070. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  84071. * 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.
  84072. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  84073. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  84074. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  84075. * @returns The target texture that was bound to be written to.
  84076. */
  84077. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  84078. /**
  84079. * If the post process is supported.
  84080. */
  84081. readonly isSupported: boolean;
  84082. /**
  84083. * The aspect ratio of the output texture.
  84084. */
  84085. readonly aspectRatio: number;
  84086. /**
  84087. * Get a value indicating if the post-process is ready to be used
  84088. * @returns true if the post-process is ready (shader is compiled)
  84089. */
  84090. isReady(): boolean;
  84091. /**
  84092. * Binds all textures and uniforms to the shader, this will be run on every pass.
  84093. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  84094. */
  84095. apply(): Nullable<Effect>;
  84096. private _disposeTextures;
  84097. /**
  84098. * Disposes the post process.
  84099. * @param camera The camera to dispose the post process on.
  84100. */
  84101. dispose(camera?: Camera): void;
  84102. }
  84103. }
  84104. declare module BABYLON {
  84105. /** @hidden */
  84106. export var kernelBlurVaryingDeclaration: {
  84107. name: string;
  84108. shader: string;
  84109. };
  84110. }
  84111. declare module BABYLON {
  84112. /** @hidden */
  84113. export var kernelBlurFragment: {
  84114. name: string;
  84115. shader: string;
  84116. };
  84117. }
  84118. declare module BABYLON {
  84119. /** @hidden */
  84120. export var kernelBlurFragment2: {
  84121. name: string;
  84122. shader: string;
  84123. };
  84124. }
  84125. declare module BABYLON {
  84126. /** @hidden */
  84127. export var kernelBlurPixelShader: {
  84128. name: string;
  84129. shader: string;
  84130. };
  84131. }
  84132. declare module BABYLON {
  84133. /** @hidden */
  84134. export var kernelBlurVertex: {
  84135. name: string;
  84136. shader: string;
  84137. };
  84138. }
  84139. declare module BABYLON {
  84140. /** @hidden */
  84141. export var kernelBlurVertexShader: {
  84142. name: string;
  84143. shader: string;
  84144. };
  84145. }
  84146. declare module BABYLON {
  84147. /**
  84148. * The Blur Post Process which blurs an image based on a kernel and direction.
  84149. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  84150. */
  84151. export class BlurPostProcess extends PostProcess {
  84152. /** The direction in which to blur the image. */
  84153. direction: Vector2;
  84154. private blockCompilation;
  84155. protected _kernel: number;
  84156. protected _idealKernel: number;
  84157. protected _packedFloat: boolean;
  84158. private _staticDefines;
  84159. /**
  84160. * Sets the length in pixels of the blur sample region
  84161. */
  84162. /**
  84163. * Gets the length in pixels of the blur sample region
  84164. */
  84165. kernel: number;
  84166. /**
  84167. * Sets wether or not the blur needs to unpack/repack floats
  84168. */
  84169. /**
  84170. * Gets wether or not the blur is unpacking/repacking floats
  84171. */
  84172. packedFloat: boolean;
  84173. /**
  84174. * Creates a new instance BlurPostProcess
  84175. * @param name The name of the effect.
  84176. * @param direction The direction in which to blur the image.
  84177. * @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.
  84178. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  84179. * @param camera The camera to apply the render pass to.
  84180. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  84181. * @param engine The engine which the post process will be applied. (default: current engine)
  84182. * @param reusable If the post process can be reused on the same frame. (default: false)
  84183. * @param textureType Type of textures used when performing the post process. (default: 0)
  84184. * @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)
  84185. */
  84186. constructor(name: string,
  84187. /** The direction in which to blur the image. */
  84188. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  84189. /**
  84190. * Updates the effect with the current post process compile time values and recompiles the shader.
  84191. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  84192. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  84193. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  84194. * @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
  84195. * @param onCompiled Called when the shader has been compiled.
  84196. * @param onError Called if there is an error when compiling a shader.
  84197. */
  84198. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  84199. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  84200. /**
  84201. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  84202. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  84203. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  84204. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  84205. * The gaps between physical kernels are compensated for in the weighting of the samples
  84206. * @param idealKernel Ideal blur kernel.
  84207. * @return Nearest best kernel.
  84208. */
  84209. protected _nearestBestKernel(idealKernel: number): number;
  84210. /**
  84211. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  84212. * @param x The point on the Gaussian distribution to sample.
  84213. * @return the value of the Gaussian function at x.
  84214. */
  84215. protected _gaussianWeight(x: number): number;
  84216. /**
  84217. * Generates a string that can be used as a floating point number in GLSL.
  84218. * @param x Value to print.
  84219. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  84220. * @return GLSL float string.
  84221. */
  84222. protected _glslFloat(x: number, decimalFigures?: number): string;
  84223. }
  84224. }
  84225. declare module BABYLON {
  84226. /**
  84227. * Mirror texture can be used to simulate the view from a mirror in a scene.
  84228. * It will dynamically be rendered every frame to adapt to the camera point of view.
  84229. * You can then easily use it as a reflectionTexture on a flat surface.
  84230. * In case the surface is not a plane, please consider relying on reflection probes.
  84231. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  84232. */
  84233. export class MirrorTexture extends RenderTargetTexture {
  84234. private scene;
  84235. /**
  84236. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  84237. * 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.
  84238. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  84239. */
  84240. mirrorPlane: Plane;
  84241. /**
  84242. * Define the blur ratio used to blur the reflection if needed.
  84243. */
  84244. blurRatio: number;
  84245. /**
  84246. * Define the adaptive blur kernel used to blur the reflection if needed.
  84247. * This will autocompute the closest best match for the `blurKernel`
  84248. */
  84249. adaptiveBlurKernel: number;
  84250. /**
  84251. * Define the blur kernel used to blur the reflection if needed.
  84252. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  84253. */
  84254. blurKernel: number;
  84255. /**
  84256. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  84257. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  84258. */
  84259. blurKernelX: number;
  84260. /**
  84261. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  84262. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  84263. */
  84264. blurKernelY: number;
  84265. private _autoComputeBlurKernel;
  84266. protected _onRatioRescale(): void;
  84267. private _updateGammaSpace;
  84268. private _imageProcessingConfigChangeObserver;
  84269. private _transformMatrix;
  84270. private _mirrorMatrix;
  84271. private _savedViewMatrix;
  84272. private _blurX;
  84273. private _blurY;
  84274. private _adaptiveBlurKernel;
  84275. private _blurKernelX;
  84276. private _blurKernelY;
  84277. private _blurRatio;
  84278. /**
  84279. * Instantiates a Mirror Texture.
  84280. * Mirror texture can be used to simulate the view from a mirror in a scene.
  84281. * It will dynamically be rendered every frame to adapt to the camera point of view.
  84282. * You can then easily use it as a reflectionTexture on a flat surface.
  84283. * In case the surface is not a plane, please consider relying on reflection probes.
  84284. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  84285. * @param name
  84286. * @param size
  84287. * @param scene
  84288. * @param generateMipMaps
  84289. * @param type
  84290. * @param samplingMode
  84291. * @param generateDepthBuffer
  84292. */
  84293. constructor(name: string, size: number | {
  84294. width: number;
  84295. height: number;
  84296. } | {
  84297. ratio: number;
  84298. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  84299. private _preparePostProcesses;
  84300. /**
  84301. * Clone the mirror texture.
  84302. * @returns the cloned texture
  84303. */
  84304. clone(): MirrorTexture;
  84305. /**
  84306. * Serialize the texture to a JSON representation you could use in Parse later on
  84307. * @returns the serialized JSON representation
  84308. */
  84309. serialize(): any;
  84310. /**
  84311. * Dispose the texture and release its associated resources.
  84312. */
  84313. dispose(): void;
  84314. }
  84315. }
  84316. declare module BABYLON {
  84317. /**
  84318. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  84319. * @see http://doc.babylonjs.com/babylon101/materials#texture
  84320. */
  84321. export class Texture extends BaseTexture {
  84322. /**
  84323. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  84324. */
  84325. static SerializeBuffers: boolean;
  84326. /** @hidden */
  84327. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  84328. /** @hidden */
  84329. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  84330. /** @hidden */
  84331. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  84332. /** nearest is mag = nearest and min = nearest and mip = linear */
  84333. static readonly NEAREST_SAMPLINGMODE: number;
  84334. /** nearest is mag = nearest and min = nearest and mip = linear */
  84335. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  84336. /** Bilinear is mag = linear and min = linear and mip = nearest */
  84337. static readonly BILINEAR_SAMPLINGMODE: number;
  84338. /** Bilinear is mag = linear and min = linear and mip = nearest */
  84339. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  84340. /** Trilinear is mag = linear and min = linear and mip = linear */
  84341. static readonly TRILINEAR_SAMPLINGMODE: number;
  84342. /** Trilinear is mag = linear and min = linear and mip = linear */
  84343. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  84344. /** mag = nearest and min = nearest and mip = nearest */
  84345. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  84346. /** mag = nearest and min = linear and mip = nearest */
  84347. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  84348. /** mag = nearest and min = linear and mip = linear */
  84349. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  84350. /** mag = nearest and min = linear and mip = none */
  84351. static readonly NEAREST_LINEAR: number;
  84352. /** mag = nearest and min = nearest and mip = none */
  84353. static readonly NEAREST_NEAREST: number;
  84354. /** mag = linear and min = nearest and mip = nearest */
  84355. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  84356. /** mag = linear and min = nearest and mip = linear */
  84357. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  84358. /** mag = linear and min = linear and mip = none */
  84359. static readonly LINEAR_LINEAR: number;
  84360. /** mag = linear and min = nearest and mip = none */
  84361. static readonly LINEAR_NEAREST: number;
  84362. /** Explicit coordinates mode */
  84363. static readonly EXPLICIT_MODE: number;
  84364. /** Spherical coordinates mode */
  84365. static readonly SPHERICAL_MODE: number;
  84366. /** Planar coordinates mode */
  84367. static readonly PLANAR_MODE: number;
  84368. /** Cubic coordinates mode */
  84369. static readonly CUBIC_MODE: number;
  84370. /** Projection coordinates mode */
  84371. static readonly PROJECTION_MODE: number;
  84372. /** Inverse Cubic coordinates mode */
  84373. static readonly SKYBOX_MODE: number;
  84374. /** Inverse Cubic coordinates mode */
  84375. static readonly INVCUBIC_MODE: number;
  84376. /** Equirectangular coordinates mode */
  84377. static readonly EQUIRECTANGULAR_MODE: number;
  84378. /** Equirectangular Fixed coordinates mode */
  84379. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  84380. /** Equirectangular Fixed Mirrored coordinates mode */
  84381. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  84382. /** Texture is not repeating outside of 0..1 UVs */
  84383. static readonly CLAMP_ADDRESSMODE: number;
  84384. /** Texture is repeating outside of 0..1 UVs */
  84385. static readonly WRAP_ADDRESSMODE: number;
  84386. /** Texture is repeating and mirrored */
  84387. static readonly MIRROR_ADDRESSMODE: number;
  84388. /**
  84389. * 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
  84390. */
  84391. static UseSerializedUrlIfAny: boolean;
  84392. /**
  84393. * Define the url of the texture.
  84394. */
  84395. url: Nullable<string>;
  84396. /**
  84397. * Define an offset on the texture to offset the u coordinates of the UVs
  84398. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  84399. */
  84400. uOffset: number;
  84401. /**
  84402. * Define an offset on the texture to offset the v coordinates of the UVs
  84403. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  84404. */
  84405. vOffset: number;
  84406. /**
  84407. * Define an offset on the texture to scale the u coordinates of the UVs
  84408. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  84409. */
  84410. uScale: number;
  84411. /**
  84412. * Define an offset on the texture to scale the v coordinates of the UVs
  84413. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  84414. */
  84415. vScale: number;
  84416. /**
  84417. * Define an offset on the texture to rotate around the u coordinates of the UVs
  84418. * @see http://doc.babylonjs.com/how_to/more_materials
  84419. */
  84420. uAng: number;
  84421. /**
  84422. * Define an offset on the texture to rotate around the v coordinates of the UVs
  84423. * @see http://doc.babylonjs.com/how_to/more_materials
  84424. */
  84425. vAng: number;
  84426. /**
  84427. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  84428. * @see http://doc.babylonjs.com/how_to/more_materials
  84429. */
  84430. wAng: number;
  84431. /**
  84432. * Defines the center of rotation (U)
  84433. */
  84434. uRotationCenter: number;
  84435. /**
  84436. * Defines the center of rotation (V)
  84437. */
  84438. vRotationCenter: number;
  84439. /**
  84440. * Defines the center of rotation (W)
  84441. */
  84442. wRotationCenter: number;
  84443. /**
  84444. * Are mip maps generated for this texture or not.
  84445. */
  84446. readonly noMipmap: boolean;
  84447. /**
  84448. * List of inspectable custom properties (used by the Inspector)
  84449. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  84450. */
  84451. inspectableCustomProperties: Nullable<IInspectable[]>;
  84452. private _noMipmap;
  84453. /** @hidden */
  84454. _invertY: boolean;
  84455. private _rowGenerationMatrix;
  84456. private _cachedTextureMatrix;
  84457. private _projectionModeMatrix;
  84458. private _t0;
  84459. private _t1;
  84460. private _t2;
  84461. private _cachedUOffset;
  84462. private _cachedVOffset;
  84463. private _cachedUScale;
  84464. private _cachedVScale;
  84465. private _cachedUAng;
  84466. private _cachedVAng;
  84467. private _cachedWAng;
  84468. private _cachedProjectionMatrixId;
  84469. private _cachedCoordinatesMode;
  84470. /** @hidden */
  84471. protected _initialSamplingMode: number;
  84472. /** @hidden */
  84473. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  84474. private _deleteBuffer;
  84475. protected _format: Nullable<number>;
  84476. private _delayedOnLoad;
  84477. private _delayedOnError;
  84478. private _mimeType?;
  84479. /**
  84480. * Observable triggered once the texture has been loaded.
  84481. */
  84482. onLoadObservable: Observable<Texture>;
  84483. protected _isBlocking: boolean;
  84484. /**
  84485. * Is the texture preventing material to render while loading.
  84486. * If false, a default texture will be used instead of the loading one during the preparation step.
  84487. */
  84488. isBlocking: boolean;
  84489. /**
  84490. * Get the current sampling mode associated with the texture.
  84491. */
  84492. readonly samplingMode: number;
  84493. /**
  84494. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  84495. */
  84496. readonly invertY: boolean;
  84497. /**
  84498. * Instantiates a new texture.
  84499. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  84500. * @see http://doc.babylonjs.com/babylon101/materials#texture
  84501. * @param url defines the url of the picture to load as a texture
  84502. * @param scene defines the scene or engine the texture will belong to
  84503. * @param noMipmap defines if the texture will require mip maps or not
  84504. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  84505. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  84506. * @param onLoad defines a callback triggered when the texture has been loaded
  84507. * @param onError defines a callback triggered when an error occurred during the loading session
  84508. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  84509. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  84510. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  84511. * @param mimeType defines an optional mime type information
  84512. */
  84513. 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);
  84514. /**
  84515. * Update the url (and optional buffer) of this texture if url was null during construction.
  84516. * @param url the url of the texture
  84517. * @param buffer the buffer of the texture (defaults to null)
  84518. * @param onLoad callback called when the texture is loaded (defaults to null)
  84519. */
  84520. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  84521. /**
  84522. * Finish the loading sequence of a texture flagged as delayed load.
  84523. * @hidden
  84524. */
  84525. delayLoad(): void;
  84526. private _prepareRowForTextureGeneration;
  84527. /**
  84528. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  84529. * @returns the transform matrix of the texture.
  84530. */
  84531. getTextureMatrix(uBase?: number): Matrix;
  84532. /**
  84533. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  84534. * @returns The reflection texture transform
  84535. */
  84536. getReflectionTextureMatrix(): Matrix;
  84537. /**
  84538. * Clones the texture.
  84539. * @returns the cloned texture
  84540. */
  84541. clone(): Texture;
  84542. /**
  84543. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  84544. * @returns The JSON representation of the texture
  84545. */
  84546. serialize(): any;
  84547. /**
  84548. * Get the current class name of the texture useful for serialization or dynamic coding.
  84549. * @returns "Texture"
  84550. */
  84551. getClassName(): string;
  84552. /**
  84553. * Dispose the texture and release its associated resources.
  84554. */
  84555. dispose(): void;
  84556. /**
  84557. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  84558. * @param parsedTexture Define the JSON representation of the texture
  84559. * @param scene Define the scene the parsed texture should be instantiated in
  84560. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  84561. * @returns The parsed texture if successful
  84562. */
  84563. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  84564. /**
  84565. * Creates a texture from its base 64 representation.
  84566. * @param data Define the base64 payload without the data: prefix
  84567. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  84568. * @param scene Define the scene the texture should belong to
  84569. * @param noMipmap Forces the texture to not create mip map information if true
  84570. * @param invertY define if the texture needs to be inverted on the y axis during loading
  84571. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  84572. * @param onLoad define a callback triggered when the texture has been loaded
  84573. * @param onError define a callback triggered when an error occurred during the loading session
  84574. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  84575. * @returns the created texture
  84576. */
  84577. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  84578. /**
  84579. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  84580. * @param data Define the base64 payload without the data: prefix
  84581. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  84582. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  84583. * @param scene Define the scene the texture should belong to
  84584. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  84585. * @param noMipmap Forces the texture to not create mip map information if true
  84586. * @param invertY define if the texture needs to be inverted on the y axis during loading
  84587. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  84588. * @param onLoad define a callback triggered when the texture has been loaded
  84589. * @param onError define a callback triggered when an error occurred during the loading session
  84590. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  84591. * @returns the created texture
  84592. */
  84593. 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;
  84594. }
  84595. }
  84596. declare module BABYLON {
  84597. /**
  84598. * PostProcessManager is used to manage one or more post processes or post process pipelines
  84599. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  84600. */
  84601. export class PostProcessManager {
  84602. private _scene;
  84603. private _indexBuffer;
  84604. private _vertexBuffers;
  84605. /**
  84606. * Creates a new instance PostProcess
  84607. * @param scene The scene that the post process is associated with.
  84608. */
  84609. constructor(scene: Scene);
  84610. private _prepareBuffers;
  84611. private _buildIndexBuffer;
  84612. /**
  84613. * Rebuilds the vertex buffers of the manager.
  84614. * @hidden
  84615. */
  84616. _rebuild(): void;
  84617. /**
  84618. * Prepares a frame to be run through a post process.
  84619. * @param sourceTexture The input texture to the post procesess. (default: null)
  84620. * @param postProcesses An array of post processes to be run. (default: null)
  84621. * @returns True if the post processes were able to be run.
  84622. * @hidden
  84623. */
  84624. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  84625. /**
  84626. * Manually render a set of post processes to a texture.
  84627. * @param postProcesses An array of post processes to be run.
  84628. * @param targetTexture The target texture to render to.
  84629. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  84630. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  84631. * @param lodLevel defines which lod of the texture to render to
  84632. */
  84633. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  84634. /**
  84635. * Finalize the result of the output of the postprocesses.
  84636. * @param doNotPresent If true the result will not be displayed to the screen.
  84637. * @param targetTexture The target texture to render to.
  84638. * @param faceIndex The index of the face to bind the target texture to.
  84639. * @param postProcesses The array of post processes to render.
  84640. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  84641. * @hidden
  84642. */
  84643. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  84644. /**
  84645. * Disposes of the post process manager.
  84646. */
  84647. dispose(): void;
  84648. }
  84649. }
  84650. declare module BABYLON {
  84651. /** Interface used by value gradients (color, factor, ...) */
  84652. export interface IValueGradient {
  84653. /**
  84654. * Gets or sets the gradient value (between 0 and 1)
  84655. */
  84656. gradient: number;
  84657. }
  84658. /** Class used to store color4 gradient */
  84659. export class ColorGradient implements IValueGradient {
  84660. /**
  84661. * Gets or sets the gradient value (between 0 and 1)
  84662. */
  84663. gradient: number;
  84664. /**
  84665. * Gets or sets first associated color
  84666. */
  84667. color1: Color4;
  84668. /**
  84669. * Gets or sets second associated color
  84670. */
  84671. color2?: Color4;
  84672. /**
  84673. * Will get a color picked randomly between color1 and color2.
  84674. * If color2 is undefined then color1 will be used
  84675. * @param result defines the target Color4 to store the result in
  84676. */
  84677. getColorToRef(result: Color4): void;
  84678. }
  84679. /** Class used to store color 3 gradient */
  84680. export class Color3Gradient implements IValueGradient {
  84681. /**
  84682. * Gets or sets the gradient value (between 0 and 1)
  84683. */
  84684. gradient: number;
  84685. /**
  84686. * Gets or sets the associated color
  84687. */
  84688. color: Color3;
  84689. }
  84690. /** Class used to store factor gradient */
  84691. export class FactorGradient implements IValueGradient {
  84692. /**
  84693. * Gets or sets the gradient value (between 0 and 1)
  84694. */
  84695. gradient: number;
  84696. /**
  84697. * Gets or sets first associated factor
  84698. */
  84699. factor1: number;
  84700. /**
  84701. * Gets or sets second associated factor
  84702. */
  84703. factor2?: number;
  84704. /**
  84705. * Will get a number picked randomly between factor1 and factor2.
  84706. * If factor2 is undefined then factor1 will be used
  84707. * @returns the picked number
  84708. */
  84709. getFactor(): number;
  84710. }
  84711. /**
  84712. * Helper used to simplify some generic gradient tasks
  84713. */
  84714. export class GradientHelper {
  84715. /**
  84716. * Gets the current gradient from an array of IValueGradient
  84717. * @param ratio defines the current ratio to get
  84718. * @param gradients defines the array of IValueGradient
  84719. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  84720. */
  84721. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  84722. }
  84723. }
  84724. declare module BABYLON {
  84725. interface ThinEngine {
  84726. /**
  84727. * Creates a dynamic texture
  84728. * @param width defines the width of the texture
  84729. * @param height defines the height of the texture
  84730. * @param generateMipMaps defines if the engine should generate the mip levels
  84731. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  84732. * @returns the dynamic texture inside an InternalTexture
  84733. */
  84734. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  84735. /**
  84736. * Update the content of a dynamic texture
  84737. * @param texture defines the texture to update
  84738. * @param canvas defines the canvas containing the source
  84739. * @param invertY defines if data must be stored with Y axis inverted
  84740. * @param premulAlpha defines if alpha is stored as premultiplied
  84741. * @param format defines the format of the data
  84742. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  84743. */
  84744. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  84745. }
  84746. }
  84747. declare module BABYLON {
  84748. /**
  84749. * Helper class used to generate a canvas to manipulate images
  84750. */
  84751. export class CanvasGenerator {
  84752. /**
  84753. * Create a new canvas (or offscreen canvas depending on the context)
  84754. * @param width defines the expected width
  84755. * @param height defines the expected height
  84756. * @return a new canvas or offscreen canvas
  84757. */
  84758. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  84759. }
  84760. }
  84761. declare module BABYLON {
  84762. /**
  84763. * A class extending Texture allowing drawing on a texture
  84764. * @see http://doc.babylonjs.com/how_to/dynamictexture
  84765. */
  84766. export class DynamicTexture extends Texture {
  84767. private _generateMipMaps;
  84768. private _canvas;
  84769. private _context;
  84770. private _engine;
  84771. /**
  84772. * Creates a DynamicTexture
  84773. * @param name defines the name of the texture
  84774. * @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
  84775. * @param scene defines the scene where you want the texture
  84776. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  84777. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  84778. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  84779. */
  84780. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  84781. /**
  84782. * Get the current class name of the texture useful for serialization or dynamic coding.
  84783. * @returns "DynamicTexture"
  84784. */
  84785. getClassName(): string;
  84786. /**
  84787. * Gets the current state of canRescale
  84788. */
  84789. readonly canRescale: boolean;
  84790. private _recreate;
  84791. /**
  84792. * Scales the texture
  84793. * @param ratio the scale factor to apply to both width and height
  84794. */
  84795. scale(ratio: number): void;
  84796. /**
  84797. * Resizes the texture
  84798. * @param width the new width
  84799. * @param height the new height
  84800. */
  84801. scaleTo(width: number, height: number): void;
  84802. /**
  84803. * Gets the context of the canvas used by the texture
  84804. * @returns the canvas context of the dynamic texture
  84805. */
  84806. getContext(): CanvasRenderingContext2D;
  84807. /**
  84808. * Clears the texture
  84809. */
  84810. clear(): void;
  84811. /**
  84812. * Updates the texture
  84813. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  84814. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  84815. */
  84816. update(invertY?: boolean, premulAlpha?: boolean): void;
  84817. /**
  84818. * Draws text onto the texture
  84819. * @param text defines the text to be drawn
  84820. * @param x defines the placement of the text from the left
  84821. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  84822. * @param font defines the font to be used with font-style, font-size, font-name
  84823. * @param color defines the color used for the text
  84824. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  84825. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  84826. * @param update defines whether texture is immediately update (default is true)
  84827. */
  84828. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  84829. /**
  84830. * Clones the texture
  84831. * @returns the clone of the texture.
  84832. */
  84833. clone(): DynamicTexture;
  84834. /**
  84835. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  84836. * @returns a serialized dynamic texture object
  84837. */
  84838. serialize(): any;
  84839. /** @hidden */
  84840. _rebuild(): void;
  84841. }
  84842. }
  84843. declare module BABYLON {
  84844. interface AbstractScene {
  84845. /**
  84846. * The list of procedural textures added to the scene
  84847. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  84848. */
  84849. proceduralTextures: Array<ProceduralTexture>;
  84850. }
  84851. /**
  84852. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  84853. * in a given scene.
  84854. */
  84855. export class ProceduralTextureSceneComponent implements ISceneComponent {
  84856. /**
  84857. * The component name helpfull to identify the component in the list of scene components.
  84858. */
  84859. readonly name: string;
  84860. /**
  84861. * The scene the component belongs to.
  84862. */
  84863. scene: Scene;
  84864. /**
  84865. * Creates a new instance of the component for the given scene
  84866. * @param scene Defines the scene to register the component in
  84867. */
  84868. constructor(scene: Scene);
  84869. /**
  84870. * Registers the component in a given scene
  84871. */
  84872. register(): void;
  84873. /**
  84874. * Rebuilds the elements related to this component in case of
  84875. * context lost for instance.
  84876. */
  84877. rebuild(): void;
  84878. /**
  84879. * Disposes the component and the associated ressources.
  84880. */
  84881. dispose(): void;
  84882. private _beforeClear;
  84883. }
  84884. }
  84885. declare module BABYLON {
  84886. interface ThinEngine {
  84887. /**
  84888. * Creates a new render target cube texture
  84889. * @param size defines the size of the texture
  84890. * @param options defines the options used to create the texture
  84891. * @returns a new render target cube texture stored in an InternalTexture
  84892. */
  84893. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  84894. }
  84895. }
  84896. declare module BABYLON {
  84897. /** @hidden */
  84898. export var proceduralVertexShader: {
  84899. name: string;
  84900. shader: string;
  84901. };
  84902. }
  84903. declare module BABYLON {
  84904. /**
  84905. * 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.
  84906. * This is the base class of any Procedural texture and contains most of the shareable code.
  84907. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  84908. */
  84909. export class ProceduralTexture extends Texture {
  84910. isCube: boolean;
  84911. /**
  84912. * Define if the texture is enabled or not (disabled texture will not render)
  84913. */
  84914. isEnabled: boolean;
  84915. /**
  84916. * Define if the texture must be cleared before rendering (default is true)
  84917. */
  84918. autoClear: boolean;
  84919. /**
  84920. * Callback called when the texture is generated
  84921. */
  84922. onGenerated: () => void;
  84923. /**
  84924. * Event raised when the texture is generated
  84925. */
  84926. onGeneratedObservable: Observable<ProceduralTexture>;
  84927. /** @hidden */
  84928. _generateMipMaps: boolean;
  84929. /** @hidden **/
  84930. _effect: Effect;
  84931. /** @hidden */
  84932. _textures: {
  84933. [key: string]: Texture;
  84934. };
  84935. private _size;
  84936. private _currentRefreshId;
  84937. private _refreshRate;
  84938. private _vertexBuffers;
  84939. private _indexBuffer;
  84940. private _uniforms;
  84941. private _samplers;
  84942. private _fragment;
  84943. private _floats;
  84944. private _ints;
  84945. private _floatsArrays;
  84946. private _colors3;
  84947. private _colors4;
  84948. private _vectors2;
  84949. private _vectors3;
  84950. private _matrices;
  84951. private _fallbackTexture;
  84952. private _fallbackTextureUsed;
  84953. private _engine;
  84954. private _cachedDefines;
  84955. private _contentUpdateId;
  84956. private _contentData;
  84957. /**
  84958. * Instantiates a new procedural texture.
  84959. * 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.
  84960. * This is the base class of any Procedural texture and contains most of the shareable code.
  84961. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  84962. * @param name Define the name of the texture
  84963. * @param size Define the size of the texture to create
  84964. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  84965. * @param scene Define the scene the texture belongs to
  84966. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  84967. * @param generateMipMaps Define if the texture should creates mip maps or not
  84968. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  84969. */
  84970. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  84971. /**
  84972. * The effect that is created when initializing the post process.
  84973. * @returns The created effect corresponding the the postprocess.
  84974. */
  84975. getEffect(): Effect;
  84976. /**
  84977. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  84978. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  84979. */
  84980. getContent(): Nullable<ArrayBufferView>;
  84981. private _createIndexBuffer;
  84982. /** @hidden */
  84983. _rebuild(): void;
  84984. /**
  84985. * Resets the texture in order to recreate its associated resources.
  84986. * This can be called in case of context loss
  84987. */
  84988. reset(): void;
  84989. protected _getDefines(): string;
  84990. /**
  84991. * Is the texture ready to be used ? (rendered at least once)
  84992. * @returns true if ready, otherwise, false.
  84993. */
  84994. isReady(): boolean;
  84995. /**
  84996. * Resets the refresh counter of the texture and start bak from scratch.
  84997. * Could be useful to regenerate the texture if it is setup to render only once.
  84998. */
  84999. resetRefreshCounter(): void;
  85000. /**
  85001. * Set the fragment shader to use in order to render the texture.
  85002. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  85003. */
  85004. setFragment(fragment: any): void;
  85005. /**
  85006. * Define the refresh rate of the texture or the rendering frequency.
  85007. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  85008. */
  85009. refreshRate: number;
  85010. /** @hidden */
  85011. _shouldRender(): boolean;
  85012. /**
  85013. * Get the size the texture is rendering at.
  85014. * @returns the size (texture is always squared)
  85015. */
  85016. getRenderSize(): number;
  85017. /**
  85018. * Resize the texture to new value.
  85019. * @param size Define the new size the texture should have
  85020. * @param generateMipMaps Define whether the new texture should create mip maps
  85021. */
  85022. resize(size: number, generateMipMaps: boolean): void;
  85023. private _checkUniform;
  85024. /**
  85025. * Set a texture in the shader program used to render.
  85026. * @param name Define the name of the uniform samplers as defined in the shader
  85027. * @param texture Define the texture to bind to this sampler
  85028. * @return the texture itself allowing "fluent" like uniform updates
  85029. */
  85030. setTexture(name: string, texture: Texture): ProceduralTexture;
  85031. /**
  85032. * Set a float in the shader.
  85033. * @param name Define the name of the uniform as defined in the shader
  85034. * @param value Define the value to give to the uniform
  85035. * @return the texture itself allowing "fluent" like uniform updates
  85036. */
  85037. setFloat(name: string, value: number): ProceduralTexture;
  85038. /**
  85039. * Set a int in the shader.
  85040. * @param name Define the name of the uniform as defined in the shader
  85041. * @param value Define the value to give to the uniform
  85042. * @return the texture itself allowing "fluent" like uniform updates
  85043. */
  85044. setInt(name: string, value: number): ProceduralTexture;
  85045. /**
  85046. * Set an array of floats in the shader.
  85047. * @param name Define the name of the uniform as defined in the shader
  85048. * @param value Define the value to give to the uniform
  85049. * @return the texture itself allowing "fluent" like uniform updates
  85050. */
  85051. setFloats(name: string, value: number[]): ProceduralTexture;
  85052. /**
  85053. * Set a vec3 in the shader from a Color3.
  85054. * @param name Define the name of the uniform as defined in the shader
  85055. * @param value Define the value to give to the uniform
  85056. * @return the texture itself allowing "fluent" like uniform updates
  85057. */
  85058. setColor3(name: string, value: Color3): ProceduralTexture;
  85059. /**
  85060. * Set a vec4 in the shader from a Color4.
  85061. * @param name Define the name of the uniform as defined in the shader
  85062. * @param value Define the value to give to the uniform
  85063. * @return the texture itself allowing "fluent" like uniform updates
  85064. */
  85065. setColor4(name: string, value: Color4): ProceduralTexture;
  85066. /**
  85067. * Set a vec2 in the shader from a Vector2.
  85068. * @param name Define the name of the uniform as defined in the shader
  85069. * @param value Define the value to give to the uniform
  85070. * @return the texture itself allowing "fluent" like uniform updates
  85071. */
  85072. setVector2(name: string, value: Vector2): ProceduralTexture;
  85073. /**
  85074. * Set a vec3 in the shader from a Vector3.
  85075. * @param name Define the name of the uniform as defined in the shader
  85076. * @param value Define the value to give to the uniform
  85077. * @return the texture itself allowing "fluent" like uniform updates
  85078. */
  85079. setVector3(name: string, value: Vector3): ProceduralTexture;
  85080. /**
  85081. * Set a mat4 in the shader from a MAtrix.
  85082. * @param name Define the name of the uniform as defined in the shader
  85083. * @param value Define the value to give to the uniform
  85084. * @return the texture itself allowing "fluent" like uniform updates
  85085. */
  85086. setMatrix(name: string, value: Matrix): ProceduralTexture;
  85087. /**
  85088. * Render the texture to its associated render target.
  85089. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  85090. */
  85091. render(useCameraPostProcess?: boolean): void;
  85092. /**
  85093. * Clone the texture.
  85094. * @returns the cloned texture
  85095. */
  85096. clone(): ProceduralTexture;
  85097. /**
  85098. * Dispose the texture and release its asoociated resources.
  85099. */
  85100. dispose(): void;
  85101. }
  85102. }
  85103. declare module BABYLON {
  85104. /**
  85105. * This represents the base class for particle system in Babylon.
  85106. * 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.
  85107. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  85108. * @example https://doc.babylonjs.com/babylon101/particles
  85109. */
  85110. export class BaseParticleSystem {
  85111. /**
  85112. * Source color is added to the destination color without alpha affecting the result
  85113. */
  85114. static BLENDMODE_ONEONE: number;
  85115. /**
  85116. * Blend current color and particle color using particle’s alpha
  85117. */
  85118. static BLENDMODE_STANDARD: number;
  85119. /**
  85120. * Add current color and particle color multiplied by particle’s alpha
  85121. */
  85122. static BLENDMODE_ADD: number;
  85123. /**
  85124. * Multiply current color with particle color
  85125. */
  85126. static BLENDMODE_MULTIPLY: number;
  85127. /**
  85128. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  85129. */
  85130. static BLENDMODE_MULTIPLYADD: number;
  85131. /**
  85132. * List of animations used by the particle system.
  85133. */
  85134. animations: Animation[];
  85135. /**
  85136. * The id of the Particle system.
  85137. */
  85138. id: string;
  85139. /**
  85140. * The friendly name of the Particle system.
  85141. */
  85142. name: string;
  85143. /**
  85144. * The rendering group used by the Particle system to chose when to render.
  85145. */
  85146. renderingGroupId: number;
  85147. /**
  85148. * The emitter represents the Mesh or position we are attaching the particle system to.
  85149. */
  85150. emitter: Nullable<AbstractMesh | Vector3>;
  85151. /**
  85152. * The maximum number of particles to emit per frame
  85153. */
  85154. emitRate: number;
  85155. /**
  85156. * If you want to launch only a few particles at once, that can be done, as well.
  85157. */
  85158. manualEmitCount: number;
  85159. /**
  85160. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  85161. */
  85162. updateSpeed: number;
  85163. /**
  85164. * The amount of time the particle system is running (depends of the overall update speed).
  85165. */
  85166. targetStopDuration: number;
  85167. /**
  85168. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  85169. */
  85170. disposeOnStop: boolean;
  85171. /**
  85172. * Minimum power of emitting particles.
  85173. */
  85174. minEmitPower: number;
  85175. /**
  85176. * Maximum power of emitting particles.
  85177. */
  85178. maxEmitPower: number;
  85179. /**
  85180. * Minimum life time of emitting particles.
  85181. */
  85182. minLifeTime: number;
  85183. /**
  85184. * Maximum life time of emitting particles.
  85185. */
  85186. maxLifeTime: number;
  85187. /**
  85188. * Minimum Size of emitting particles.
  85189. */
  85190. minSize: number;
  85191. /**
  85192. * Maximum Size of emitting particles.
  85193. */
  85194. maxSize: number;
  85195. /**
  85196. * Minimum scale of emitting particles on X axis.
  85197. */
  85198. minScaleX: number;
  85199. /**
  85200. * Maximum scale of emitting particles on X axis.
  85201. */
  85202. maxScaleX: number;
  85203. /**
  85204. * Minimum scale of emitting particles on Y axis.
  85205. */
  85206. minScaleY: number;
  85207. /**
  85208. * Maximum scale of emitting particles on Y axis.
  85209. */
  85210. maxScaleY: number;
  85211. /**
  85212. * Gets or sets the minimal initial rotation in radians.
  85213. */
  85214. minInitialRotation: number;
  85215. /**
  85216. * Gets or sets the maximal initial rotation in radians.
  85217. */
  85218. maxInitialRotation: number;
  85219. /**
  85220. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  85221. */
  85222. minAngularSpeed: number;
  85223. /**
  85224. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  85225. */
  85226. maxAngularSpeed: number;
  85227. /**
  85228. * The texture used to render each particle. (this can be a spritesheet)
  85229. */
  85230. particleTexture: Nullable<Texture>;
  85231. /**
  85232. * The layer mask we are rendering the particles through.
  85233. */
  85234. layerMask: number;
  85235. /**
  85236. * This can help using your own shader to render the particle system.
  85237. * The according effect will be created
  85238. */
  85239. customShader: any;
  85240. /**
  85241. * By default particle system starts as soon as they are created. This prevents the
  85242. * automatic start to happen and let you decide when to start emitting particles.
  85243. */
  85244. preventAutoStart: boolean;
  85245. private _noiseTexture;
  85246. /**
  85247. * Gets or sets a texture used to add random noise to particle positions
  85248. */
  85249. noiseTexture: Nullable<ProceduralTexture>;
  85250. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  85251. noiseStrength: Vector3;
  85252. /**
  85253. * Callback triggered when the particle animation is ending.
  85254. */
  85255. onAnimationEnd: Nullable<() => void>;
  85256. /**
  85257. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  85258. */
  85259. blendMode: number;
  85260. /**
  85261. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  85262. * to override the particles.
  85263. */
  85264. forceDepthWrite: boolean;
  85265. /** 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 */
  85266. preWarmCycles: number;
  85267. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  85268. preWarmStepOffset: number;
  85269. /**
  85270. * 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)
  85271. */
  85272. spriteCellChangeSpeed: number;
  85273. /**
  85274. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  85275. */
  85276. startSpriteCellID: number;
  85277. /**
  85278. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  85279. */
  85280. endSpriteCellID: number;
  85281. /**
  85282. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  85283. */
  85284. spriteCellWidth: number;
  85285. /**
  85286. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  85287. */
  85288. spriteCellHeight: number;
  85289. /**
  85290. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  85291. */
  85292. spriteRandomStartCell: boolean;
  85293. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  85294. translationPivot: Vector2;
  85295. /** @hidden */
  85296. protected _isAnimationSheetEnabled: boolean;
  85297. /**
  85298. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  85299. */
  85300. beginAnimationOnStart: boolean;
  85301. /**
  85302. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  85303. */
  85304. beginAnimationFrom: number;
  85305. /**
  85306. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  85307. */
  85308. beginAnimationTo: number;
  85309. /**
  85310. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  85311. */
  85312. beginAnimationLoop: boolean;
  85313. /**
  85314. * Gets or sets a world offset applied to all particles
  85315. */
  85316. worldOffset: Vector3;
  85317. /**
  85318. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  85319. */
  85320. isAnimationSheetEnabled: boolean;
  85321. /**
  85322. * Get hosting scene
  85323. * @returns the scene
  85324. */
  85325. getScene(): Scene;
  85326. /**
  85327. * You can use gravity if you want to give an orientation to your particles.
  85328. */
  85329. gravity: Vector3;
  85330. protected _colorGradients: Nullable<Array<ColorGradient>>;
  85331. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  85332. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  85333. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  85334. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  85335. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  85336. protected _dragGradients: Nullable<Array<FactorGradient>>;
  85337. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  85338. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  85339. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  85340. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  85341. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  85342. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  85343. /**
  85344. * Defines the delay in milliseconds before starting the system (0 by default)
  85345. */
  85346. startDelay: number;
  85347. /**
  85348. * Gets the current list of drag gradients.
  85349. * You must use addDragGradient and removeDragGradient to udpate this list
  85350. * @returns the list of drag gradients
  85351. */
  85352. getDragGradients(): Nullable<Array<FactorGradient>>;
  85353. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  85354. limitVelocityDamping: number;
  85355. /**
  85356. * Gets the current list of limit velocity gradients.
  85357. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  85358. * @returns the list of limit velocity gradients
  85359. */
  85360. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  85361. /**
  85362. * Gets the current list of color gradients.
  85363. * You must use addColorGradient and removeColorGradient to udpate this list
  85364. * @returns the list of color gradients
  85365. */
  85366. getColorGradients(): Nullable<Array<ColorGradient>>;
  85367. /**
  85368. * Gets the current list of size gradients.
  85369. * You must use addSizeGradient and removeSizeGradient to udpate this list
  85370. * @returns the list of size gradients
  85371. */
  85372. getSizeGradients(): Nullable<Array<FactorGradient>>;
  85373. /**
  85374. * Gets the current list of color remap gradients.
  85375. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  85376. * @returns the list of color remap gradients
  85377. */
  85378. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  85379. /**
  85380. * Gets the current list of alpha remap gradients.
  85381. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  85382. * @returns the list of alpha remap gradients
  85383. */
  85384. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  85385. /**
  85386. * Gets the current list of life time gradients.
  85387. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  85388. * @returns the list of life time gradients
  85389. */
  85390. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  85391. /**
  85392. * Gets the current list of angular speed gradients.
  85393. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  85394. * @returns the list of angular speed gradients
  85395. */
  85396. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  85397. /**
  85398. * Gets the current list of velocity gradients.
  85399. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  85400. * @returns the list of velocity gradients
  85401. */
  85402. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  85403. /**
  85404. * Gets the current list of start size gradients.
  85405. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  85406. * @returns the list of start size gradients
  85407. */
  85408. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  85409. /**
  85410. * Gets the current list of emit rate gradients.
  85411. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  85412. * @returns the list of emit rate gradients
  85413. */
  85414. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  85415. /**
  85416. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  85417. * This only works when particleEmitterTyps is a BoxParticleEmitter
  85418. */
  85419. direction1: Vector3;
  85420. /**
  85421. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  85422. * This only works when particleEmitterTyps is a BoxParticleEmitter
  85423. */
  85424. direction2: Vector3;
  85425. /**
  85426. * 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.
  85427. * This only works when particleEmitterTyps is a BoxParticleEmitter
  85428. */
  85429. minEmitBox: Vector3;
  85430. /**
  85431. * 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.
  85432. * This only works when particleEmitterTyps is a BoxParticleEmitter
  85433. */
  85434. maxEmitBox: Vector3;
  85435. /**
  85436. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  85437. */
  85438. color1: Color4;
  85439. /**
  85440. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  85441. */
  85442. color2: Color4;
  85443. /**
  85444. * Color the particle will have at the end of its lifetime
  85445. */
  85446. colorDead: Color4;
  85447. /**
  85448. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  85449. */
  85450. textureMask: Color4;
  85451. /**
  85452. * The particle emitter type defines the emitter used by the particle system.
  85453. * It can be for example box, sphere, or cone...
  85454. */
  85455. particleEmitterType: IParticleEmitterType;
  85456. /** @hidden */
  85457. _isSubEmitter: boolean;
  85458. /**
  85459. * Gets or sets the billboard mode to use when isBillboardBased = true.
  85460. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  85461. */
  85462. billboardMode: number;
  85463. protected _isBillboardBased: boolean;
  85464. /**
  85465. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  85466. */
  85467. isBillboardBased: boolean;
  85468. /**
  85469. * The scene the particle system belongs to.
  85470. */
  85471. protected _scene: Scene;
  85472. /**
  85473. * Local cache of defines for image processing.
  85474. */
  85475. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  85476. /**
  85477. * Default configuration related to image processing available in the standard Material.
  85478. */
  85479. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  85480. /**
  85481. * Gets the image processing configuration used either in this material.
  85482. */
  85483. /**
  85484. * Sets the Default image processing configuration used either in the this material.
  85485. *
  85486. * If sets to null, the scene one is in use.
  85487. */
  85488. imageProcessingConfiguration: ImageProcessingConfiguration;
  85489. /**
  85490. * Attaches a new image processing configuration to the Standard Material.
  85491. * @param configuration
  85492. */
  85493. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  85494. /** @hidden */
  85495. protected _reset(): void;
  85496. /** @hidden */
  85497. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  85498. /**
  85499. * Instantiates a particle system.
  85500. * 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.
  85501. * @param name The name of the particle system
  85502. */
  85503. constructor(name: string);
  85504. /**
  85505. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  85506. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  85507. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  85508. * @returns the emitter
  85509. */
  85510. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  85511. /**
  85512. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  85513. * @param radius The radius of the hemisphere to emit from
  85514. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  85515. * @returns the emitter
  85516. */
  85517. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  85518. /**
  85519. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  85520. * @param radius The radius of the sphere to emit from
  85521. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  85522. * @returns the emitter
  85523. */
  85524. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  85525. /**
  85526. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  85527. * @param radius The radius of the sphere to emit from
  85528. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  85529. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  85530. * @returns the emitter
  85531. */
  85532. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  85533. /**
  85534. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  85535. * @param radius The radius of the emission cylinder
  85536. * @param height The height of the emission cylinder
  85537. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  85538. * @param directionRandomizer How much to randomize the particle direction [0-1]
  85539. * @returns the emitter
  85540. */
  85541. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  85542. /**
  85543. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  85544. * @param radius The radius of the cylinder to emit from
  85545. * @param height The height of the emission cylinder
  85546. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  85547. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  85548. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  85549. * @returns the emitter
  85550. */
  85551. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  85552. /**
  85553. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  85554. * @param radius The radius of the cone to emit from
  85555. * @param angle The base angle of the cone
  85556. * @returns the emitter
  85557. */
  85558. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  85559. /**
  85560. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  85561. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  85562. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  85563. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  85564. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  85565. * @returns the emitter
  85566. */
  85567. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  85568. }
  85569. }
  85570. declare module BABYLON {
  85571. /**
  85572. * Type of sub emitter
  85573. */
  85574. export enum SubEmitterType {
  85575. /**
  85576. * Attached to the particle over it's lifetime
  85577. */
  85578. ATTACHED = 0,
  85579. /**
  85580. * Created when the particle dies
  85581. */
  85582. END = 1
  85583. }
  85584. /**
  85585. * Sub emitter class used to emit particles from an existing particle
  85586. */
  85587. export class SubEmitter {
  85588. /**
  85589. * the particle system to be used by the sub emitter
  85590. */
  85591. particleSystem: ParticleSystem;
  85592. /**
  85593. * Type of the submitter (Default: END)
  85594. */
  85595. type: SubEmitterType;
  85596. /**
  85597. * 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)
  85598. * Note: This only is supported when using an emitter of type Mesh
  85599. */
  85600. inheritDirection: boolean;
  85601. /**
  85602. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  85603. */
  85604. inheritedVelocityAmount: number;
  85605. /**
  85606. * Creates a sub emitter
  85607. * @param particleSystem the particle system to be used by the sub emitter
  85608. */
  85609. constructor(
  85610. /**
  85611. * the particle system to be used by the sub emitter
  85612. */
  85613. particleSystem: ParticleSystem);
  85614. /**
  85615. * Clones the sub emitter
  85616. * @returns the cloned sub emitter
  85617. */
  85618. clone(): SubEmitter;
  85619. /**
  85620. * Serialize current object to a JSON object
  85621. * @returns the serialized object
  85622. */
  85623. serialize(): any;
  85624. /** @hidden */
  85625. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  85626. /**
  85627. * Creates a new SubEmitter from a serialized JSON version
  85628. * @param serializationObject defines the JSON object to read from
  85629. * @param scene defines the hosting scene
  85630. * @param rootUrl defines the rootUrl for data loading
  85631. * @returns a new SubEmitter
  85632. */
  85633. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  85634. /** Release associated resources */
  85635. dispose(): void;
  85636. }
  85637. }
  85638. declare module BABYLON {
  85639. /** @hidden */
  85640. export var clipPlaneFragmentDeclaration: {
  85641. name: string;
  85642. shader: string;
  85643. };
  85644. }
  85645. declare module BABYLON {
  85646. /** @hidden */
  85647. export var imageProcessingDeclaration: {
  85648. name: string;
  85649. shader: string;
  85650. };
  85651. }
  85652. declare module BABYLON {
  85653. /** @hidden */
  85654. export var imageProcessingFunctions: {
  85655. name: string;
  85656. shader: string;
  85657. };
  85658. }
  85659. declare module BABYLON {
  85660. /** @hidden */
  85661. export var clipPlaneFragment: {
  85662. name: string;
  85663. shader: string;
  85664. };
  85665. }
  85666. declare module BABYLON {
  85667. /** @hidden */
  85668. export var particlesPixelShader: {
  85669. name: string;
  85670. shader: string;
  85671. };
  85672. }
  85673. declare module BABYLON {
  85674. /** @hidden */
  85675. export var clipPlaneVertexDeclaration: {
  85676. name: string;
  85677. shader: string;
  85678. };
  85679. }
  85680. declare module BABYLON {
  85681. /** @hidden */
  85682. export var clipPlaneVertex: {
  85683. name: string;
  85684. shader: string;
  85685. };
  85686. }
  85687. declare module BABYLON {
  85688. /** @hidden */
  85689. export var particlesVertexShader: {
  85690. name: string;
  85691. shader: string;
  85692. };
  85693. }
  85694. declare module BABYLON {
  85695. /**
  85696. * This represents a particle system in Babylon.
  85697. * 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.
  85698. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  85699. * @example https://doc.babylonjs.com/babylon101/particles
  85700. */
  85701. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  85702. /**
  85703. * Billboard mode will only apply to Y axis
  85704. */
  85705. static readonly BILLBOARDMODE_Y: number;
  85706. /**
  85707. * Billboard mode will apply to all axes
  85708. */
  85709. static readonly BILLBOARDMODE_ALL: number;
  85710. /**
  85711. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  85712. */
  85713. static readonly BILLBOARDMODE_STRETCHED: number;
  85714. /**
  85715. * This function can be defined to provide custom update for active particles.
  85716. * This function will be called instead of regular update (age, position, color, etc.).
  85717. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  85718. */
  85719. updateFunction: (particles: Particle[]) => void;
  85720. private _emitterWorldMatrix;
  85721. /**
  85722. * This function can be defined to specify initial direction for every new particle.
  85723. * It by default use the emitterType defined function
  85724. */
  85725. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  85726. /**
  85727. * This function can be defined to specify initial position for every new particle.
  85728. * It by default use the emitterType defined function
  85729. */
  85730. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  85731. /**
  85732. * @hidden
  85733. */
  85734. _inheritedVelocityOffset: Vector3;
  85735. /**
  85736. * An event triggered when the system is disposed
  85737. */
  85738. onDisposeObservable: Observable<ParticleSystem>;
  85739. private _onDisposeObserver;
  85740. /**
  85741. * Sets a callback that will be triggered when the system is disposed
  85742. */
  85743. onDispose: () => void;
  85744. private _particles;
  85745. private _epsilon;
  85746. private _capacity;
  85747. private _stockParticles;
  85748. private _newPartsExcess;
  85749. private _vertexData;
  85750. private _vertexBuffer;
  85751. private _vertexBuffers;
  85752. private _spriteBuffer;
  85753. private _indexBuffer;
  85754. private _effect;
  85755. private _customEffect;
  85756. private _cachedDefines;
  85757. private _scaledColorStep;
  85758. private _colorDiff;
  85759. private _scaledDirection;
  85760. private _scaledGravity;
  85761. private _currentRenderId;
  85762. private _alive;
  85763. private _useInstancing;
  85764. private _started;
  85765. private _stopped;
  85766. private _actualFrame;
  85767. private _scaledUpdateSpeed;
  85768. private _vertexBufferSize;
  85769. /** @hidden */
  85770. _currentEmitRateGradient: Nullable<FactorGradient>;
  85771. /** @hidden */
  85772. _currentEmitRate1: number;
  85773. /** @hidden */
  85774. _currentEmitRate2: number;
  85775. /** @hidden */
  85776. _currentStartSizeGradient: Nullable<FactorGradient>;
  85777. /** @hidden */
  85778. _currentStartSize1: number;
  85779. /** @hidden */
  85780. _currentStartSize2: number;
  85781. private readonly _rawTextureWidth;
  85782. private _rampGradientsTexture;
  85783. private _useRampGradients;
  85784. /** Gets or sets a boolean indicating that ramp gradients must be used
  85785. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  85786. */
  85787. useRampGradients: boolean;
  85788. /**
  85789. * 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.
  85790. * 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: [])
  85791. */
  85792. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  85793. private _subEmitters;
  85794. /**
  85795. * @hidden
  85796. * If the particle systems emitter should be disposed when the particle system is disposed
  85797. */
  85798. _disposeEmitterOnDispose: boolean;
  85799. /**
  85800. * The current active Sub-systems, this property is used by the root particle system only.
  85801. */
  85802. activeSubSystems: Array<ParticleSystem>;
  85803. private _rootParticleSystem;
  85804. /**
  85805. * Gets the current list of active particles
  85806. */
  85807. readonly particles: Particle[];
  85808. /**
  85809. * Returns the string "ParticleSystem"
  85810. * @returns a string containing the class name
  85811. */
  85812. getClassName(): string;
  85813. /**
  85814. * Instantiates a particle system.
  85815. * 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.
  85816. * @param name The name of the particle system
  85817. * @param capacity The max number of particles alive at the same time
  85818. * @param scene The scene the particle system belongs to
  85819. * @param customEffect a custom effect used to change the way particles are rendered by default
  85820. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  85821. * @param epsilon Offset used to render the particles
  85822. */
  85823. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  85824. private _addFactorGradient;
  85825. private _removeFactorGradient;
  85826. /**
  85827. * Adds a new life time gradient
  85828. * @param gradient defines the gradient to use (between 0 and 1)
  85829. * @param factor defines the life time factor to affect to the specified gradient
  85830. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85831. * @returns the current particle system
  85832. */
  85833. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85834. /**
  85835. * Remove a specific life time gradient
  85836. * @param gradient defines the gradient to remove
  85837. * @returns the current particle system
  85838. */
  85839. removeLifeTimeGradient(gradient: number): IParticleSystem;
  85840. /**
  85841. * Adds a new size gradient
  85842. * @param gradient defines the gradient to use (between 0 and 1)
  85843. * @param factor defines the size factor to affect to the specified gradient
  85844. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85845. * @returns the current particle system
  85846. */
  85847. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85848. /**
  85849. * Remove a specific size gradient
  85850. * @param gradient defines the gradient to remove
  85851. * @returns the current particle system
  85852. */
  85853. removeSizeGradient(gradient: number): IParticleSystem;
  85854. /**
  85855. * Adds a new color remap gradient
  85856. * @param gradient defines the gradient to use (between 0 and 1)
  85857. * @param min defines the color remap minimal range
  85858. * @param max defines the color remap maximal range
  85859. * @returns the current particle system
  85860. */
  85861. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  85862. /**
  85863. * Remove a specific color remap gradient
  85864. * @param gradient defines the gradient to remove
  85865. * @returns the current particle system
  85866. */
  85867. removeColorRemapGradient(gradient: number): IParticleSystem;
  85868. /**
  85869. * Adds a new alpha remap gradient
  85870. * @param gradient defines the gradient to use (between 0 and 1)
  85871. * @param min defines the alpha remap minimal range
  85872. * @param max defines the alpha remap maximal range
  85873. * @returns the current particle system
  85874. */
  85875. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  85876. /**
  85877. * Remove a specific alpha remap gradient
  85878. * @param gradient defines the gradient to remove
  85879. * @returns the current particle system
  85880. */
  85881. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  85882. /**
  85883. * Adds a new angular speed gradient
  85884. * @param gradient defines the gradient to use (between 0 and 1)
  85885. * @param factor defines the angular speed to affect to the specified gradient
  85886. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85887. * @returns the current particle system
  85888. */
  85889. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85890. /**
  85891. * Remove a specific angular speed gradient
  85892. * @param gradient defines the gradient to remove
  85893. * @returns the current particle system
  85894. */
  85895. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  85896. /**
  85897. * Adds a new velocity gradient
  85898. * @param gradient defines the gradient to use (between 0 and 1)
  85899. * @param factor defines the velocity to affect to the specified gradient
  85900. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85901. * @returns the current particle system
  85902. */
  85903. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85904. /**
  85905. * Remove a specific velocity gradient
  85906. * @param gradient defines the gradient to remove
  85907. * @returns the current particle system
  85908. */
  85909. removeVelocityGradient(gradient: number): IParticleSystem;
  85910. /**
  85911. * Adds a new limit velocity gradient
  85912. * @param gradient defines the gradient to use (between 0 and 1)
  85913. * @param factor defines the limit velocity value to affect to the specified gradient
  85914. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85915. * @returns the current particle system
  85916. */
  85917. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85918. /**
  85919. * Remove a specific limit velocity gradient
  85920. * @param gradient defines the gradient to remove
  85921. * @returns the current particle system
  85922. */
  85923. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  85924. /**
  85925. * Adds a new drag gradient
  85926. * @param gradient defines the gradient to use (between 0 and 1)
  85927. * @param factor defines the drag value to affect to the specified gradient
  85928. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85929. * @returns the current particle system
  85930. */
  85931. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85932. /**
  85933. * Remove a specific drag gradient
  85934. * @param gradient defines the gradient to remove
  85935. * @returns the current particle system
  85936. */
  85937. removeDragGradient(gradient: number): IParticleSystem;
  85938. /**
  85939. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  85940. * @param gradient defines the gradient to use (between 0 and 1)
  85941. * @param factor defines the emit rate value to affect to the specified gradient
  85942. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85943. * @returns the current particle system
  85944. */
  85945. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85946. /**
  85947. * Remove a specific emit rate gradient
  85948. * @param gradient defines the gradient to remove
  85949. * @returns the current particle system
  85950. */
  85951. removeEmitRateGradient(gradient: number): IParticleSystem;
  85952. /**
  85953. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  85954. * @param gradient defines the gradient to use (between 0 and 1)
  85955. * @param factor defines the start size value to affect to the specified gradient
  85956. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85957. * @returns the current particle system
  85958. */
  85959. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85960. /**
  85961. * Remove a specific start size gradient
  85962. * @param gradient defines the gradient to remove
  85963. * @returns the current particle system
  85964. */
  85965. removeStartSizeGradient(gradient: number): IParticleSystem;
  85966. private _createRampGradientTexture;
  85967. /**
  85968. * Gets the current list of ramp gradients.
  85969. * You must use addRampGradient and removeRampGradient to udpate this list
  85970. * @returns the list of ramp gradients
  85971. */
  85972. getRampGradients(): Nullable<Array<Color3Gradient>>;
  85973. /**
  85974. * Adds a new ramp gradient used to remap particle colors
  85975. * @param gradient defines the gradient to use (between 0 and 1)
  85976. * @param color defines the color to affect to the specified gradient
  85977. * @returns the current particle system
  85978. */
  85979. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  85980. /**
  85981. * Remove a specific ramp gradient
  85982. * @param gradient defines the gradient to remove
  85983. * @returns the current particle system
  85984. */
  85985. removeRampGradient(gradient: number): ParticleSystem;
  85986. /**
  85987. * Adds a new color gradient
  85988. * @param gradient defines the gradient to use (between 0 and 1)
  85989. * @param color1 defines the color to affect to the specified gradient
  85990. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  85991. * @returns this particle system
  85992. */
  85993. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  85994. /**
  85995. * Remove a specific color gradient
  85996. * @param gradient defines the gradient to remove
  85997. * @returns this particle system
  85998. */
  85999. removeColorGradient(gradient: number): IParticleSystem;
  86000. private _fetchR;
  86001. protected _reset(): void;
  86002. private _resetEffect;
  86003. private _createVertexBuffers;
  86004. private _createIndexBuffer;
  86005. /**
  86006. * Gets the maximum number of particles active at the same time.
  86007. * @returns The max number of active particles.
  86008. */
  86009. getCapacity(): number;
  86010. /**
  86011. * Gets whether there are still active particles in the system.
  86012. * @returns True if it is alive, otherwise false.
  86013. */
  86014. isAlive(): boolean;
  86015. /**
  86016. * Gets if the system has been started. (Note: this will still be true after stop is called)
  86017. * @returns True if it has been started, otherwise false.
  86018. */
  86019. isStarted(): boolean;
  86020. private _prepareSubEmitterInternalArray;
  86021. /**
  86022. * Starts the particle system and begins to emit
  86023. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  86024. */
  86025. start(delay?: number): void;
  86026. /**
  86027. * Stops the particle system.
  86028. * @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.
  86029. */
  86030. stop(stopSubEmitters?: boolean): void;
  86031. /**
  86032. * Remove all active particles
  86033. */
  86034. reset(): void;
  86035. /**
  86036. * @hidden (for internal use only)
  86037. */
  86038. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  86039. /**
  86040. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  86041. * Its lifetime will start back at 0.
  86042. */
  86043. recycleParticle: (particle: Particle) => void;
  86044. private _stopSubEmitters;
  86045. private _createParticle;
  86046. private _removeFromRoot;
  86047. private _emitFromParticle;
  86048. private _update;
  86049. /** @hidden */
  86050. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  86051. /** @hidden */
  86052. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  86053. /** @hidden */
  86054. private _getEffect;
  86055. /**
  86056. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  86057. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  86058. */
  86059. animate(preWarmOnly?: boolean): void;
  86060. private _appendParticleVertices;
  86061. /**
  86062. * Rebuilds the particle system.
  86063. */
  86064. rebuild(): void;
  86065. /**
  86066. * Is this system ready to be used/rendered
  86067. * @return true if the system is ready
  86068. */
  86069. isReady(): boolean;
  86070. private _render;
  86071. /**
  86072. * Renders the particle system in its current state.
  86073. * @returns the current number of particles
  86074. */
  86075. render(): number;
  86076. /**
  86077. * Disposes the particle system and free the associated resources
  86078. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  86079. */
  86080. dispose(disposeTexture?: boolean): void;
  86081. /**
  86082. * Clones the particle system.
  86083. * @param name The name of the cloned object
  86084. * @param newEmitter The new emitter to use
  86085. * @returns the cloned particle system
  86086. */
  86087. clone(name: string, newEmitter: any): ParticleSystem;
  86088. /**
  86089. * Serializes the particle system to a JSON object.
  86090. * @returns the JSON object
  86091. */
  86092. serialize(): any;
  86093. /** @hidden */
  86094. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  86095. /** @hidden */
  86096. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  86097. /**
  86098. * Parses a JSON object to create a particle system.
  86099. * @param parsedParticleSystem The JSON object to parse
  86100. * @param scene The scene to create the particle system in
  86101. * @param rootUrl The root url to use to load external dependencies like texture
  86102. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  86103. * @returns the Parsed particle system
  86104. */
  86105. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  86106. }
  86107. }
  86108. declare module BABYLON {
  86109. /**
  86110. * A particle represents one of the element emitted by a particle system.
  86111. * This is mainly define by its coordinates, direction, velocity and age.
  86112. */
  86113. export class Particle {
  86114. /**
  86115. * The particle system the particle belongs to.
  86116. */
  86117. particleSystem: ParticleSystem;
  86118. private static _Count;
  86119. /**
  86120. * Unique ID of the particle
  86121. */
  86122. id: number;
  86123. /**
  86124. * The world position of the particle in the scene.
  86125. */
  86126. position: Vector3;
  86127. /**
  86128. * The world direction of the particle in the scene.
  86129. */
  86130. direction: Vector3;
  86131. /**
  86132. * The color of the particle.
  86133. */
  86134. color: Color4;
  86135. /**
  86136. * The color change of the particle per step.
  86137. */
  86138. colorStep: Color4;
  86139. /**
  86140. * Defines how long will the life of the particle be.
  86141. */
  86142. lifeTime: number;
  86143. /**
  86144. * The current age of the particle.
  86145. */
  86146. age: number;
  86147. /**
  86148. * The current size of the particle.
  86149. */
  86150. size: number;
  86151. /**
  86152. * The current scale of the particle.
  86153. */
  86154. scale: Vector2;
  86155. /**
  86156. * The current angle of the particle.
  86157. */
  86158. angle: number;
  86159. /**
  86160. * Defines how fast is the angle changing.
  86161. */
  86162. angularSpeed: number;
  86163. /**
  86164. * Defines the cell index used by the particle to be rendered from a sprite.
  86165. */
  86166. cellIndex: number;
  86167. /**
  86168. * The information required to support color remapping
  86169. */
  86170. remapData: Vector4;
  86171. /** @hidden */
  86172. _randomCellOffset?: number;
  86173. /** @hidden */
  86174. _initialDirection: Nullable<Vector3>;
  86175. /** @hidden */
  86176. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  86177. /** @hidden */
  86178. _initialStartSpriteCellID: number;
  86179. /** @hidden */
  86180. _initialEndSpriteCellID: number;
  86181. /** @hidden */
  86182. _currentColorGradient: Nullable<ColorGradient>;
  86183. /** @hidden */
  86184. _currentColor1: Color4;
  86185. /** @hidden */
  86186. _currentColor2: Color4;
  86187. /** @hidden */
  86188. _currentSizeGradient: Nullable<FactorGradient>;
  86189. /** @hidden */
  86190. _currentSize1: number;
  86191. /** @hidden */
  86192. _currentSize2: number;
  86193. /** @hidden */
  86194. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  86195. /** @hidden */
  86196. _currentAngularSpeed1: number;
  86197. /** @hidden */
  86198. _currentAngularSpeed2: number;
  86199. /** @hidden */
  86200. _currentVelocityGradient: Nullable<FactorGradient>;
  86201. /** @hidden */
  86202. _currentVelocity1: number;
  86203. /** @hidden */
  86204. _currentVelocity2: number;
  86205. /** @hidden */
  86206. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  86207. /** @hidden */
  86208. _currentLimitVelocity1: number;
  86209. /** @hidden */
  86210. _currentLimitVelocity2: number;
  86211. /** @hidden */
  86212. _currentDragGradient: Nullable<FactorGradient>;
  86213. /** @hidden */
  86214. _currentDrag1: number;
  86215. /** @hidden */
  86216. _currentDrag2: number;
  86217. /** @hidden */
  86218. _randomNoiseCoordinates1: Vector3;
  86219. /** @hidden */
  86220. _randomNoiseCoordinates2: Vector3;
  86221. /**
  86222. * Creates a new instance Particle
  86223. * @param particleSystem the particle system the particle belongs to
  86224. */
  86225. constructor(
  86226. /**
  86227. * The particle system the particle belongs to.
  86228. */
  86229. particleSystem: ParticleSystem);
  86230. private updateCellInfoFromSystem;
  86231. /**
  86232. * Defines how the sprite cell index is updated for the particle
  86233. */
  86234. updateCellIndex(): void;
  86235. /** @hidden */
  86236. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  86237. /** @hidden */
  86238. _inheritParticleInfoToSubEmitters(): void;
  86239. /** @hidden */
  86240. _reset(): void;
  86241. /**
  86242. * Copy the properties of particle to another one.
  86243. * @param other the particle to copy the information to.
  86244. */
  86245. copyTo(other: Particle): void;
  86246. }
  86247. }
  86248. declare module BABYLON {
  86249. /**
  86250. * Particle emitter represents a volume emitting particles.
  86251. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  86252. */
  86253. export interface IParticleEmitterType {
  86254. /**
  86255. * Called by the particle System when the direction is computed for the created particle.
  86256. * @param worldMatrix is the world matrix of the particle system
  86257. * @param directionToUpdate is the direction vector to update with the result
  86258. * @param particle is the particle we are computed the direction for
  86259. */
  86260. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  86261. /**
  86262. * Called by the particle System when the position is computed for the created particle.
  86263. * @param worldMatrix is the world matrix of the particle system
  86264. * @param positionToUpdate is the position vector to update with the result
  86265. * @param particle is the particle we are computed the position for
  86266. */
  86267. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  86268. /**
  86269. * Clones the current emitter and returns a copy of it
  86270. * @returns the new emitter
  86271. */
  86272. clone(): IParticleEmitterType;
  86273. /**
  86274. * Called by the GPUParticleSystem to setup the update shader
  86275. * @param effect defines the update shader
  86276. */
  86277. applyToShader(effect: Effect): void;
  86278. /**
  86279. * Returns a string to use to update the GPU particles update shader
  86280. * @returns the effect defines string
  86281. */
  86282. getEffectDefines(): string;
  86283. /**
  86284. * Returns a string representing the class name
  86285. * @returns a string containing the class name
  86286. */
  86287. getClassName(): string;
  86288. /**
  86289. * Serializes the particle system to a JSON object.
  86290. * @returns the JSON object
  86291. */
  86292. serialize(): any;
  86293. /**
  86294. * Parse properties from a JSON object
  86295. * @param serializationObject defines the JSON object
  86296. */
  86297. parse(serializationObject: any): void;
  86298. }
  86299. }
  86300. declare module BABYLON {
  86301. /**
  86302. * Particle emitter emitting particles from the inside of a box.
  86303. * It emits the particles randomly between 2 given directions.
  86304. */
  86305. export class BoxParticleEmitter implements IParticleEmitterType {
  86306. /**
  86307. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  86308. */
  86309. direction1: Vector3;
  86310. /**
  86311. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  86312. */
  86313. direction2: Vector3;
  86314. /**
  86315. * 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.
  86316. */
  86317. minEmitBox: Vector3;
  86318. /**
  86319. * 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.
  86320. */
  86321. maxEmitBox: Vector3;
  86322. /**
  86323. * Creates a new instance BoxParticleEmitter
  86324. */
  86325. constructor();
  86326. /**
  86327. * Called by the particle System when the direction is computed for the created particle.
  86328. * @param worldMatrix is the world matrix of the particle system
  86329. * @param directionToUpdate is the direction vector to update with the result
  86330. * @param particle is the particle we are computed the direction for
  86331. */
  86332. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  86333. /**
  86334. * Called by the particle System when the position is computed for the created particle.
  86335. * @param worldMatrix is the world matrix of the particle system
  86336. * @param positionToUpdate is the position vector to update with the result
  86337. * @param particle is the particle we are computed the position for
  86338. */
  86339. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  86340. /**
  86341. * Clones the current emitter and returns a copy of it
  86342. * @returns the new emitter
  86343. */
  86344. clone(): BoxParticleEmitter;
  86345. /**
  86346. * Called by the GPUParticleSystem to setup the update shader
  86347. * @param effect defines the update shader
  86348. */
  86349. applyToShader(effect: Effect): void;
  86350. /**
  86351. * Returns a string to use to update the GPU particles update shader
  86352. * @returns a string containng the defines string
  86353. */
  86354. getEffectDefines(): string;
  86355. /**
  86356. * Returns the string "BoxParticleEmitter"
  86357. * @returns a string containing the class name
  86358. */
  86359. getClassName(): string;
  86360. /**
  86361. * Serializes the particle system to a JSON object.
  86362. * @returns the JSON object
  86363. */
  86364. serialize(): any;
  86365. /**
  86366. * Parse properties from a JSON object
  86367. * @param serializationObject defines the JSON object
  86368. */
  86369. parse(serializationObject: any): void;
  86370. }
  86371. }
  86372. declare module BABYLON {
  86373. /**
  86374. * Particle emitter emitting particles from the inside of a cone.
  86375. * It emits the particles alongside the cone volume from the base to the particle.
  86376. * The emission direction might be randomized.
  86377. */
  86378. export class ConeParticleEmitter implements IParticleEmitterType {
  86379. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  86380. directionRandomizer: number;
  86381. private _radius;
  86382. private _angle;
  86383. private _height;
  86384. /**
  86385. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  86386. */
  86387. radiusRange: number;
  86388. /**
  86389. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  86390. */
  86391. heightRange: number;
  86392. /**
  86393. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  86394. */
  86395. emitFromSpawnPointOnly: boolean;
  86396. /**
  86397. * Gets or sets the radius of the emission cone
  86398. */
  86399. radius: number;
  86400. /**
  86401. * Gets or sets the angle of the emission cone
  86402. */
  86403. angle: number;
  86404. private _buildHeight;
  86405. /**
  86406. * Creates a new instance ConeParticleEmitter
  86407. * @param radius the radius of the emission cone (1 by default)
  86408. * @param angle the cone base angle (PI by default)
  86409. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  86410. */
  86411. constructor(radius?: number, angle?: number,
  86412. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  86413. directionRandomizer?: number);
  86414. /**
  86415. * Called by the particle System when the direction is computed for the created particle.
  86416. * @param worldMatrix is the world matrix of the particle system
  86417. * @param directionToUpdate is the direction vector to update with the result
  86418. * @param particle is the particle we are computed the direction for
  86419. */
  86420. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  86421. /**
  86422. * Called by the particle System when the position is computed for the created particle.
  86423. * @param worldMatrix is the world matrix of the particle system
  86424. * @param positionToUpdate is the position vector to update with the result
  86425. * @param particle is the particle we are computed the position for
  86426. */
  86427. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  86428. /**
  86429. * Clones the current emitter and returns a copy of it
  86430. * @returns the new emitter
  86431. */
  86432. clone(): ConeParticleEmitter;
  86433. /**
  86434. * Called by the GPUParticleSystem to setup the update shader
  86435. * @param effect defines the update shader
  86436. */
  86437. applyToShader(effect: Effect): void;
  86438. /**
  86439. * Returns a string to use to update the GPU particles update shader
  86440. * @returns a string containng the defines string
  86441. */
  86442. getEffectDefines(): string;
  86443. /**
  86444. * Returns the string "ConeParticleEmitter"
  86445. * @returns a string containing the class name
  86446. */
  86447. getClassName(): string;
  86448. /**
  86449. * Serializes the particle system to a JSON object.
  86450. * @returns the JSON object
  86451. */
  86452. serialize(): any;
  86453. /**
  86454. * Parse properties from a JSON object
  86455. * @param serializationObject defines the JSON object
  86456. */
  86457. parse(serializationObject: any): void;
  86458. }
  86459. }
  86460. declare module BABYLON {
  86461. /**
  86462. * Particle emitter emitting particles from the inside of a cylinder.
  86463. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  86464. */
  86465. export class CylinderParticleEmitter implements IParticleEmitterType {
  86466. /**
  86467. * The radius of the emission cylinder.
  86468. */
  86469. radius: number;
  86470. /**
  86471. * The height of the emission cylinder.
  86472. */
  86473. height: number;
  86474. /**
  86475. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  86476. */
  86477. radiusRange: number;
  86478. /**
  86479. * How much to randomize the particle direction [0-1].
  86480. */
  86481. directionRandomizer: number;
  86482. /**
  86483. * Creates a new instance CylinderParticleEmitter
  86484. * @param radius the radius of the emission cylinder (1 by default)
  86485. * @param height the height of the emission cylinder (1 by default)
  86486. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  86487. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  86488. */
  86489. constructor(
  86490. /**
  86491. * The radius of the emission cylinder.
  86492. */
  86493. radius?: number,
  86494. /**
  86495. * The height of the emission cylinder.
  86496. */
  86497. height?: number,
  86498. /**
  86499. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  86500. */
  86501. radiusRange?: number,
  86502. /**
  86503. * How much to randomize the particle direction [0-1].
  86504. */
  86505. directionRandomizer?: number);
  86506. /**
  86507. * Called by the particle System when the direction is computed for the created particle.
  86508. * @param worldMatrix is the world matrix of the particle system
  86509. * @param directionToUpdate is the direction vector to update with the result
  86510. * @param particle is the particle we are computed the direction for
  86511. */
  86512. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  86513. /**
  86514. * Called by the particle System when the position is computed for the created particle.
  86515. * @param worldMatrix is the world matrix of the particle system
  86516. * @param positionToUpdate is the position vector to update with the result
  86517. * @param particle is the particle we are computed the position for
  86518. */
  86519. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  86520. /**
  86521. * Clones the current emitter and returns a copy of it
  86522. * @returns the new emitter
  86523. */
  86524. clone(): CylinderParticleEmitter;
  86525. /**
  86526. * Called by the GPUParticleSystem to setup the update shader
  86527. * @param effect defines the update shader
  86528. */
  86529. applyToShader(effect: Effect): void;
  86530. /**
  86531. * Returns a string to use to update the GPU particles update shader
  86532. * @returns a string containng the defines string
  86533. */
  86534. getEffectDefines(): string;
  86535. /**
  86536. * Returns the string "CylinderParticleEmitter"
  86537. * @returns a string containing the class name
  86538. */
  86539. getClassName(): string;
  86540. /**
  86541. * Serializes the particle system to a JSON object.
  86542. * @returns the JSON object
  86543. */
  86544. serialize(): any;
  86545. /**
  86546. * Parse properties from a JSON object
  86547. * @param serializationObject defines the JSON object
  86548. */
  86549. parse(serializationObject: any): void;
  86550. }
  86551. /**
  86552. * Particle emitter emitting particles from the inside of a cylinder.
  86553. * It emits the particles randomly between two vectors.
  86554. */
  86555. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  86556. /**
  86557. * The min limit of the emission direction.
  86558. */
  86559. direction1: Vector3;
  86560. /**
  86561. * The max limit of the emission direction.
  86562. */
  86563. direction2: Vector3;
  86564. /**
  86565. * Creates a new instance CylinderDirectedParticleEmitter
  86566. * @param radius the radius of the emission cylinder (1 by default)
  86567. * @param height the height of the emission cylinder (1 by default)
  86568. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  86569. * @param direction1 the min limit of the emission direction (up vector by default)
  86570. * @param direction2 the max limit of the emission direction (up vector by default)
  86571. */
  86572. constructor(radius?: number, height?: number, radiusRange?: number,
  86573. /**
  86574. * The min limit of the emission direction.
  86575. */
  86576. direction1?: Vector3,
  86577. /**
  86578. * The max limit of the emission direction.
  86579. */
  86580. direction2?: Vector3);
  86581. /**
  86582. * Called by the particle System when the direction is computed for the created particle.
  86583. * @param worldMatrix is the world matrix of the particle system
  86584. * @param directionToUpdate is the direction vector to update with the result
  86585. * @param particle is the particle we are computed the direction for
  86586. */
  86587. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  86588. /**
  86589. * Clones the current emitter and returns a copy of it
  86590. * @returns the new emitter
  86591. */
  86592. clone(): CylinderDirectedParticleEmitter;
  86593. /**
  86594. * Called by the GPUParticleSystem to setup the update shader
  86595. * @param effect defines the update shader
  86596. */
  86597. applyToShader(effect: Effect): void;
  86598. /**
  86599. * Returns a string to use to update the GPU particles update shader
  86600. * @returns a string containng the defines string
  86601. */
  86602. getEffectDefines(): string;
  86603. /**
  86604. * Returns the string "CylinderDirectedParticleEmitter"
  86605. * @returns a string containing the class name
  86606. */
  86607. getClassName(): string;
  86608. /**
  86609. * Serializes the particle system to a JSON object.
  86610. * @returns the JSON object
  86611. */
  86612. serialize(): any;
  86613. /**
  86614. * Parse properties from a JSON object
  86615. * @param serializationObject defines the JSON object
  86616. */
  86617. parse(serializationObject: any): void;
  86618. }
  86619. }
  86620. declare module BABYLON {
  86621. /**
  86622. * Particle emitter emitting particles from the inside of a hemisphere.
  86623. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  86624. */
  86625. export class HemisphericParticleEmitter implements IParticleEmitterType {
  86626. /**
  86627. * The radius of the emission hemisphere.
  86628. */
  86629. radius: number;
  86630. /**
  86631. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  86632. */
  86633. radiusRange: number;
  86634. /**
  86635. * How much to randomize the particle direction [0-1].
  86636. */
  86637. directionRandomizer: number;
  86638. /**
  86639. * Creates a new instance HemisphericParticleEmitter
  86640. * @param radius the radius of the emission hemisphere (1 by default)
  86641. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  86642. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  86643. */
  86644. constructor(
  86645. /**
  86646. * The radius of the emission hemisphere.
  86647. */
  86648. radius?: number,
  86649. /**
  86650. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  86651. */
  86652. radiusRange?: number,
  86653. /**
  86654. * How much to randomize the particle direction [0-1].
  86655. */
  86656. directionRandomizer?: number);
  86657. /**
  86658. * Called by the particle System when the direction is computed for the created particle.
  86659. * @param worldMatrix is the world matrix of the particle system
  86660. * @param directionToUpdate is the direction vector to update with the result
  86661. * @param particle is the particle we are computed the direction for
  86662. */
  86663. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  86664. /**
  86665. * Called by the particle System when the position is computed for the created particle.
  86666. * @param worldMatrix is the world matrix of the particle system
  86667. * @param positionToUpdate is the position vector to update with the result
  86668. * @param particle is the particle we are computed the position for
  86669. */
  86670. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  86671. /**
  86672. * Clones the current emitter and returns a copy of it
  86673. * @returns the new emitter
  86674. */
  86675. clone(): HemisphericParticleEmitter;
  86676. /**
  86677. * Called by the GPUParticleSystem to setup the update shader
  86678. * @param effect defines the update shader
  86679. */
  86680. applyToShader(effect: Effect): void;
  86681. /**
  86682. * Returns a string to use to update the GPU particles update shader
  86683. * @returns a string containng the defines string
  86684. */
  86685. getEffectDefines(): string;
  86686. /**
  86687. * Returns the string "HemisphericParticleEmitter"
  86688. * @returns a string containing the class name
  86689. */
  86690. getClassName(): string;
  86691. /**
  86692. * Serializes the particle system to a JSON object.
  86693. * @returns the JSON object
  86694. */
  86695. serialize(): any;
  86696. /**
  86697. * Parse properties from a JSON object
  86698. * @param serializationObject defines the JSON object
  86699. */
  86700. parse(serializationObject: any): void;
  86701. }
  86702. }
  86703. declare module BABYLON {
  86704. /**
  86705. * Particle emitter emitting particles from a point.
  86706. * It emits the particles randomly between 2 given directions.
  86707. */
  86708. export class PointParticleEmitter implements IParticleEmitterType {
  86709. /**
  86710. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  86711. */
  86712. direction1: Vector3;
  86713. /**
  86714. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  86715. */
  86716. direction2: Vector3;
  86717. /**
  86718. * Creates a new instance PointParticleEmitter
  86719. */
  86720. constructor();
  86721. /**
  86722. * Called by the particle System when the direction is computed for the created particle.
  86723. * @param worldMatrix is the world matrix of the particle system
  86724. * @param directionToUpdate is the direction vector to update with the result
  86725. * @param particle is the particle we are computed the direction for
  86726. */
  86727. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  86728. /**
  86729. * Called by the particle System when the position is computed for the created particle.
  86730. * @param worldMatrix is the world matrix of the particle system
  86731. * @param positionToUpdate is the position vector to update with the result
  86732. * @param particle is the particle we are computed the position for
  86733. */
  86734. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  86735. /**
  86736. * Clones the current emitter and returns a copy of it
  86737. * @returns the new emitter
  86738. */
  86739. clone(): PointParticleEmitter;
  86740. /**
  86741. * Called by the GPUParticleSystem to setup the update shader
  86742. * @param effect defines the update shader
  86743. */
  86744. applyToShader(effect: Effect): void;
  86745. /**
  86746. * Returns a string to use to update the GPU particles update shader
  86747. * @returns a string containng the defines string
  86748. */
  86749. getEffectDefines(): string;
  86750. /**
  86751. * Returns the string "PointParticleEmitter"
  86752. * @returns a string containing the class name
  86753. */
  86754. getClassName(): string;
  86755. /**
  86756. * Serializes the particle system to a JSON object.
  86757. * @returns the JSON object
  86758. */
  86759. serialize(): any;
  86760. /**
  86761. * Parse properties from a JSON object
  86762. * @param serializationObject defines the JSON object
  86763. */
  86764. parse(serializationObject: any): void;
  86765. }
  86766. }
  86767. declare module BABYLON {
  86768. /**
  86769. * Particle emitter emitting particles from the inside of a sphere.
  86770. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  86771. */
  86772. export class SphereParticleEmitter implements IParticleEmitterType {
  86773. /**
  86774. * The radius of the emission sphere.
  86775. */
  86776. radius: number;
  86777. /**
  86778. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  86779. */
  86780. radiusRange: number;
  86781. /**
  86782. * How much to randomize the particle direction [0-1].
  86783. */
  86784. directionRandomizer: number;
  86785. /**
  86786. * Creates a new instance SphereParticleEmitter
  86787. * @param radius the radius of the emission sphere (1 by default)
  86788. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  86789. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  86790. */
  86791. constructor(
  86792. /**
  86793. * The radius of the emission sphere.
  86794. */
  86795. radius?: number,
  86796. /**
  86797. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  86798. */
  86799. radiusRange?: number,
  86800. /**
  86801. * How much to randomize the particle direction [0-1].
  86802. */
  86803. directionRandomizer?: number);
  86804. /**
  86805. * Called by the particle System when the direction is computed for the created particle.
  86806. * @param worldMatrix is the world matrix of the particle system
  86807. * @param directionToUpdate is the direction vector to update with the result
  86808. * @param particle is the particle we are computed the direction for
  86809. */
  86810. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  86811. /**
  86812. * Called by the particle System when the position is computed for the created particle.
  86813. * @param worldMatrix is the world matrix of the particle system
  86814. * @param positionToUpdate is the position vector to update with the result
  86815. * @param particle is the particle we are computed the position for
  86816. */
  86817. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  86818. /**
  86819. * Clones the current emitter and returns a copy of it
  86820. * @returns the new emitter
  86821. */
  86822. clone(): SphereParticleEmitter;
  86823. /**
  86824. * Called by the GPUParticleSystem to setup the update shader
  86825. * @param effect defines the update shader
  86826. */
  86827. applyToShader(effect: Effect): void;
  86828. /**
  86829. * Returns a string to use to update the GPU particles update shader
  86830. * @returns a string containng the defines string
  86831. */
  86832. getEffectDefines(): string;
  86833. /**
  86834. * Returns the string "SphereParticleEmitter"
  86835. * @returns a string containing the class name
  86836. */
  86837. getClassName(): string;
  86838. /**
  86839. * Serializes the particle system to a JSON object.
  86840. * @returns the JSON object
  86841. */
  86842. serialize(): any;
  86843. /**
  86844. * Parse properties from a JSON object
  86845. * @param serializationObject defines the JSON object
  86846. */
  86847. parse(serializationObject: any): void;
  86848. }
  86849. /**
  86850. * Particle emitter emitting particles from the inside of a sphere.
  86851. * It emits the particles randomly between two vectors.
  86852. */
  86853. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  86854. /**
  86855. * The min limit of the emission direction.
  86856. */
  86857. direction1: Vector3;
  86858. /**
  86859. * The max limit of the emission direction.
  86860. */
  86861. direction2: Vector3;
  86862. /**
  86863. * Creates a new instance SphereDirectedParticleEmitter
  86864. * @param radius the radius of the emission sphere (1 by default)
  86865. * @param direction1 the min limit of the emission direction (up vector by default)
  86866. * @param direction2 the max limit of the emission direction (up vector by default)
  86867. */
  86868. constructor(radius?: number,
  86869. /**
  86870. * The min limit of the emission direction.
  86871. */
  86872. direction1?: Vector3,
  86873. /**
  86874. * The max limit of the emission direction.
  86875. */
  86876. direction2?: Vector3);
  86877. /**
  86878. * Called by the particle System when the direction is computed for the created particle.
  86879. * @param worldMatrix is the world matrix of the particle system
  86880. * @param directionToUpdate is the direction vector to update with the result
  86881. * @param particle is the particle we are computed the direction for
  86882. */
  86883. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  86884. /**
  86885. * Clones the current emitter and returns a copy of it
  86886. * @returns the new emitter
  86887. */
  86888. clone(): SphereDirectedParticleEmitter;
  86889. /**
  86890. * Called by the GPUParticleSystem to setup the update shader
  86891. * @param effect defines the update shader
  86892. */
  86893. applyToShader(effect: Effect): void;
  86894. /**
  86895. * Returns a string to use to update the GPU particles update shader
  86896. * @returns a string containng the defines string
  86897. */
  86898. getEffectDefines(): string;
  86899. /**
  86900. * Returns the string "SphereDirectedParticleEmitter"
  86901. * @returns a string containing the class name
  86902. */
  86903. getClassName(): string;
  86904. /**
  86905. * Serializes the particle system to a JSON object.
  86906. * @returns the JSON object
  86907. */
  86908. serialize(): any;
  86909. /**
  86910. * Parse properties from a JSON object
  86911. * @param serializationObject defines the JSON object
  86912. */
  86913. parse(serializationObject: any): void;
  86914. }
  86915. }
  86916. declare module BABYLON {
  86917. /**
  86918. * Interface representing a particle system in Babylon.js.
  86919. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  86920. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  86921. */
  86922. export interface IParticleSystem {
  86923. /**
  86924. * List of animations used by the particle system.
  86925. */
  86926. animations: Animation[];
  86927. /**
  86928. * The id of the Particle system.
  86929. */
  86930. id: string;
  86931. /**
  86932. * The name of the Particle system.
  86933. */
  86934. name: string;
  86935. /**
  86936. * The emitter represents the Mesh or position we are attaching the particle system to.
  86937. */
  86938. emitter: Nullable<AbstractMesh | Vector3>;
  86939. /**
  86940. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  86941. */
  86942. isBillboardBased: boolean;
  86943. /**
  86944. * The rendering group used by the Particle system to chose when to render.
  86945. */
  86946. renderingGroupId: number;
  86947. /**
  86948. * The layer mask we are rendering the particles through.
  86949. */
  86950. layerMask: number;
  86951. /**
  86952. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  86953. */
  86954. updateSpeed: number;
  86955. /**
  86956. * The amount of time the particle system is running (depends of the overall update speed).
  86957. */
  86958. targetStopDuration: number;
  86959. /**
  86960. * The texture used to render each particle. (this can be a spritesheet)
  86961. */
  86962. particleTexture: Nullable<Texture>;
  86963. /**
  86964. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  86965. */
  86966. blendMode: number;
  86967. /**
  86968. * Minimum life time of emitting particles.
  86969. */
  86970. minLifeTime: number;
  86971. /**
  86972. * Maximum life time of emitting particles.
  86973. */
  86974. maxLifeTime: number;
  86975. /**
  86976. * Minimum Size of emitting particles.
  86977. */
  86978. minSize: number;
  86979. /**
  86980. * Maximum Size of emitting particles.
  86981. */
  86982. maxSize: number;
  86983. /**
  86984. * Minimum scale of emitting particles on X axis.
  86985. */
  86986. minScaleX: number;
  86987. /**
  86988. * Maximum scale of emitting particles on X axis.
  86989. */
  86990. maxScaleX: number;
  86991. /**
  86992. * Minimum scale of emitting particles on Y axis.
  86993. */
  86994. minScaleY: number;
  86995. /**
  86996. * Maximum scale of emitting particles on Y axis.
  86997. */
  86998. maxScaleY: number;
  86999. /**
  87000. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  87001. */
  87002. color1: Color4;
  87003. /**
  87004. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  87005. */
  87006. color2: Color4;
  87007. /**
  87008. * Color the particle will have at the end of its lifetime.
  87009. */
  87010. colorDead: Color4;
  87011. /**
  87012. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  87013. */
  87014. emitRate: number;
  87015. /**
  87016. * You can use gravity if you want to give an orientation to your particles.
  87017. */
  87018. gravity: Vector3;
  87019. /**
  87020. * Minimum power of emitting particles.
  87021. */
  87022. minEmitPower: number;
  87023. /**
  87024. * Maximum power of emitting particles.
  87025. */
  87026. maxEmitPower: number;
  87027. /**
  87028. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  87029. */
  87030. minAngularSpeed: number;
  87031. /**
  87032. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  87033. */
  87034. maxAngularSpeed: number;
  87035. /**
  87036. * Gets or sets the minimal initial rotation in radians.
  87037. */
  87038. minInitialRotation: number;
  87039. /**
  87040. * Gets or sets the maximal initial rotation in radians.
  87041. */
  87042. maxInitialRotation: number;
  87043. /**
  87044. * The particle emitter type defines the emitter used by the particle system.
  87045. * It can be for example box, sphere, or cone...
  87046. */
  87047. particleEmitterType: Nullable<IParticleEmitterType>;
  87048. /**
  87049. * Defines the delay in milliseconds before starting the system (0 by default)
  87050. */
  87051. startDelay: number;
  87052. /**
  87053. * 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
  87054. */
  87055. preWarmCycles: number;
  87056. /**
  87057. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  87058. */
  87059. preWarmStepOffset: number;
  87060. /**
  87061. * 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)
  87062. */
  87063. spriteCellChangeSpeed: number;
  87064. /**
  87065. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  87066. */
  87067. startSpriteCellID: number;
  87068. /**
  87069. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  87070. */
  87071. endSpriteCellID: number;
  87072. /**
  87073. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  87074. */
  87075. spriteCellWidth: number;
  87076. /**
  87077. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  87078. */
  87079. spriteCellHeight: number;
  87080. /**
  87081. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  87082. */
  87083. spriteRandomStartCell: boolean;
  87084. /**
  87085. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  87086. */
  87087. isAnimationSheetEnabled: boolean;
  87088. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  87089. translationPivot: Vector2;
  87090. /**
  87091. * Gets or sets a texture used to add random noise to particle positions
  87092. */
  87093. noiseTexture: Nullable<BaseTexture>;
  87094. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  87095. noiseStrength: Vector3;
  87096. /**
  87097. * Gets or sets the billboard mode to use when isBillboardBased = true.
  87098. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  87099. */
  87100. billboardMode: number;
  87101. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  87102. limitVelocityDamping: number;
  87103. /**
  87104. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  87105. */
  87106. beginAnimationOnStart: boolean;
  87107. /**
  87108. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  87109. */
  87110. beginAnimationFrom: number;
  87111. /**
  87112. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  87113. */
  87114. beginAnimationTo: number;
  87115. /**
  87116. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  87117. */
  87118. beginAnimationLoop: boolean;
  87119. /**
  87120. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  87121. */
  87122. disposeOnStop: boolean;
  87123. /**
  87124. * Gets the maximum number of particles active at the same time.
  87125. * @returns The max number of active particles.
  87126. */
  87127. getCapacity(): number;
  87128. /**
  87129. * Gets if the system has been started. (Note: this will still be true after stop is called)
  87130. * @returns True if it has been started, otherwise false.
  87131. */
  87132. isStarted(): boolean;
  87133. /**
  87134. * Animates the particle system for this frame.
  87135. */
  87136. animate(): void;
  87137. /**
  87138. * Renders the particle system in its current state.
  87139. * @returns the current number of particles
  87140. */
  87141. render(): number;
  87142. /**
  87143. * Dispose the particle system and frees its associated resources.
  87144. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  87145. */
  87146. dispose(disposeTexture?: boolean): void;
  87147. /**
  87148. * Clones the particle system.
  87149. * @param name The name of the cloned object
  87150. * @param newEmitter The new emitter to use
  87151. * @returns the cloned particle system
  87152. */
  87153. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  87154. /**
  87155. * Serializes the particle system to a JSON object.
  87156. * @returns the JSON object
  87157. */
  87158. serialize(): any;
  87159. /**
  87160. * Rebuild the particle system
  87161. */
  87162. rebuild(): void;
  87163. /**
  87164. * Starts the particle system and begins to emit
  87165. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  87166. */
  87167. start(delay?: number): void;
  87168. /**
  87169. * Stops the particle system.
  87170. */
  87171. stop(): void;
  87172. /**
  87173. * Remove all active particles
  87174. */
  87175. reset(): void;
  87176. /**
  87177. * Is this system ready to be used/rendered
  87178. * @return true if the system is ready
  87179. */
  87180. isReady(): boolean;
  87181. /**
  87182. * Adds a new color gradient
  87183. * @param gradient defines the gradient to use (between 0 and 1)
  87184. * @param color1 defines the color to affect to the specified gradient
  87185. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  87186. * @returns the current particle system
  87187. */
  87188. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  87189. /**
  87190. * Remove a specific color gradient
  87191. * @param gradient defines the gradient to remove
  87192. * @returns the current particle system
  87193. */
  87194. removeColorGradient(gradient: number): IParticleSystem;
  87195. /**
  87196. * Adds a new size gradient
  87197. * @param gradient defines the gradient to use (between 0 and 1)
  87198. * @param factor defines the size factor to affect to the specified gradient
  87199. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  87200. * @returns the current particle system
  87201. */
  87202. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  87203. /**
  87204. * Remove a specific size gradient
  87205. * @param gradient defines the gradient to remove
  87206. * @returns the current particle system
  87207. */
  87208. removeSizeGradient(gradient: number): IParticleSystem;
  87209. /**
  87210. * Gets the current list of color gradients.
  87211. * You must use addColorGradient and removeColorGradient to udpate this list
  87212. * @returns the list of color gradients
  87213. */
  87214. getColorGradients(): Nullable<Array<ColorGradient>>;
  87215. /**
  87216. * Gets the current list of size gradients.
  87217. * You must use addSizeGradient and removeSizeGradient to udpate this list
  87218. * @returns the list of size gradients
  87219. */
  87220. getSizeGradients(): Nullable<Array<FactorGradient>>;
  87221. /**
  87222. * Gets the current list of angular speed gradients.
  87223. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  87224. * @returns the list of angular speed gradients
  87225. */
  87226. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  87227. /**
  87228. * Adds a new angular speed gradient
  87229. * @param gradient defines the gradient to use (between 0 and 1)
  87230. * @param factor defines the angular speed to affect to the specified gradient
  87231. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  87232. * @returns the current particle system
  87233. */
  87234. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  87235. /**
  87236. * Remove a specific angular speed gradient
  87237. * @param gradient defines the gradient to remove
  87238. * @returns the current particle system
  87239. */
  87240. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  87241. /**
  87242. * Gets the current list of velocity gradients.
  87243. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  87244. * @returns the list of velocity gradients
  87245. */
  87246. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  87247. /**
  87248. * Adds a new velocity gradient
  87249. * @param gradient defines the gradient to use (between 0 and 1)
  87250. * @param factor defines the velocity to affect to the specified gradient
  87251. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  87252. * @returns the current particle system
  87253. */
  87254. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  87255. /**
  87256. * Remove a specific velocity gradient
  87257. * @param gradient defines the gradient to remove
  87258. * @returns the current particle system
  87259. */
  87260. removeVelocityGradient(gradient: number): IParticleSystem;
  87261. /**
  87262. * Gets the current list of limit velocity gradients.
  87263. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  87264. * @returns the list of limit velocity gradients
  87265. */
  87266. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  87267. /**
  87268. * Adds a new limit velocity gradient
  87269. * @param gradient defines the gradient to use (between 0 and 1)
  87270. * @param factor defines the limit velocity to affect to the specified gradient
  87271. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  87272. * @returns the current particle system
  87273. */
  87274. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  87275. /**
  87276. * Remove a specific limit velocity gradient
  87277. * @param gradient defines the gradient to remove
  87278. * @returns the current particle system
  87279. */
  87280. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  87281. /**
  87282. * Adds a new drag gradient
  87283. * @param gradient defines the gradient to use (between 0 and 1)
  87284. * @param factor defines the drag to affect to the specified gradient
  87285. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  87286. * @returns the current particle system
  87287. */
  87288. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  87289. /**
  87290. * Remove a specific drag gradient
  87291. * @param gradient defines the gradient to remove
  87292. * @returns the current particle system
  87293. */
  87294. removeDragGradient(gradient: number): IParticleSystem;
  87295. /**
  87296. * Gets the current list of drag gradients.
  87297. * You must use addDragGradient and removeDragGradient to udpate this list
  87298. * @returns the list of drag gradients
  87299. */
  87300. getDragGradients(): Nullable<Array<FactorGradient>>;
  87301. /**
  87302. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  87303. * @param gradient defines the gradient to use (between 0 and 1)
  87304. * @param factor defines the emit rate to affect to the specified gradient
  87305. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  87306. * @returns the current particle system
  87307. */
  87308. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  87309. /**
  87310. * Remove a specific emit rate gradient
  87311. * @param gradient defines the gradient to remove
  87312. * @returns the current particle system
  87313. */
  87314. removeEmitRateGradient(gradient: number): IParticleSystem;
  87315. /**
  87316. * Gets the current list of emit rate gradients.
  87317. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  87318. * @returns the list of emit rate gradients
  87319. */
  87320. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  87321. /**
  87322. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  87323. * @param gradient defines the gradient to use (between 0 and 1)
  87324. * @param factor defines the start size to affect to the specified gradient
  87325. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  87326. * @returns the current particle system
  87327. */
  87328. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  87329. /**
  87330. * Remove a specific start size gradient
  87331. * @param gradient defines the gradient to remove
  87332. * @returns the current particle system
  87333. */
  87334. removeStartSizeGradient(gradient: number): IParticleSystem;
  87335. /**
  87336. * Gets the current list of start size gradients.
  87337. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  87338. * @returns the list of start size gradients
  87339. */
  87340. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  87341. /**
  87342. * Adds a new life time gradient
  87343. * @param gradient defines the gradient to use (between 0 and 1)
  87344. * @param factor defines the life time factor to affect to the specified gradient
  87345. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  87346. * @returns the current particle system
  87347. */
  87348. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  87349. /**
  87350. * Remove a specific life time gradient
  87351. * @param gradient defines the gradient to remove
  87352. * @returns the current particle system
  87353. */
  87354. removeLifeTimeGradient(gradient: number): IParticleSystem;
  87355. /**
  87356. * Gets the current list of life time gradients.
  87357. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  87358. * @returns the list of life time gradients
  87359. */
  87360. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  87361. /**
  87362. * Gets the current list of color gradients.
  87363. * You must use addColorGradient and removeColorGradient to udpate this list
  87364. * @returns the list of color gradients
  87365. */
  87366. getColorGradients(): Nullable<Array<ColorGradient>>;
  87367. /**
  87368. * Adds a new ramp gradient used to remap particle colors
  87369. * @param gradient defines the gradient to use (between 0 and 1)
  87370. * @param color defines the color to affect to the specified gradient
  87371. * @returns the current particle system
  87372. */
  87373. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  87374. /**
  87375. * Gets the current list of ramp gradients.
  87376. * You must use addRampGradient and removeRampGradient to udpate this list
  87377. * @returns the list of ramp gradients
  87378. */
  87379. getRampGradients(): Nullable<Array<Color3Gradient>>;
  87380. /** Gets or sets a boolean indicating that ramp gradients must be used
  87381. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  87382. */
  87383. useRampGradients: boolean;
  87384. /**
  87385. * Adds a new color remap gradient
  87386. * @param gradient defines the gradient to use (between 0 and 1)
  87387. * @param min defines the color remap minimal range
  87388. * @param max defines the color remap maximal range
  87389. * @returns the current particle system
  87390. */
  87391. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  87392. /**
  87393. * Gets the current list of color remap gradients.
  87394. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  87395. * @returns the list of color remap gradients
  87396. */
  87397. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  87398. /**
  87399. * Adds a new alpha remap gradient
  87400. * @param gradient defines the gradient to use (between 0 and 1)
  87401. * @param min defines the alpha remap minimal range
  87402. * @param max defines the alpha remap maximal range
  87403. * @returns the current particle system
  87404. */
  87405. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  87406. /**
  87407. * Gets the current list of alpha remap gradients.
  87408. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  87409. * @returns the list of alpha remap gradients
  87410. */
  87411. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  87412. /**
  87413. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  87414. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  87415. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  87416. * @returns the emitter
  87417. */
  87418. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  87419. /**
  87420. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  87421. * @param radius The radius of the hemisphere to emit from
  87422. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  87423. * @returns the emitter
  87424. */
  87425. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  87426. /**
  87427. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  87428. * @param radius The radius of the sphere to emit from
  87429. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  87430. * @returns the emitter
  87431. */
  87432. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  87433. /**
  87434. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  87435. * @param radius The radius of the sphere to emit from
  87436. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  87437. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  87438. * @returns the emitter
  87439. */
  87440. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  87441. /**
  87442. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  87443. * @param radius The radius of the emission cylinder
  87444. * @param height The height of the emission cylinder
  87445. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  87446. * @param directionRandomizer How much to randomize the particle direction [0-1]
  87447. * @returns the emitter
  87448. */
  87449. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  87450. /**
  87451. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  87452. * @param radius The radius of the cylinder to emit from
  87453. * @param height The height of the emission cylinder
  87454. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  87455. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  87456. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  87457. * @returns the emitter
  87458. */
  87459. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  87460. /**
  87461. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  87462. * @param radius The radius of the cone to emit from
  87463. * @param angle The base angle of the cone
  87464. * @returns the emitter
  87465. */
  87466. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  87467. /**
  87468. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  87469. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  87470. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  87471. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  87472. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  87473. * @returns the emitter
  87474. */
  87475. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  87476. /**
  87477. * Get hosting scene
  87478. * @returns the scene
  87479. */
  87480. getScene(): Scene;
  87481. }
  87482. }
  87483. declare module BABYLON {
  87484. /**
  87485. * Creates an instance based on a source mesh.
  87486. */
  87487. export class InstancedMesh extends AbstractMesh {
  87488. private _sourceMesh;
  87489. private _currentLOD;
  87490. /** @hidden */
  87491. _indexInSourceMeshInstanceArray: number;
  87492. constructor(name: string, source: Mesh);
  87493. /**
  87494. * Returns the string "InstancedMesh".
  87495. */
  87496. getClassName(): string;
  87497. /** Gets the list of lights affecting that mesh */
  87498. readonly lightSources: Light[];
  87499. _resyncLightSources(): void;
  87500. _resyncLighSource(light: Light): void;
  87501. _removeLightSource(light: Light, dispose: boolean): void;
  87502. /**
  87503. * If the source mesh receives shadows
  87504. */
  87505. readonly receiveShadows: boolean;
  87506. /**
  87507. * The material of the source mesh
  87508. */
  87509. readonly material: Nullable<Material>;
  87510. /**
  87511. * Visibility of the source mesh
  87512. */
  87513. readonly visibility: number;
  87514. /**
  87515. * Skeleton of the source mesh
  87516. */
  87517. readonly skeleton: Nullable<Skeleton>;
  87518. /**
  87519. * Rendering ground id of the source mesh
  87520. */
  87521. renderingGroupId: number;
  87522. /**
  87523. * Returns the total number of vertices (integer).
  87524. */
  87525. getTotalVertices(): number;
  87526. /**
  87527. * Returns a positive integer : the total number of indices in this mesh geometry.
  87528. * @returns the numner of indices or zero if the mesh has no geometry.
  87529. */
  87530. getTotalIndices(): number;
  87531. /**
  87532. * The source mesh of the instance
  87533. */
  87534. readonly sourceMesh: Mesh;
  87535. /**
  87536. * Is this node ready to be used/rendered
  87537. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  87538. * @return {boolean} is it ready
  87539. */
  87540. isReady(completeCheck?: boolean): boolean;
  87541. /**
  87542. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  87543. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  87544. * @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.
  87545. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  87546. */
  87547. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  87548. /**
  87549. * Sets the vertex data of the mesh geometry for the requested `kind`.
  87550. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  87551. * The `data` are either a numeric array either a Float32Array.
  87552. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  87553. * 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).
  87554. * Note that a new underlying VertexBuffer object is created each call.
  87555. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  87556. *
  87557. * Possible `kind` values :
  87558. * - VertexBuffer.PositionKind
  87559. * - VertexBuffer.UVKind
  87560. * - VertexBuffer.UV2Kind
  87561. * - VertexBuffer.UV3Kind
  87562. * - VertexBuffer.UV4Kind
  87563. * - VertexBuffer.UV5Kind
  87564. * - VertexBuffer.UV6Kind
  87565. * - VertexBuffer.ColorKind
  87566. * - VertexBuffer.MatricesIndicesKind
  87567. * - VertexBuffer.MatricesIndicesExtraKind
  87568. * - VertexBuffer.MatricesWeightsKind
  87569. * - VertexBuffer.MatricesWeightsExtraKind
  87570. *
  87571. * Returns the Mesh.
  87572. */
  87573. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  87574. /**
  87575. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  87576. * If the mesh has no geometry, it is simply returned as it is.
  87577. * The `data` are either a numeric array either a Float32Array.
  87578. * No new underlying VertexBuffer object is created.
  87579. * 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.
  87580. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  87581. *
  87582. * Possible `kind` values :
  87583. * - VertexBuffer.PositionKind
  87584. * - VertexBuffer.UVKind
  87585. * - VertexBuffer.UV2Kind
  87586. * - VertexBuffer.UV3Kind
  87587. * - VertexBuffer.UV4Kind
  87588. * - VertexBuffer.UV5Kind
  87589. * - VertexBuffer.UV6Kind
  87590. * - VertexBuffer.ColorKind
  87591. * - VertexBuffer.MatricesIndicesKind
  87592. * - VertexBuffer.MatricesIndicesExtraKind
  87593. * - VertexBuffer.MatricesWeightsKind
  87594. * - VertexBuffer.MatricesWeightsExtraKind
  87595. *
  87596. * Returns the Mesh.
  87597. */
  87598. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  87599. /**
  87600. * Sets the mesh indices.
  87601. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  87602. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  87603. * This method creates a new index buffer each call.
  87604. * Returns the Mesh.
  87605. */
  87606. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  87607. /**
  87608. * Boolean : True if the mesh owns the requested kind of data.
  87609. */
  87610. isVerticesDataPresent(kind: string): boolean;
  87611. /**
  87612. * Returns an array of indices (IndicesArray).
  87613. */
  87614. getIndices(): Nullable<IndicesArray>;
  87615. readonly _positions: Nullable<Vector3[]>;
  87616. /**
  87617. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  87618. * This means the mesh underlying bounding box and sphere are recomputed.
  87619. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  87620. * @returns the current mesh
  87621. */
  87622. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  87623. /** @hidden */
  87624. _preActivate(): InstancedMesh;
  87625. /** @hidden */
  87626. _activate(renderId: number, intermediateRendering: boolean): boolean;
  87627. /** @hidden */
  87628. _postActivate(): void;
  87629. getWorldMatrix(): Matrix;
  87630. readonly isAnInstance: boolean;
  87631. /**
  87632. * Returns the current associated LOD AbstractMesh.
  87633. */
  87634. getLOD(camera: Camera): AbstractMesh;
  87635. /** @hidden */
  87636. _syncSubMeshes(): InstancedMesh;
  87637. /** @hidden */
  87638. _generatePointsArray(): boolean;
  87639. /**
  87640. * Creates a new InstancedMesh from the current mesh.
  87641. * - name (string) : the cloned mesh name
  87642. * - newParent (optional Node) : the optional Node to parent the clone to.
  87643. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  87644. *
  87645. * Returns the clone.
  87646. */
  87647. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  87648. /**
  87649. * Disposes the InstancedMesh.
  87650. * Returns nothing.
  87651. */
  87652. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  87653. }
  87654. interface Mesh {
  87655. /**
  87656. * Register a custom buffer that will be instanced
  87657. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  87658. * @param kind defines the buffer kind
  87659. * @param stride defines the stride in floats
  87660. */
  87661. registerInstancedBuffer(kind: string, stride: number): void;
  87662. /** @hidden */
  87663. _userInstancedBuffersStorage: {
  87664. data: {
  87665. [key: string]: Float32Array;
  87666. };
  87667. sizes: {
  87668. [key: string]: number;
  87669. };
  87670. vertexBuffers: {
  87671. [key: string]: Nullable<VertexBuffer>;
  87672. };
  87673. strides: {
  87674. [key: string]: number;
  87675. };
  87676. };
  87677. }
  87678. interface AbstractMesh {
  87679. /**
  87680. * Object used to store instanced buffers defined by user
  87681. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  87682. */
  87683. instancedBuffers: {
  87684. [key: string]: any;
  87685. };
  87686. }
  87687. }
  87688. declare module BABYLON {
  87689. /**
  87690. * Defines the options associated with the creation of a shader material.
  87691. */
  87692. export interface IShaderMaterialOptions {
  87693. /**
  87694. * Does the material work in alpha blend mode
  87695. */
  87696. needAlphaBlending: boolean;
  87697. /**
  87698. * Does the material work in alpha test mode
  87699. */
  87700. needAlphaTesting: boolean;
  87701. /**
  87702. * The list of attribute names used in the shader
  87703. */
  87704. attributes: string[];
  87705. /**
  87706. * The list of unifrom names used in the shader
  87707. */
  87708. uniforms: string[];
  87709. /**
  87710. * The list of UBO names used in the shader
  87711. */
  87712. uniformBuffers: string[];
  87713. /**
  87714. * The list of sampler names used in the shader
  87715. */
  87716. samplers: string[];
  87717. /**
  87718. * The list of defines used in the shader
  87719. */
  87720. defines: string[];
  87721. }
  87722. /**
  87723. * 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.
  87724. *
  87725. * This returned material effects how the mesh will look based on the code in the shaders.
  87726. *
  87727. * @see http://doc.babylonjs.com/how_to/shader_material
  87728. */
  87729. export class ShaderMaterial extends Material {
  87730. private _shaderPath;
  87731. private _options;
  87732. private _textures;
  87733. private _textureArrays;
  87734. private _floats;
  87735. private _ints;
  87736. private _floatsArrays;
  87737. private _colors3;
  87738. private _colors3Arrays;
  87739. private _colors4;
  87740. private _colors4Arrays;
  87741. private _vectors2;
  87742. private _vectors3;
  87743. private _vectors4;
  87744. private _matrices;
  87745. private _matrixArrays;
  87746. private _matrices3x3;
  87747. private _matrices2x2;
  87748. private _vectors2Arrays;
  87749. private _vectors3Arrays;
  87750. private _vectors4Arrays;
  87751. private _cachedWorldViewMatrix;
  87752. private _cachedWorldViewProjectionMatrix;
  87753. private _renderId;
  87754. private _multiview;
  87755. /**
  87756. * Instantiate a new shader material.
  87757. * 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.
  87758. * This returned material effects how the mesh will look based on the code in the shaders.
  87759. * @see http://doc.babylonjs.com/how_to/shader_material
  87760. * @param name Define the name of the material in the scene
  87761. * @param scene Define the scene the material belongs to
  87762. * @param shaderPath Defines the route to the shader code in one of three ways:
  87763. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  87764. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  87765. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  87766. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  87767. * @param options Define the options used to create the shader
  87768. */
  87769. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  87770. /**
  87771. * Gets the shader path used to define the shader code
  87772. * It can be modified to trigger a new compilation
  87773. */
  87774. /**
  87775. * Sets the shader path used to define the shader code
  87776. * It can be modified to trigger a new compilation
  87777. */
  87778. shaderPath: any;
  87779. /**
  87780. * Gets the options used to compile the shader.
  87781. * They can be modified to trigger a new compilation
  87782. */
  87783. readonly options: IShaderMaterialOptions;
  87784. /**
  87785. * Gets the current class name of the material e.g. "ShaderMaterial"
  87786. * Mainly use in serialization.
  87787. * @returns the class name
  87788. */
  87789. getClassName(): string;
  87790. /**
  87791. * Specifies if the material will require alpha blending
  87792. * @returns a boolean specifying if alpha blending is needed
  87793. */
  87794. needAlphaBlending(): boolean;
  87795. /**
  87796. * Specifies if this material should be rendered in alpha test mode
  87797. * @returns a boolean specifying if an alpha test is needed.
  87798. */
  87799. needAlphaTesting(): boolean;
  87800. private _checkUniform;
  87801. /**
  87802. * Set a texture in the shader.
  87803. * @param name Define the name of the uniform samplers as defined in the shader
  87804. * @param texture Define the texture to bind to this sampler
  87805. * @return the material itself allowing "fluent" like uniform updates
  87806. */
  87807. setTexture(name: string, texture: Texture): ShaderMaterial;
  87808. /**
  87809. * Set a texture array in the shader.
  87810. * @param name Define the name of the uniform sampler array as defined in the shader
  87811. * @param textures Define the list of textures to bind to this sampler
  87812. * @return the material itself allowing "fluent" like uniform updates
  87813. */
  87814. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  87815. /**
  87816. * Set a float in the shader.
  87817. * @param name Define the name of the uniform as defined in the shader
  87818. * @param value Define the value to give to the uniform
  87819. * @return the material itself allowing "fluent" like uniform updates
  87820. */
  87821. setFloat(name: string, value: number): ShaderMaterial;
  87822. /**
  87823. * Set a int in the shader.
  87824. * @param name Define the name of the uniform as defined in the shader
  87825. * @param value Define the value to give to the uniform
  87826. * @return the material itself allowing "fluent" like uniform updates
  87827. */
  87828. setInt(name: string, value: number): ShaderMaterial;
  87829. /**
  87830. * Set an array of floats in the shader.
  87831. * @param name Define the name of the uniform as defined in the shader
  87832. * @param value Define the value to give to the uniform
  87833. * @return the material itself allowing "fluent" like uniform updates
  87834. */
  87835. setFloats(name: string, value: number[]): ShaderMaterial;
  87836. /**
  87837. * Set a vec3 in the shader from a Color3.
  87838. * @param name Define the name of the uniform as defined in the shader
  87839. * @param value Define the value to give to the uniform
  87840. * @return the material itself allowing "fluent" like uniform updates
  87841. */
  87842. setColor3(name: string, value: Color3): ShaderMaterial;
  87843. /**
  87844. * Set a vec3 array in the shader from a Color3 array.
  87845. * @param name Define the name of the uniform as defined in the shader
  87846. * @param value Define the value to give to the uniform
  87847. * @return the material itself allowing "fluent" like uniform updates
  87848. */
  87849. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  87850. /**
  87851. * Set a vec4 in the shader from a Color4.
  87852. * @param name Define the name of the uniform as defined in the shader
  87853. * @param value Define the value to give to the uniform
  87854. * @return the material itself allowing "fluent" like uniform updates
  87855. */
  87856. setColor4(name: string, value: Color4): ShaderMaterial;
  87857. /**
  87858. * Set a vec4 array in the shader from a Color4 array.
  87859. * @param name Define the name of the uniform as defined in the shader
  87860. * @param value Define the value to give to the uniform
  87861. * @return the material itself allowing "fluent" like uniform updates
  87862. */
  87863. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  87864. /**
  87865. * Set a vec2 in the shader from a Vector2.
  87866. * @param name Define the name of the uniform as defined in the shader
  87867. * @param value Define the value to give to the uniform
  87868. * @return the material itself allowing "fluent" like uniform updates
  87869. */
  87870. setVector2(name: string, value: Vector2): ShaderMaterial;
  87871. /**
  87872. * Set a vec3 in the shader from a Vector3.
  87873. * @param name Define the name of the uniform as defined in the shader
  87874. * @param value Define the value to give to the uniform
  87875. * @return the material itself allowing "fluent" like uniform updates
  87876. */
  87877. setVector3(name: string, value: Vector3): ShaderMaterial;
  87878. /**
  87879. * Set a vec4 in the shader from a Vector4.
  87880. * @param name Define the name of the uniform as defined in the shader
  87881. * @param value Define the value to give to the uniform
  87882. * @return the material itself allowing "fluent" like uniform updates
  87883. */
  87884. setVector4(name: string, value: Vector4): ShaderMaterial;
  87885. /**
  87886. * Set a mat4 in the shader from a Matrix.
  87887. * @param name Define the name of the uniform as defined in the shader
  87888. * @param value Define the value to give to the uniform
  87889. * @return the material itself allowing "fluent" like uniform updates
  87890. */
  87891. setMatrix(name: string, value: Matrix): ShaderMaterial;
  87892. /**
  87893. * Set a float32Array in the shader from a matrix array.
  87894. * @param name Define the name of the uniform as defined in the shader
  87895. * @param value Define the value to give to the uniform
  87896. * @return the material itself allowing "fluent" like uniform updates
  87897. */
  87898. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  87899. /**
  87900. * Set a mat3 in the shader from a Float32Array.
  87901. * @param name Define the name of the uniform as defined in the shader
  87902. * @param value Define the value to give to the uniform
  87903. * @return the material itself allowing "fluent" like uniform updates
  87904. */
  87905. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  87906. /**
  87907. * Set a mat2 in the shader from a Float32Array.
  87908. * @param name Define the name of the uniform as defined in the shader
  87909. * @param value Define the value to give to the uniform
  87910. * @return the material itself allowing "fluent" like uniform updates
  87911. */
  87912. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  87913. /**
  87914. * Set a vec2 array in the shader from a number array.
  87915. * @param name Define the name of the uniform as defined in the shader
  87916. * @param value Define the value to give to the uniform
  87917. * @return the material itself allowing "fluent" like uniform updates
  87918. */
  87919. setArray2(name: string, value: number[]): ShaderMaterial;
  87920. /**
  87921. * Set a vec3 array in the shader from a number array.
  87922. * @param name Define the name of the uniform as defined in the shader
  87923. * @param value Define the value to give to the uniform
  87924. * @return the material itself allowing "fluent" like uniform updates
  87925. */
  87926. setArray3(name: string, value: number[]): ShaderMaterial;
  87927. /**
  87928. * Set a vec4 array in the shader from a number array.
  87929. * @param name Define the name of the uniform as defined in the shader
  87930. * @param value Define the value to give to the uniform
  87931. * @return the material itself allowing "fluent" like uniform updates
  87932. */
  87933. setArray4(name: string, value: number[]): ShaderMaterial;
  87934. private _checkCache;
  87935. /**
  87936. * Specifies that the submesh is ready to be used
  87937. * @param mesh defines the mesh to check
  87938. * @param subMesh defines which submesh to check
  87939. * @param useInstances specifies that instances should be used
  87940. * @returns a boolean indicating that the submesh is ready or not
  87941. */
  87942. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  87943. /**
  87944. * Checks if the material is ready to render the requested mesh
  87945. * @param mesh Define the mesh to render
  87946. * @param useInstances Define whether or not the material is used with instances
  87947. * @returns true if ready, otherwise false
  87948. */
  87949. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  87950. /**
  87951. * Binds the world matrix to the material
  87952. * @param world defines the world transformation matrix
  87953. */
  87954. bindOnlyWorldMatrix(world: Matrix): void;
  87955. /**
  87956. * Binds the material to the mesh
  87957. * @param world defines the world transformation matrix
  87958. * @param mesh defines the mesh to bind the material to
  87959. */
  87960. bind(world: Matrix, mesh?: Mesh): void;
  87961. /**
  87962. * Gets the active textures from the material
  87963. * @returns an array of textures
  87964. */
  87965. getActiveTextures(): BaseTexture[];
  87966. /**
  87967. * Specifies if the material uses a texture
  87968. * @param texture defines the texture to check against the material
  87969. * @returns a boolean specifying if the material uses the texture
  87970. */
  87971. hasTexture(texture: BaseTexture): boolean;
  87972. /**
  87973. * Makes a duplicate of the material, and gives it a new name
  87974. * @param name defines the new name for the duplicated material
  87975. * @returns the cloned material
  87976. */
  87977. clone(name: string): ShaderMaterial;
  87978. /**
  87979. * Disposes the material
  87980. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  87981. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  87982. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  87983. */
  87984. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  87985. /**
  87986. * Serializes this material in a JSON representation
  87987. * @returns the serialized material object
  87988. */
  87989. serialize(): any;
  87990. /**
  87991. * Creates a shader material from parsed shader material data
  87992. * @param source defines the JSON represnetation of the material
  87993. * @param scene defines the hosting scene
  87994. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  87995. * @returns a new material
  87996. */
  87997. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  87998. }
  87999. }
  88000. declare module BABYLON {
  88001. /** @hidden */
  88002. export var colorPixelShader: {
  88003. name: string;
  88004. shader: string;
  88005. };
  88006. }
  88007. declare module BABYLON {
  88008. /** @hidden */
  88009. export var colorVertexShader: {
  88010. name: string;
  88011. shader: string;
  88012. };
  88013. }
  88014. declare module BABYLON {
  88015. /**
  88016. * Line mesh
  88017. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  88018. */
  88019. export class LinesMesh extends Mesh {
  88020. /**
  88021. * If vertex color should be applied to the mesh
  88022. */
  88023. readonly useVertexColor?: boolean | undefined;
  88024. /**
  88025. * If vertex alpha should be applied to the mesh
  88026. */
  88027. readonly useVertexAlpha?: boolean | undefined;
  88028. /**
  88029. * Color of the line (Default: White)
  88030. */
  88031. color: Color3;
  88032. /**
  88033. * Alpha of the line (Default: 1)
  88034. */
  88035. alpha: number;
  88036. /**
  88037. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  88038. * This margin is expressed in world space coordinates, so its value may vary.
  88039. * Default value is 0.1
  88040. */
  88041. intersectionThreshold: number;
  88042. private _colorShader;
  88043. private color4;
  88044. /**
  88045. * Creates a new LinesMesh
  88046. * @param name defines the name
  88047. * @param scene defines the hosting scene
  88048. * @param parent defines the parent mesh if any
  88049. * @param source defines the optional source LinesMesh used to clone data from
  88050. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  88051. * When false, achieved by calling a clone(), also passing False.
  88052. * This will make creation of children, recursive.
  88053. * @param useVertexColor defines if this LinesMesh supports vertex color
  88054. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  88055. */
  88056. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  88057. /**
  88058. * If vertex color should be applied to the mesh
  88059. */
  88060. useVertexColor?: boolean | undefined,
  88061. /**
  88062. * If vertex alpha should be applied to the mesh
  88063. */
  88064. useVertexAlpha?: boolean | undefined);
  88065. private _addClipPlaneDefine;
  88066. private _removeClipPlaneDefine;
  88067. isReady(): boolean;
  88068. /**
  88069. * Returns the string "LineMesh"
  88070. */
  88071. getClassName(): string;
  88072. /**
  88073. * @hidden
  88074. */
  88075. /**
  88076. * @hidden
  88077. */
  88078. material: Material;
  88079. /**
  88080. * @hidden
  88081. */
  88082. readonly checkCollisions: boolean;
  88083. /** @hidden */
  88084. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  88085. /** @hidden */
  88086. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  88087. /**
  88088. * Disposes of the line mesh
  88089. * @param doNotRecurse If children should be disposed
  88090. */
  88091. dispose(doNotRecurse?: boolean): void;
  88092. /**
  88093. * Returns a new LineMesh object cloned from the current one.
  88094. */
  88095. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  88096. /**
  88097. * Creates a new InstancedLinesMesh object from the mesh model.
  88098. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  88099. * @param name defines the name of the new instance
  88100. * @returns a new InstancedLinesMesh
  88101. */
  88102. createInstance(name: string): InstancedLinesMesh;
  88103. }
  88104. /**
  88105. * Creates an instance based on a source LinesMesh
  88106. */
  88107. export class InstancedLinesMesh extends InstancedMesh {
  88108. /**
  88109. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  88110. * This margin is expressed in world space coordinates, so its value may vary.
  88111. * Initilized with the intersectionThreshold value of the source LinesMesh
  88112. */
  88113. intersectionThreshold: number;
  88114. constructor(name: string, source: LinesMesh);
  88115. /**
  88116. * Returns the string "InstancedLinesMesh".
  88117. */
  88118. getClassName(): string;
  88119. }
  88120. }
  88121. declare module BABYLON {
  88122. /** @hidden */
  88123. export var linePixelShader: {
  88124. name: string;
  88125. shader: string;
  88126. };
  88127. }
  88128. declare module BABYLON {
  88129. /** @hidden */
  88130. export var lineVertexShader: {
  88131. name: string;
  88132. shader: string;
  88133. };
  88134. }
  88135. declare module BABYLON {
  88136. interface AbstractMesh {
  88137. /**
  88138. * Gets the edgesRenderer associated with the mesh
  88139. */
  88140. edgesRenderer: Nullable<EdgesRenderer>;
  88141. }
  88142. interface LinesMesh {
  88143. /**
  88144. * Enables the edge rendering mode on the mesh.
  88145. * This mode makes the mesh edges visible
  88146. * @param epsilon defines the maximal distance between two angles to detect a face
  88147. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  88148. * @returns the currentAbstractMesh
  88149. * @see https://www.babylonjs-playground.com/#19O9TU#0
  88150. */
  88151. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  88152. }
  88153. interface InstancedLinesMesh {
  88154. /**
  88155. * Enables the edge rendering mode on the mesh.
  88156. * This mode makes the mesh edges visible
  88157. * @param epsilon defines the maximal distance between two angles to detect a face
  88158. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  88159. * @returns the current InstancedLinesMesh
  88160. * @see https://www.babylonjs-playground.com/#19O9TU#0
  88161. */
  88162. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  88163. }
  88164. /**
  88165. * Defines the minimum contract an Edges renderer should follow.
  88166. */
  88167. export interface IEdgesRenderer extends IDisposable {
  88168. /**
  88169. * Gets or sets a boolean indicating if the edgesRenderer is active
  88170. */
  88171. isEnabled: boolean;
  88172. /**
  88173. * Renders the edges of the attached mesh,
  88174. */
  88175. render(): void;
  88176. /**
  88177. * Checks wether or not the edges renderer is ready to render.
  88178. * @return true if ready, otherwise false.
  88179. */
  88180. isReady(): boolean;
  88181. }
  88182. /**
  88183. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  88184. */
  88185. export class EdgesRenderer implements IEdgesRenderer {
  88186. /**
  88187. * Define the size of the edges with an orthographic camera
  88188. */
  88189. edgesWidthScalerForOrthographic: number;
  88190. /**
  88191. * Define the size of the edges with a perspective camera
  88192. */
  88193. edgesWidthScalerForPerspective: number;
  88194. protected _source: AbstractMesh;
  88195. protected _linesPositions: number[];
  88196. protected _linesNormals: number[];
  88197. protected _linesIndices: number[];
  88198. protected _epsilon: number;
  88199. protected _indicesCount: number;
  88200. protected _lineShader: ShaderMaterial;
  88201. protected _ib: DataBuffer;
  88202. protected _buffers: {
  88203. [key: string]: Nullable<VertexBuffer>;
  88204. };
  88205. protected _checkVerticesInsteadOfIndices: boolean;
  88206. private _meshRebuildObserver;
  88207. private _meshDisposeObserver;
  88208. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  88209. isEnabled: boolean;
  88210. /**
  88211. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  88212. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  88213. * @param source Mesh used to create edges
  88214. * @param epsilon sum of angles in adjacency to check for edge
  88215. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  88216. * @param generateEdgesLines - should generate Lines or only prepare resources.
  88217. */
  88218. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  88219. protected _prepareRessources(): void;
  88220. /** @hidden */
  88221. _rebuild(): void;
  88222. /**
  88223. * Releases the required resources for the edges renderer
  88224. */
  88225. dispose(): void;
  88226. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  88227. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  88228. /**
  88229. * Checks if the pair of p0 and p1 is en edge
  88230. * @param faceIndex
  88231. * @param edge
  88232. * @param faceNormals
  88233. * @param p0
  88234. * @param p1
  88235. * @private
  88236. */
  88237. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  88238. /**
  88239. * push line into the position, normal and index buffer
  88240. * @protected
  88241. */
  88242. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  88243. /**
  88244. * Generates lines edges from adjacencjes
  88245. * @private
  88246. */
  88247. _generateEdgesLines(): void;
  88248. /**
  88249. * Checks wether or not the edges renderer is ready to render.
  88250. * @return true if ready, otherwise false.
  88251. */
  88252. isReady(): boolean;
  88253. /**
  88254. * Renders the edges of the attached mesh,
  88255. */
  88256. render(): void;
  88257. }
  88258. /**
  88259. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  88260. */
  88261. export class LineEdgesRenderer extends EdgesRenderer {
  88262. /**
  88263. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  88264. * @param source LineMesh used to generate edges
  88265. * @param epsilon not important (specified angle for edge detection)
  88266. * @param checkVerticesInsteadOfIndices not important for LineMesh
  88267. */
  88268. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  88269. /**
  88270. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  88271. */
  88272. _generateEdgesLines(): void;
  88273. }
  88274. }
  88275. declare module BABYLON {
  88276. /**
  88277. * This represents the object necessary to create a rendering group.
  88278. * This is exclusively used and created by the rendering manager.
  88279. * To modify the behavior, you use the available helpers in your scene or meshes.
  88280. * @hidden
  88281. */
  88282. export class RenderingGroup {
  88283. index: number;
  88284. private static _zeroVector;
  88285. private _scene;
  88286. private _opaqueSubMeshes;
  88287. private _transparentSubMeshes;
  88288. private _alphaTestSubMeshes;
  88289. private _depthOnlySubMeshes;
  88290. private _particleSystems;
  88291. private _spriteManagers;
  88292. private _opaqueSortCompareFn;
  88293. private _alphaTestSortCompareFn;
  88294. private _transparentSortCompareFn;
  88295. private _renderOpaque;
  88296. private _renderAlphaTest;
  88297. private _renderTransparent;
  88298. /** @hidden */
  88299. _edgesRenderers: SmartArray<IEdgesRenderer>;
  88300. onBeforeTransparentRendering: () => void;
  88301. /**
  88302. * Set the opaque sort comparison function.
  88303. * If null the sub meshes will be render in the order they were created
  88304. */
  88305. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  88306. /**
  88307. * Set the alpha test sort comparison function.
  88308. * If null the sub meshes will be render in the order they were created
  88309. */
  88310. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  88311. /**
  88312. * Set the transparent sort comparison function.
  88313. * If null the sub meshes will be render in the order they were created
  88314. */
  88315. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  88316. /**
  88317. * Creates a new rendering group.
  88318. * @param index The rendering group index
  88319. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  88320. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  88321. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  88322. */
  88323. 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>);
  88324. /**
  88325. * Render all the sub meshes contained in the group.
  88326. * @param customRenderFunction Used to override the default render behaviour of the group.
  88327. * @returns true if rendered some submeshes.
  88328. */
  88329. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  88330. /**
  88331. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  88332. * @param subMeshes The submeshes to render
  88333. */
  88334. private renderOpaqueSorted;
  88335. /**
  88336. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  88337. * @param subMeshes The submeshes to render
  88338. */
  88339. private renderAlphaTestSorted;
  88340. /**
  88341. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  88342. * @param subMeshes The submeshes to render
  88343. */
  88344. private renderTransparentSorted;
  88345. /**
  88346. * Renders the submeshes in a specified order.
  88347. * @param subMeshes The submeshes to sort before render
  88348. * @param sortCompareFn The comparison function use to sort
  88349. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  88350. * @param transparent Specifies to activate blending if true
  88351. */
  88352. private static renderSorted;
  88353. /**
  88354. * Renders the submeshes in the order they were dispatched (no sort applied).
  88355. * @param subMeshes The submeshes to render
  88356. */
  88357. private static renderUnsorted;
  88358. /**
  88359. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  88360. * are rendered back to front if in the same alpha index.
  88361. *
  88362. * @param a The first submesh
  88363. * @param b The second submesh
  88364. * @returns The result of the comparison
  88365. */
  88366. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  88367. /**
  88368. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  88369. * are rendered back to front.
  88370. *
  88371. * @param a The first submesh
  88372. * @param b The second submesh
  88373. * @returns The result of the comparison
  88374. */
  88375. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  88376. /**
  88377. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  88378. * are rendered front to back (prevent overdraw).
  88379. *
  88380. * @param a The first submesh
  88381. * @param b The second submesh
  88382. * @returns The result of the comparison
  88383. */
  88384. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  88385. /**
  88386. * Resets the different lists of submeshes to prepare a new frame.
  88387. */
  88388. prepare(): void;
  88389. dispose(): void;
  88390. /**
  88391. * Inserts the submesh in its correct queue depending on its material.
  88392. * @param subMesh The submesh to dispatch
  88393. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  88394. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  88395. */
  88396. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  88397. dispatchSprites(spriteManager: ISpriteManager): void;
  88398. dispatchParticles(particleSystem: IParticleSystem): void;
  88399. private _renderParticles;
  88400. private _renderSprites;
  88401. }
  88402. }
  88403. declare module BABYLON {
  88404. /**
  88405. * Interface describing the different options available in the rendering manager
  88406. * regarding Auto Clear between groups.
  88407. */
  88408. export interface IRenderingManagerAutoClearSetup {
  88409. /**
  88410. * Defines whether or not autoclear is enable.
  88411. */
  88412. autoClear: boolean;
  88413. /**
  88414. * Defines whether or not to autoclear the depth buffer.
  88415. */
  88416. depth: boolean;
  88417. /**
  88418. * Defines whether or not to autoclear the stencil buffer.
  88419. */
  88420. stencil: boolean;
  88421. }
  88422. /**
  88423. * This class is used by the onRenderingGroupObservable
  88424. */
  88425. export class RenderingGroupInfo {
  88426. /**
  88427. * The Scene that being rendered
  88428. */
  88429. scene: Scene;
  88430. /**
  88431. * The camera currently used for the rendering pass
  88432. */
  88433. camera: Nullable<Camera>;
  88434. /**
  88435. * The ID of the renderingGroup being processed
  88436. */
  88437. renderingGroupId: number;
  88438. }
  88439. /**
  88440. * This is the manager responsible of all the rendering for meshes sprites and particles.
  88441. * It is enable to manage the different groups as well as the different necessary sort functions.
  88442. * This should not be used directly aside of the few static configurations
  88443. */
  88444. export class RenderingManager {
  88445. /**
  88446. * The max id used for rendering groups (not included)
  88447. */
  88448. static MAX_RENDERINGGROUPS: number;
  88449. /**
  88450. * The min id used for rendering groups (included)
  88451. */
  88452. static MIN_RENDERINGGROUPS: number;
  88453. /**
  88454. * Used to globally prevent autoclearing scenes.
  88455. */
  88456. static AUTOCLEAR: boolean;
  88457. /**
  88458. * @hidden
  88459. */
  88460. _useSceneAutoClearSetup: boolean;
  88461. private _scene;
  88462. private _renderingGroups;
  88463. private _depthStencilBufferAlreadyCleaned;
  88464. private _autoClearDepthStencil;
  88465. private _customOpaqueSortCompareFn;
  88466. private _customAlphaTestSortCompareFn;
  88467. private _customTransparentSortCompareFn;
  88468. private _renderingGroupInfo;
  88469. /**
  88470. * Instantiates a new rendering group for a particular scene
  88471. * @param scene Defines the scene the groups belongs to
  88472. */
  88473. constructor(scene: Scene);
  88474. private _clearDepthStencilBuffer;
  88475. /**
  88476. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  88477. * @hidden
  88478. */
  88479. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  88480. /**
  88481. * Resets the different information of the group to prepare a new frame
  88482. * @hidden
  88483. */
  88484. reset(): void;
  88485. /**
  88486. * Dispose and release the group and its associated resources.
  88487. * @hidden
  88488. */
  88489. dispose(): void;
  88490. /**
  88491. * Clear the info related to rendering groups preventing retention points during dispose.
  88492. */
  88493. freeRenderingGroups(): void;
  88494. private _prepareRenderingGroup;
  88495. /**
  88496. * Add a sprite manager to the rendering manager in order to render it this frame.
  88497. * @param spriteManager Define the sprite manager to render
  88498. */
  88499. dispatchSprites(spriteManager: ISpriteManager): void;
  88500. /**
  88501. * Add a particle system to the rendering manager in order to render it this frame.
  88502. * @param particleSystem Define the particle system to render
  88503. */
  88504. dispatchParticles(particleSystem: IParticleSystem): void;
  88505. /**
  88506. * Add a submesh to the manager in order to render it this frame
  88507. * @param subMesh The submesh to dispatch
  88508. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  88509. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  88510. */
  88511. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  88512. /**
  88513. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  88514. * This allowed control for front to back rendering or reversly depending of the special needs.
  88515. *
  88516. * @param renderingGroupId The rendering group id corresponding to its index
  88517. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  88518. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  88519. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  88520. */
  88521. 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;
  88522. /**
  88523. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  88524. *
  88525. * @param renderingGroupId The rendering group id corresponding to its index
  88526. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  88527. * @param depth Automatically clears depth between groups if true and autoClear is true.
  88528. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  88529. */
  88530. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  88531. /**
  88532. * Gets the current auto clear configuration for one rendering group of the rendering
  88533. * manager.
  88534. * @param index the rendering group index to get the information for
  88535. * @returns The auto clear setup for the requested rendering group
  88536. */
  88537. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  88538. }
  88539. }
  88540. declare module BABYLON {
  88541. /**
  88542. * This Helps creating a texture that will be created from a camera in your scene.
  88543. * It is basically a dynamic texture that could be used to create special effects for instance.
  88544. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  88545. */
  88546. export class RenderTargetTexture extends Texture {
  88547. isCube: boolean;
  88548. /**
  88549. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  88550. */
  88551. static readonly REFRESHRATE_RENDER_ONCE: number;
  88552. /**
  88553. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  88554. */
  88555. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  88556. /**
  88557. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  88558. * the central point of your effect and can save a lot of performances.
  88559. */
  88560. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  88561. /**
  88562. * Use this predicate to dynamically define the list of mesh you want to render.
  88563. * If set, the renderList property will be overwritten.
  88564. */
  88565. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  88566. private _renderList;
  88567. /**
  88568. * Use this list to define the list of mesh you want to render.
  88569. */
  88570. renderList: Nullable<Array<AbstractMesh>>;
  88571. private _hookArray;
  88572. /**
  88573. * Define if particles should be rendered in your texture.
  88574. */
  88575. renderParticles: boolean;
  88576. /**
  88577. * Define if sprites should be rendered in your texture.
  88578. */
  88579. renderSprites: boolean;
  88580. /**
  88581. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  88582. */
  88583. coordinatesMode: number;
  88584. /**
  88585. * Define the camera used to render the texture.
  88586. */
  88587. activeCamera: Nullable<Camera>;
  88588. /**
  88589. * Override the render function of the texture with your own one.
  88590. */
  88591. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  88592. /**
  88593. * Define if camera post processes should be use while rendering the texture.
  88594. */
  88595. useCameraPostProcesses: boolean;
  88596. /**
  88597. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  88598. */
  88599. ignoreCameraViewport: boolean;
  88600. private _postProcessManager;
  88601. private _postProcesses;
  88602. private _resizeObserver;
  88603. /**
  88604. * An event triggered when the texture is unbind.
  88605. */
  88606. onBeforeBindObservable: Observable<RenderTargetTexture>;
  88607. /**
  88608. * An event triggered when the texture is unbind.
  88609. */
  88610. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  88611. private _onAfterUnbindObserver;
  88612. /**
  88613. * Set a after unbind callback in the texture.
  88614. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  88615. */
  88616. onAfterUnbind: () => void;
  88617. /**
  88618. * An event triggered before rendering the texture
  88619. */
  88620. onBeforeRenderObservable: Observable<number>;
  88621. private _onBeforeRenderObserver;
  88622. /**
  88623. * Set a before render callback in the texture.
  88624. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  88625. */
  88626. onBeforeRender: (faceIndex: number) => void;
  88627. /**
  88628. * An event triggered after rendering the texture
  88629. */
  88630. onAfterRenderObservable: Observable<number>;
  88631. private _onAfterRenderObserver;
  88632. /**
  88633. * Set a after render callback in the texture.
  88634. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  88635. */
  88636. onAfterRender: (faceIndex: number) => void;
  88637. /**
  88638. * An event triggered after the texture clear
  88639. */
  88640. onClearObservable: Observable<Engine>;
  88641. private _onClearObserver;
  88642. /**
  88643. * Set a clear callback in the texture.
  88644. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  88645. */
  88646. onClear: (Engine: Engine) => void;
  88647. /**
  88648. * An event triggered when the texture is resized.
  88649. */
  88650. onResizeObservable: Observable<RenderTargetTexture>;
  88651. /**
  88652. * Define the clear color of the Render Target if it should be different from the scene.
  88653. */
  88654. clearColor: Color4;
  88655. protected _size: number | {
  88656. width: number;
  88657. height: number;
  88658. };
  88659. protected _initialSizeParameter: number | {
  88660. width: number;
  88661. height: number;
  88662. } | {
  88663. ratio: number;
  88664. };
  88665. protected _sizeRatio: Nullable<number>;
  88666. /** @hidden */
  88667. _generateMipMaps: boolean;
  88668. protected _renderingManager: RenderingManager;
  88669. /** @hidden */
  88670. _waitingRenderList: string[];
  88671. protected _doNotChangeAspectRatio: boolean;
  88672. protected _currentRefreshId: number;
  88673. protected _refreshRate: number;
  88674. protected _textureMatrix: Matrix;
  88675. protected _samples: number;
  88676. protected _renderTargetOptions: RenderTargetCreationOptions;
  88677. /**
  88678. * Gets render target creation options that were used.
  88679. */
  88680. readonly renderTargetOptions: RenderTargetCreationOptions;
  88681. protected _engine: Engine;
  88682. protected _onRatioRescale(): void;
  88683. /**
  88684. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  88685. * It must define where the camera used to render the texture is set
  88686. */
  88687. boundingBoxPosition: Vector3;
  88688. private _boundingBoxSize;
  88689. /**
  88690. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  88691. * When defined, the cubemap will switch to local mode
  88692. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  88693. * @example https://www.babylonjs-playground.com/#RNASML
  88694. */
  88695. boundingBoxSize: Vector3;
  88696. /**
  88697. * In case the RTT has been created with a depth texture, get the associated
  88698. * depth texture.
  88699. * Otherwise, return null.
  88700. */
  88701. depthStencilTexture: Nullable<InternalTexture>;
  88702. /**
  88703. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  88704. * or used a shadow, depth texture...
  88705. * @param name The friendly name of the texture
  88706. * @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)
  88707. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  88708. * @param generateMipMaps True if mip maps need to be generated after render.
  88709. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  88710. * @param type The type of the buffer in the RTT (int, half float, float...)
  88711. * @param isCube True if a cube texture needs to be created
  88712. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  88713. * @param generateDepthBuffer True to generate a depth buffer
  88714. * @param generateStencilBuffer True to generate a stencil buffer
  88715. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  88716. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  88717. * @param delayAllocation if the texture allocation should be delayed (default: false)
  88718. */
  88719. constructor(name: string, size: number | {
  88720. width: number;
  88721. height: number;
  88722. } | {
  88723. ratio: number;
  88724. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  88725. /**
  88726. * Creates a depth stencil texture.
  88727. * This is only available in WebGL 2 or with the depth texture extension available.
  88728. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  88729. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  88730. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  88731. */
  88732. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  88733. private _processSizeParameter;
  88734. /**
  88735. * Define the number of samples to use in case of MSAA.
  88736. * It defaults to one meaning no MSAA has been enabled.
  88737. */
  88738. samples: number;
  88739. /**
  88740. * Resets the refresh counter of the texture and start bak from scratch.
  88741. * Could be useful to regenerate the texture if it is setup to render only once.
  88742. */
  88743. resetRefreshCounter(): void;
  88744. /**
  88745. * Define the refresh rate of the texture or the rendering frequency.
  88746. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  88747. */
  88748. refreshRate: number;
  88749. /**
  88750. * Adds a post process to the render target rendering passes.
  88751. * @param postProcess define the post process to add
  88752. */
  88753. addPostProcess(postProcess: PostProcess): void;
  88754. /**
  88755. * Clear all the post processes attached to the render target
  88756. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  88757. */
  88758. clearPostProcesses(dispose?: boolean): void;
  88759. /**
  88760. * Remove one of the post process from the list of attached post processes to the texture
  88761. * @param postProcess define the post process to remove from the list
  88762. */
  88763. removePostProcess(postProcess: PostProcess): void;
  88764. /** @hidden */
  88765. _shouldRender(): boolean;
  88766. /**
  88767. * Gets the actual render size of the texture.
  88768. * @returns the width of the render size
  88769. */
  88770. getRenderSize(): number;
  88771. /**
  88772. * Gets the actual render width of the texture.
  88773. * @returns the width of the render size
  88774. */
  88775. getRenderWidth(): number;
  88776. /**
  88777. * Gets the actual render height of the texture.
  88778. * @returns the height of the render size
  88779. */
  88780. getRenderHeight(): number;
  88781. /**
  88782. * Get if the texture can be rescaled or not.
  88783. */
  88784. readonly canRescale: boolean;
  88785. /**
  88786. * Resize the texture using a ratio.
  88787. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  88788. */
  88789. scale(ratio: number): void;
  88790. /**
  88791. * Get the texture reflection matrix used to rotate/transform the reflection.
  88792. * @returns the reflection matrix
  88793. */
  88794. getReflectionTextureMatrix(): Matrix;
  88795. /**
  88796. * Resize the texture to a new desired size.
  88797. * Be carrefull as it will recreate all the data in the new texture.
  88798. * @param size Define the new size. It can be:
  88799. * - a number for squared texture,
  88800. * - an object containing { width: number, height: number }
  88801. * - or an object containing a ratio { ratio: number }
  88802. */
  88803. resize(size: number | {
  88804. width: number;
  88805. height: number;
  88806. } | {
  88807. ratio: number;
  88808. }): void;
  88809. /**
  88810. * Renders all the objects from the render list into the texture.
  88811. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  88812. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  88813. */
  88814. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  88815. private _bestReflectionRenderTargetDimension;
  88816. /**
  88817. * @hidden
  88818. * @param faceIndex face index to bind to if this is a cubetexture
  88819. */
  88820. _bindFrameBuffer(faceIndex?: number): void;
  88821. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  88822. private renderToTarget;
  88823. /**
  88824. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  88825. * This allowed control for front to back rendering or reversly depending of the special needs.
  88826. *
  88827. * @param renderingGroupId The rendering group id corresponding to its index
  88828. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  88829. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  88830. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  88831. */
  88832. 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;
  88833. /**
  88834. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  88835. *
  88836. * @param renderingGroupId The rendering group id corresponding to its index
  88837. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  88838. */
  88839. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  88840. /**
  88841. * Clones the texture.
  88842. * @returns the cloned texture
  88843. */
  88844. clone(): RenderTargetTexture;
  88845. /**
  88846. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  88847. * @returns The JSON representation of the texture
  88848. */
  88849. serialize(): any;
  88850. /**
  88851. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  88852. */
  88853. disposeFramebufferObjects(): void;
  88854. /**
  88855. * Dispose the texture and release its associated resources.
  88856. */
  88857. dispose(): void;
  88858. /** @hidden */
  88859. _rebuild(): void;
  88860. /**
  88861. * Clear the info related to rendering groups preventing retention point in material dispose.
  88862. */
  88863. freeRenderingGroups(): void;
  88864. /**
  88865. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  88866. * @returns the view count
  88867. */
  88868. getViewCount(): number;
  88869. }
  88870. }
  88871. declare module BABYLON {
  88872. /**
  88873. * Options for compiling materials.
  88874. */
  88875. export interface IMaterialCompilationOptions {
  88876. /**
  88877. * Defines whether clip planes are enabled.
  88878. */
  88879. clipPlane: boolean;
  88880. /**
  88881. * Defines whether instances are enabled.
  88882. */
  88883. useInstances: boolean;
  88884. }
  88885. /**
  88886. * Base class for the main features of a material in Babylon.js
  88887. */
  88888. export class Material implements IAnimatable {
  88889. /**
  88890. * Returns the triangle fill mode
  88891. */
  88892. static readonly TriangleFillMode: number;
  88893. /**
  88894. * Returns the wireframe mode
  88895. */
  88896. static readonly WireFrameFillMode: number;
  88897. /**
  88898. * Returns the point fill mode
  88899. */
  88900. static readonly PointFillMode: number;
  88901. /**
  88902. * Returns the point list draw mode
  88903. */
  88904. static readonly PointListDrawMode: number;
  88905. /**
  88906. * Returns the line list draw mode
  88907. */
  88908. static readonly LineListDrawMode: number;
  88909. /**
  88910. * Returns the line loop draw mode
  88911. */
  88912. static readonly LineLoopDrawMode: number;
  88913. /**
  88914. * Returns the line strip draw mode
  88915. */
  88916. static readonly LineStripDrawMode: number;
  88917. /**
  88918. * Returns the triangle strip draw mode
  88919. */
  88920. static readonly TriangleStripDrawMode: number;
  88921. /**
  88922. * Returns the triangle fan draw mode
  88923. */
  88924. static readonly TriangleFanDrawMode: number;
  88925. /**
  88926. * Stores the clock-wise side orientation
  88927. */
  88928. static readonly ClockWiseSideOrientation: number;
  88929. /**
  88930. * Stores the counter clock-wise side orientation
  88931. */
  88932. static readonly CounterClockWiseSideOrientation: number;
  88933. /**
  88934. * The dirty texture flag value
  88935. */
  88936. static readonly TextureDirtyFlag: number;
  88937. /**
  88938. * The dirty light flag value
  88939. */
  88940. static readonly LightDirtyFlag: number;
  88941. /**
  88942. * The dirty fresnel flag value
  88943. */
  88944. static readonly FresnelDirtyFlag: number;
  88945. /**
  88946. * The dirty attribute flag value
  88947. */
  88948. static readonly AttributesDirtyFlag: number;
  88949. /**
  88950. * The dirty misc flag value
  88951. */
  88952. static readonly MiscDirtyFlag: number;
  88953. /**
  88954. * The all dirty flag value
  88955. */
  88956. static readonly AllDirtyFlag: number;
  88957. /**
  88958. * The ID of the material
  88959. */
  88960. id: string;
  88961. /**
  88962. * Gets or sets the unique id of the material
  88963. */
  88964. uniqueId: number;
  88965. /**
  88966. * The name of the material
  88967. */
  88968. name: string;
  88969. /**
  88970. * Gets or sets user defined metadata
  88971. */
  88972. metadata: any;
  88973. /**
  88974. * For internal use only. Please do not use.
  88975. */
  88976. reservedDataStore: any;
  88977. /**
  88978. * Specifies if the ready state should be checked on each call
  88979. */
  88980. checkReadyOnEveryCall: boolean;
  88981. /**
  88982. * Specifies if the ready state should be checked once
  88983. */
  88984. checkReadyOnlyOnce: boolean;
  88985. /**
  88986. * The state of the material
  88987. */
  88988. state: string;
  88989. /**
  88990. * The alpha value of the material
  88991. */
  88992. protected _alpha: number;
  88993. /**
  88994. * List of inspectable custom properties (used by the Inspector)
  88995. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  88996. */
  88997. inspectableCustomProperties: IInspectable[];
  88998. /**
  88999. * Sets the alpha value of the material
  89000. */
  89001. /**
  89002. * Gets the alpha value of the material
  89003. */
  89004. alpha: number;
  89005. /**
  89006. * Specifies if back face culling is enabled
  89007. */
  89008. protected _backFaceCulling: boolean;
  89009. /**
  89010. * Sets the back-face culling state
  89011. */
  89012. /**
  89013. * Gets the back-face culling state
  89014. */
  89015. backFaceCulling: boolean;
  89016. /**
  89017. * Stores the value for side orientation
  89018. */
  89019. sideOrientation: number;
  89020. /**
  89021. * Callback triggered when the material is compiled
  89022. */
  89023. onCompiled: Nullable<(effect: Effect) => void>;
  89024. /**
  89025. * Callback triggered when an error occurs
  89026. */
  89027. onError: Nullable<(effect: Effect, errors: string) => void>;
  89028. /**
  89029. * Callback triggered to get the render target textures
  89030. */
  89031. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  89032. /**
  89033. * Gets a boolean indicating that current material needs to register RTT
  89034. */
  89035. readonly hasRenderTargetTextures: boolean;
  89036. /**
  89037. * Specifies if the material should be serialized
  89038. */
  89039. doNotSerialize: boolean;
  89040. /**
  89041. * @hidden
  89042. */
  89043. _storeEffectOnSubMeshes: boolean;
  89044. /**
  89045. * Stores the animations for the material
  89046. */
  89047. animations: Nullable<Array<Animation>>;
  89048. /**
  89049. * An event triggered when the material is disposed
  89050. */
  89051. onDisposeObservable: Observable<Material>;
  89052. /**
  89053. * An observer which watches for dispose events
  89054. */
  89055. private _onDisposeObserver;
  89056. private _onUnBindObservable;
  89057. /**
  89058. * Called during a dispose event
  89059. */
  89060. onDispose: () => void;
  89061. private _onBindObservable;
  89062. /**
  89063. * An event triggered when the material is bound
  89064. */
  89065. readonly onBindObservable: Observable<AbstractMesh>;
  89066. /**
  89067. * An observer which watches for bind events
  89068. */
  89069. private _onBindObserver;
  89070. /**
  89071. * Called during a bind event
  89072. */
  89073. onBind: (Mesh: AbstractMesh) => void;
  89074. /**
  89075. * An event triggered when the material is unbound
  89076. */
  89077. readonly onUnBindObservable: Observable<Material>;
  89078. /**
  89079. * Stores the value of the alpha mode
  89080. */
  89081. private _alphaMode;
  89082. /**
  89083. * Sets the value of the alpha mode.
  89084. *
  89085. * | Value | Type | Description |
  89086. * | --- | --- | --- |
  89087. * | 0 | ALPHA_DISABLE | |
  89088. * | 1 | ALPHA_ADD | |
  89089. * | 2 | ALPHA_COMBINE | |
  89090. * | 3 | ALPHA_SUBTRACT | |
  89091. * | 4 | ALPHA_MULTIPLY | |
  89092. * | 5 | ALPHA_MAXIMIZED | |
  89093. * | 6 | ALPHA_ONEONE | |
  89094. * | 7 | ALPHA_PREMULTIPLIED | |
  89095. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  89096. * | 9 | ALPHA_INTERPOLATE | |
  89097. * | 10 | ALPHA_SCREENMODE | |
  89098. *
  89099. */
  89100. /**
  89101. * Gets the value of the alpha mode
  89102. */
  89103. alphaMode: number;
  89104. /**
  89105. * Stores the state of the need depth pre-pass value
  89106. */
  89107. private _needDepthPrePass;
  89108. /**
  89109. * Sets the need depth pre-pass value
  89110. */
  89111. /**
  89112. * Gets the depth pre-pass value
  89113. */
  89114. needDepthPrePass: boolean;
  89115. /**
  89116. * Specifies if depth writing should be disabled
  89117. */
  89118. disableDepthWrite: boolean;
  89119. /**
  89120. * Specifies if depth writing should be forced
  89121. */
  89122. forceDepthWrite: boolean;
  89123. /**
  89124. * Specifies the depth function that should be used. 0 means the default engine function
  89125. */
  89126. depthFunction: number;
  89127. /**
  89128. * Specifies if there should be a separate pass for culling
  89129. */
  89130. separateCullingPass: boolean;
  89131. /**
  89132. * Stores the state specifing if fog should be enabled
  89133. */
  89134. private _fogEnabled;
  89135. /**
  89136. * Sets the state for enabling fog
  89137. */
  89138. /**
  89139. * Gets the value of the fog enabled state
  89140. */
  89141. fogEnabled: boolean;
  89142. /**
  89143. * Stores the size of points
  89144. */
  89145. pointSize: number;
  89146. /**
  89147. * Stores the z offset value
  89148. */
  89149. zOffset: number;
  89150. /**
  89151. * Gets a value specifying if wireframe mode is enabled
  89152. */
  89153. /**
  89154. * Sets the state of wireframe mode
  89155. */
  89156. wireframe: boolean;
  89157. /**
  89158. * Gets the value specifying if point clouds are enabled
  89159. */
  89160. /**
  89161. * Sets the state of point cloud mode
  89162. */
  89163. pointsCloud: boolean;
  89164. /**
  89165. * Gets the material fill mode
  89166. */
  89167. /**
  89168. * Sets the material fill mode
  89169. */
  89170. fillMode: number;
  89171. /**
  89172. * @hidden
  89173. * Stores the effects for the material
  89174. */
  89175. _effect: Nullable<Effect>;
  89176. /**
  89177. * @hidden
  89178. * Specifies if the material was previously ready
  89179. */
  89180. _wasPreviouslyReady: boolean;
  89181. /**
  89182. * Specifies if uniform buffers should be used
  89183. */
  89184. private _useUBO;
  89185. /**
  89186. * Stores a reference to the scene
  89187. */
  89188. private _scene;
  89189. /**
  89190. * Stores the fill mode state
  89191. */
  89192. private _fillMode;
  89193. /**
  89194. * Specifies if the depth write state should be cached
  89195. */
  89196. private _cachedDepthWriteState;
  89197. /**
  89198. * Specifies if the depth function state should be cached
  89199. */
  89200. private _cachedDepthFunctionState;
  89201. /**
  89202. * Stores the uniform buffer
  89203. */
  89204. protected _uniformBuffer: UniformBuffer;
  89205. /** @hidden */
  89206. _indexInSceneMaterialArray: number;
  89207. /** @hidden */
  89208. meshMap: Nullable<{
  89209. [id: string]: AbstractMesh | undefined;
  89210. }>;
  89211. /**
  89212. * Creates a material instance
  89213. * @param name defines the name of the material
  89214. * @param scene defines the scene to reference
  89215. * @param doNotAdd specifies if the material should be added to the scene
  89216. */
  89217. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  89218. /**
  89219. * Returns a string representation of the current material
  89220. * @param fullDetails defines a boolean indicating which levels of logging is desired
  89221. * @returns a string with material information
  89222. */
  89223. toString(fullDetails?: boolean): string;
  89224. /**
  89225. * Gets the class name of the material
  89226. * @returns a string with the class name of the material
  89227. */
  89228. getClassName(): string;
  89229. /**
  89230. * Specifies if updates for the material been locked
  89231. */
  89232. readonly isFrozen: boolean;
  89233. /**
  89234. * Locks updates for the material
  89235. */
  89236. freeze(): void;
  89237. /**
  89238. * Unlocks updates for the material
  89239. */
  89240. unfreeze(): void;
  89241. /**
  89242. * Specifies if the material is ready to be used
  89243. * @param mesh defines the mesh to check
  89244. * @param useInstances specifies if instances should be used
  89245. * @returns a boolean indicating if the material is ready to be used
  89246. */
  89247. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  89248. /**
  89249. * Specifies that the submesh is ready to be used
  89250. * @param mesh defines the mesh to check
  89251. * @param subMesh defines which submesh to check
  89252. * @param useInstances specifies that instances should be used
  89253. * @returns a boolean indicating that the submesh is ready or not
  89254. */
  89255. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  89256. /**
  89257. * Returns the material effect
  89258. * @returns the effect associated with the material
  89259. */
  89260. getEffect(): Nullable<Effect>;
  89261. /**
  89262. * Returns the current scene
  89263. * @returns a Scene
  89264. */
  89265. getScene(): Scene;
  89266. /**
  89267. * Specifies if the material will require alpha blending
  89268. * @returns a boolean specifying if alpha blending is needed
  89269. */
  89270. needAlphaBlending(): boolean;
  89271. /**
  89272. * Specifies if the mesh will require alpha blending
  89273. * @param mesh defines the mesh to check
  89274. * @returns a boolean specifying if alpha blending is needed for the mesh
  89275. */
  89276. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  89277. /**
  89278. * Specifies if this material should be rendered in alpha test mode
  89279. * @returns a boolean specifying if an alpha test is needed.
  89280. */
  89281. needAlphaTesting(): boolean;
  89282. /**
  89283. * Gets the texture used for the alpha test
  89284. * @returns the texture to use for alpha testing
  89285. */
  89286. getAlphaTestTexture(): Nullable<BaseTexture>;
  89287. /**
  89288. * Marks the material to indicate that it needs to be re-calculated
  89289. */
  89290. markDirty(): void;
  89291. /** @hidden */
  89292. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  89293. /**
  89294. * Binds the material to the mesh
  89295. * @param world defines the world transformation matrix
  89296. * @param mesh defines the mesh to bind the material to
  89297. */
  89298. bind(world: Matrix, mesh?: Mesh): void;
  89299. /**
  89300. * Binds the submesh to the material
  89301. * @param world defines the world transformation matrix
  89302. * @param mesh defines the mesh containing the submesh
  89303. * @param subMesh defines the submesh to bind the material to
  89304. */
  89305. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  89306. /**
  89307. * Binds the world matrix to the material
  89308. * @param world defines the world transformation matrix
  89309. */
  89310. bindOnlyWorldMatrix(world: Matrix): void;
  89311. /**
  89312. * Binds the scene's uniform buffer to the effect.
  89313. * @param effect defines the effect to bind to the scene uniform buffer
  89314. * @param sceneUbo defines the uniform buffer storing scene data
  89315. */
  89316. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  89317. /**
  89318. * Binds the view matrix to the effect
  89319. * @param effect defines the effect to bind the view matrix to
  89320. */
  89321. bindView(effect: Effect): void;
  89322. /**
  89323. * Binds the view projection matrix to the effect
  89324. * @param effect defines the effect to bind the view projection matrix to
  89325. */
  89326. bindViewProjection(effect: Effect): void;
  89327. /**
  89328. * Specifies if material alpha testing should be turned on for the mesh
  89329. * @param mesh defines the mesh to check
  89330. */
  89331. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  89332. /**
  89333. * Processes to execute after binding the material to a mesh
  89334. * @param mesh defines the rendered mesh
  89335. */
  89336. protected _afterBind(mesh?: Mesh): void;
  89337. /**
  89338. * Unbinds the material from the mesh
  89339. */
  89340. unbind(): void;
  89341. /**
  89342. * Gets the active textures from the material
  89343. * @returns an array of textures
  89344. */
  89345. getActiveTextures(): BaseTexture[];
  89346. /**
  89347. * Specifies if the material uses a texture
  89348. * @param texture defines the texture to check against the material
  89349. * @returns a boolean specifying if the material uses the texture
  89350. */
  89351. hasTexture(texture: BaseTexture): boolean;
  89352. /**
  89353. * Makes a duplicate of the material, and gives it a new name
  89354. * @param name defines the new name for the duplicated material
  89355. * @returns the cloned material
  89356. */
  89357. clone(name: string): Nullable<Material>;
  89358. /**
  89359. * Gets the meshes bound to the material
  89360. * @returns an array of meshes bound to the material
  89361. */
  89362. getBindedMeshes(): AbstractMesh[];
  89363. /**
  89364. * Force shader compilation
  89365. * @param mesh defines the mesh associated with this material
  89366. * @param onCompiled defines a function to execute once the material is compiled
  89367. * @param options defines the options to configure the compilation
  89368. * @param onError defines a function to execute if the material fails compiling
  89369. */
  89370. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  89371. /**
  89372. * Force shader compilation
  89373. * @param mesh defines the mesh that will use this material
  89374. * @param options defines additional options for compiling the shaders
  89375. * @returns a promise that resolves when the compilation completes
  89376. */
  89377. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  89378. private static readonly _AllDirtyCallBack;
  89379. private static readonly _ImageProcessingDirtyCallBack;
  89380. private static readonly _TextureDirtyCallBack;
  89381. private static readonly _FresnelDirtyCallBack;
  89382. private static readonly _MiscDirtyCallBack;
  89383. private static readonly _LightsDirtyCallBack;
  89384. private static readonly _AttributeDirtyCallBack;
  89385. private static _FresnelAndMiscDirtyCallBack;
  89386. private static _TextureAndMiscDirtyCallBack;
  89387. private static readonly _DirtyCallbackArray;
  89388. private static readonly _RunDirtyCallBacks;
  89389. /**
  89390. * Marks a define in the material to indicate that it needs to be re-computed
  89391. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  89392. */
  89393. markAsDirty(flag: number): void;
  89394. /**
  89395. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  89396. * @param func defines a function which checks material defines against the submeshes
  89397. */
  89398. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  89399. /**
  89400. * Indicates that we need to re-calculated for all submeshes
  89401. */
  89402. protected _markAllSubMeshesAsAllDirty(): void;
  89403. /**
  89404. * Indicates that image processing needs to be re-calculated for all submeshes
  89405. */
  89406. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  89407. /**
  89408. * Indicates that textures need to be re-calculated for all submeshes
  89409. */
  89410. protected _markAllSubMeshesAsTexturesDirty(): void;
  89411. /**
  89412. * Indicates that fresnel needs to be re-calculated for all submeshes
  89413. */
  89414. protected _markAllSubMeshesAsFresnelDirty(): void;
  89415. /**
  89416. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  89417. */
  89418. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  89419. /**
  89420. * Indicates that lights need to be re-calculated for all submeshes
  89421. */
  89422. protected _markAllSubMeshesAsLightsDirty(): void;
  89423. /**
  89424. * Indicates that attributes need to be re-calculated for all submeshes
  89425. */
  89426. protected _markAllSubMeshesAsAttributesDirty(): void;
  89427. /**
  89428. * Indicates that misc needs to be re-calculated for all submeshes
  89429. */
  89430. protected _markAllSubMeshesAsMiscDirty(): void;
  89431. /**
  89432. * Indicates that textures and misc need to be re-calculated for all submeshes
  89433. */
  89434. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  89435. /**
  89436. * Disposes the material
  89437. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  89438. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  89439. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  89440. */
  89441. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  89442. /** @hidden */
  89443. private releaseVertexArrayObject;
  89444. /**
  89445. * Serializes this material
  89446. * @returns the serialized material object
  89447. */
  89448. serialize(): any;
  89449. /**
  89450. * Creates a material from parsed material data
  89451. * @param parsedMaterial defines parsed material data
  89452. * @param scene defines the hosting scene
  89453. * @param rootUrl defines the root URL to use to load textures
  89454. * @returns a new material
  89455. */
  89456. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  89457. }
  89458. }
  89459. declare module BABYLON {
  89460. /**
  89461. * A multi-material is used to apply different materials to different parts of the same object without the need of
  89462. * separate meshes. This can be use to improve performances.
  89463. * @see http://doc.babylonjs.com/how_to/multi_materials
  89464. */
  89465. export class MultiMaterial extends Material {
  89466. private _subMaterials;
  89467. /**
  89468. * Gets or Sets the list of Materials used within the multi material.
  89469. * They need to be ordered according to the submeshes order in the associated mesh
  89470. */
  89471. subMaterials: Nullable<Material>[];
  89472. /**
  89473. * Function used to align with Node.getChildren()
  89474. * @returns the list of Materials used within the multi material
  89475. */
  89476. getChildren(): Nullable<Material>[];
  89477. /**
  89478. * Instantiates a new Multi Material
  89479. * A multi-material is used to apply different materials to different parts of the same object without the need of
  89480. * separate meshes. This can be use to improve performances.
  89481. * @see http://doc.babylonjs.com/how_to/multi_materials
  89482. * @param name Define the name in the scene
  89483. * @param scene Define the scene the material belongs to
  89484. */
  89485. constructor(name: string, scene: Scene);
  89486. private _hookArray;
  89487. /**
  89488. * Get one of the submaterial by its index in the submaterials array
  89489. * @param index The index to look the sub material at
  89490. * @returns The Material if the index has been defined
  89491. */
  89492. getSubMaterial(index: number): Nullable<Material>;
  89493. /**
  89494. * Get the list of active textures for the whole sub materials list.
  89495. * @returns All the textures that will be used during the rendering
  89496. */
  89497. getActiveTextures(): BaseTexture[];
  89498. /**
  89499. * Gets the current class name of the material e.g. "MultiMaterial"
  89500. * Mainly use in serialization.
  89501. * @returns the class name
  89502. */
  89503. getClassName(): string;
  89504. /**
  89505. * Checks if the material is ready to render the requested sub mesh
  89506. * @param mesh Define the mesh the submesh belongs to
  89507. * @param subMesh Define the sub mesh to look readyness for
  89508. * @param useInstances Define whether or not the material is used with instances
  89509. * @returns true if ready, otherwise false
  89510. */
  89511. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  89512. /**
  89513. * Clones the current material and its related sub materials
  89514. * @param name Define the name of the newly cloned material
  89515. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  89516. * @returns the cloned material
  89517. */
  89518. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  89519. /**
  89520. * Serializes the materials into a JSON representation.
  89521. * @returns the JSON representation
  89522. */
  89523. serialize(): any;
  89524. /**
  89525. * Dispose the material and release its associated resources
  89526. * @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)
  89527. * @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)
  89528. * @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)
  89529. */
  89530. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  89531. /**
  89532. * Creates a MultiMaterial from parsed MultiMaterial data.
  89533. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  89534. * @param scene defines the hosting scene
  89535. * @returns a new MultiMaterial
  89536. */
  89537. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  89538. }
  89539. }
  89540. declare module BABYLON {
  89541. /**
  89542. * Base class for submeshes
  89543. */
  89544. export class BaseSubMesh {
  89545. /** @hidden */
  89546. _materialDefines: Nullable<MaterialDefines>;
  89547. /** @hidden */
  89548. _materialEffect: Nullable<Effect>;
  89549. /**
  89550. * Gets associated effect
  89551. */
  89552. readonly effect: Nullable<Effect>;
  89553. /**
  89554. * Sets associated effect (effect used to render this submesh)
  89555. * @param effect defines the effect to associate with
  89556. * @param defines defines the set of defines used to compile this effect
  89557. */
  89558. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  89559. }
  89560. /**
  89561. * Defines a subdivision inside a mesh
  89562. */
  89563. export class SubMesh extends BaseSubMesh implements ICullable {
  89564. /** the material index to use */
  89565. materialIndex: number;
  89566. /** vertex index start */
  89567. verticesStart: number;
  89568. /** vertices count */
  89569. verticesCount: number;
  89570. /** index start */
  89571. indexStart: number;
  89572. /** indices count */
  89573. indexCount: number;
  89574. /** @hidden */
  89575. _linesIndexCount: number;
  89576. private _mesh;
  89577. private _renderingMesh;
  89578. private _boundingInfo;
  89579. private _linesIndexBuffer;
  89580. /** @hidden */
  89581. _lastColliderWorldVertices: Nullable<Vector3[]>;
  89582. /** @hidden */
  89583. _trianglePlanes: Plane[];
  89584. /** @hidden */
  89585. _lastColliderTransformMatrix: Nullable<Matrix>;
  89586. /** @hidden */
  89587. _renderId: number;
  89588. /** @hidden */
  89589. _alphaIndex: number;
  89590. /** @hidden */
  89591. _distanceToCamera: number;
  89592. /** @hidden */
  89593. _id: number;
  89594. private _currentMaterial;
  89595. /**
  89596. * Add a new submesh to a mesh
  89597. * @param materialIndex defines the material index to use
  89598. * @param verticesStart defines vertex index start
  89599. * @param verticesCount defines vertices count
  89600. * @param indexStart defines index start
  89601. * @param indexCount defines indices count
  89602. * @param mesh defines the parent mesh
  89603. * @param renderingMesh defines an optional rendering mesh
  89604. * @param createBoundingBox defines if bounding box should be created for this submesh
  89605. * @returns the new submesh
  89606. */
  89607. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  89608. /**
  89609. * Creates a new submesh
  89610. * @param materialIndex defines the material index to use
  89611. * @param verticesStart defines vertex index start
  89612. * @param verticesCount defines vertices count
  89613. * @param indexStart defines index start
  89614. * @param indexCount defines indices count
  89615. * @param mesh defines the parent mesh
  89616. * @param renderingMesh defines an optional rendering mesh
  89617. * @param createBoundingBox defines if bounding box should be created for this submesh
  89618. */
  89619. constructor(
  89620. /** the material index to use */
  89621. materialIndex: number,
  89622. /** vertex index start */
  89623. verticesStart: number,
  89624. /** vertices count */
  89625. verticesCount: number,
  89626. /** index start */
  89627. indexStart: number,
  89628. /** indices count */
  89629. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  89630. /**
  89631. * Returns true if this submesh covers the entire parent mesh
  89632. * @ignorenaming
  89633. */
  89634. readonly IsGlobal: boolean;
  89635. /**
  89636. * Returns the submesh BoudingInfo object
  89637. * @returns current bounding info (or mesh's one if the submesh is global)
  89638. */
  89639. getBoundingInfo(): BoundingInfo;
  89640. /**
  89641. * Sets the submesh BoundingInfo
  89642. * @param boundingInfo defines the new bounding info to use
  89643. * @returns the SubMesh
  89644. */
  89645. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  89646. /**
  89647. * Returns the mesh of the current submesh
  89648. * @return the parent mesh
  89649. */
  89650. getMesh(): AbstractMesh;
  89651. /**
  89652. * Returns the rendering mesh of the submesh
  89653. * @returns the rendering mesh (could be different from parent mesh)
  89654. */
  89655. getRenderingMesh(): Mesh;
  89656. /**
  89657. * Returns the submesh material
  89658. * @returns null or the current material
  89659. */
  89660. getMaterial(): Nullable<Material>;
  89661. /**
  89662. * Sets a new updated BoundingInfo object to the submesh
  89663. * @param data defines an optional position array to use to determine the bounding info
  89664. * @returns the SubMesh
  89665. */
  89666. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  89667. /** @hidden */
  89668. _checkCollision(collider: Collider): boolean;
  89669. /**
  89670. * Updates the submesh BoundingInfo
  89671. * @param world defines the world matrix to use to update the bounding info
  89672. * @returns the submesh
  89673. */
  89674. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  89675. /**
  89676. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  89677. * @param frustumPlanes defines the frustum planes
  89678. * @returns true if the submesh is intersecting with the frustum
  89679. */
  89680. isInFrustum(frustumPlanes: Plane[]): boolean;
  89681. /**
  89682. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  89683. * @param frustumPlanes defines the frustum planes
  89684. * @returns true if the submesh is inside the frustum
  89685. */
  89686. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  89687. /**
  89688. * Renders the submesh
  89689. * @param enableAlphaMode defines if alpha needs to be used
  89690. * @returns the submesh
  89691. */
  89692. render(enableAlphaMode: boolean): SubMesh;
  89693. /**
  89694. * @hidden
  89695. */
  89696. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  89697. /**
  89698. * Checks if the submesh intersects with a ray
  89699. * @param ray defines the ray to test
  89700. * @returns true is the passed ray intersects the submesh bounding box
  89701. */
  89702. canIntersects(ray: Ray): boolean;
  89703. /**
  89704. * Intersects current submesh with a ray
  89705. * @param ray defines the ray to test
  89706. * @param positions defines mesh's positions array
  89707. * @param indices defines mesh's indices array
  89708. * @param fastCheck defines if only bounding info should be used
  89709. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  89710. * @returns intersection info or null if no intersection
  89711. */
  89712. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  89713. /** @hidden */
  89714. private _intersectLines;
  89715. /** @hidden */
  89716. private _intersectUnIndexedLines;
  89717. /** @hidden */
  89718. private _intersectTriangles;
  89719. /** @hidden */
  89720. private _intersectUnIndexedTriangles;
  89721. /** @hidden */
  89722. _rebuild(): void;
  89723. /**
  89724. * Creates a new submesh from the passed mesh
  89725. * @param newMesh defines the new hosting mesh
  89726. * @param newRenderingMesh defines an optional rendering mesh
  89727. * @returns the new submesh
  89728. */
  89729. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  89730. /**
  89731. * Release associated resources
  89732. */
  89733. dispose(): void;
  89734. /**
  89735. * Gets the class name
  89736. * @returns the string "SubMesh".
  89737. */
  89738. getClassName(): string;
  89739. /**
  89740. * Creates a new submesh from indices data
  89741. * @param materialIndex the index of the main mesh material
  89742. * @param startIndex the index where to start the copy in the mesh indices array
  89743. * @param indexCount the number of indices to copy then from the startIndex
  89744. * @param mesh the main mesh to create the submesh from
  89745. * @param renderingMesh the optional rendering mesh
  89746. * @returns a new submesh
  89747. */
  89748. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  89749. }
  89750. }
  89751. declare module BABYLON {
  89752. /**
  89753. * Class used to represent data loading progression
  89754. */
  89755. export class SceneLoaderFlags {
  89756. private static _ForceFullSceneLoadingForIncremental;
  89757. private static _ShowLoadingScreen;
  89758. private static _CleanBoneMatrixWeights;
  89759. private static _loggingLevel;
  89760. /**
  89761. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  89762. */
  89763. static ForceFullSceneLoadingForIncremental: boolean;
  89764. /**
  89765. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  89766. */
  89767. static ShowLoadingScreen: boolean;
  89768. /**
  89769. * Defines the current logging level (while loading the scene)
  89770. * @ignorenaming
  89771. */
  89772. static loggingLevel: number;
  89773. /**
  89774. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  89775. */
  89776. static CleanBoneMatrixWeights: boolean;
  89777. }
  89778. }
  89779. declare module BABYLON {
  89780. /**
  89781. * Class used to store geometry data (vertex buffers + index buffer)
  89782. */
  89783. export class Geometry implements IGetSetVerticesData {
  89784. /**
  89785. * Gets or sets the ID of the geometry
  89786. */
  89787. id: string;
  89788. /**
  89789. * Gets or sets the unique ID of the geometry
  89790. */
  89791. uniqueId: number;
  89792. /**
  89793. * Gets the delay loading state of the geometry (none by default which means not delayed)
  89794. */
  89795. delayLoadState: number;
  89796. /**
  89797. * Gets the file containing the data to load when running in delay load state
  89798. */
  89799. delayLoadingFile: Nullable<string>;
  89800. /**
  89801. * Callback called when the geometry is updated
  89802. */
  89803. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  89804. private _scene;
  89805. private _engine;
  89806. private _meshes;
  89807. private _totalVertices;
  89808. /** @hidden */
  89809. _indices: IndicesArray;
  89810. /** @hidden */
  89811. _vertexBuffers: {
  89812. [key: string]: VertexBuffer;
  89813. };
  89814. private _isDisposed;
  89815. private _extend;
  89816. private _boundingBias;
  89817. /** @hidden */
  89818. _delayInfo: Array<string>;
  89819. private _indexBuffer;
  89820. private _indexBufferIsUpdatable;
  89821. /** @hidden */
  89822. _boundingInfo: Nullable<BoundingInfo>;
  89823. /** @hidden */
  89824. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  89825. /** @hidden */
  89826. _softwareSkinningFrameId: number;
  89827. private _vertexArrayObjects;
  89828. private _updatable;
  89829. /** @hidden */
  89830. _positions: Nullable<Vector3[]>;
  89831. /**
  89832. * 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
  89833. */
  89834. /**
  89835. * 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
  89836. */
  89837. boundingBias: Vector2;
  89838. /**
  89839. * Static function used to attach a new empty geometry to a mesh
  89840. * @param mesh defines the mesh to attach the geometry to
  89841. * @returns the new Geometry
  89842. */
  89843. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  89844. /**
  89845. * Creates a new geometry
  89846. * @param id defines the unique ID
  89847. * @param scene defines the hosting scene
  89848. * @param vertexData defines the VertexData used to get geometry data
  89849. * @param updatable defines if geometry must be updatable (false by default)
  89850. * @param mesh defines the mesh that will be associated with the geometry
  89851. */
  89852. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  89853. /**
  89854. * Gets the current extend of the geometry
  89855. */
  89856. readonly extend: {
  89857. minimum: Vector3;
  89858. maximum: Vector3;
  89859. };
  89860. /**
  89861. * Gets the hosting scene
  89862. * @returns the hosting Scene
  89863. */
  89864. getScene(): Scene;
  89865. /**
  89866. * Gets the hosting engine
  89867. * @returns the hosting Engine
  89868. */
  89869. getEngine(): Engine;
  89870. /**
  89871. * Defines if the geometry is ready to use
  89872. * @returns true if the geometry is ready to be used
  89873. */
  89874. isReady(): boolean;
  89875. /**
  89876. * Gets a value indicating that the geometry should not be serialized
  89877. */
  89878. readonly doNotSerialize: boolean;
  89879. /** @hidden */
  89880. _rebuild(): void;
  89881. /**
  89882. * Affects all geometry data in one call
  89883. * @param vertexData defines the geometry data
  89884. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  89885. */
  89886. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  89887. /**
  89888. * Set specific vertex data
  89889. * @param kind defines the data kind (Position, normal, etc...)
  89890. * @param data defines the vertex data to use
  89891. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  89892. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  89893. */
  89894. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  89895. /**
  89896. * Removes a specific vertex data
  89897. * @param kind defines the data kind (Position, normal, etc...)
  89898. */
  89899. removeVerticesData(kind: string): void;
  89900. /**
  89901. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  89902. * @param buffer defines the vertex buffer to use
  89903. * @param totalVertices defines the total number of vertices for position kind (could be null)
  89904. */
  89905. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  89906. /**
  89907. * Update a specific vertex buffer
  89908. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  89909. * It will do nothing if the buffer is not updatable
  89910. * @param kind defines the data kind (Position, normal, etc...)
  89911. * @param data defines the data to use
  89912. * @param offset defines the offset in the target buffer where to store the data
  89913. * @param useBytes set to true if the offset is in bytes
  89914. */
  89915. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  89916. /**
  89917. * Update a specific vertex buffer
  89918. * This function will create a new buffer if the current one is not updatable
  89919. * @param kind defines the data kind (Position, normal, etc...)
  89920. * @param data defines the data to use
  89921. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  89922. */
  89923. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  89924. private _updateBoundingInfo;
  89925. /** @hidden */
  89926. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  89927. /**
  89928. * Gets total number of vertices
  89929. * @returns the total number of vertices
  89930. */
  89931. getTotalVertices(): number;
  89932. /**
  89933. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  89934. * @param kind defines the data kind (Position, normal, etc...)
  89935. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  89936. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  89937. * @returns a float array containing vertex data
  89938. */
  89939. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  89940. /**
  89941. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  89942. * @param kind defines the data kind (Position, normal, etc...)
  89943. * @returns true if the vertex buffer with the specified kind is updatable
  89944. */
  89945. isVertexBufferUpdatable(kind: string): boolean;
  89946. /**
  89947. * Gets a specific vertex buffer
  89948. * @param kind defines the data kind (Position, normal, etc...)
  89949. * @returns a VertexBuffer
  89950. */
  89951. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  89952. /**
  89953. * Returns all vertex buffers
  89954. * @return an object holding all vertex buffers indexed by kind
  89955. */
  89956. getVertexBuffers(): Nullable<{
  89957. [key: string]: VertexBuffer;
  89958. }>;
  89959. /**
  89960. * Gets a boolean indicating if specific vertex buffer is present
  89961. * @param kind defines the data kind (Position, normal, etc...)
  89962. * @returns true if data is present
  89963. */
  89964. isVerticesDataPresent(kind: string): boolean;
  89965. /**
  89966. * Gets a list of all attached data kinds (Position, normal, etc...)
  89967. * @returns a list of string containing all kinds
  89968. */
  89969. getVerticesDataKinds(): string[];
  89970. /**
  89971. * Update index buffer
  89972. * @param indices defines the indices to store in the index buffer
  89973. * @param offset defines the offset in the target buffer where to store the data
  89974. * @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)
  89975. */
  89976. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  89977. /**
  89978. * Creates a new index buffer
  89979. * @param indices defines the indices to store in the index buffer
  89980. * @param totalVertices defines the total number of vertices (could be null)
  89981. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  89982. */
  89983. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  89984. /**
  89985. * Return the total number of indices
  89986. * @returns the total number of indices
  89987. */
  89988. getTotalIndices(): number;
  89989. /**
  89990. * Gets the index buffer array
  89991. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  89992. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  89993. * @returns the index buffer array
  89994. */
  89995. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  89996. /**
  89997. * Gets the index buffer
  89998. * @return the index buffer
  89999. */
  90000. getIndexBuffer(): Nullable<DataBuffer>;
  90001. /** @hidden */
  90002. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  90003. /**
  90004. * Release the associated resources for a specific mesh
  90005. * @param mesh defines the source mesh
  90006. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  90007. */
  90008. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  90009. /**
  90010. * Apply current geometry to a given mesh
  90011. * @param mesh defines the mesh to apply geometry to
  90012. */
  90013. applyToMesh(mesh: Mesh): void;
  90014. private _updateExtend;
  90015. private _applyToMesh;
  90016. private notifyUpdate;
  90017. /**
  90018. * Load the geometry if it was flagged as delay loaded
  90019. * @param scene defines the hosting scene
  90020. * @param onLoaded defines a callback called when the geometry is loaded
  90021. */
  90022. load(scene: Scene, onLoaded?: () => void): void;
  90023. private _queueLoad;
  90024. /**
  90025. * Invert the geometry to move from a right handed system to a left handed one.
  90026. */
  90027. toLeftHanded(): void;
  90028. /** @hidden */
  90029. _resetPointsArrayCache(): void;
  90030. /** @hidden */
  90031. _generatePointsArray(): boolean;
  90032. /**
  90033. * Gets a value indicating if the geometry is disposed
  90034. * @returns true if the geometry was disposed
  90035. */
  90036. isDisposed(): boolean;
  90037. private _disposeVertexArrayObjects;
  90038. /**
  90039. * Free all associated resources
  90040. */
  90041. dispose(): void;
  90042. /**
  90043. * Clone the current geometry into a new geometry
  90044. * @param id defines the unique ID of the new geometry
  90045. * @returns a new geometry object
  90046. */
  90047. copy(id: string): Geometry;
  90048. /**
  90049. * Serialize the current geometry info (and not the vertices data) into a JSON object
  90050. * @return a JSON representation of the current geometry data (without the vertices data)
  90051. */
  90052. serialize(): any;
  90053. private toNumberArray;
  90054. /**
  90055. * Serialize all vertices data into a JSON oject
  90056. * @returns a JSON representation of the current geometry data
  90057. */
  90058. serializeVerticeData(): any;
  90059. /**
  90060. * Extracts a clone of a mesh geometry
  90061. * @param mesh defines the source mesh
  90062. * @param id defines the unique ID of the new geometry object
  90063. * @returns the new geometry object
  90064. */
  90065. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  90066. /**
  90067. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  90068. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  90069. * Be aware Math.random() could cause collisions, but:
  90070. * "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"
  90071. * @returns a string containing a new GUID
  90072. */
  90073. static RandomId(): string;
  90074. /** @hidden */
  90075. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  90076. private static _CleanMatricesWeights;
  90077. /**
  90078. * Create a new geometry from persisted data (Using .babylon file format)
  90079. * @param parsedVertexData defines the persisted data
  90080. * @param scene defines the hosting scene
  90081. * @param rootUrl defines the root url to use to load assets (like delayed data)
  90082. * @returns the new geometry object
  90083. */
  90084. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  90085. }
  90086. }
  90087. declare module BABYLON {
  90088. /**
  90089. * Define an interface for all classes that will get and set the data on vertices
  90090. */
  90091. export interface IGetSetVerticesData {
  90092. /**
  90093. * Gets a boolean indicating if specific vertex data is present
  90094. * @param kind defines the vertex data kind to use
  90095. * @returns true is data kind is present
  90096. */
  90097. isVerticesDataPresent(kind: string): boolean;
  90098. /**
  90099. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  90100. * @param kind defines the data kind (Position, normal, etc...)
  90101. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  90102. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  90103. * @returns a float array containing vertex data
  90104. */
  90105. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  90106. /**
  90107. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  90108. * @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.
  90109. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  90110. * @returns the indices array or an empty array if the mesh has no geometry
  90111. */
  90112. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  90113. /**
  90114. * Set specific vertex data
  90115. * @param kind defines the data kind (Position, normal, etc...)
  90116. * @param data defines the vertex data to use
  90117. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  90118. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  90119. */
  90120. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  90121. /**
  90122. * Update a specific associated vertex buffer
  90123. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  90124. * - VertexBuffer.PositionKind
  90125. * - VertexBuffer.UVKind
  90126. * - VertexBuffer.UV2Kind
  90127. * - VertexBuffer.UV3Kind
  90128. * - VertexBuffer.UV4Kind
  90129. * - VertexBuffer.UV5Kind
  90130. * - VertexBuffer.UV6Kind
  90131. * - VertexBuffer.ColorKind
  90132. * - VertexBuffer.MatricesIndicesKind
  90133. * - VertexBuffer.MatricesIndicesExtraKind
  90134. * - VertexBuffer.MatricesWeightsKind
  90135. * - VertexBuffer.MatricesWeightsExtraKind
  90136. * @param data defines the data source
  90137. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  90138. * @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)
  90139. */
  90140. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  90141. /**
  90142. * Creates a new index buffer
  90143. * @param indices defines the indices to store in the index buffer
  90144. * @param totalVertices defines the total number of vertices (could be null)
  90145. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  90146. */
  90147. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  90148. }
  90149. /**
  90150. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  90151. */
  90152. export class VertexData {
  90153. /**
  90154. * Mesh side orientation : usually the external or front surface
  90155. */
  90156. static readonly FRONTSIDE: number;
  90157. /**
  90158. * Mesh side orientation : usually the internal or back surface
  90159. */
  90160. static readonly BACKSIDE: number;
  90161. /**
  90162. * Mesh side orientation : both internal and external or front and back surfaces
  90163. */
  90164. static readonly DOUBLESIDE: number;
  90165. /**
  90166. * Mesh side orientation : by default, `FRONTSIDE`
  90167. */
  90168. static readonly DEFAULTSIDE: number;
  90169. /**
  90170. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  90171. */
  90172. positions: Nullable<FloatArray>;
  90173. /**
  90174. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  90175. */
  90176. normals: Nullable<FloatArray>;
  90177. /**
  90178. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  90179. */
  90180. tangents: Nullable<FloatArray>;
  90181. /**
  90182. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  90183. */
  90184. uvs: Nullable<FloatArray>;
  90185. /**
  90186. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  90187. */
  90188. uvs2: Nullable<FloatArray>;
  90189. /**
  90190. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  90191. */
  90192. uvs3: Nullable<FloatArray>;
  90193. /**
  90194. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  90195. */
  90196. uvs4: Nullable<FloatArray>;
  90197. /**
  90198. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  90199. */
  90200. uvs5: Nullable<FloatArray>;
  90201. /**
  90202. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  90203. */
  90204. uvs6: Nullable<FloatArray>;
  90205. /**
  90206. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  90207. */
  90208. colors: Nullable<FloatArray>;
  90209. /**
  90210. * 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).
  90211. */
  90212. matricesIndices: Nullable<FloatArray>;
  90213. /**
  90214. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  90215. */
  90216. matricesWeights: Nullable<FloatArray>;
  90217. /**
  90218. * An array extending the number of possible indices
  90219. */
  90220. matricesIndicesExtra: Nullable<FloatArray>;
  90221. /**
  90222. * An array extending the number of possible weights when the number of indices is extended
  90223. */
  90224. matricesWeightsExtra: Nullable<FloatArray>;
  90225. /**
  90226. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  90227. */
  90228. indices: Nullable<IndicesArray>;
  90229. /**
  90230. * Uses the passed data array to set the set the values for the specified kind of data
  90231. * @param data a linear array of floating numbers
  90232. * @param kind the type of data that is being set, eg positions, colors etc
  90233. */
  90234. set(data: FloatArray, kind: string): void;
  90235. /**
  90236. * Associates the vertexData to the passed Mesh.
  90237. * Sets it as updatable or not (default `false`)
  90238. * @param mesh the mesh the vertexData is applied to
  90239. * @param updatable when used and having the value true allows new data to update the vertexData
  90240. * @returns the VertexData
  90241. */
  90242. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  90243. /**
  90244. * Associates the vertexData to the passed Geometry.
  90245. * Sets it as updatable or not (default `false`)
  90246. * @param geometry the geometry the vertexData is applied to
  90247. * @param updatable when used and having the value true allows new data to update the vertexData
  90248. * @returns VertexData
  90249. */
  90250. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  90251. /**
  90252. * Updates the associated mesh
  90253. * @param mesh the mesh to be updated
  90254. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  90255. * @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
  90256. * @returns VertexData
  90257. */
  90258. updateMesh(mesh: Mesh): VertexData;
  90259. /**
  90260. * Updates the associated geometry
  90261. * @param geometry the geometry to be updated
  90262. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  90263. * @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
  90264. * @returns VertexData.
  90265. */
  90266. updateGeometry(geometry: Geometry): VertexData;
  90267. private _applyTo;
  90268. private _update;
  90269. /**
  90270. * Transforms each position and each normal of the vertexData according to the passed Matrix
  90271. * @param matrix the transforming matrix
  90272. * @returns the VertexData
  90273. */
  90274. transform(matrix: Matrix): VertexData;
  90275. /**
  90276. * Merges the passed VertexData into the current one
  90277. * @param other the VertexData to be merged into the current one
  90278. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  90279. * @returns the modified VertexData
  90280. */
  90281. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  90282. private _mergeElement;
  90283. private _validate;
  90284. /**
  90285. * Serializes the VertexData
  90286. * @returns a serialized object
  90287. */
  90288. serialize(): any;
  90289. /**
  90290. * Extracts the vertexData from a mesh
  90291. * @param mesh the mesh from which to extract the VertexData
  90292. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  90293. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  90294. * @returns the object VertexData associated to the passed mesh
  90295. */
  90296. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  90297. /**
  90298. * Extracts the vertexData from the geometry
  90299. * @param geometry the geometry from which to extract the VertexData
  90300. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  90301. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  90302. * @returns the object VertexData associated to the passed mesh
  90303. */
  90304. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  90305. private static _ExtractFrom;
  90306. /**
  90307. * Creates the VertexData for a Ribbon
  90308. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  90309. * * pathArray array of paths, each of which an array of successive Vector3
  90310. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  90311. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  90312. * * 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
  90313. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90314. * * 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)
  90315. * * 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)
  90316. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  90317. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  90318. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  90319. * @returns the VertexData of the ribbon
  90320. */
  90321. static CreateRibbon(options: {
  90322. pathArray: Vector3[][];
  90323. closeArray?: boolean;
  90324. closePath?: boolean;
  90325. offset?: number;
  90326. sideOrientation?: number;
  90327. frontUVs?: Vector4;
  90328. backUVs?: Vector4;
  90329. invertUV?: boolean;
  90330. uvs?: Vector2[];
  90331. colors?: Color4[];
  90332. }): VertexData;
  90333. /**
  90334. * Creates the VertexData for a box
  90335. * @param options an object used to set the following optional parameters for the box, required but can be empty
  90336. * * size sets the width, height and depth of the box to the value of size, optional default 1
  90337. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  90338. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  90339. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  90340. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  90341. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  90342. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90343. * * 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)
  90344. * * 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)
  90345. * @returns the VertexData of the box
  90346. */
  90347. static CreateBox(options: {
  90348. size?: number;
  90349. width?: number;
  90350. height?: number;
  90351. depth?: number;
  90352. faceUV?: Vector4[];
  90353. faceColors?: Color4[];
  90354. sideOrientation?: number;
  90355. frontUVs?: Vector4;
  90356. backUVs?: Vector4;
  90357. }): VertexData;
  90358. /**
  90359. * Creates the VertexData for a tiled box
  90360. * @param options an object used to set the following optional parameters for the box, required but can be empty
  90361. * * faceTiles sets the pattern, tile size and number of tiles for a face
  90362. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  90363. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  90364. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90365. * @returns the VertexData of the box
  90366. */
  90367. static CreateTiledBox(options: {
  90368. pattern?: number;
  90369. width?: number;
  90370. height?: number;
  90371. depth?: number;
  90372. tileSize?: number;
  90373. tileWidth?: number;
  90374. tileHeight?: number;
  90375. alignHorizontal?: number;
  90376. alignVertical?: number;
  90377. faceUV?: Vector4[];
  90378. faceColors?: Color4[];
  90379. sideOrientation?: number;
  90380. }): VertexData;
  90381. /**
  90382. * Creates the VertexData for a tiled plane
  90383. * @param options an object used to set the following optional parameters for the box, required but can be empty
  90384. * * pattern a limited pattern arrangement depending on the number
  90385. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  90386. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  90387. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  90388. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90389. * * 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)
  90390. * * 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)
  90391. * @returns the VertexData of the tiled plane
  90392. */
  90393. static CreateTiledPlane(options: {
  90394. pattern?: number;
  90395. tileSize?: number;
  90396. tileWidth?: number;
  90397. tileHeight?: number;
  90398. size?: number;
  90399. width?: number;
  90400. height?: number;
  90401. alignHorizontal?: number;
  90402. alignVertical?: number;
  90403. sideOrientation?: number;
  90404. frontUVs?: Vector4;
  90405. backUVs?: Vector4;
  90406. }): VertexData;
  90407. /**
  90408. * Creates the VertexData for an ellipsoid, defaults to a sphere
  90409. * @param options an object used to set the following optional parameters for the box, required but can be empty
  90410. * * segments sets the number of horizontal strips optional, default 32
  90411. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  90412. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  90413. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  90414. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  90415. * * 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
  90416. * * 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
  90417. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90418. * * 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)
  90419. * * 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)
  90420. * @returns the VertexData of the ellipsoid
  90421. */
  90422. static CreateSphere(options: {
  90423. segments?: number;
  90424. diameter?: number;
  90425. diameterX?: number;
  90426. diameterY?: number;
  90427. diameterZ?: number;
  90428. arc?: number;
  90429. slice?: number;
  90430. sideOrientation?: number;
  90431. frontUVs?: Vector4;
  90432. backUVs?: Vector4;
  90433. }): VertexData;
  90434. /**
  90435. * Creates the VertexData for a cylinder, cone or prism
  90436. * @param options an object used to set the following optional parameters for the box, required but can be empty
  90437. * * height sets the height (y direction) of the cylinder, optional, default 2
  90438. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  90439. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  90440. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  90441. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  90442. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  90443. * * 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
  90444. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  90445. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  90446. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  90447. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  90448. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90449. * * 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)
  90450. * * 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)
  90451. * @returns the VertexData of the cylinder, cone or prism
  90452. */
  90453. static CreateCylinder(options: {
  90454. height?: number;
  90455. diameterTop?: number;
  90456. diameterBottom?: number;
  90457. diameter?: number;
  90458. tessellation?: number;
  90459. subdivisions?: number;
  90460. arc?: number;
  90461. faceColors?: Color4[];
  90462. faceUV?: Vector4[];
  90463. hasRings?: boolean;
  90464. enclose?: boolean;
  90465. sideOrientation?: number;
  90466. frontUVs?: Vector4;
  90467. backUVs?: Vector4;
  90468. }): VertexData;
  90469. /**
  90470. * Creates the VertexData for a torus
  90471. * @param options an object used to set the following optional parameters for the box, required but can be empty
  90472. * * diameter the diameter of the torus, optional default 1
  90473. * * thickness the diameter of the tube forming the torus, optional default 0.5
  90474. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  90475. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90476. * * 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)
  90477. * * 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)
  90478. * @returns the VertexData of the torus
  90479. */
  90480. static CreateTorus(options: {
  90481. diameter?: number;
  90482. thickness?: number;
  90483. tessellation?: number;
  90484. sideOrientation?: number;
  90485. frontUVs?: Vector4;
  90486. backUVs?: Vector4;
  90487. }): VertexData;
  90488. /**
  90489. * Creates the VertexData of the LineSystem
  90490. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  90491. * - lines an array of lines, each line being an array of successive Vector3
  90492. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  90493. * @returns the VertexData of the LineSystem
  90494. */
  90495. static CreateLineSystem(options: {
  90496. lines: Vector3[][];
  90497. colors?: Nullable<Color4[][]>;
  90498. }): VertexData;
  90499. /**
  90500. * Create the VertexData for a DashedLines
  90501. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  90502. * - points an array successive Vector3
  90503. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  90504. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  90505. * - dashNb the intended total number of dashes, optional, default 200
  90506. * @returns the VertexData for the DashedLines
  90507. */
  90508. static CreateDashedLines(options: {
  90509. points: Vector3[];
  90510. dashSize?: number;
  90511. gapSize?: number;
  90512. dashNb?: number;
  90513. }): VertexData;
  90514. /**
  90515. * Creates the VertexData for a Ground
  90516. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  90517. * - width the width (x direction) of the ground, optional, default 1
  90518. * - height the height (z direction) of the ground, optional, default 1
  90519. * - subdivisions the number of subdivisions per side, optional, default 1
  90520. * @returns the VertexData of the Ground
  90521. */
  90522. static CreateGround(options: {
  90523. width?: number;
  90524. height?: number;
  90525. subdivisions?: number;
  90526. subdivisionsX?: number;
  90527. subdivisionsY?: number;
  90528. }): VertexData;
  90529. /**
  90530. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  90531. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  90532. * * xmin the ground minimum X coordinate, optional, default -1
  90533. * * zmin the ground minimum Z coordinate, optional, default -1
  90534. * * xmax the ground maximum X coordinate, optional, default 1
  90535. * * zmax the ground maximum Z coordinate, optional, default 1
  90536. * * 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}
  90537. * * 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}
  90538. * @returns the VertexData of the TiledGround
  90539. */
  90540. static CreateTiledGround(options: {
  90541. xmin: number;
  90542. zmin: number;
  90543. xmax: number;
  90544. zmax: number;
  90545. subdivisions?: {
  90546. w: number;
  90547. h: number;
  90548. };
  90549. precision?: {
  90550. w: number;
  90551. h: number;
  90552. };
  90553. }): VertexData;
  90554. /**
  90555. * Creates the VertexData of the Ground designed from a heightmap
  90556. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  90557. * * width the width (x direction) of the ground
  90558. * * height the height (z direction) of the ground
  90559. * * subdivisions the number of subdivisions per side
  90560. * * minHeight the minimum altitude on the ground, optional, default 0
  90561. * * maxHeight the maximum altitude on the ground, optional default 1
  90562. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  90563. * * buffer the array holding the image color data
  90564. * * bufferWidth the width of image
  90565. * * bufferHeight the height of image
  90566. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  90567. * @returns the VertexData of the Ground designed from a heightmap
  90568. */
  90569. static CreateGroundFromHeightMap(options: {
  90570. width: number;
  90571. height: number;
  90572. subdivisions: number;
  90573. minHeight: number;
  90574. maxHeight: number;
  90575. colorFilter: Color3;
  90576. buffer: Uint8Array;
  90577. bufferWidth: number;
  90578. bufferHeight: number;
  90579. alphaFilter: number;
  90580. }): VertexData;
  90581. /**
  90582. * Creates the VertexData for a Plane
  90583. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  90584. * * size sets the width and height of the plane to the value of size, optional default 1
  90585. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  90586. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  90587. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90588. * * 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)
  90589. * * 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)
  90590. * @returns the VertexData of the box
  90591. */
  90592. static CreatePlane(options: {
  90593. size?: number;
  90594. width?: number;
  90595. height?: number;
  90596. sideOrientation?: number;
  90597. frontUVs?: Vector4;
  90598. backUVs?: Vector4;
  90599. }): VertexData;
  90600. /**
  90601. * Creates the VertexData of the Disc or regular Polygon
  90602. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  90603. * * radius the radius of the disc, optional default 0.5
  90604. * * tessellation the number of polygon sides, optional, default 64
  90605. * * 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
  90606. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90607. * * 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)
  90608. * * 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)
  90609. * @returns the VertexData of the box
  90610. */
  90611. static CreateDisc(options: {
  90612. radius?: number;
  90613. tessellation?: number;
  90614. arc?: number;
  90615. sideOrientation?: number;
  90616. frontUVs?: Vector4;
  90617. backUVs?: Vector4;
  90618. }): VertexData;
  90619. /**
  90620. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  90621. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  90622. * @param polygon a mesh built from polygonTriangulation.build()
  90623. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90624. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  90625. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  90626. * @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)
  90627. * @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)
  90628. * @returns the VertexData of the Polygon
  90629. */
  90630. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  90631. /**
  90632. * Creates the VertexData of the IcoSphere
  90633. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  90634. * * radius the radius of the IcoSphere, optional default 1
  90635. * * radiusX allows stretching in the x direction, optional, default radius
  90636. * * radiusY allows stretching in the y direction, optional, default radius
  90637. * * radiusZ allows stretching in the z direction, optional, default radius
  90638. * * flat when true creates a flat shaded mesh, optional, default true
  90639. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  90640. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90641. * * 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)
  90642. * * 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)
  90643. * @returns the VertexData of the IcoSphere
  90644. */
  90645. static CreateIcoSphere(options: {
  90646. radius?: number;
  90647. radiusX?: number;
  90648. radiusY?: number;
  90649. radiusZ?: number;
  90650. flat?: boolean;
  90651. subdivisions?: number;
  90652. sideOrientation?: number;
  90653. frontUVs?: Vector4;
  90654. backUVs?: Vector4;
  90655. }): VertexData;
  90656. /**
  90657. * Creates the VertexData for a Polyhedron
  90658. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  90659. * * type provided types are:
  90660. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  90661. * * 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)
  90662. * * size the size of the IcoSphere, optional default 1
  90663. * * sizeX allows stretching in the x direction, optional, default size
  90664. * * sizeY allows stretching in the y direction, optional, default size
  90665. * * sizeZ allows stretching in the z direction, optional, default size
  90666. * * 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
  90667. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  90668. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  90669. * * flat when true creates a flat shaded mesh, optional, default true
  90670. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  90671. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90672. * * 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)
  90673. * * 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)
  90674. * @returns the VertexData of the Polyhedron
  90675. */
  90676. static CreatePolyhedron(options: {
  90677. type?: number;
  90678. size?: number;
  90679. sizeX?: number;
  90680. sizeY?: number;
  90681. sizeZ?: number;
  90682. custom?: any;
  90683. faceUV?: Vector4[];
  90684. faceColors?: Color4[];
  90685. flat?: boolean;
  90686. sideOrientation?: number;
  90687. frontUVs?: Vector4;
  90688. backUVs?: Vector4;
  90689. }): VertexData;
  90690. /**
  90691. * Creates the VertexData for a TorusKnot
  90692. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  90693. * * radius the radius of the torus knot, optional, default 2
  90694. * * tube the thickness of the tube, optional, default 0.5
  90695. * * radialSegments the number of sides on each tube segments, optional, default 32
  90696. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  90697. * * p the number of windings around the z axis, optional, default 2
  90698. * * q the number of windings around the x axis, optional, default 3
  90699. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90700. * * 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)
  90701. * * 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)
  90702. * @returns the VertexData of the Torus Knot
  90703. */
  90704. static CreateTorusKnot(options: {
  90705. radius?: number;
  90706. tube?: number;
  90707. radialSegments?: number;
  90708. tubularSegments?: number;
  90709. p?: number;
  90710. q?: number;
  90711. sideOrientation?: number;
  90712. frontUVs?: Vector4;
  90713. backUVs?: Vector4;
  90714. }): VertexData;
  90715. /**
  90716. * Compute normals for given positions and indices
  90717. * @param positions an array of vertex positions, [...., x, y, z, ......]
  90718. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  90719. * @param normals an array of vertex normals, [...., x, y, z, ......]
  90720. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  90721. * * facetNormals : optional array of facet normals (vector3)
  90722. * * facetPositions : optional array of facet positions (vector3)
  90723. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  90724. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  90725. * * bInfo : optional bounding info, required for facetPartitioning computation
  90726. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  90727. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  90728. * * useRightHandedSystem: optional boolean to for right handed system computation
  90729. * * depthSort : optional boolean to enable the facet depth sort computation
  90730. * * distanceTo : optional Vector3 to compute the facet depth from this location
  90731. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  90732. */
  90733. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  90734. facetNormals?: any;
  90735. facetPositions?: any;
  90736. facetPartitioning?: any;
  90737. ratio?: number;
  90738. bInfo?: any;
  90739. bbSize?: Vector3;
  90740. subDiv?: any;
  90741. useRightHandedSystem?: boolean;
  90742. depthSort?: boolean;
  90743. distanceTo?: Vector3;
  90744. depthSortedFacets?: any;
  90745. }): void;
  90746. /** @hidden */
  90747. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  90748. /**
  90749. * Applies VertexData created from the imported parameters to the geometry
  90750. * @param parsedVertexData the parsed data from an imported file
  90751. * @param geometry the geometry to apply the VertexData to
  90752. */
  90753. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  90754. }
  90755. }
  90756. declare module BABYLON {
  90757. /**
  90758. * Defines a target to use with MorphTargetManager
  90759. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  90760. */
  90761. export class MorphTarget implements IAnimatable {
  90762. /** defines the name of the target */
  90763. name: string;
  90764. /**
  90765. * Gets or sets the list of animations
  90766. */
  90767. animations: Animation[];
  90768. private _scene;
  90769. private _positions;
  90770. private _normals;
  90771. private _tangents;
  90772. private _uvs;
  90773. private _influence;
  90774. private _uniqueId;
  90775. /**
  90776. * Observable raised when the influence changes
  90777. */
  90778. onInfluenceChanged: Observable<boolean>;
  90779. /** @hidden */
  90780. _onDataLayoutChanged: Observable<void>;
  90781. /**
  90782. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  90783. */
  90784. influence: number;
  90785. /**
  90786. * Gets or sets the id of the morph Target
  90787. */
  90788. id: string;
  90789. private _animationPropertiesOverride;
  90790. /**
  90791. * Gets or sets the animation properties override
  90792. */
  90793. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  90794. /**
  90795. * Creates a new MorphTarget
  90796. * @param name defines the name of the target
  90797. * @param influence defines the influence to use
  90798. * @param scene defines the scene the morphtarget belongs to
  90799. */
  90800. constructor(
  90801. /** defines the name of the target */
  90802. name: string, influence?: number, scene?: Nullable<Scene>);
  90803. /**
  90804. * Gets the unique ID of this manager
  90805. */
  90806. readonly uniqueId: number;
  90807. /**
  90808. * Gets a boolean defining if the target contains position data
  90809. */
  90810. readonly hasPositions: boolean;
  90811. /**
  90812. * Gets a boolean defining if the target contains normal data
  90813. */
  90814. readonly hasNormals: boolean;
  90815. /**
  90816. * Gets a boolean defining if the target contains tangent data
  90817. */
  90818. readonly hasTangents: boolean;
  90819. /**
  90820. * Gets a boolean defining if the target contains texture coordinates data
  90821. */
  90822. readonly hasUVs: boolean;
  90823. /**
  90824. * Affects position data to this target
  90825. * @param data defines the position data to use
  90826. */
  90827. setPositions(data: Nullable<FloatArray>): void;
  90828. /**
  90829. * Gets the position data stored in this target
  90830. * @returns a FloatArray containing the position data (or null if not present)
  90831. */
  90832. getPositions(): Nullable<FloatArray>;
  90833. /**
  90834. * Affects normal data to this target
  90835. * @param data defines the normal data to use
  90836. */
  90837. setNormals(data: Nullable<FloatArray>): void;
  90838. /**
  90839. * Gets the normal data stored in this target
  90840. * @returns a FloatArray containing the normal data (or null if not present)
  90841. */
  90842. getNormals(): Nullable<FloatArray>;
  90843. /**
  90844. * Affects tangent data to this target
  90845. * @param data defines the tangent data to use
  90846. */
  90847. setTangents(data: Nullable<FloatArray>): void;
  90848. /**
  90849. * Gets the tangent data stored in this target
  90850. * @returns a FloatArray containing the tangent data (or null if not present)
  90851. */
  90852. getTangents(): Nullable<FloatArray>;
  90853. /**
  90854. * Affects texture coordinates data to this target
  90855. * @param data defines the texture coordinates data to use
  90856. */
  90857. setUVs(data: Nullable<FloatArray>): void;
  90858. /**
  90859. * Gets the texture coordinates data stored in this target
  90860. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  90861. */
  90862. getUVs(): Nullable<FloatArray>;
  90863. /**
  90864. * Clone the current target
  90865. * @returns a new MorphTarget
  90866. */
  90867. clone(): MorphTarget;
  90868. /**
  90869. * Serializes the current target into a Serialization object
  90870. * @returns the serialized object
  90871. */
  90872. serialize(): any;
  90873. /**
  90874. * Returns the string "MorphTarget"
  90875. * @returns "MorphTarget"
  90876. */
  90877. getClassName(): string;
  90878. /**
  90879. * Creates a new target from serialized data
  90880. * @param serializationObject defines the serialized data to use
  90881. * @returns a new MorphTarget
  90882. */
  90883. static Parse(serializationObject: any): MorphTarget;
  90884. /**
  90885. * Creates a MorphTarget from mesh data
  90886. * @param mesh defines the source mesh
  90887. * @param name defines the name to use for the new target
  90888. * @param influence defines the influence to attach to the target
  90889. * @returns a new MorphTarget
  90890. */
  90891. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  90892. }
  90893. }
  90894. declare module BABYLON {
  90895. /**
  90896. * This class is used to deform meshes using morphing between different targets
  90897. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  90898. */
  90899. export class MorphTargetManager {
  90900. private _targets;
  90901. private _targetInfluenceChangedObservers;
  90902. private _targetDataLayoutChangedObservers;
  90903. private _activeTargets;
  90904. private _scene;
  90905. private _influences;
  90906. private _supportsNormals;
  90907. private _supportsTangents;
  90908. private _supportsUVs;
  90909. private _vertexCount;
  90910. private _uniqueId;
  90911. private _tempInfluences;
  90912. /**
  90913. * Gets or sets a boolean indicating if normals must be morphed
  90914. */
  90915. enableNormalMorphing: boolean;
  90916. /**
  90917. * Gets or sets a boolean indicating if tangents must be morphed
  90918. */
  90919. enableTangentMorphing: boolean;
  90920. /**
  90921. * Gets or sets a boolean indicating if UV must be morphed
  90922. */
  90923. enableUVMorphing: boolean;
  90924. /**
  90925. * Creates a new MorphTargetManager
  90926. * @param scene defines the current scene
  90927. */
  90928. constructor(scene?: Nullable<Scene>);
  90929. /**
  90930. * Gets the unique ID of this manager
  90931. */
  90932. readonly uniqueId: number;
  90933. /**
  90934. * Gets the number of vertices handled by this manager
  90935. */
  90936. readonly vertexCount: number;
  90937. /**
  90938. * Gets a boolean indicating if this manager supports morphing of normals
  90939. */
  90940. readonly supportsNormals: boolean;
  90941. /**
  90942. * Gets a boolean indicating if this manager supports morphing of tangents
  90943. */
  90944. readonly supportsTangents: boolean;
  90945. /**
  90946. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  90947. */
  90948. readonly supportsUVs: boolean;
  90949. /**
  90950. * Gets the number of targets stored in this manager
  90951. */
  90952. readonly numTargets: number;
  90953. /**
  90954. * Gets the number of influencers (ie. the number of targets with influences > 0)
  90955. */
  90956. readonly numInfluencers: number;
  90957. /**
  90958. * Gets the list of influences (one per target)
  90959. */
  90960. readonly influences: Float32Array;
  90961. /**
  90962. * Gets the active target at specified index. An active target is a target with an influence > 0
  90963. * @param index defines the index to check
  90964. * @returns the requested target
  90965. */
  90966. getActiveTarget(index: number): MorphTarget;
  90967. /**
  90968. * Gets the target at specified index
  90969. * @param index defines the index to check
  90970. * @returns the requested target
  90971. */
  90972. getTarget(index: number): MorphTarget;
  90973. /**
  90974. * Add a new target to this manager
  90975. * @param target defines the target to add
  90976. */
  90977. addTarget(target: MorphTarget): void;
  90978. /**
  90979. * Removes a target from the manager
  90980. * @param target defines the target to remove
  90981. */
  90982. removeTarget(target: MorphTarget): void;
  90983. /**
  90984. * Clone the current manager
  90985. * @returns a new MorphTargetManager
  90986. */
  90987. clone(): MorphTargetManager;
  90988. /**
  90989. * Serializes the current manager into a Serialization object
  90990. * @returns the serialized object
  90991. */
  90992. serialize(): any;
  90993. private _syncActiveTargets;
  90994. /**
  90995. * Syncrhonize the targets with all the meshes using this morph target manager
  90996. */
  90997. synchronize(): void;
  90998. /**
  90999. * Creates a new MorphTargetManager from serialized data
  91000. * @param serializationObject defines the serialized data
  91001. * @param scene defines the hosting scene
  91002. * @returns the new MorphTargetManager
  91003. */
  91004. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  91005. }
  91006. }
  91007. declare module BABYLON {
  91008. /**
  91009. * Class used to represent a specific level of detail of a mesh
  91010. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  91011. */
  91012. export class MeshLODLevel {
  91013. /** Defines the distance where this level should start being displayed */
  91014. distance: number;
  91015. /** Defines the mesh to use to render this level */
  91016. mesh: Nullable<Mesh>;
  91017. /**
  91018. * Creates a new LOD level
  91019. * @param distance defines the distance where this level should star being displayed
  91020. * @param mesh defines the mesh to use to render this level
  91021. */
  91022. constructor(
  91023. /** Defines the distance where this level should start being displayed */
  91024. distance: number,
  91025. /** Defines the mesh to use to render this level */
  91026. mesh: Nullable<Mesh>);
  91027. }
  91028. }
  91029. declare module BABYLON {
  91030. /**
  91031. * Mesh representing the gorund
  91032. */
  91033. export class GroundMesh extends Mesh {
  91034. /** If octree should be generated */
  91035. generateOctree: boolean;
  91036. private _heightQuads;
  91037. /** @hidden */
  91038. _subdivisionsX: number;
  91039. /** @hidden */
  91040. _subdivisionsY: number;
  91041. /** @hidden */
  91042. _width: number;
  91043. /** @hidden */
  91044. _height: number;
  91045. /** @hidden */
  91046. _minX: number;
  91047. /** @hidden */
  91048. _maxX: number;
  91049. /** @hidden */
  91050. _minZ: number;
  91051. /** @hidden */
  91052. _maxZ: number;
  91053. constructor(name: string, scene: Scene);
  91054. /**
  91055. * "GroundMesh"
  91056. * @returns "GroundMesh"
  91057. */
  91058. getClassName(): string;
  91059. /**
  91060. * The minimum of x and y subdivisions
  91061. */
  91062. readonly subdivisions: number;
  91063. /**
  91064. * X subdivisions
  91065. */
  91066. readonly subdivisionsX: number;
  91067. /**
  91068. * Y subdivisions
  91069. */
  91070. readonly subdivisionsY: number;
  91071. /**
  91072. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  91073. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  91074. * @param chunksCount the number of subdivisions for x and y
  91075. * @param octreeBlocksSize (Default: 32)
  91076. */
  91077. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  91078. /**
  91079. * Returns a height (y) value in the Worl system :
  91080. * the ground altitude at the coordinates (x, z) expressed in the World system.
  91081. * @param x x coordinate
  91082. * @param z z coordinate
  91083. * @returns the ground y position if (x, z) are outside the ground surface.
  91084. */
  91085. getHeightAtCoordinates(x: number, z: number): number;
  91086. /**
  91087. * Returns a normalized vector (Vector3) orthogonal to the ground
  91088. * at the ground coordinates (x, z) expressed in the World system.
  91089. * @param x x coordinate
  91090. * @param z z coordinate
  91091. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  91092. */
  91093. getNormalAtCoordinates(x: number, z: number): Vector3;
  91094. /**
  91095. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  91096. * at the ground coordinates (x, z) expressed in the World system.
  91097. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  91098. * @param x x coordinate
  91099. * @param z z coordinate
  91100. * @param ref vector to store the result
  91101. * @returns the GroundMesh.
  91102. */
  91103. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  91104. /**
  91105. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  91106. * if the ground has been updated.
  91107. * This can be used in the render loop.
  91108. * @returns the GroundMesh.
  91109. */
  91110. updateCoordinateHeights(): GroundMesh;
  91111. private _getFacetAt;
  91112. private _initHeightQuads;
  91113. private _computeHeightQuads;
  91114. /**
  91115. * Serializes this ground mesh
  91116. * @param serializationObject object to write serialization to
  91117. */
  91118. serialize(serializationObject: any): void;
  91119. /**
  91120. * Parses a serialized ground mesh
  91121. * @param parsedMesh the serialized mesh
  91122. * @param scene the scene to create the ground mesh in
  91123. * @returns the created ground mesh
  91124. */
  91125. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  91126. }
  91127. }
  91128. declare module BABYLON {
  91129. /**
  91130. * Interface for Physics-Joint data
  91131. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  91132. */
  91133. export interface PhysicsJointData {
  91134. /**
  91135. * The main pivot of the joint
  91136. */
  91137. mainPivot?: Vector3;
  91138. /**
  91139. * The connected pivot of the joint
  91140. */
  91141. connectedPivot?: Vector3;
  91142. /**
  91143. * The main axis of the joint
  91144. */
  91145. mainAxis?: Vector3;
  91146. /**
  91147. * The connected axis of the joint
  91148. */
  91149. connectedAxis?: Vector3;
  91150. /**
  91151. * The collision of the joint
  91152. */
  91153. collision?: boolean;
  91154. /**
  91155. * Native Oimo/Cannon/Energy data
  91156. */
  91157. nativeParams?: any;
  91158. }
  91159. /**
  91160. * This is a holder class for the physics joint created by the physics plugin
  91161. * It holds a set of functions to control the underlying joint
  91162. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  91163. */
  91164. export class PhysicsJoint {
  91165. /**
  91166. * The type of the physics joint
  91167. */
  91168. type: number;
  91169. /**
  91170. * The data for the physics joint
  91171. */
  91172. jointData: PhysicsJointData;
  91173. private _physicsJoint;
  91174. protected _physicsPlugin: IPhysicsEnginePlugin;
  91175. /**
  91176. * Initializes the physics joint
  91177. * @param type The type of the physics joint
  91178. * @param jointData The data for the physics joint
  91179. */
  91180. constructor(
  91181. /**
  91182. * The type of the physics joint
  91183. */
  91184. type: number,
  91185. /**
  91186. * The data for the physics joint
  91187. */
  91188. jointData: PhysicsJointData);
  91189. /**
  91190. * Gets the physics joint
  91191. */
  91192. /**
  91193. * Sets the physics joint
  91194. */
  91195. physicsJoint: any;
  91196. /**
  91197. * Sets the physics plugin
  91198. */
  91199. physicsPlugin: IPhysicsEnginePlugin;
  91200. /**
  91201. * Execute a function that is physics-plugin specific.
  91202. * @param {Function} func the function that will be executed.
  91203. * It accepts two parameters: the physics world and the physics joint
  91204. */
  91205. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  91206. /**
  91207. * Distance-Joint type
  91208. */
  91209. static DistanceJoint: number;
  91210. /**
  91211. * Hinge-Joint type
  91212. */
  91213. static HingeJoint: number;
  91214. /**
  91215. * Ball-and-Socket joint type
  91216. */
  91217. static BallAndSocketJoint: number;
  91218. /**
  91219. * Wheel-Joint type
  91220. */
  91221. static WheelJoint: number;
  91222. /**
  91223. * Slider-Joint type
  91224. */
  91225. static SliderJoint: number;
  91226. /**
  91227. * Prismatic-Joint type
  91228. */
  91229. static PrismaticJoint: number;
  91230. /**
  91231. * Universal-Joint type
  91232. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  91233. */
  91234. static UniversalJoint: number;
  91235. /**
  91236. * Hinge-Joint 2 type
  91237. */
  91238. static Hinge2Joint: number;
  91239. /**
  91240. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  91241. */
  91242. static PointToPointJoint: number;
  91243. /**
  91244. * Spring-Joint type
  91245. */
  91246. static SpringJoint: number;
  91247. /**
  91248. * Lock-Joint type
  91249. */
  91250. static LockJoint: number;
  91251. }
  91252. /**
  91253. * A class representing a physics distance joint
  91254. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  91255. */
  91256. export class DistanceJoint extends PhysicsJoint {
  91257. /**
  91258. *
  91259. * @param jointData The data for the Distance-Joint
  91260. */
  91261. constructor(jointData: DistanceJointData);
  91262. /**
  91263. * Update the predefined distance.
  91264. * @param maxDistance The maximum preferred distance
  91265. * @param minDistance The minimum preferred distance
  91266. */
  91267. updateDistance(maxDistance: number, minDistance?: number): void;
  91268. }
  91269. /**
  91270. * Represents a Motor-Enabled Joint
  91271. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  91272. */
  91273. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  91274. /**
  91275. * Initializes the Motor-Enabled Joint
  91276. * @param type The type of the joint
  91277. * @param jointData The physica joint data for the joint
  91278. */
  91279. constructor(type: number, jointData: PhysicsJointData);
  91280. /**
  91281. * Set the motor values.
  91282. * Attention, this function is plugin specific. Engines won't react 100% the same.
  91283. * @param force the force to apply
  91284. * @param maxForce max force for this motor.
  91285. */
  91286. setMotor(force?: number, maxForce?: number): void;
  91287. /**
  91288. * Set the motor's limits.
  91289. * Attention, this function is plugin specific. Engines won't react 100% the same.
  91290. * @param upperLimit The upper limit of the motor
  91291. * @param lowerLimit The lower limit of the motor
  91292. */
  91293. setLimit(upperLimit: number, lowerLimit?: number): void;
  91294. }
  91295. /**
  91296. * This class represents a single physics Hinge-Joint
  91297. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  91298. */
  91299. export class HingeJoint extends MotorEnabledJoint {
  91300. /**
  91301. * Initializes the Hinge-Joint
  91302. * @param jointData The joint data for the Hinge-Joint
  91303. */
  91304. constructor(jointData: PhysicsJointData);
  91305. /**
  91306. * Set the motor values.
  91307. * Attention, this function is plugin specific. Engines won't react 100% the same.
  91308. * @param {number} force the force to apply
  91309. * @param {number} maxForce max force for this motor.
  91310. */
  91311. setMotor(force?: number, maxForce?: number): void;
  91312. /**
  91313. * Set the motor's limits.
  91314. * Attention, this function is plugin specific. Engines won't react 100% the same.
  91315. * @param upperLimit The upper limit of the motor
  91316. * @param lowerLimit The lower limit of the motor
  91317. */
  91318. setLimit(upperLimit: number, lowerLimit?: number): void;
  91319. }
  91320. /**
  91321. * This class represents a dual hinge physics joint (same as wheel joint)
  91322. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  91323. */
  91324. export class Hinge2Joint extends MotorEnabledJoint {
  91325. /**
  91326. * Initializes the Hinge2-Joint
  91327. * @param jointData The joint data for the Hinge2-Joint
  91328. */
  91329. constructor(jointData: PhysicsJointData);
  91330. /**
  91331. * Set the motor values.
  91332. * Attention, this function is plugin specific. Engines won't react 100% the same.
  91333. * @param {number} targetSpeed the speed the motor is to reach
  91334. * @param {number} maxForce max force for this motor.
  91335. * @param {motorIndex} the motor's index, 0 or 1.
  91336. */
  91337. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  91338. /**
  91339. * Set the motor limits.
  91340. * Attention, this function is plugin specific. Engines won't react 100% the same.
  91341. * @param {number} upperLimit the upper limit
  91342. * @param {number} lowerLimit lower limit
  91343. * @param {motorIndex} the motor's index, 0 or 1.
  91344. */
  91345. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  91346. }
  91347. /**
  91348. * Interface for a motor enabled joint
  91349. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  91350. */
  91351. export interface IMotorEnabledJoint {
  91352. /**
  91353. * Physics joint
  91354. */
  91355. physicsJoint: any;
  91356. /**
  91357. * Sets the motor of the motor-enabled joint
  91358. * @param force The force of the motor
  91359. * @param maxForce The maximum force of the motor
  91360. * @param motorIndex The index of the motor
  91361. */
  91362. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  91363. /**
  91364. * Sets the limit of the motor
  91365. * @param upperLimit The upper limit of the motor
  91366. * @param lowerLimit The lower limit of the motor
  91367. * @param motorIndex The index of the motor
  91368. */
  91369. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  91370. }
  91371. /**
  91372. * Joint data for a Distance-Joint
  91373. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  91374. */
  91375. export interface DistanceJointData extends PhysicsJointData {
  91376. /**
  91377. * Max distance the 2 joint objects can be apart
  91378. */
  91379. maxDistance: number;
  91380. }
  91381. /**
  91382. * Joint data from a spring joint
  91383. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  91384. */
  91385. export interface SpringJointData extends PhysicsJointData {
  91386. /**
  91387. * Length of the spring
  91388. */
  91389. length: number;
  91390. /**
  91391. * Stiffness of the spring
  91392. */
  91393. stiffness: number;
  91394. /**
  91395. * Damping of the spring
  91396. */
  91397. damping: number;
  91398. /** this callback will be called when applying the force to the impostors. */
  91399. forceApplicationCallback: () => void;
  91400. }
  91401. }
  91402. declare module BABYLON {
  91403. /**
  91404. * Holds the data for the raycast result
  91405. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  91406. */
  91407. export class PhysicsRaycastResult {
  91408. private _hasHit;
  91409. private _hitDistance;
  91410. private _hitNormalWorld;
  91411. private _hitPointWorld;
  91412. private _rayFromWorld;
  91413. private _rayToWorld;
  91414. /**
  91415. * Gets if there was a hit
  91416. */
  91417. readonly hasHit: boolean;
  91418. /**
  91419. * Gets the distance from the hit
  91420. */
  91421. readonly hitDistance: number;
  91422. /**
  91423. * Gets the hit normal/direction in the world
  91424. */
  91425. readonly hitNormalWorld: Vector3;
  91426. /**
  91427. * Gets the hit point in the world
  91428. */
  91429. readonly hitPointWorld: Vector3;
  91430. /**
  91431. * Gets the ray "start point" of the ray in the world
  91432. */
  91433. readonly rayFromWorld: Vector3;
  91434. /**
  91435. * Gets the ray "end point" of the ray in the world
  91436. */
  91437. readonly rayToWorld: Vector3;
  91438. /**
  91439. * Sets the hit data (normal & point in world space)
  91440. * @param hitNormalWorld defines the normal in world space
  91441. * @param hitPointWorld defines the point in world space
  91442. */
  91443. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  91444. /**
  91445. * Sets the distance from the start point to the hit point
  91446. * @param distance
  91447. */
  91448. setHitDistance(distance: number): void;
  91449. /**
  91450. * Calculates the distance manually
  91451. */
  91452. calculateHitDistance(): void;
  91453. /**
  91454. * Resets all the values to default
  91455. * @param from The from point on world space
  91456. * @param to The to point on world space
  91457. */
  91458. reset(from?: Vector3, to?: Vector3): void;
  91459. }
  91460. /**
  91461. * Interface for the size containing width and height
  91462. */
  91463. interface IXYZ {
  91464. /**
  91465. * X
  91466. */
  91467. x: number;
  91468. /**
  91469. * Y
  91470. */
  91471. y: number;
  91472. /**
  91473. * Z
  91474. */
  91475. z: number;
  91476. }
  91477. }
  91478. declare module BABYLON {
  91479. /**
  91480. * Interface used to describe a physics joint
  91481. */
  91482. export interface PhysicsImpostorJoint {
  91483. /** Defines the main impostor to which the joint is linked */
  91484. mainImpostor: PhysicsImpostor;
  91485. /** Defines the impostor that is connected to the main impostor using this joint */
  91486. connectedImpostor: PhysicsImpostor;
  91487. /** Defines the joint itself */
  91488. joint: PhysicsJoint;
  91489. }
  91490. /** @hidden */
  91491. export interface IPhysicsEnginePlugin {
  91492. world: any;
  91493. name: string;
  91494. setGravity(gravity: Vector3): void;
  91495. setTimeStep(timeStep: number): void;
  91496. getTimeStep(): number;
  91497. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  91498. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  91499. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  91500. generatePhysicsBody(impostor: PhysicsImpostor): void;
  91501. removePhysicsBody(impostor: PhysicsImpostor): void;
  91502. generateJoint(joint: PhysicsImpostorJoint): void;
  91503. removeJoint(joint: PhysicsImpostorJoint): void;
  91504. isSupported(): boolean;
  91505. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  91506. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  91507. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  91508. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  91509. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  91510. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  91511. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  91512. getBodyMass(impostor: PhysicsImpostor): number;
  91513. getBodyFriction(impostor: PhysicsImpostor): number;
  91514. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  91515. getBodyRestitution(impostor: PhysicsImpostor): number;
  91516. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  91517. getBodyPressure?(impostor: PhysicsImpostor): number;
  91518. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  91519. getBodyStiffness?(impostor: PhysicsImpostor): number;
  91520. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  91521. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  91522. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  91523. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  91524. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  91525. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  91526. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  91527. sleepBody(impostor: PhysicsImpostor): void;
  91528. wakeUpBody(impostor: PhysicsImpostor): void;
  91529. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  91530. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  91531. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  91532. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  91533. getRadius(impostor: PhysicsImpostor): number;
  91534. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  91535. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  91536. dispose(): void;
  91537. }
  91538. /**
  91539. * Interface used to define a physics engine
  91540. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  91541. */
  91542. export interface IPhysicsEngine {
  91543. /**
  91544. * Gets the gravity vector used by the simulation
  91545. */
  91546. gravity: Vector3;
  91547. /**
  91548. * Sets the gravity vector used by the simulation
  91549. * @param gravity defines the gravity vector to use
  91550. */
  91551. setGravity(gravity: Vector3): void;
  91552. /**
  91553. * Set the time step of the physics engine.
  91554. * Default is 1/60.
  91555. * To slow it down, enter 1/600 for example.
  91556. * To speed it up, 1/30
  91557. * @param newTimeStep the new timestep to apply to this world.
  91558. */
  91559. setTimeStep(newTimeStep: number): void;
  91560. /**
  91561. * Get the time step of the physics engine.
  91562. * @returns the current time step
  91563. */
  91564. getTimeStep(): number;
  91565. /**
  91566. * Release all resources
  91567. */
  91568. dispose(): void;
  91569. /**
  91570. * Gets the name of the current physics plugin
  91571. * @returns the name of the plugin
  91572. */
  91573. getPhysicsPluginName(): string;
  91574. /**
  91575. * Adding a new impostor for the impostor tracking.
  91576. * This will be done by the impostor itself.
  91577. * @param impostor the impostor to add
  91578. */
  91579. addImpostor(impostor: PhysicsImpostor): void;
  91580. /**
  91581. * Remove an impostor from the engine.
  91582. * This impostor and its mesh will not longer be updated by the physics engine.
  91583. * @param impostor the impostor to remove
  91584. */
  91585. removeImpostor(impostor: PhysicsImpostor): void;
  91586. /**
  91587. * Add a joint to the physics engine
  91588. * @param mainImpostor defines the main impostor to which the joint is added.
  91589. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  91590. * @param joint defines the joint that will connect both impostors.
  91591. */
  91592. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  91593. /**
  91594. * Removes a joint from the simulation
  91595. * @param mainImpostor defines the impostor used with the joint
  91596. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  91597. * @param joint defines the joint to remove
  91598. */
  91599. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  91600. /**
  91601. * Gets the current plugin used to run the simulation
  91602. * @returns current plugin
  91603. */
  91604. getPhysicsPlugin(): IPhysicsEnginePlugin;
  91605. /**
  91606. * Gets the list of physic impostors
  91607. * @returns an array of PhysicsImpostor
  91608. */
  91609. getImpostors(): Array<PhysicsImpostor>;
  91610. /**
  91611. * Gets the impostor for a physics enabled object
  91612. * @param object defines the object impersonated by the impostor
  91613. * @returns the PhysicsImpostor or null if not found
  91614. */
  91615. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  91616. /**
  91617. * Gets the impostor for a physics body object
  91618. * @param body defines physics body used by the impostor
  91619. * @returns the PhysicsImpostor or null if not found
  91620. */
  91621. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  91622. /**
  91623. * Does a raycast in the physics world
  91624. * @param from when should the ray start?
  91625. * @param to when should the ray end?
  91626. * @returns PhysicsRaycastResult
  91627. */
  91628. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  91629. /**
  91630. * Called by the scene. No need to call it.
  91631. * @param delta defines the timespam between frames
  91632. */
  91633. _step(delta: number): void;
  91634. }
  91635. }
  91636. declare module BABYLON {
  91637. /**
  91638. * The interface for the physics imposter parameters
  91639. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  91640. */
  91641. export interface PhysicsImpostorParameters {
  91642. /**
  91643. * The mass of the physics imposter
  91644. */
  91645. mass: number;
  91646. /**
  91647. * The friction of the physics imposter
  91648. */
  91649. friction?: number;
  91650. /**
  91651. * The coefficient of restitution of the physics imposter
  91652. */
  91653. restitution?: number;
  91654. /**
  91655. * The native options of the physics imposter
  91656. */
  91657. nativeOptions?: any;
  91658. /**
  91659. * Specifies if the parent should be ignored
  91660. */
  91661. ignoreParent?: boolean;
  91662. /**
  91663. * Specifies if bi-directional transformations should be disabled
  91664. */
  91665. disableBidirectionalTransformation?: boolean;
  91666. /**
  91667. * The pressure inside the physics imposter, soft object only
  91668. */
  91669. pressure?: number;
  91670. /**
  91671. * The stiffness the physics imposter, soft object only
  91672. */
  91673. stiffness?: number;
  91674. /**
  91675. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  91676. */
  91677. velocityIterations?: number;
  91678. /**
  91679. * The number of iterations used in maintaining consistent vertex positions, soft object only
  91680. */
  91681. positionIterations?: number;
  91682. /**
  91683. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  91684. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  91685. * Add to fix multiple points
  91686. */
  91687. fixedPoints?: number;
  91688. /**
  91689. * The collision margin around a soft object
  91690. */
  91691. margin?: number;
  91692. /**
  91693. * The collision margin around a soft object
  91694. */
  91695. damping?: number;
  91696. /**
  91697. * The path for a rope based on an extrusion
  91698. */
  91699. path?: any;
  91700. /**
  91701. * The shape of an extrusion used for a rope based on an extrusion
  91702. */
  91703. shape?: any;
  91704. }
  91705. /**
  91706. * Interface for a physics-enabled object
  91707. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  91708. */
  91709. export interface IPhysicsEnabledObject {
  91710. /**
  91711. * The position of the physics-enabled object
  91712. */
  91713. position: Vector3;
  91714. /**
  91715. * The rotation of the physics-enabled object
  91716. */
  91717. rotationQuaternion: Nullable<Quaternion>;
  91718. /**
  91719. * The scale of the physics-enabled object
  91720. */
  91721. scaling: Vector3;
  91722. /**
  91723. * The rotation of the physics-enabled object
  91724. */
  91725. rotation?: Vector3;
  91726. /**
  91727. * The parent of the physics-enabled object
  91728. */
  91729. parent?: any;
  91730. /**
  91731. * The bounding info of the physics-enabled object
  91732. * @returns The bounding info of the physics-enabled object
  91733. */
  91734. getBoundingInfo(): BoundingInfo;
  91735. /**
  91736. * Computes the world matrix
  91737. * @param force Specifies if the world matrix should be computed by force
  91738. * @returns A world matrix
  91739. */
  91740. computeWorldMatrix(force: boolean): Matrix;
  91741. /**
  91742. * Gets the world matrix
  91743. * @returns A world matrix
  91744. */
  91745. getWorldMatrix?(): Matrix;
  91746. /**
  91747. * Gets the child meshes
  91748. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  91749. * @returns An array of abstract meshes
  91750. */
  91751. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  91752. /**
  91753. * Gets the vertex data
  91754. * @param kind The type of vertex data
  91755. * @returns A nullable array of numbers, or a float32 array
  91756. */
  91757. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  91758. /**
  91759. * Gets the indices from the mesh
  91760. * @returns A nullable array of index arrays
  91761. */
  91762. getIndices?(): Nullable<IndicesArray>;
  91763. /**
  91764. * Gets the scene from the mesh
  91765. * @returns the indices array or null
  91766. */
  91767. getScene?(): Scene;
  91768. /**
  91769. * Gets the absolute position from the mesh
  91770. * @returns the absolute position
  91771. */
  91772. getAbsolutePosition(): Vector3;
  91773. /**
  91774. * Gets the absolute pivot point from the mesh
  91775. * @returns the absolute pivot point
  91776. */
  91777. getAbsolutePivotPoint(): Vector3;
  91778. /**
  91779. * Rotates the mesh
  91780. * @param axis The axis of rotation
  91781. * @param amount The amount of rotation
  91782. * @param space The space of the rotation
  91783. * @returns The rotation transform node
  91784. */
  91785. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  91786. /**
  91787. * Translates the mesh
  91788. * @param axis The axis of translation
  91789. * @param distance The distance of translation
  91790. * @param space The space of the translation
  91791. * @returns The transform node
  91792. */
  91793. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  91794. /**
  91795. * Sets the absolute position of the mesh
  91796. * @param absolutePosition The absolute position of the mesh
  91797. * @returns The transform node
  91798. */
  91799. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  91800. /**
  91801. * Gets the class name of the mesh
  91802. * @returns The class name
  91803. */
  91804. getClassName(): string;
  91805. }
  91806. /**
  91807. * Represents a physics imposter
  91808. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  91809. */
  91810. export class PhysicsImpostor {
  91811. /**
  91812. * The physics-enabled object used as the physics imposter
  91813. */
  91814. object: IPhysicsEnabledObject;
  91815. /**
  91816. * The type of the physics imposter
  91817. */
  91818. type: number;
  91819. private _options;
  91820. private _scene?;
  91821. /**
  91822. * The default object size of the imposter
  91823. */
  91824. static DEFAULT_OBJECT_SIZE: Vector3;
  91825. /**
  91826. * The identity quaternion of the imposter
  91827. */
  91828. static IDENTITY_QUATERNION: Quaternion;
  91829. /** @hidden */
  91830. _pluginData: any;
  91831. private _physicsEngine;
  91832. private _physicsBody;
  91833. private _bodyUpdateRequired;
  91834. private _onBeforePhysicsStepCallbacks;
  91835. private _onAfterPhysicsStepCallbacks;
  91836. /** @hidden */
  91837. _onPhysicsCollideCallbacks: Array<{
  91838. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  91839. otherImpostors: Array<PhysicsImpostor>;
  91840. }>;
  91841. private _deltaPosition;
  91842. private _deltaRotation;
  91843. private _deltaRotationConjugated;
  91844. /** @hidden */
  91845. _isFromLine: boolean;
  91846. private _parent;
  91847. private _isDisposed;
  91848. private static _tmpVecs;
  91849. private static _tmpQuat;
  91850. /**
  91851. * Specifies if the physics imposter is disposed
  91852. */
  91853. readonly isDisposed: boolean;
  91854. /**
  91855. * Gets the mass of the physics imposter
  91856. */
  91857. mass: number;
  91858. /**
  91859. * Gets the coefficient of friction
  91860. */
  91861. /**
  91862. * Sets the coefficient of friction
  91863. */
  91864. friction: number;
  91865. /**
  91866. * Gets the coefficient of restitution
  91867. */
  91868. /**
  91869. * Sets the coefficient of restitution
  91870. */
  91871. restitution: number;
  91872. /**
  91873. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  91874. */
  91875. /**
  91876. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  91877. */
  91878. pressure: number;
  91879. /**
  91880. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  91881. */
  91882. /**
  91883. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  91884. */
  91885. stiffness: number;
  91886. /**
  91887. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  91888. */
  91889. /**
  91890. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  91891. */
  91892. velocityIterations: number;
  91893. /**
  91894. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  91895. */
  91896. /**
  91897. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  91898. */
  91899. positionIterations: number;
  91900. /**
  91901. * The unique id of the physics imposter
  91902. * set by the physics engine when adding this impostor to the array
  91903. */
  91904. uniqueId: number;
  91905. /**
  91906. * @hidden
  91907. */
  91908. soft: boolean;
  91909. /**
  91910. * @hidden
  91911. */
  91912. segments: number;
  91913. private _joints;
  91914. /**
  91915. * Initializes the physics imposter
  91916. * @param object The physics-enabled object used as the physics imposter
  91917. * @param type The type of the physics imposter
  91918. * @param _options The options for the physics imposter
  91919. * @param _scene The Babylon scene
  91920. */
  91921. constructor(
  91922. /**
  91923. * The physics-enabled object used as the physics imposter
  91924. */
  91925. object: IPhysicsEnabledObject,
  91926. /**
  91927. * The type of the physics imposter
  91928. */
  91929. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  91930. /**
  91931. * This function will completly initialize this impostor.
  91932. * It will create a new body - but only if this mesh has no parent.
  91933. * If it has, this impostor will not be used other than to define the impostor
  91934. * of the child mesh.
  91935. * @hidden
  91936. */
  91937. _init(): void;
  91938. private _getPhysicsParent;
  91939. /**
  91940. * Should a new body be generated.
  91941. * @returns boolean specifying if body initialization is required
  91942. */
  91943. isBodyInitRequired(): boolean;
  91944. /**
  91945. * Sets the updated scaling
  91946. * @param updated Specifies if the scaling is updated
  91947. */
  91948. setScalingUpdated(): void;
  91949. /**
  91950. * Force a regeneration of this or the parent's impostor's body.
  91951. * Use under cautious - This will remove all joints already implemented.
  91952. */
  91953. forceUpdate(): void;
  91954. /**
  91955. * Gets the body that holds this impostor. Either its own, or its parent.
  91956. */
  91957. /**
  91958. * Set the physics body. Used mainly by the physics engine/plugin
  91959. */
  91960. physicsBody: any;
  91961. /**
  91962. * Get the parent of the physics imposter
  91963. * @returns Physics imposter or null
  91964. */
  91965. /**
  91966. * Sets the parent of the physics imposter
  91967. */
  91968. parent: Nullable<PhysicsImpostor>;
  91969. /**
  91970. * Resets the update flags
  91971. */
  91972. resetUpdateFlags(): void;
  91973. /**
  91974. * Gets the object extend size
  91975. * @returns the object extend size
  91976. */
  91977. getObjectExtendSize(): Vector3;
  91978. /**
  91979. * Gets the object center
  91980. * @returns The object center
  91981. */
  91982. getObjectCenter(): Vector3;
  91983. /**
  91984. * Get a specific parametes from the options parameter
  91985. * @param paramName The object parameter name
  91986. * @returns The object parameter
  91987. */
  91988. getParam(paramName: string): any;
  91989. /**
  91990. * Sets a specific parameter in the options given to the physics plugin
  91991. * @param paramName The parameter name
  91992. * @param value The value of the parameter
  91993. */
  91994. setParam(paramName: string, value: number): void;
  91995. /**
  91996. * Specifically change the body's mass option. Won't recreate the physics body object
  91997. * @param mass The mass of the physics imposter
  91998. */
  91999. setMass(mass: number): void;
  92000. /**
  92001. * Gets the linear velocity
  92002. * @returns linear velocity or null
  92003. */
  92004. getLinearVelocity(): Nullable<Vector3>;
  92005. /**
  92006. * Sets the linear velocity
  92007. * @param velocity linear velocity or null
  92008. */
  92009. setLinearVelocity(velocity: Nullable<Vector3>): void;
  92010. /**
  92011. * Gets the angular velocity
  92012. * @returns angular velocity or null
  92013. */
  92014. getAngularVelocity(): Nullable<Vector3>;
  92015. /**
  92016. * Sets the angular velocity
  92017. * @param velocity The velocity or null
  92018. */
  92019. setAngularVelocity(velocity: Nullable<Vector3>): void;
  92020. /**
  92021. * Execute a function with the physics plugin native code
  92022. * Provide a function the will have two variables - the world object and the physics body object
  92023. * @param func The function to execute with the physics plugin native code
  92024. */
  92025. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  92026. /**
  92027. * Register a function that will be executed before the physics world is stepping forward
  92028. * @param func The function to execute before the physics world is stepped forward
  92029. */
  92030. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  92031. /**
  92032. * Unregister a function that will be executed before the physics world is stepping forward
  92033. * @param func The function to execute before the physics world is stepped forward
  92034. */
  92035. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  92036. /**
  92037. * Register a function that will be executed after the physics step
  92038. * @param func The function to execute after physics step
  92039. */
  92040. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  92041. /**
  92042. * Unregisters a function that will be executed after the physics step
  92043. * @param func The function to execute after physics step
  92044. */
  92045. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  92046. /**
  92047. * register a function that will be executed when this impostor collides against a different body
  92048. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  92049. * @param func Callback that is executed on collision
  92050. */
  92051. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  92052. /**
  92053. * Unregisters the physics imposter on contact
  92054. * @param collideAgainst The physics object to collide against
  92055. * @param func Callback to execute on collision
  92056. */
  92057. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  92058. private _tmpQuat;
  92059. private _tmpQuat2;
  92060. /**
  92061. * Get the parent rotation
  92062. * @returns The parent rotation
  92063. */
  92064. getParentsRotation(): Quaternion;
  92065. /**
  92066. * this function is executed by the physics engine.
  92067. */
  92068. beforeStep: () => void;
  92069. /**
  92070. * this function is executed by the physics engine
  92071. */
  92072. afterStep: () => void;
  92073. /**
  92074. * Legacy collision detection event support
  92075. */
  92076. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  92077. /**
  92078. * event and body object due to cannon's event-based architecture.
  92079. */
  92080. onCollide: (e: {
  92081. body: any;
  92082. }) => void;
  92083. /**
  92084. * Apply a force
  92085. * @param force The force to apply
  92086. * @param contactPoint The contact point for the force
  92087. * @returns The physics imposter
  92088. */
  92089. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  92090. /**
  92091. * Apply an impulse
  92092. * @param force The impulse force
  92093. * @param contactPoint The contact point for the impulse force
  92094. * @returns The physics imposter
  92095. */
  92096. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  92097. /**
  92098. * A help function to create a joint
  92099. * @param otherImpostor A physics imposter used to create a joint
  92100. * @param jointType The type of joint
  92101. * @param jointData The data for the joint
  92102. * @returns The physics imposter
  92103. */
  92104. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  92105. /**
  92106. * Add a joint to this impostor with a different impostor
  92107. * @param otherImpostor A physics imposter used to add a joint
  92108. * @param joint The joint to add
  92109. * @returns The physics imposter
  92110. */
  92111. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  92112. /**
  92113. * Add an anchor to a cloth impostor
  92114. * @param otherImpostor rigid impostor to anchor to
  92115. * @param width ratio across width from 0 to 1
  92116. * @param height ratio up height from 0 to 1
  92117. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  92118. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  92119. * @returns impostor the soft imposter
  92120. */
  92121. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  92122. /**
  92123. * Add a hook to a rope impostor
  92124. * @param otherImpostor rigid impostor to anchor to
  92125. * @param length ratio across rope from 0 to 1
  92126. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  92127. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  92128. * @returns impostor the rope imposter
  92129. */
  92130. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  92131. /**
  92132. * Will keep this body still, in a sleep mode.
  92133. * @returns the physics imposter
  92134. */
  92135. sleep(): PhysicsImpostor;
  92136. /**
  92137. * Wake the body up.
  92138. * @returns The physics imposter
  92139. */
  92140. wakeUp(): PhysicsImpostor;
  92141. /**
  92142. * Clones the physics imposter
  92143. * @param newObject The physics imposter clones to this physics-enabled object
  92144. * @returns A nullable physics imposter
  92145. */
  92146. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  92147. /**
  92148. * Disposes the physics imposter
  92149. */
  92150. dispose(): void;
  92151. /**
  92152. * Sets the delta position
  92153. * @param position The delta position amount
  92154. */
  92155. setDeltaPosition(position: Vector3): void;
  92156. /**
  92157. * Sets the delta rotation
  92158. * @param rotation The delta rotation amount
  92159. */
  92160. setDeltaRotation(rotation: Quaternion): void;
  92161. /**
  92162. * Gets the box size of the physics imposter and stores the result in the input parameter
  92163. * @param result Stores the box size
  92164. * @returns The physics imposter
  92165. */
  92166. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  92167. /**
  92168. * Gets the radius of the physics imposter
  92169. * @returns Radius of the physics imposter
  92170. */
  92171. getRadius(): number;
  92172. /**
  92173. * Sync a bone with this impostor
  92174. * @param bone The bone to sync to the impostor.
  92175. * @param boneMesh The mesh that the bone is influencing.
  92176. * @param jointPivot The pivot of the joint / bone in local space.
  92177. * @param distToJoint Optional distance from the impostor to the joint.
  92178. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  92179. */
  92180. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  92181. /**
  92182. * Sync impostor to a bone
  92183. * @param bone The bone that the impostor will be synced to.
  92184. * @param boneMesh The mesh that the bone is influencing.
  92185. * @param jointPivot The pivot of the joint / bone in local space.
  92186. * @param distToJoint Optional distance from the impostor to the joint.
  92187. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  92188. * @param boneAxis Optional vector3 axis the bone is aligned with
  92189. */
  92190. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  92191. /**
  92192. * No-Imposter type
  92193. */
  92194. static NoImpostor: number;
  92195. /**
  92196. * Sphere-Imposter type
  92197. */
  92198. static SphereImpostor: number;
  92199. /**
  92200. * Box-Imposter type
  92201. */
  92202. static BoxImpostor: number;
  92203. /**
  92204. * Plane-Imposter type
  92205. */
  92206. static PlaneImpostor: number;
  92207. /**
  92208. * Mesh-imposter type
  92209. */
  92210. static MeshImpostor: number;
  92211. /**
  92212. * Capsule-Impostor type (Ammo.js plugin only)
  92213. */
  92214. static CapsuleImpostor: number;
  92215. /**
  92216. * Cylinder-Imposter type
  92217. */
  92218. static CylinderImpostor: number;
  92219. /**
  92220. * Particle-Imposter type
  92221. */
  92222. static ParticleImpostor: number;
  92223. /**
  92224. * Heightmap-Imposter type
  92225. */
  92226. static HeightmapImpostor: number;
  92227. /**
  92228. * ConvexHull-Impostor type (Ammo.js plugin only)
  92229. */
  92230. static ConvexHullImpostor: number;
  92231. /**
  92232. * Rope-Imposter type
  92233. */
  92234. static RopeImpostor: number;
  92235. /**
  92236. * Cloth-Imposter type
  92237. */
  92238. static ClothImpostor: number;
  92239. /**
  92240. * Softbody-Imposter type
  92241. */
  92242. static SoftbodyImpostor: number;
  92243. }
  92244. }
  92245. declare module BABYLON {
  92246. /**
  92247. * @hidden
  92248. **/
  92249. export class _CreationDataStorage {
  92250. closePath?: boolean;
  92251. closeArray?: boolean;
  92252. idx: number[];
  92253. dashSize: number;
  92254. gapSize: number;
  92255. path3D: Path3D;
  92256. pathArray: Vector3[][];
  92257. arc: number;
  92258. radius: number;
  92259. cap: number;
  92260. tessellation: number;
  92261. }
  92262. /**
  92263. * @hidden
  92264. **/
  92265. class _InstanceDataStorage {
  92266. visibleInstances: any;
  92267. batchCache: _InstancesBatch;
  92268. instancesBufferSize: number;
  92269. instancesBuffer: Nullable<Buffer>;
  92270. instancesData: Float32Array;
  92271. overridenInstanceCount: number;
  92272. isFrozen: boolean;
  92273. previousBatch: Nullable<_InstancesBatch>;
  92274. hardwareInstancedRendering: boolean;
  92275. sideOrientation: number;
  92276. manualUpdate: boolean;
  92277. }
  92278. /**
  92279. * @hidden
  92280. **/
  92281. export class _InstancesBatch {
  92282. mustReturn: boolean;
  92283. visibleInstances: Nullable<InstancedMesh[]>[];
  92284. renderSelf: boolean[];
  92285. hardwareInstancedRendering: boolean[];
  92286. }
  92287. /**
  92288. * Class used to represent renderable models
  92289. */
  92290. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  92291. /**
  92292. * Mesh side orientation : usually the external or front surface
  92293. */
  92294. static readonly FRONTSIDE: number;
  92295. /**
  92296. * Mesh side orientation : usually the internal or back surface
  92297. */
  92298. static readonly BACKSIDE: number;
  92299. /**
  92300. * Mesh side orientation : both internal and external or front and back surfaces
  92301. */
  92302. static readonly DOUBLESIDE: number;
  92303. /**
  92304. * Mesh side orientation : by default, `FRONTSIDE`
  92305. */
  92306. static readonly DEFAULTSIDE: number;
  92307. /**
  92308. * Mesh cap setting : no cap
  92309. */
  92310. static readonly NO_CAP: number;
  92311. /**
  92312. * Mesh cap setting : one cap at the beginning of the mesh
  92313. */
  92314. static readonly CAP_START: number;
  92315. /**
  92316. * Mesh cap setting : one cap at the end of the mesh
  92317. */
  92318. static readonly CAP_END: number;
  92319. /**
  92320. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  92321. */
  92322. static readonly CAP_ALL: number;
  92323. /**
  92324. * Mesh pattern setting : no flip or rotate
  92325. */
  92326. static readonly NO_FLIP: number;
  92327. /**
  92328. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  92329. */
  92330. static readonly FLIP_TILE: number;
  92331. /**
  92332. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  92333. */
  92334. static readonly ROTATE_TILE: number;
  92335. /**
  92336. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  92337. */
  92338. static readonly FLIP_ROW: number;
  92339. /**
  92340. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  92341. */
  92342. static readonly ROTATE_ROW: number;
  92343. /**
  92344. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  92345. */
  92346. static readonly FLIP_N_ROTATE_TILE: number;
  92347. /**
  92348. * Mesh pattern setting : rotate pattern and rotate
  92349. */
  92350. static readonly FLIP_N_ROTATE_ROW: number;
  92351. /**
  92352. * Mesh tile positioning : part tiles same on left/right or top/bottom
  92353. */
  92354. static readonly CENTER: number;
  92355. /**
  92356. * Mesh tile positioning : part tiles on left
  92357. */
  92358. static readonly LEFT: number;
  92359. /**
  92360. * Mesh tile positioning : part tiles on right
  92361. */
  92362. static readonly RIGHT: number;
  92363. /**
  92364. * Mesh tile positioning : part tiles on top
  92365. */
  92366. static readonly TOP: number;
  92367. /**
  92368. * Mesh tile positioning : part tiles on bottom
  92369. */
  92370. static readonly BOTTOM: number;
  92371. /**
  92372. * Gets the default side orientation.
  92373. * @param orientation the orientation to value to attempt to get
  92374. * @returns the default orientation
  92375. * @hidden
  92376. */
  92377. static _GetDefaultSideOrientation(orientation?: number): number;
  92378. private _internalMeshDataInfo;
  92379. /**
  92380. * An event triggered before rendering the mesh
  92381. */
  92382. readonly onBeforeRenderObservable: Observable<Mesh>;
  92383. /**
  92384. * An event triggered before binding the mesh
  92385. */
  92386. readonly onBeforeBindObservable: Observable<Mesh>;
  92387. /**
  92388. * An event triggered after rendering the mesh
  92389. */
  92390. readonly onAfterRenderObservable: Observable<Mesh>;
  92391. /**
  92392. * An event triggered before drawing the mesh
  92393. */
  92394. readonly onBeforeDrawObservable: Observable<Mesh>;
  92395. private _onBeforeDrawObserver;
  92396. /**
  92397. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  92398. */
  92399. onBeforeDraw: () => void;
  92400. readonly hasInstances: boolean;
  92401. /**
  92402. * Gets the delay loading state of the mesh (when delay loading is turned on)
  92403. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  92404. */
  92405. delayLoadState: number;
  92406. /**
  92407. * Gets the list of instances created from this mesh
  92408. * it is not supposed to be modified manually.
  92409. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  92410. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  92411. */
  92412. instances: InstancedMesh[];
  92413. /**
  92414. * Gets the file containing delay loading data for this mesh
  92415. */
  92416. delayLoadingFile: string;
  92417. /** @hidden */
  92418. _binaryInfo: any;
  92419. /**
  92420. * User defined function used to change how LOD level selection is done
  92421. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  92422. */
  92423. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  92424. /**
  92425. * Gets or sets the morph target manager
  92426. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  92427. */
  92428. morphTargetManager: Nullable<MorphTargetManager>;
  92429. /** @hidden */
  92430. _creationDataStorage: Nullable<_CreationDataStorage>;
  92431. /** @hidden */
  92432. _geometry: Nullable<Geometry>;
  92433. /** @hidden */
  92434. _delayInfo: Array<string>;
  92435. /** @hidden */
  92436. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  92437. /** @hidden */
  92438. _instanceDataStorage: _InstanceDataStorage;
  92439. private _effectiveMaterial;
  92440. /** @hidden */
  92441. _shouldGenerateFlatShading: boolean;
  92442. /** @hidden */
  92443. _originalBuilderSideOrientation: number;
  92444. /**
  92445. * Use this property to change the original side orientation defined at construction time
  92446. */
  92447. overrideMaterialSideOrientation: Nullable<number>;
  92448. /**
  92449. * Gets the source mesh (the one used to clone this one from)
  92450. */
  92451. readonly source: Nullable<Mesh>;
  92452. /**
  92453. * Gets or sets a boolean indicating that this mesh does not use index buffer
  92454. */
  92455. isUnIndexed: boolean;
  92456. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  92457. readonly worldMatrixInstancedBuffer: Float32Array;
  92458. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  92459. manualUpdateOfWorldMatrixInstancedBuffer: boolean;
  92460. /**
  92461. * @constructor
  92462. * @param name The value used by scene.getMeshByName() to do a lookup.
  92463. * @param scene The scene to add this mesh to.
  92464. * @param parent The parent of this mesh, if it has one
  92465. * @param source An optional Mesh from which geometry is shared, cloned.
  92466. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  92467. * When false, achieved by calling a clone(), also passing False.
  92468. * This will make creation of children, recursive.
  92469. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  92470. */
  92471. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  92472. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  92473. doNotInstantiate: boolean;
  92474. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  92475. /**
  92476. * Gets the class name
  92477. * @returns the string "Mesh".
  92478. */
  92479. getClassName(): string;
  92480. /** @hidden */
  92481. readonly _isMesh: boolean;
  92482. /**
  92483. * Returns a description of this mesh
  92484. * @param fullDetails define if full details about this mesh must be used
  92485. * @returns a descriptive string representing this mesh
  92486. */
  92487. toString(fullDetails?: boolean): string;
  92488. /** @hidden */
  92489. _unBindEffect(): void;
  92490. /**
  92491. * Gets a boolean indicating if this mesh has LOD
  92492. */
  92493. readonly hasLODLevels: boolean;
  92494. /**
  92495. * Gets the list of MeshLODLevel associated with the current mesh
  92496. * @returns an array of MeshLODLevel
  92497. */
  92498. getLODLevels(): MeshLODLevel[];
  92499. private _sortLODLevels;
  92500. /**
  92501. * Add a mesh as LOD level triggered at the given distance.
  92502. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  92503. * @param distance The distance from the center of the object to show this level
  92504. * @param mesh The mesh to be added as LOD level (can be null)
  92505. * @return This mesh (for chaining)
  92506. */
  92507. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  92508. /**
  92509. * Returns the LOD level mesh at the passed distance or null if not found.
  92510. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  92511. * @param distance The distance from the center of the object to show this level
  92512. * @returns a Mesh or `null`
  92513. */
  92514. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  92515. /**
  92516. * Remove a mesh from the LOD array
  92517. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  92518. * @param mesh defines the mesh to be removed
  92519. * @return This mesh (for chaining)
  92520. */
  92521. removeLODLevel(mesh: Mesh): Mesh;
  92522. /**
  92523. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  92524. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  92525. * @param camera defines the camera to use to compute distance
  92526. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  92527. * @return This mesh (for chaining)
  92528. */
  92529. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  92530. /**
  92531. * Gets the mesh internal Geometry object
  92532. */
  92533. readonly geometry: Nullable<Geometry>;
  92534. /**
  92535. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  92536. * @returns the total number of vertices
  92537. */
  92538. getTotalVertices(): number;
  92539. /**
  92540. * Returns the content of an associated vertex buffer
  92541. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  92542. * - VertexBuffer.PositionKind
  92543. * - VertexBuffer.UVKind
  92544. * - VertexBuffer.UV2Kind
  92545. * - VertexBuffer.UV3Kind
  92546. * - VertexBuffer.UV4Kind
  92547. * - VertexBuffer.UV5Kind
  92548. * - VertexBuffer.UV6Kind
  92549. * - VertexBuffer.ColorKind
  92550. * - VertexBuffer.MatricesIndicesKind
  92551. * - VertexBuffer.MatricesIndicesExtraKind
  92552. * - VertexBuffer.MatricesWeightsKind
  92553. * - VertexBuffer.MatricesWeightsExtraKind
  92554. * @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
  92555. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  92556. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  92557. */
  92558. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  92559. /**
  92560. * Returns the mesh VertexBuffer object from the requested `kind`
  92561. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  92562. * - VertexBuffer.PositionKind
  92563. * - VertexBuffer.NormalKind
  92564. * - VertexBuffer.UVKind
  92565. * - VertexBuffer.UV2Kind
  92566. * - VertexBuffer.UV3Kind
  92567. * - VertexBuffer.UV4Kind
  92568. * - VertexBuffer.UV5Kind
  92569. * - VertexBuffer.UV6Kind
  92570. * - VertexBuffer.ColorKind
  92571. * - VertexBuffer.MatricesIndicesKind
  92572. * - VertexBuffer.MatricesIndicesExtraKind
  92573. * - VertexBuffer.MatricesWeightsKind
  92574. * - VertexBuffer.MatricesWeightsExtraKind
  92575. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  92576. */
  92577. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  92578. /**
  92579. * Tests if a specific vertex buffer is associated with this mesh
  92580. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  92581. * - VertexBuffer.PositionKind
  92582. * - VertexBuffer.NormalKind
  92583. * - VertexBuffer.UVKind
  92584. * - VertexBuffer.UV2Kind
  92585. * - VertexBuffer.UV3Kind
  92586. * - VertexBuffer.UV4Kind
  92587. * - VertexBuffer.UV5Kind
  92588. * - VertexBuffer.UV6Kind
  92589. * - VertexBuffer.ColorKind
  92590. * - VertexBuffer.MatricesIndicesKind
  92591. * - VertexBuffer.MatricesIndicesExtraKind
  92592. * - VertexBuffer.MatricesWeightsKind
  92593. * - VertexBuffer.MatricesWeightsExtraKind
  92594. * @returns a boolean
  92595. */
  92596. isVerticesDataPresent(kind: string): boolean;
  92597. /**
  92598. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  92599. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  92600. * - VertexBuffer.PositionKind
  92601. * - VertexBuffer.UVKind
  92602. * - VertexBuffer.UV2Kind
  92603. * - VertexBuffer.UV3Kind
  92604. * - VertexBuffer.UV4Kind
  92605. * - VertexBuffer.UV5Kind
  92606. * - VertexBuffer.UV6Kind
  92607. * - VertexBuffer.ColorKind
  92608. * - VertexBuffer.MatricesIndicesKind
  92609. * - VertexBuffer.MatricesIndicesExtraKind
  92610. * - VertexBuffer.MatricesWeightsKind
  92611. * - VertexBuffer.MatricesWeightsExtraKind
  92612. * @returns a boolean
  92613. */
  92614. isVertexBufferUpdatable(kind: string): boolean;
  92615. /**
  92616. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  92617. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  92618. * - VertexBuffer.PositionKind
  92619. * - VertexBuffer.NormalKind
  92620. * - VertexBuffer.UVKind
  92621. * - VertexBuffer.UV2Kind
  92622. * - VertexBuffer.UV3Kind
  92623. * - VertexBuffer.UV4Kind
  92624. * - VertexBuffer.UV5Kind
  92625. * - VertexBuffer.UV6Kind
  92626. * - VertexBuffer.ColorKind
  92627. * - VertexBuffer.MatricesIndicesKind
  92628. * - VertexBuffer.MatricesIndicesExtraKind
  92629. * - VertexBuffer.MatricesWeightsKind
  92630. * - VertexBuffer.MatricesWeightsExtraKind
  92631. * @returns an array of strings
  92632. */
  92633. getVerticesDataKinds(): string[];
  92634. /**
  92635. * Returns a positive integer : the total number of indices in this mesh geometry.
  92636. * @returns the numner of indices or zero if the mesh has no geometry.
  92637. */
  92638. getTotalIndices(): number;
  92639. /**
  92640. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  92641. * @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.
  92642. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  92643. * @returns the indices array or an empty array if the mesh has no geometry
  92644. */
  92645. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  92646. readonly isBlocked: boolean;
  92647. /**
  92648. * Determine if the current mesh is ready to be rendered
  92649. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  92650. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  92651. * @returns true if all associated assets are ready (material, textures, shaders)
  92652. */
  92653. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  92654. /**
  92655. * 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.
  92656. */
  92657. readonly areNormalsFrozen: boolean;
  92658. /**
  92659. * 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.
  92660. * @returns the current mesh
  92661. */
  92662. freezeNormals(): Mesh;
  92663. /**
  92664. * 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
  92665. * @returns the current mesh
  92666. */
  92667. unfreezeNormals(): Mesh;
  92668. /**
  92669. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  92670. */
  92671. overridenInstanceCount: number;
  92672. /** @hidden */
  92673. _preActivate(): Mesh;
  92674. /** @hidden */
  92675. _preActivateForIntermediateRendering(renderId: number): Mesh;
  92676. /** @hidden */
  92677. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  92678. /**
  92679. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  92680. * This means the mesh underlying bounding box and sphere are recomputed.
  92681. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  92682. * @returns the current mesh
  92683. */
  92684. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  92685. /** @hidden */
  92686. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  92687. /**
  92688. * This function will subdivide the mesh into multiple submeshes
  92689. * @param count defines the expected number of submeshes
  92690. */
  92691. subdivide(count: number): void;
  92692. /**
  92693. * Copy a FloatArray into a specific associated vertex buffer
  92694. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  92695. * - VertexBuffer.PositionKind
  92696. * - VertexBuffer.UVKind
  92697. * - VertexBuffer.UV2Kind
  92698. * - VertexBuffer.UV3Kind
  92699. * - VertexBuffer.UV4Kind
  92700. * - VertexBuffer.UV5Kind
  92701. * - VertexBuffer.UV6Kind
  92702. * - VertexBuffer.ColorKind
  92703. * - VertexBuffer.MatricesIndicesKind
  92704. * - VertexBuffer.MatricesIndicesExtraKind
  92705. * - VertexBuffer.MatricesWeightsKind
  92706. * - VertexBuffer.MatricesWeightsExtraKind
  92707. * @param data defines the data source
  92708. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  92709. * @param stride defines the data stride size (can be null)
  92710. * @returns the current mesh
  92711. */
  92712. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  92713. /**
  92714. * Delete a vertex buffer associated with this mesh
  92715. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  92716. * - VertexBuffer.PositionKind
  92717. * - VertexBuffer.UVKind
  92718. * - VertexBuffer.UV2Kind
  92719. * - VertexBuffer.UV3Kind
  92720. * - VertexBuffer.UV4Kind
  92721. * - VertexBuffer.UV5Kind
  92722. * - VertexBuffer.UV6Kind
  92723. * - VertexBuffer.ColorKind
  92724. * - VertexBuffer.MatricesIndicesKind
  92725. * - VertexBuffer.MatricesIndicesExtraKind
  92726. * - VertexBuffer.MatricesWeightsKind
  92727. * - VertexBuffer.MatricesWeightsExtraKind
  92728. */
  92729. removeVerticesData(kind: string): void;
  92730. /**
  92731. * Flags an associated vertex buffer as updatable
  92732. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  92733. * - VertexBuffer.PositionKind
  92734. * - VertexBuffer.UVKind
  92735. * - VertexBuffer.UV2Kind
  92736. * - VertexBuffer.UV3Kind
  92737. * - VertexBuffer.UV4Kind
  92738. * - VertexBuffer.UV5Kind
  92739. * - VertexBuffer.UV6Kind
  92740. * - VertexBuffer.ColorKind
  92741. * - VertexBuffer.MatricesIndicesKind
  92742. * - VertexBuffer.MatricesIndicesExtraKind
  92743. * - VertexBuffer.MatricesWeightsKind
  92744. * - VertexBuffer.MatricesWeightsExtraKind
  92745. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  92746. */
  92747. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  92748. /**
  92749. * Sets the mesh global Vertex Buffer
  92750. * @param buffer defines the buffer to use
  92751. * @returns the current mesh
  92752. */
  92753. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  92754. /**
  92755. * Update a specific associated vertex buffer
  92756. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  92757. * - VertexBuffer.PositionKind
  92758. * - VertexBuffer.UVKind
  92759. * - VertexBuffer.UV2Kind
  92760. * - VertexBuffer.UV3Kind
  92761. * - VertexBuffer.UV4Kind
  92762. * - VertexBuffer.UV5Kind
  92763. * - VertexBuffer.UV6Kind
  92764. * - VertexBuffer.ColorKind
  92765. * - VertexBuffer.MatricesIndicesKind
  92766. * - VertexBuffer.MatricesIndicesExtraKind
  92767. * - VertexBuffer.MatricesWeightsKind
  92768. * - VertexBuffer.MatricesWeightsExtraKind
  92769. * @param data defines the data source
  92770. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  92771. * @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)
  92772. * @returns the current mesh
  92773. */
  92774. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  92775. /**
  92776. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  92777. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  92778. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  92779. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  92780. * @returns the current mesh
  92781. */
  92782. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  92783. /**
  92784. * Creates a un-shared specific occurence of the geometry for the mesh.
  92785. * @returns the current mesh
  92786. */
  92787. makeGeometryUnique(): Mesh;
  92788. /**
  92789. * Set the index buffer of this mesh
  92790. * @param indices defines the source data
  92791. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  92792. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  92793. * @returns the current mesh
  92794. */
  92795. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  92796. /**
  92797. * Update the current index buffer
  92798. * @param indices defines the source data
  92799. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  92800. * @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)
  92801. * @returns the current mesh
  92802. */
  92803. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  92804. /**
  92805. * Invert the geometry to move from a right handed system to a left handed one.
  92806. * @returns the current mesh
  92807. */
  92808. toLeftHanded(): Mesh;
  92809. /** @hidden */
  92810. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  92811. /** @hidden */
  92812. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  92813. /**
  92814. * Registers for this mesh a javascript function called just before the rendering process
  92815. * @param func defines the function to call before rendering this mesh
  92816. * @returns the current mesh
  92817. */
  92818. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  92819. /**
  92820. * Disposes a previously registered javascript function called before the rendering
  92821. * @param func defines the function to remove
  92822. * @returns the current mesh
  92823. */
  92824. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  92825. /**
  92826. * Registers for this mesh a javascript function called just after the rendering is complete
  92827. * @param func defines the function to call after rendering this mesh
  92828. * @returns the current mesh
  92829. */
  92830. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  92831. /**
  92832. * Disposes a previously registered javascript function called after the rendering.
  92833. * @param func defines the function to remove
  92834. * @returns the current mesh
  92835. */
  92836. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  92837. /** @hidden */
  92838. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  92839. /** @hidden */
  92840. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  92841. /** @hidden */
  92842. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  92843. /** @hidden */
  92844. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  92845. /** @hidden */
  92846. _rebuild(): void;
  92847. /** @hidden */
  92848. _freeze(): void;
  92849. /** @hidden */
  92850. _unFreeze(): void;
  92851. /**
  92852. * 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
  92853. * @param subMesh defines the subMesh to render
  92854. * @param enableAlphaMode defines if alpha mode can be changed
  92855. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  92856. * @returns the current mesh
  92857. */
  92858. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  92859. private _onBeforeDraw;
  92860. /**
  92861. * Renormalize the mesh and patch it up if there are no weights
  92862. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  92863. * However in the case of zero weights then we set just a single influence to 1.
  92864. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  92865. */
  92866. cleanMatrixWeights(): void;
  92867. private normalizeSkinFourWeights;
  92868. private normalizeSkinWeightsAndExtra;
  92869. /**
  92870. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  92871. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  92872. * the user know there was an issue with importing the mesh
  92873. * @returns a validation object with skinned, valid and report string
  92874. */
  92875. validateSkinning(): {
  92876. skinned: boolean;
  92877. valid: boolean;
  92878. report: string;
  92879. };
  92880. /** @hidden */
  92881. _checkDelayState(): Mesh;
  92882. private _queueLoad;
  92883. /**
  92884. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  92885. * A mesh is in the frustum if its bounding box intersects the frustum
  92886. * @param frustumPlanes defines the frustum to test
  92887. * @returns true if the mesh is in the frustum planes
  92888. */
  92889. isInFrustum(frustumPlanes: Plane[]): boolean;
  92890. /**
  92891. * Sets the mesh material by the material or multiMaterial `id` property
  92892. * @param id is a string identifying the material or the multiMaterial
  92893. * @returns the current mesh
  92894. */
  92895. setMaterialByID(id: string): Mesh;
  92896. /**
  92897. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  92898. * @returns an array of IAnimatable
  92899. */
  92900. getAnimatables(): IAnimatable[];
  92901. /**
  92902. * Modifies the mesh geometry according to the passed transformation matrix.
  92903. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  92904. * The mesh normals are modified using the same transformation.
  92905. * Note that, under the hood, this method sets a new VertexBuffer each call.
  92906. * @param transform defines the transform matrix to use
  92907. * @see http://doc.babylonjs.com/resources/baking_transformations
  92908. * @returns the current mesh
  92909. */
  92910. bakeTransformIntoVertices(transform: Matrix): Mesh;
  92911. /**
  92912. * Modifies the mesh geometry according to its own current World Matrix.
  92913. * The mesh World Matrix is then reset.
  92914. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  92915. * Note that, under the hood, this method sets a new VertexBuffer each call.
  92916. * @see http://doc.babylonjs.com/resources/baking_transformations
  92917. * @returns the current mesh
  92918. */
  92919. bakeCurrentTransformIntoVertices(): Mesh;
  92920. /** @hidden */
  92921. readonly _positions: Nullable<Vector3[]>;
  92922. /** @hidden */
  92923. _resetPointsArrayCache(): Mesh;
  92924. /** @hidden */
  92925. _generatePointsArray(): boolean;
  92926. /**
  92927. * Returns a new Mesh object generated from the current mesh properties.
  92928. * This method must not get confused with createInstance()
  92929. * @param name is a string, the name given to the new mesh
  92930. * @param newParent can be any Node object (default `null`)
  92931. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  92932. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  92933. * @returns a new mesh
  92934. */
  92935. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Nullable<AbstractMesh>;
  92936. /**
  92937. * Releases resources associated with this mesh.
  92938. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  92939. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  92940. */
  92941. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  92942. /** @hidden */
  92943. _disposeInstanceSpecificData(): void;
  92944. /**
  92945. * Modifies the mesh geometry according to a displacement map.
  92946. * 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.
  92947. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  92948. * @param url is a string, the URL from the image file is to be downloaded.
  92949. * @param minHeight is the lower limit of the displacement.
  92950. * @param maxHeight is the upper limit of the displacement.
  92951. * @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.
  92952. * @param uvOffset is an optional vector2 used to offset UV.
  92953. * @param uvScale is an optional vector2 used to scale UV.
  92954. * @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.
  92955. * @returns the Mesh.
  92956. */
  92957. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  92958. /**
  92959. * Modifies the mesh geometry according to a displacementMap buffer.
  92960. * 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.
  92961. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  92962. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  92963. * @param heightMapWidth is the width of the buffer image.
  92964. * @param heightMapHeight is the height of the buffer image.
  92965. * @param minHeight is the lower limit of the displacement.
  92966. * @param maxHeight is the upper limit of the displacement.
  92967. * @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.
  92968. * @param uvOffset is an optional vector2 used to offset UV.
  92969. * @param uvScale is an optional vector2 used to scale UV.
  92970. * @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.
  92971. * @returns the Mesh.
  92972. */
  92973. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  92974. /**
  92975. * Modify the mesh to get a flat shading rendering.
  92976. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  92977. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  92978. * @returns current mesh
  92979. */
  92980. convertToFlatShadedMesh(): Mesh;
  92981. /**
  92982. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  92983. * In other words, more vertices, no more indices and a single bigger VBO.
  92984. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  92985. * @returns current mesh
  92986. */
  92987. convertToUnIndexedMesh(): Mesh;
  92988. /**
  92989. * Inverses facet orientations.
  92990. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  92991. * @param flipNormals will also inverts the normals
  92992. * @returns current mesh
  92993. */
  92994. flipFaces(flipNormals?: boolean): Mesh;
  92995. /**
  92996. * Increase the number of facets and hence vertices in a mesh
  92997. * Vertex normals are interpolated from existing vertex normals
  92998. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  92999. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  93000. */
  93001. increaseVertices(numberPerEdge: number): void;
  93002. /**
  93003. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  93004. * This will undo any application of covertToFlatShadedMesh
  93005. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  93006. */
  93007. forceSharedVertices(): void;
  93008. /** @hidden */
  93009. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  93010. /** @hidden */
  93011. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  93012. /**
  93013. * Creates a new InstancedMesh object from the mesh model.
  93014. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  93015. * @param name defines the name of the new instance
  93016. * @returns a new InstancedMesh
  93017. */
  93018. createInstance(name: string): InstancedMesh;
  93019. /**
  93020. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  93021. * After this call, all the mesh instances have the same submeshes than the current mesh.
  93022. * @returns the current mesh
  93023. */
  93024. synchronizeInstances(): Mesh;
  93025. /**
  93026. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  93027. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  93028. * This should be used together with the simplification to avoid disappearing triangles.
  93029. * @param successCallback an optional success callback to be called after the optimization finished.
  93030. * @returns the current mesh
  93031. */
  93032. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  93033. /**
  93034. * Serialize current mesh
  93035. * @param serializationObject defines the object which will receive the serialization data
  93036. */
  93037. serialize(serializationObject: any): void;
  93038. /** @hidden */
  93039. _syncGeometryWithMorphTargetManager(): void;
  93040. /** @hidden */
  93041. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  93042. /**
  93043. * Returns a new Mesh object parsed from the source provided.
  93044. * @param parsedMesh is the source
  93045. * @param scene defines the hosting scene
  93046. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  93047. * @returns a new Mesh
  93048. */
  93049. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  93050. /**
  93051. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  93052. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  93053. * @param name defines the name of the mesh to create
  93054. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  93055. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  93056. * @param closePath creates a seam between the first and the last points of each path of the path array
  93057. * @param offset is taken in account only if the `pathArray` is containing a single path
  93058. * @param scene defines the hosting scene
  93059. * @param updatable defines if the mesh must be flagged as updatable
  93060. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  93061. * @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)
  93062. * @returns a new Mesh
  93063. */
  93064. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  93065. /**
  93066. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  93067. * @param name defines the name of the mesh to create
  93068. * @param radius sets the radius size (float) of the polygon (default 0.5)
  93069. * @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
  93070. * @param scene defines the hosting scene
  93071. * @param updatable defines if the mesh must be flagged as updatable
  93072. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  93073. * @returns a new Mesh
  93074. */
  93075. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  93076. /**
  93077. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  93078. * @param name defines the name of the mesh to create
  93079. * @param size sets the size (float) of each box side (default 1)
  93080. * @param scene defines the hosting scene
  93081. * @param updatable defines if the mesh must be flagged as updatable
  93082. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  93083. * @returns a new Mesh
  93084. */
  93085. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  93086. /**
  93087. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  93088. * @param name defines the name of the mesh to create
  93089. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  93090. * @param diameter sets the diameter size (float) of the sphere (default 1)
  93091. * @param scene defines the hosting scene
  93092. * @param updatable defines if the mesh must be flagged as updatable
  93093. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  93094. * @returns a new Mesh
  93095. */
  93096. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  93097. /**
  93098. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  93099. * @param name defines the name of the mesh to create
  93100. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  93101. * @param diameter sets the diameter size (float) of the sphere (default 1)
  93102. * @param scene defines the hosting scene
  93103. * @returns a new Mesh
  93104. */
  93105. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  93106. /**
  93107. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  93108. * @param name defines the name of the mesh to create
  93109. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  93110. * @param diameterTop set the top cap diameter (floats, default 1)
  93111. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  93112. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  93113. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  93114. * @param scene defines the hosting scene
  93115. * @param updatable defines if the mesh must be flagged as updatable
  93116. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  93117. * @returns a new Mesh
  93118. */
  93119. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  93120. /**
  93121. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  93122. * @param name defines the name of the mesh to create
  93123. * @param diameter sets the diameter size (float) of the torus (default 1)
  93124. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  93125. * @param tessellation sets the number of torus sides (postive integer, default 16)
  93126. * @param scene defines the hosting scene
  93127. * @param updatable defines if the mesh must be flagged as updatable
  93128. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  93129. * @returns a new Mesh
  93130. */
  93131. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  93132. /**
  93133. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  93134. * @param name defines the name of the mesh to create
  93135. * @param radius sets the global radius size (float) of the torus knot (default 2)
  93136. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  93137. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  93138. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  93139. * @param p the number of windings on X axis (positive integers, default 2)
  93140. * @param q the number of windings on Y axis (positive integers, default 3)
  93141. * @param scene defines the hosting scene
  93142. * @param updatable defines if the mesh must be flagged as updatable
  93143. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  93144. * @returns a new Mesh
  93145. */
  93146. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  93147. /**
  93148. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  93149. * @param name defines the name of the mesh to create
  93150. * @param points is an array successive Vector3
  93151. * @param scene defines the hosting scene
  93152. * @param updatable defines if the mesh must be flagged as updatable
  93153. * @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).
  93154. * @returns a new Mesh
  93155. */
  93156. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  93157. /**
  93158. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  93159. * @param name defines the name of the mesh to create
  93160. * @param points is an array successive Vector3
  93161. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  93162. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  93163. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  93164. * @param scene defines the hosting scene
  93165. * @param updatable defines if the mesh must be flagged as updatable
  93166. * @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)
  93167. * @returns a new Mesh
  93168. */
  93169. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  93170. /**
  93171. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  93172. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  93173. * 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.
  93174. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  93175. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  93176. * Remember you can only change the shape positions, not their number when updating a polygon.
  93177. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  93178. * @param name defines the name of the mesh to create
  93179. * @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
  93180. * @param scene defines the hosting scene
  93181. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  93182. * @param updatable defines if the mesh must be flagged as updatable
  93183. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  93184. * @param earcutInjection can be used to inject your own earcut reference
  93185. * @returns a new Mesh
  93186. */
  93187. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  93188. /**
  93189. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  93190. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  93191. * @param name defines the name of the mesh to create
  93192. * @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
  93193. * @param depth defines the height of extrusion
  93194. * @param scene defines the hosting scene
  93195. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  93196. * @param updatable defines if the mesh must be flagged as updatable
  93197. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  93198. * @param earcutInjection can be used to inject your own earcut reference
  93199. * @returns a new Mesh
  93200. */
  93201. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  93202. /**
  93203. * Creates an extruded shape mesh.
  93204. * 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
  93205. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  93206. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  93207. * @param name defines the name of the mesh to create
  93208. * @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
  93209. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  93210. * @param scale is the value to scale the shape
  93211. * @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
  93212. * @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
  93213. * @param scene defines the hosting scene
  93214. * @param updatable defines if the mesh must be flagged as updatable
  93215. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  93216. * @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)
  93217. * @returns a new Mesh
  93218. */
  93219. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  93220. /**
  93221. * Creates an custom extruded shape mesh.
  93222. * The custom extrusion is a parametric shape.
  93223. * It has no predefined shape. Its final shape will depend on the input parameters.
  93224. * Please consider using the same method from the MeshBuilder class instead
  93225. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  93226. * @param name defines the name of the mesh to create
  93227. * @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
  93228. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  93229. * @param scaleFunction is a custom Javascript function called on each path point
  93230. * @param rotationFunction is a custom Javascript function called on each path point
  93231. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  93232. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  93233. * @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
  93234. * @param scene defines the hosting scene
  93235. * @param updatable defines if the mesh must be flagged as updatable
  93236. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  93237. * @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)
  93238. * @returns a new Mesh
  93239. */
  93240. 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;
  93241. /**
  93242. * Creates lathe mesh.
  93243. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  93244. * Please consider using the same method from the MeshBuilder class instead
  93245. * @param name defines the name of the mesh to create
  93246. * @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
  93247. * @param radius is the radius value of the lathe
  93248. * @param tessellation is the side number of the lathe.
  93249. * @param scene defines the hosting scene
  93250. * @param updatable defines if the mesh must be flagged as updatable
  93251. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  93252. * @returns a new Mesh
  93253. */
  93254. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  93255. /**
  93256. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  93257. * @param name defines the name of the mesh to create
  93258. * @param size sets the size (float) of both sides of the plane at once (default 1)
  93259. * @param scene defines the hosting scene
  93260. * @param updatable defines if the mesh must be flagged as updatable
  93261. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  93262. * @returns a new Mesh
  93263. */
  93264. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  93265. /**
  93266. * Creates a ground mesh.
  93267. * Please consider using the same method from the MeshBuilder class instead
  93268. * @param name defines the name of the mesh to create
  93269. * @param width set the width of the ground
  93270. * @param height set the height of the ground
  93271. * @param subdivisions sets the number of subdivisions per side
  93272. * @param scene defines the hosting scene
  93273. * @param updatable defines if the mesh must be flagged as updatable
  93274. * @returns a new Mesh
  93275. */
  93276. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  93277. /**
  93278. * Creates a tiled ground mesh.
  93279. * Please consider using the same method from the MeshBuilder class instead
  93280. * @param name defines the name of the mesh to create
  93281. * @param xmin set the ground minimum X coordinate
  93282. * @param zmin set the ground minimum Y coordinate
  93283. * @param xmax set the ground maximum X coordinate
  93284. * @param zmax set the ground maximum Z coordinate
  93285. * @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
  93286. * @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
  93287. * @param scene defines the hosting scene
  93288. * @param updatable defines if the mesh must be flagged as updatable
  93289. * @returns a new Mesh
  93290. */
  93291. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  93292. w: number;
  93293. h: number;
  93294. }, precision: {
  93295. w: number;
  93296. h: number;
  93297. }, scene: Scene, updatable?: boolean): Mesh;
  93298. /**
  93299. * Creates a ground mesh from a height map.
  93300. * Please consider using the same method from the MeshBuilder class instead
  93301. * @see http://doc.babylonjs.com/babylon101/height_map
  93302. * @param name defines the name of the mesh to create
  93303. * @param url sets the URL of the height map image resource
  93304. * @param width set the ground width size
  93305. * @param height set the ground height size
  93306. * @param subdivisions sets the number of subdivision per side
  93307. * @param minHeight is the minimum altitude on the ground
  93308. * @param maxHeight is the maximum altitude on the ground
  93309. * @param scene defines the hosting scene
  93310. * @param updatable defines if the mesh must be flagged as updatable
  93311. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  93312. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  93313. * @returns a new Mesh
  93314. */
  93315. 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;
  93316. /**
  93317. * Creates a tube mesh.
  93318. * The tube is a parametric shape.
  93319. * It has no predefined shape. Its final shape will depend on the input parameters.
  93320. * Please consider using the same method from the MeshBuilder class instead
  93321. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  93322. * @param name defines the name of the mesh to create
  93323. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  93324. * @param radius sets the tube radius size
  93325. * @param tessellation is the number of sides on the tubular surface
  93326. * @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
  93327. * @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
  93328. * @param scene defines the hosting scene
  93329. * @param updatable defines if the mesh must be flagged as updatable
  93330. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  93331. * @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)
  93332. * @returns a new Mesh
  93333. */
  93334. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  93335. (i: number, distance: number): number;
  93336. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  93337. /**
  93338. * Creates a polyhedron mesh.
  93339. * Please consider using the same method from the MeshBuilder class instead.
  93340. * * 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
  93341. * * The parameter `size` (positive float, default 1) sets the polygon size
  93342. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  93343. * * 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`
  93344. * * 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
  93345. * * 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)`)
  93346. * * 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
  93347. * * 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
  93348. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  93349. * * If you create a double-sided mesh, you can choose what parts of 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
  93350. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  93351. * @param name defines the name of the mesh to create
  93352. * @param options defines the options used to create the mesh
  93353. * @param scene defines the hosting scene
  93354. * @returns a new Mesh
  93355. */
  93356. static CreatePolyhedron(name: string, options: {
  93357. type?: number;
  93358. size?: number;
  93359. sizeX?: number;
  93360. sizeY?: number;
  93361. sizeZ?: number;
  93362. custom?: any;
  93363. faceUV?: Vector4[];
  93364. faceColors?: Color4[];
  93365. updatable?: boolean;
  93366. sideOrientation?: number;
  93367. }, scene: Scene): Mesh;
  93368. /**
  93369. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  93370. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  93371. * * 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`)
  93372. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  93373. * * 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
  93374. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  93375. * * If you create a double-sided mesh, you can choose what parts of 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
  93376. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  93377. * @param name defines the name of the mesh
  93378. * @param options defines the options used to create the mesh
  93379. * @param scene defines the hosting scene
  93380. * @returns a new Mesh
  93381. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  93382. */
  93383. static CreateIcoSphere(name: string, options: {
  93384. radius?: number;
  93385. flat?: boolean;
  93386. subdivisions?: number;
  93387. sideOrientation?: number;
  93388. updatable?: boolean;
  93389. }, scene: Scene): Mesh;
  93390. /**
  93391. * Creates a decal mesh.
  93392. * Please consider using the same method from the MeshBuilder class instead.
  93393. * A decal is a mesh usually applied as a model onto the surface of another mesh
  93394. * @param name defines the name of the mesh
  93395. * @param sourceMesh defines the mesh receiving the decal
  93396. * @param position sets the position of the decal in world coordinates
  93397. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  93398. * @param size sets the decal scaling
  93399. * @param angle sets the angle to rotate the decal
  93400. * @returns a new Mesh
  93401. */
  93402. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  93403. /**
  93404. * Prepare internal position array for software CPU skinning
  93405. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  93406. */
  93407. setPositionsForCPUSkinning(): Float32Array;
  93408. /**
  93409. * Prepare internal normal array for software CPU skinning
  93410. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  93411. */
  93412. setNormalsForCPUSkinning(): Float32Array;
  93413. /**
  93414. * Updates the vertex buffer by applying transformation from the bones
  93415. * @param skeleton defines the skeleton to apply to current mesh
  93416. * @returns the current mesh
  93417. */
  93418. applySkeleton(skeleton: Skeleton): Mesh;
  93419. /**
  93420. * 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
  93421. * @param meshes defines the list of meshes to scan
  93422. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  93423. */
  93424. static MinMax(meshes: AbstractMesh[]): {
  93425. min: Vector3;
  93426. max: Vector3;
  93427. };
  93428. /**
  93429. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  93430. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  93431. * @returns a vector3
  93432. */
  93433. static Center(meshesOrMinMaxVector: {
  93434. min: Vector3;
  93435. max: Vector3;
  93436. } | AbstractMesh[]): Vector3;
  93437. /**
  93438. * Merge the array of meshes into a single mesh for performance reasons.
  93439. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  93440. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  93441. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  93442. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  93443. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  93444. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  93445. * @returns a new mesh
  93446. */
  93447. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  93448. /** @hidden */
  93449. addInstance(instance: InstancedMesh): void;
  93450. /** @hidden */
  93451. removeInstance(instance: InstancedMesh): void;
  93452. }
  93453. }
  93454. declare module BABYLON {
  93455. /**
  93456. * This is the base class of all the camera used in the application.
  93457. * @see http://doc.babylonjs.com/features/cameras
  93458. */
  93459. export class Camera extends Node {
  93460. /** @hidden */
  93461. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  93462. /**
  93463. * This is the default projection mode used by the cameras.
  93464. * It helps recreating a feeling of perspective and better appreciate depth.
  93465. * This is the best way to simulate real life cameras.
  93466. */
  93467. static readonly PERSPECTIVE_CAMERA: number;
  93468. /**
  93469. * This helps creating camera with an orthographic mode.
  93470. * 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.
  93471. */
  93472. static readonly ORTHOGRAPHIC_CAMERA: number;
  93473. /**
  93474. * This is the default FOV mode for perspective cameras.
  93475. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  93476. */
  93477. static readonly FOVMODE_VERTICAL_FIXED: number;
  93478. /**
  93479. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  93480. */
  93481. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  93482. /**
  93483. * This specifies ther is no need for a camera rig.
  93484. * Basically only one eye is rendered corresponding to the camera.
  93485. */
  93486. static readonly RIG_MODE_NONE: number;
  93487. /**
  93488. * Simulates a camera Rig with one blue eye and one red eye.
  93489. * This can be use with 3d blue and red glasses.
  93490. */
  93491. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  93492. /**
  93493. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  93494. */
  93495. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  93496. /**
  93497. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  93498. */
  93499. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  93500. /**
  93501. * Defines that both eyes of the camera will be rendered over under each other.
  93502. */
  93503. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  93504. /**
  93505. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  93506. */
  93507. static readonly RIG_MODE_VR: number;
  93508. /**
  93509. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  93510. */
  93511. static readonly RIG_MODE_WEBVR: number;
  93512. /**
  93513. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  93514. */
  93515. static readonly RIG_MODE_CUSTOM: number;
  93516. /**
  93517. * Defines if by default attaching controls should prevent the default javascript event to continue.
  93518. */
  93519. static ForceAttachControlToAlwaysPreventDefault: boolean;
  93520. /**
  93521. * Define the input manager associated with the camera.
  93522. */
  93523. inputs: CameraInputsManager<Camera>;
  93524. /** @hidden */
  93525. _position: Vector3;
  93526. /**
  93527. * Define the current local position of the camera in the scene
  93528. */
  93529. position: Vector3;
  93530. /**
  93531. * The vector the camera should consider as up.
  93532. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  93533. */
  93534. upVector: Vector3;
  93535. /**
  93536. * Define the current limit on the left side for an orthographic camera
  93537. * In scene unit
  93538. */
  93539. orthoLeft: Nullable<number>;
  93540. /**
  93541. * Define the current limit on the right side for an orthographic camera
  93542. * In scene unit
  93543. */
  93544. orthoRight: Nullable<number>;
  93545. /**
  93546. * Define the current limit on the bottom side for an orthographic camera
  93547. * In scene unit
  93548. */
  93549. orthoBottom: Nullable<number>;
  93550. /**
  93551. * Define the current limit on the top side for an orthographic camera
  93552. * In scene unit
  93553. */
  93554. orthoTop: Nullable<number>;
  93555. /**
  93556. * Field Of View is set in Radians. (default is 0.8)
  93557. */
  93558. fov: number;
  93559. /**
  93560. * Define the minimum distance the camera can see from.
  93561. * This is important to note that the depth buffer are not infinite and the closer it starts
  93562. * the more your scene might encounter depth fighting issue.
  93563. */
  93564. minZ: number;
  93565. /**
  93566. * Define the maximum distance the camera can see to.
  93567. * This is important to note that the depth buffer are not infinite and the further it end
  93568. * the more your scene might encounter depth fighting issue.
  93569. */
  93570. maxZ: number;
  93571. /**
  93572. * Define the default inertia of the camera.
  93573. * This helps giving a smooth feeling to the camera movement.
  93574. */
  93575. inertia: number;
  93576. /**
  93577. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  93578. */
  93579. mode: number;
  93580. /**
  93581. * Define wether the camera is intermediate.
  93582. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  93583. */
  93584. isIntermediate: boolean;
  93585. /**
  93586. * Define the viewport of the camera.
  93587. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  93588. */
  93589. viewport: Viewport;
  93590. /**
  93591. * Restricts the camera to viewing objects with the same layerMask.
  93592. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  93593. */
  93594. layerMask: number;
  93595. /**
  93596. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  93597. */
  93598. fovMode: number;
  93599. /**
  93600. * Rig mode of the camera.
  93601. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  93602. * This is normally controlled byt the camera themselves as internal use.
  93603. */
  93604. cameraRigMode: number;
  93605. /**
  93606. * Defines the distance between both "eyes" in case of a RIG
  93607. */
  93608. interaxialDistance: number;
  93609. /**
  93610. * Defines if stereoscopic rendering is done side by side or over under.
  93611. */
  93612. isStereoscopicSideBySide: boolean;
  93613. /**
  93614. * 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
  93615. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  93616. * else in the scene. (Eg. security camera)
  93617. *
  93618. * 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)
  93619. */
  93620. customRenderTargets: RenderTargetTexture[];
  93621. /**
  93622. * When set, the camera will render to this render target instead of the default canvas
  93623. *
  93624. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  93625. */
  93626. outputRenderTarget: Nullable<RenderTargetTexture>;
  93627. /**
  93628. * Observable triggered when the camera view matrix has changed.
  93629. */
  93630. onViewMatrixChangedObservable: Observable<Camera>;
  93631. /**
  93632. * Observable triggered when the camera Projection matrix has changed.
  93633. */
  93634. onProjectionMatrixChangedObservable: Observable<Camera>;
  93635. /**
  93636. * Observable triggered when the inputs have been processed.
  93637. */
  93638. onAfterCheckInputsObservable: Observable<Camera>;
  93639. /**
  93640. * Observable triggered when reset has been called and applied to the camera.
  93641. */
  93642. onRestoreStateObservable: Observable<Camera>;
  93643. /** @hidden */
  93644. _cameraRigParams: any;
  93645. /** @hidden */
  93646. _rigCameras: Camera[];
  93647. /** @hidden */
  93648. _rigPostProcess: Nullable<PostProcess>;
  93649. protected _webvrViewMatrix: Matrix;
  93650. /** @hidden */
  93651. _skipRendering: boolean;
  93652. /** @hidden */
  93653. _projectionMatrix: Matrix;
  93654. /** @hidden */
  93655. _postProcesses: Nullable<PostProcess>[];
  93656. /** @hidden */
  93657. _activeMeshes: SmartArray<AbstractMesh>;
  93658. protected _globalPosition: Vector3;
  93659. /** @hidden */
  93660. _computedViewMatrix: Matrix;
  93661. private _doNotComputeProjectionMatrix;
  93662. private _transformMatrix;
  93663. private _frustumPlanes;
  93664. private _refreshFrustumPlanes;
  93665. private _storedFov;
  93666. private _stateStored;
  93667. /**
  93668. * Instantiates a new camera object.
  93669. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  93670. * @see http://doc.babylonjs.com/features/cameras
  93671. * @param name Defines the name of the camera in the scene
  93672. * @param position Defines the position of the camera
  93673. * @param scene Defines the scene the camera belongs too
  93674. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  93675. */
  93676. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  93677. /**
  93678. * Store current camera state (fov, position, etc..)
  93679. * @returns the camera
  93680. */
  93681. storeState(): Camera;
  93682. /**
  93683. * Restores the camera state values if it has been stored. You must call storeState() first
  93684. */
  93685. protected _restoreStateValues(): boolean;
  93686. /**
  93687. * Restored camera state. You must call storeState() first.
  93688. * @returns true if restored and false otherwise
  93689. */
  93690. restoreState(): boolean;
  93691. /**
  93692. * Gets the class name of the camera.
  93693. * @returns the class name
  93694. */
  93695. getClassName(): string;
  93696. /** @hidden */
  93697. readonly _isCamera: boolean;
  93698. /**
  93699. * Gets a string representation of the camera useful for debug purpose.
  93700. * @param fullDetails Defines that a more verboe level of logging is required
  93701. * @returns the string representation
  93702. */
  93703. toString(fullDetails?: boolean): string;
  93704. /**
  93705. * Gets the current world space position of the camera.
  93706. */
  93707. readonly globalPosition: Vector3;
  93708. /**
  93709. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  93710. * @returns the active meshe list
  93711. */
  93712. getActiveMeshes(): SmartArray<AbstractMesh>;
  93713. /**
  93714. * Check wether a mesh is part of the current active mesh list of the camera
  93715. * @param mesh Defines the mesh to check
  93716. * @returns true if active, false otherwise
  93717. */
  93718. isActiveMesh(mesh: Mesh): boolean;
  93719. /**
  93720. * Is this camera ready to be used/rendered
  93721. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  93722. * @return true if the camera is ready
  93723. */
  93724. isReady(completeCheck?: boolean): boolean;
  93725. /** @hidden */
  93726. _initCache(): void;
  93727. /** @hidden */
  93728. _updateCache(ignoreParentClass?: boolean): void;
  93729. /** @hidden */
  93730. _isSynchronized(): boolean;
  93731. /** @hidden */
  93732. _isSynchronizedViewMatrix(): boolean;
  93733. /** @hidden */
  93734. _isSynchronizedProjectionMatrix(): boolean;
  93735. /**
  93736. * Attach the input controls to a specific dom element to get the input from.
  93737. * @param element Defines the element the controls should be listened from
  93738. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  93739. */
  93740. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  93741. /**
  93742. * Detach the current controls from the specified dom element.
  93743. * @param element Defines the element to stop listening the inputs from
  93744. */
  93745. detachControl(element: HTMLElement): void;
  93746. /**
  93747. * Update the camera state according to the different inputs gathered during the frame.
  93748. */
  93749. update(): void;
  93750. /** @hidden */
  93751. _checkInputs(): void;
  93752. /** @hidden */
  93753. readonly rigCameras: Camera[];
  93754. /**
  93755. * Gets the post process used by the rig cameras
  93756. */
  93757. readonly rigPostProcess: Nullable<PostProcess>;
  93758. /**
  93759. * Internal, gets the first post proces.
  93760. * @returns the first post process to be run on this camera.
  93761. */
  93762. _getFirstPostProcess(): Nullable<PostProcess>;
  93763. private _cascadePostProcessesToRigCams;
  93764. /**
  93765. * Attach a post process to the camera.
  93766. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  93767. * @param postProcess The post process to attach to the camera
  93768. * @param insertAt The position of the post process in case several of them are in use in the scene
  93769. * @returns the position the post process has been inserted at
  93770. */
  93771. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  93772. /**
  93773. * Detach a post process to the camera.
  93774. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  93775. * @param postProcess The post process to detach from the camera
  93776. */
  93777. detachPostProcess(postProcess: PostProcess): void;
  93778. /**
  93779. * Gets the current world matrix of the camera
  93780. */
  93781. getWorldMatrix(): Matrix;
  93782. /** @hidden */
  93783. _getViewMatrix(): Matrix;
  93784. /**
  93785. * Gets the current view matrix of the camera.
  93786. * @param force forces the camera to recompute the matrix without looking at the cached state
  93787. * @returns the view matrix
  93788. */
  93789. getViewMatrix(force?: boolean): Matrix;
  93790. /**
  93791. * Freeze the projection matrix.
  93792. * It will prevent the cache check of the camera projection compute and can speed up perf
  93793. * if no parameter of the camera are meant to change
  93794. * @param projection Defines manually a projection if necessary
  93795. */
  93796. freezeProjectionMatrix(projection?: Matrix): void;
  93797. /**
  93798. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  93799. */
  93800. unfreezeProjectionMatrix(): void;
  93801. /**
  93802. * Gets the current projection matrix of the camera.
  93803. * @param force forces the camera to recompute the matrix without looking at the cached state
  93804. * @returns the projection matrix
  93805. */
  93806. getProjectionMatrix(force?: boolean): Matrix;
  93807. /**
  93808. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  93809. * @returns a Matrix
  93810. */
  93811. getTransformationMatrix(): Matrix;
  93812. private _updateFrustumPlanes;
  93813. /**
  93814. * Checks if a cullable object (mesh...) is in the camera frustum
  93815. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  93816. * @param target The object to check
  93817. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  93818. * @returns true if the object is in frustum otherwise false
  93819. */
  93820. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  93821. /**
  93822. * Checks if a cullable object (mesh...) is in the camera frustum
  93823. * Unlike isInFrustum this cheks the full bounding box
  93824. * @param target The object to check
  93825. * @returns true if the object is in frustum otherwise false
  93826. */
  93827. isCompletelyInFrustum(target: ICullable): boolean;
  93828. /**
  93829. * Gets a ray in the forward direction from the camera.
  93830. * @param length Defines the length of the ray to create
  93831. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  93832. * @param origin Defines the start point of the ray which defaults to the camera position
  93833. * @returns the forward ray
  93834. */
  93835. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  93836. /**
  93837. * Releases resources associated with this node.
  93838. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  93839. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  93840. */
  93841. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  93842. /** @hidden */
  93843. _isLeftCamera: boolean;
  93844. /**
  93845. * Gets the left camera of a rig setup in case of Rigged Camera
  93846. */
  93847. readonly isLeftCamera: boolean;
  93848. /** @hidden */
  93849. _isRightCamera: boolean;
  93850. /**
  93851. * Gets the right camera of a rig setup in case of Rigged Camera
  93852. */
  93853. readonly isRightCamera: boolean;
  93854. /**
  93855. * Gets the left camera of a rig setup in case of Rigged Camera
  93856. */
  93857. readonly leftCamera: Nullable<FreeCamera>;
  93858. /**
  93859. * Gets the right camera of a rig setup in case of Rigged Camera
  93860. */
  93861. readonly rightCamera: Nullable<FreeCamera>;
  93862. /**
  93863. * Gets the left camera target of a rig setup in case of Rigged Camera
  93864. * @returns the target position
  93865. */
  93866. getLeftTarget(): Nullable<Vector3>;
  93867. /**
  93868. * Gets the right camera target of a rig setup in case of Rigged Camera
  93869. * @returns the target position
  93870. */
  93871. getRightTarget(): Nullable<Vector3>;
  93872. /**
  93873. * @hidden
  93874. */
  93875. setCameraRigMode(mode: number, rigParams: any): void;
  93876. /** @hidden */
  93877. static _setStereoscopicRigMode(camera: Camera): void;
  93878. /** @hidden */
  93879. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  93880. /** @hidden */
  93881. static _setVRRigMode(camera: Camera, rigParams: any): void;
  93882. /** @hidden */
  93883. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  93884. /** @hidden */
  93885. _getVRProjectionMatrix(): Matrix;
  93886. protected _updateCameraRotationMatrix(): void;
  93887. protected _updateWebVRCameraRotationMatrix(): void;
  93888. /**
  93889. * This function MUST be overwritten by the different WebVR cameras available.
  93890. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  93891. * @hidden
  93892. */
  93893. _getWebVRProjectionMatrix(): Matrix;
  93894. /**
  93895. * This function MUST be overwritten by the different WebVR cameras available.
  93896. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  93897. * @hidden
  93898. */
  93899. _getWebVRViewMatrix(): Matrix;
  93900. /** @hidden */
  93901. setCameraRigParameter(name: string, value: any): void;
  93902. /**
  93903. * needs to be overridden by children so sub has required properties to be copied
  93904. * @hidden
  93905. */
  93906. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  93907. /**
  93908. * May need to be overridden by children
  93909. * @hidden
  93910. */
  93911. _updateRigCameras(): void;
  93912. /** @hidden */
  93913. _setupInputs(): void;
  93914. /**
  93915. * Serialiaze the camera setup to a json represention
  93916. * @returns the JSON representation
  93917. */
  93918. serialize(): any;
  93919. /**
  93920. * Clones the current camera.
  93921. * @param name The cloned camera name
  93922. * @returns the cloned camera
  93923. */
  93924. clone(name: string): Camera;
  93925. /**
  93926. * Gets the direction of the camera relative to a given local axis.
  93927. * @param localAxis Defines the reference axis to provide a relative direction.
  93928. * @return the direction
  93929. */
  93930. getDirection(localAxis: Vector3): Vector3;
  93931. /**
  93932. * Returns the current camera absolute rotation
  93933. */
  93934. readonly absoluteRotation: Quaternion;
  93935. /**
  93936. * Gets the direction of the camera relative to a given local axis into a passed vector.
  93937. * @param localAxis Defines the reference axis to provide a relative direction.
  93938. * @param result Defines the vector to store the result in
  93939. */
  93940. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  93941. /**
  93942. * Gets a camera constructor for a given camera type
  93943. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  93944. * @param name The name of the camera the result will be able to instantiate
  93945. * @param scene The scene the result will construct the camera in
  93946. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  93947. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  93948. * @returns a factory method to construc the camera
  93949. */
  93950. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  93951. /**
  93952. * Compute the world matrix of the camera.
  93953. * @returns the camera world matrix
  93954. */
  93955. computeWorldMatrix(): Matrix;
  93956. /**
  93957. * Parse a JSON and creates the camera from the parsed information
  93958. * @param parsedCamera The JSON to parse
  93959. * @param scene The scene to instantiate the camera in
  93960. * @returns the newly constructed camera
  93961. */
  93962. static Parse(parsedCamera: any, scene: Scene): Camera;
  93963. }
  93964. }
  93965. declare module BABYLON {
  93966. /**
  93967. * Class containing static functions to help procedurally build meshes
  93968. */
  93969. export class DiscBuilder {
  93970. /**
  93971. * Creates a plane polygonal mesh. By default, this is a disc
  93972. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  93973. * * 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
  93974. * * 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
  93975. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  93976. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  93977. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  93978. * @param name defines the name of the mesh
  93979. * @param options defines the options used to create the mesh
  93980. * @param scene defines the hosting scene
  93981. * @returns the plane polygonal mesh
  93982. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  93983. */
  93984. static CreateDisc(name: string, options: {
  93985. radius?: number;
  93986. tessellation?: number;
  93987. arc?: number;
  93988. updatable?: boolean;
  93989. sideOrientation?: number;
  93990. frontUVs?: Vector4;
  93991. backUVs?: Vector4;
  93992. }, scene?: Nullable<Scene>): Mesh;
  93993. }
  93994. }
  93995. declare module BABYLON {
  93996. /**
  93997. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  93998. *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.
  93999. * The SPS is also a particle system. It provides some methods to manage the particles.
  94000. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  94001. *
  94002. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  94003. */
  94004. export class SolidParticleSystem implements IDisposable {
  94005. /**
  94006. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  94007. * Example : var p = SPS.particles[i];
  94008. */
  94009. particles: SolidParticle[];
  94010. /**
  94011. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  94012. */
  94013. nbParticles: number;
  94014. /**
  94015. * If the particles must ever face the camera (default false). Useful for planar particles.
  94016. */
  94017. billboard: boolean;
  94018. /**
  94019. * Recompute normals when adding a shape
  94020. */
  94021. recomputeNormals: boolean;
  94022. /**
  94023. * This a counter ofr your own usage. It's not set by any SPS functions.
  94024. */
  94025. counter: number;
  94026. /**
  94027. * The SPS name. This name is also given to the underlying mesh.
  94028. */
  94029. name: string;
  94030. /**
  94031. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  94032. */
  94033. mesh: Mesh;
  94034. /**
  94035. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  94036. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  94037. */
  94038. vars: any;
  94039. /**
  94040. * This array is populated when the SPS is set as 'pickable'.
  94041. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  94042. * Each element of this array is an object `{idx: int, faceId: int}`.
  94043. * `idx` is the picked particle index in the `SPS.particles` array
  94044. * `faceId` is the picked face index counted within this particle.
  94045. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  94046. */
  94047. pickedParticles: {
  94048. idx: number;
  94049. faceId: number;
  94050. }[];
  94051. /**
  94052. * This array is populated when `enableDepthSort` is set to true.
  94053. * Each element of this array is an instance of the class DepthSortedParticle.
  94054. */
  94055. depthSortedParticles: DepthSortedParticle[];
  94056. /**
  94057. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  94058. * @hidden
  94059. */
  94060. _bSphereOnly: boolean;
  94061. /**
  94062. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  94063. * @hidden
  94064. */
  94065. _bSphereRadiusFactor: number;
  94066. private _scene;
  94067. private _positions;
  94068. private _indices;
  94069. private _normals;
  94070. private _colors;
  94071. private _uvs;
  94072. private _indices32;
  94073. private _positions32;
  94074. private _normals32;
  94075. private _fixedNormal32;
  94076. private _colors32;
  94077. private _uvs32;
  94078. private _index;
  94079. private _updatable;
  94080. private _pickable;
  94081. private _isVisibilityBoxLocked;
  94082. private _alwaysVisible;
  94083. private _depthSort;
  94084. private _expandable;
  94085. private _shapeCounter;
  94086. private _copy;
  94087. private _color;
  94088. private _computeParticleColor;
  94089. private _computeParticleTexture;
  94090. private _computeParticleRotation;
  94091. private _computeParticleVertex;
  94092. private _computeBoundingBox;
  94093. private _depthSortParticles;
  94094. private _camera;
  94095. private _mustUnrotateFixedNormals;
  94096. private _particlesIntersect;
  94097. private _needs32Bits;
  94098. private _isNotBuilt;
  94099. private _lastParticleId;
  94100. private _idxOfId;
  94101. private _multimaterialEnabled;
  94102. private _indicesByMaterial;
  94103. private _materialIndexes;
  94104. private _depthSortFunction;
  94105. private _materialSortFunction;
  94106. /**
  94107. * Creates a SPS (Solid Particle System) object.
  94108. * @param name (String) is the SPS name, this will be the underlying mesh name.
  94109. * @param scene (Scene) is the scene in which the SPS is added.
  94110. * @param options defines the options of the sps e.g.
  94111. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  94112. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  94113. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  94114. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  94115. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  94116. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  94117. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  94118. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  94119. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  94120. */
  94121. constructor(name: string, scene: Scene, options?: {
  94122. updatable?: boolean;
  94123. isPickable?: boolean;
  94124. enableDepthSort?: boolean;
  94125. particleIntersection?: boolean;
  94126. boundingSphereOnly?: boolean;
  94127. bSphereRadiusFactor?: number;
  94128. expandable?: boolean;
  94129. enableMultiMaterial?: boolean;
  94130. });
  94131. /**
  94132. * Builds the SPS underlying mesh. Returns a standard Mesh.
  94133. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  94134. * @returns the created mesh
  94135. */
  94136. buildMesh(): Mesh;
  94137. /**
  94138. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  94139. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  94140. * Thus the particles generated from `digest()` have their property `position` set yet.
  94141. * @param mesh ( Mesh ) is the mesh to be digested
  94142. * @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
  94143. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  94144. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  94145. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  94146. * @returns the current SPS
  94147. */
  94148. digest(mesh: Mesh, options?: {
  94149. facetNb?: number;
  94150. number?: number;
  94151. delta?: number;
  94152. storage?: [];
  94153. }): SolidParticleSystem;
  94154. /**
  94155. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  94156. * @hidden
  94157. */
  94158. private _unrotateFixedNormals;
  94159. /**
  94160. * Resets the temporary working copy particle
  94161. * @hidden
  94162. */
  94163. private _resetCopy;
  94164. /**
  94165. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  94166. * @param p the current index in the positions array to be updated
  94167. * @param shape a Vector3 array, the shape geometry
  94168. * @param positions the positions array to be updated
  94169. * @param meshInd the shape indices array
  94170. * @param indices the indices array to be updated
  94171. * @param meshUV the shape uv array
  94172. * @param uvs the uv array to be updated
  94173. * @param meshCol the shape color array
  94174. * @param colors the color array to be updated
  94175. * @param meshNor the shape normals array
  94176. * @param normals the normals array to be updated
  94177. * @param idx the particle index
  94178. * @param idxInShape the particle index in its shape
  94179. * @param options the addShape() method passed options
  94180. * @hidden
  94181. */
  94182. private _meshBuilder;
  94183. /**
  94184. * Returns a shape Vector3 array from positions float array
  94185. * @param positions float array
  94186. * @returns a vector3 array
  94187. * @hidden
  94188. */
  94189. private _posToShape;
  94190. /**
  94191. * Returns a shapeUV array from a float uvs (array deep copy)
  94192. * @param uvs as a float array
  94193. * @returns a shapeUV array
  94194. * @hidden
  94195. */
  94196. private _uvsToShapeUV;
  94197. /**
  94198. * Adds a new particle object in the particles array
  94199. * @param idx particle index in particles array
  94200. * @param id particle id
  94201. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  94202. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  94203. * @param model particle ModelShape object
  94204. * @param shapeId model shape identifier
  94205. * @param idxInShape index of the particle in the current model
  94206. * @param bInfo model bounding info object
  94207. * @param storage target storage array, if any
  94208. * @hidden
  94209. */
  94210. private _addParticle;
  94211. /**
  94212. * Adds some particles to the SPS from the model shape. Returns the shape id.
  94213. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  94214. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  94215. * @param nb (positive integer) the number of particles to be created from this model
  94216. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  94217. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  94218. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  94219. * @returns the number of shapes in the system
  94220. */
  94221. addShape(mesh: Mesh, nb: number, options?: {
  94222. positionFunction?: any;
  94223. vertexFunction?: any;
  94224. storage?: [];
  94225. }): number;
  94226. /**
  94227. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  94228. * @hidden
  94229. */
  94230. private _rebuildParticle;
  94231. /**
  94232. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  94233. * @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.
  94234. * @returns the SPS.
  94235. */
  94236. rebuildMesh(reset?: boolean): SolidParticleSystem;
  94237. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  94238. * Returns an array with the removed particles.
  94239. * 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.
  94240. * The SPS can't be empty so at least one particle needs to remain in place.
  94241. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  94242. * @param start index of the first particle to remove
  94243. * @param end index of the last particle to remove (included)
  94244. * @returns an array populated with the removed particles
  94245. */
  94246. removeParticles(start: number, end: number): SolidParticle[];
  94247. /**
  94248. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  94249. * @param solidParticleArray an array populated with Solid Particles objects
  94250. * @returns the SPS
  94251. */
  94252. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  94253. /**
  94254. * Creates a new particle and modifies the SPS mesh geometry :
  94255. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  94256. * - calls _addParticle() to populate the particle array
  94257. * factorized code from addShape() and insertParticlesFromArray()
  94258. * @param idx particle index in the particles array
  94259. * @param i particle index in its shape
  94260. * @param modelShape particle ModelShape object
  94261. * @param shape shape vertex array
  94262. * @param meshInd shape indices array
  94263. * @param meshUV shape uv array
  94264. * @param meshCol shape color array
  94265. * @param meshNor shape normals array
  94266. * @param bbInfo shape bounding info
  94267. * @param storage target particle storage
  94268. * @options addShape() passed options
  94269. * @hidden
  94270. */
  94271. private _insertNewParticle;
  94272. /**
  94273. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  94274. * This method calls `updateParticle()` for each particle of the SPS.
  94275. * For an animated SPS, it is usually called within the render loop.
  94276. * 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.
  94277. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  94278. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  94279. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  94280. * @returns the SPS.
  94281. */
  94282. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  94283. /**
  94284. * Disposes the SPS.
  94285. */
  94286. dispose(): void;
  94287. /**
  94288. * Returns a SolidParticle object from its identifier : particle.id
  94289. * @param id (integer) the particle Id
  94290. * @returns the searched particle or null if not found in the SPS.
  94291. */
  94292. getParticleById(id: number): Nullable<SolidParticle>;
  94293. /**
  94294. * Returns a new array populated with the particles having the passed shapeId.
  94295. * @param shapeId (integer) the shape identifier
  94296. * @returns a new solid particle array
  94297. */
  94298. getParticlesByShapeId(shapeId: number): SolidParticle[];
  94299. /**
  94300. * Populates the passed array "ref" with the particles having the passed shapeId.
  94301. * @param shapeId the shape identifier
  94302. * @returns the SPS
  94303. * @param ref
  94304. */
  94305. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  94306. /**
  94307. * Computes the required SubMeshes according the materials assigned to the particles.
  94308. * @returns the solid particle system.
  94309. * Does nothing if called before the SPS mesh is built.
  94310. */
  94311. computeSubMeshes(): SolidParticleSystem;
  94312. /**
  94313. * Sorts the solid particles by material when MultiMaterial is enabled.
  94314. * Updates the indices32 array.
  94315. * Updates the indicesByMaterial array.
  94316. * Updates the mesh indices array.
  94317. * @returns the SPS
  94318. * @hidden
  94319. */
  94320. private _sortParticlesByMaterial;
  94321. /**
  94322. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  94323. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  94324. * @returns the SPS.
  94325. */
  94326. refreshVisibleSize(): SolidParticleSystem;
  94327. /**
  94328. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  94329. * @param size the size (float) of the visibility box
  94330. * note : this doesn't lock the SPS mesh bounding box.
  94331. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  94332. */
  94333. setVisibilityBox(size: number): void;
  94334. /**
  94335. * Gets whether the SPS as always visible or not
  94336. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  94337. */
  94338. /**
  94339. * Sets the SPS as always visible or not
  94340. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  94341. */
  94342. isAlwaysVisible: boolean;
  94343. /**
  94344. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  94345. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  94346. */
  94347. /**
  94348. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  94349. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  94350. */
  94351. isVisibilityBoxLocked: boolean;
  94352. /**
  94353. * Tells to `setParticles()` to compute the particle rotations or not.
  94354. * Default value : true. The SPS is faster when it's set to false.
  94355. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  94356. */
  94357. /**
  94358. * Gets if `setParticles()` computes the particle rotations or not.
  94359. * Default value : true. The SPS is faster when it's set to false.
  94360. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  94361. */
  94362. computeParticleRotation: boolean;
  94363. /**
  94364. * Tells to `setParticles()` to compute the particle colors or not.
  94365. * Default value : true. The SPS is faster when it's set to false.
  94366. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  94367. */
  94368. /**
  94369. * Gets if `setParticles()` computes the particle colors or not.
  94370. * Default value : true. The SPS is faster when it's set to false.
  94371. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  94372. */
  94373. computeParticleColor: boolean;
  94374. /**
  94375. * Gets if `setParticles()` computes the particle textures or not.
  94376. * Default value : true. The SPS is faster when it's set to false.
  94377. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  94378. */
  94379. computeParticleTexture: boolean;
  94380. /**
  94381. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  94382. * Default value : false. The SPS is faster when it's set to false.
  94383. * Note : the particle custom vertex positions aren't stored values.
  94384. */
  94385. /**
  94386. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  94387. * Default value : false. The SPS is faster when it's set to false.
  94388. * Note : the particle custom vertex positions aren't stored values.
  94389. */
  94390. computeParticleVertex: boolean;
  94391. /**
  94392. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  94393. */
  94394. /**
  94395. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  94396. */
  94397. computeBoundingBox: boolean;
  94398. /**
  94399. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  94400. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  94401. * Default : `true`
  94402. */
  94403. /**
  94404. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  94405. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  94406. * Default : `true`
  94407. */
  94408. depthSortParticles: boolean;
  94409. /**
  94410. * Gets if the SPS is created as expandable at construction time.
  94411. * Default : `false`
  94412. */
  94413. readonly expandable: boolean;
  94414. /**
  94415. * Gets if the SPS supports the Multi Materials
  94416. */
  94417. readonly multimaterialEnabled: boolean;
  94418. /**
  94419. * This function does nothing. It may be overwritten to set all the particle first values.
  94420. * The SPS doesn't call this function, you may have to call it by your own.
  94421. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  94422. */
  94423. initParticles(): void;
  94424. /**
  94425. * This function does nothing. It may be overwritten to recycle a particle.
  94426. * The SPS doesn't call this function, you may have to call it by your own.
  94427. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  94428. * @param particle The particle to recycle
  94429. * @returns the recycled particle
  94430. */
  94431. recycleParticle(particle: SolidParticle): SolidParticle;
  94432. /**
  94433. * Updates a particle : this function should be overwritten by the user.
  94434. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  94435. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  94436. * @example : just set a particle position or velocity and recycle conditions
  94437. * @param particle The particle to update
  94438. * @returns the updated particle
  94439. */
  94440. updateParticle(particle: SolidParticle): SolidParticle;
  94441. /**
  94442. * Updates a vertex of a particle : it can be overwritten by the user.
  94443. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  94444. * @param particle the current particle
  94445. * @param vertex the current index of the current particle
  94446. * @param pt the index of the current vertex in the particle shape
  94447. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  94448. * @example : just set a vertex particle position
  94449. * @returns the updated vertex
  94450. */
  94451. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  94452. /**
  94453. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  94454. * This does nothing and may be overwritten by the user.
  94455. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  94456. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  94457. * @param update the boolean update value actually passed to setParticles()
  94458. */
  94459. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  94460. /**
  94461. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  94462. * This will be passed three parameters.
  94463. * This does nothing and may be overwritten by the user.
  94464. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  94465. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  94466. * @param update the boolean update value actually passed to setParticles()
  94467. */
  94468. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  94469. }
  94470. }
  94471. declare module BABYLON {
  94472. /**
  94473. * Represents one particle of a solid particle system.
  94474. */
  94475. export class SolidParticle {
  94476. /**
  94477. * particle global index
  94478. */
  94479. idx: number;
  94480. /**
  94481. * particle identifier
  94482. */
  94483. id: number;
  94484. /**
  94485. * The color of the particle
  94486. */
  94487. color: Nullable<Color4>;
  94488. /**
  94489. * The world space position of the particle.
  94490. */
  94491. position: Vector3;
  94492. /**
  94493. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  94494. */
  94495. rotation: Vector3;
  94496. /**
  94497. * The world space rotation quaternion of the particle.
  94498. */
  94499. rotationQuaternion: Nullable<Quaternion>;
  94500. /**
  94501. * The scaling of the particle.
  94502. */
  94503. scaling: Vector3;
  94504. /**
  94505. * The uvs of the particle.
  94506. */
  94507. uvs: Vector4;
  94508. /**
  94509. * The current speed of the particle.
  94510. */
  94511. velocity: Vector3;
  94512. /**
  94513. * The pivot point in the particle local space.
  94514. */
  94515. pivot: Vector3;
  94516. /**
  94517. * Must the particle be translated from its pivot point in its local space ?
  94518. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  94519. * Default : false
  94520. */
  94521. translateFromPivot: boolean;
  94522. /**
  94523. * Is the particle active or not ?
  94524. */
  94525. alive: boolean;
  94526. /**
  94527. * Is the particle visible or not ?
  94528. */
  94529. isVisible: boolean;
  94530. /**
  94531. * Index of this particle in the global "positions" array (Internal use)
  94532. * @hidden
  94533. */
  94534. _pos: number;
  94535. /**
  94536. * @hidden Index of this particle in the global "indices" array (Internal use)
  94537. */
  94538. _ind: number;
  94539. /**
  94540. * @hidden ModelShape of this particle (Internal use)
  94541. */
  94542. _model: ModelShape;
  94543. /**
  94544. * ModelShape id of this particle
  94545. */
  94546. shapeId: number;
  94547. /**
  94548. * Index of the particle in its shape id
  94549. */
  94550. idxInShape: number;
  94551. /**
  94552. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  94553. */
  94554. _modelBoundingInfo: BoundingInfo;
  94555. /**
  94556. * @hidden Particle BoundingInfo object (Internal use)
  94557. */
  94558. _boundingInfo: BoundingInfo;
  94559. /**
  94560. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  94561. */
  94562. _sps: SolidParticleSystem;
  94563. /**
  94564. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  94565. */
  94566. _stillInvisible: boolean;
  94567. /**
  94568. * @hidden Last computed particle rotation matrix
  94569. */
  94570. _rotationMatrix: number[];
  94571. /**
  94572. * Parent particle Id, if any.
  94573. * Default null.
  94574. */
  94575. parentId: Nullable<number>;
  94576. /**
  94577. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  94578. */
  94579. materialIndex: Nullable<number>;
  94580. /**
  94581. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  94582. * The possible values are :
  94583. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  94584. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  94585. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  94586. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  94587. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  94588. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  94589. * */
  94590. cullingStrategy: number;
  94591. /**
  94592. * @hidden Internal global position in the SPS.
  94593. */
  94594. _globalPosition: Vector3;
  94595. /**
  94596. * Creates a Solid Particle object.
  94597. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  94598. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  94599. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  94600. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  94601. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  94602. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  94603. * @param shapeId (integer) is the model shape identifier in the SPS.
  94604. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  94605. * @param sps defines the sps it is associated to
  94606. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  94607. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  94608. */
  94609. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  94610. /**
  94611. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  94612. * @param target the particle target
  94613. * @returns the current particle
  94614. */
  94615. copyToRef(target: SolidParticle): SolidParticle;
  94616. /**
  94617. * Legacy support, changed scale to scaling
  94618. */
  94619. /**
  94620. * Legacy support, changed scale to scaling
  94621. */
  94622. scale: Vector3;
  94623. /**
  94624. * Legacy support, changed quaternion to rotationQuaternion
  94625. */
  94626. /**
  94627. * Legacy support, changed quaternion to rotationQuaternion
  94628. */
  94629. quaternion: Nullable<Quaternion>;
  94630. /**
  94631. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  94632. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  94633. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  94634. * @returns true if it intersects
  94635. */
  94636. intersectsMesh(target: Mesh | SolidParticle): boolean;
  94637. /**
  94638. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  94639. * A particle is in the frustum if its bounding box intersects the frustum
  94640. * @param frustumPlanes defines the frustum to test
  94641. * @returns true if the particle is in the frustum planes
  94642. */
  94643. isInFrustum(frustumPlanes: Plane[]): boolean;
  94644. /**
  94645. * get the rotation matrix of the particle
  94646. * @hidden
  94647. */
  94648. getRotationMatrix(m: Matrix): void;
  94649. }
  94650. /**
  94651. * Represents the shape of the model used by one particle of a solid particle system.
  94652. * SPS internal tool, don't use it manually.
  94653. */
  94654. export class ModelShape {
  94655. /**
  94656. * The shape id
  94657. * @hidden
  94658. */
  94659. shapeID: number;
  94660. /**
  94661. * flat array of model positions (internal use)
  94662. * @hidden
  94663. */
  94664. _shape: Vector3[];
  94665. /**
  94666. * flat array of model UVs (internal use)
  94667. * @hidden
  94668. */
  94669. _shapeUV: number[];
  94670. /**
  94671. * color array of the model
  94672. * @hidden
  94673. */
  94674. _shapeColors: number[];
  94675. /**
  94676. * indices array of the model
  94677. * @hidden
  94678. */
  94679. _indices: number[];
  94680. /**
  94681. * normals array of the model
  94682. * @hidden
  94683. */
  94684. _normals: number[];
  94685. /**
  94686. * length of the shape in the model indices array (internal use)
  94687. * @hidden
  94688. */
  94689. _indicesLength: number;
  94690. /**
  94691. * Custom position function (internal use)
  94692. * @hidden
  94693. */
  94694. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  94695. /**
  94696. * Custom vertex function (internal use)
  94697. * @hidden
  94698. */
  94699. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  94700. /**
  94701. * 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.
  94702. * SPS internal tool, don't use it manually.
  94703. * @hidden
  94704. */
  94705. 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>);
  94706. }
  94707. /**
  94708. * Represents a Depth Sorted Particle in the solid particle system.
  94709. * @hidden
  94710. */
  94711. export class DepthSortedParticle {
  94712. /**
  94713. * Index of the particle in the "indices" array
  94714. */
  94715. ind: number;
  94716. /**
  94717. * Length of the particle shape in the "indices" array
  94718. */
  94719. indicesLength: number;
  94720. /**
  94721. * Squared distance from the particle to the camera
  94722. */
  94723. sqDistance: number;
  94724. /**
  94725. * Material index when used with MultiMaterials
  94726. */
  94727. materialIndex: number;
  94728. /**
  94729. * Creates a new sorted particle
  94730. * @param materialIndex
  94731. */
  94732. constructor(materialIndex: number);
  94733. }
  94734. }
  94735. declare module BABYLON {
  94736. /**
  94737. * @hidden
  94738. */
  94739. export class _MeshCollisionData {
  94740. _checkCollisions: boolean;
  94741. _collisionMask: number;
  94742. _collisionGroup: number;
  94743. _collider: Nullable<Collider>;
  94744. _oldPositionForCollisions: Vector3;
  94745. _diffPositionForCollisions: Vector3;
  94746. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  94747. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  94748. }
  94749. }
  94750. declare module BABYLON {
  94751. /** @hidden */
  94752. class _FacetDataStorage {
  94753. facetPositions: Vector3[];
  94754. facetNormals: Vector3[];
  94755. facetPartitioning: number[][];
  94756. facetNb: number;
  94757. partitioningSubdivisions: number;
  94758. partitioningBBoxRatio: number;
  94759. facetDataEnabled: boolean;
  94760. facetParameters: any;
  94761. bbSize: Vector3;
  94762. subDiv: {
  94763. max: number;
  94764. X: number;
  94765. Y: number;
  94766. Z: number;
  94767. };
  94768. facetDepthSort: boolean;
  94769. facetDepthSortEnabled: boolean;
  94770. depthSortedIndices: IndicesArray;
  94771. depthSortedFacets: {
  94772. ind: number;
  94773. sqDistance: number;
  94774. }[];
  94775. facetDepthSortFunction: (f1: {
  94776. ind: number;
  94777. sqDistance: number;
  94778. }, f2: {
  94779. ind: number;
  94780. sqDistance: number;
  94781. }) => number;
  94782. facetDepthSortFrom: Vector3;
  94783. facetDepthSortOrigin: Vector3;
  94784. invertedMatrix: Matrix;
  94785. }
  94786. /**
  94787. * @hidden
  94788. **/
  94789. class _InternalAbstractMeshDataInfo {
  94790. _hasVertexAlpha: boolean;
  94791. _useVertexColors: boolean;
  94792. _numBoneInfluencers: number;
  94793. _applyFog: boolean;
  94794. _receiveShadows: boolean;
  94795. _facetData: _FacetDataStorage;
  94796. _visibility: number;
  94797. _skeleton: Nullable<Skeleton>;
  94798. _layerMask: number;
  94799. _computeBonesUsingShaders: boolean;
  94800. _isActive: boolean;
  94801. _onlyForInstances: boolean;
  94802. _isActiveIntermediate: boolean;
  94803. _onlyForInstancesIntermediate: boolean;
  94804. _actAsRegularMesh: boolean;
  94805. }
  94806. /**
  94807. * Class used to store all common mesh properties
  94808. */
  94809. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  94810. /** No occlusion */
  94811. static OCCLUSION_TYPE_NONE: number;
  94812. /** Occlusion set to optimisitic */
  94813. static OCCLUSION_TYPE_OPTIMISTIC: number;
  94814. /** Occlusion set to strict */
  94815. static OCCLUSION_TYPE_STRICT: number;
  94816. /** Use an accurante occlusion algorithm */
  94817. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  94818. /** Use a conservative occlusion algorithm */
  94819. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  94820. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  94821. * Test order :
  94822. * Is the bounding sphere outside the frustum ?
  94823. * If not, are the bounding box vertices outside the frustum ?
  94824. * It not, then the cullable object is in the frustum.
  94825. */
  94826. static readonly CULLINGSTRATEGY_STANDARD: number;
  94827. /** Culling strategy : Bounding Sphere Only.
  94828. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  94829. * It's also less accurate than the standard because some not visible objects can still be selected.
  94830. * Test : is the bounding sphere outside the frustum ?
  94831. * If not, then the cullable object is in the frustum.
  94832. */
  94833. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  94834. /** Culling strategy : Optimistic Inclusion.
  94835. * This in an inclusion test first, then the standard exclusion test.
  94836. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  94837. * 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.
  94838. * Anyway, it's as accurate as the standard strategy.
  94839. * Test :
  94840. * Is the cullable object bounding sphere center in the frustum ?
  94841. * If not, apply the default culling strategy.
  94842. */
  94843. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  94844. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  94845. * This in an inclusion test first, then the bounding sphere only exclusion test.
  94846. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  94847. * 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.
  94848. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  94849. * Test :
  94850. * Is the cullable object bounding sphere center in the frustum ?
  94851. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  94852. */
  94853. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  94854. /**
  94855. * No billboard
  94856. */
  94857. static readonly BILLBOARDMODE_NONE: number;
  94858. /** Billboard on X axis */
  94859. static readonly BILLBOARDMODE_X: number;
  94860. /** Billboard on Y axis */
  94861. static readonly BILLBOARDMODE_Y: number;
  94862. /** Billboard on Z axis */
  94863. static readonly BILLBOARDMODE_Z: number;
  94864. /** Billboard on all axes */
  94865. static readonly BILLBOARDMODE_ALL: number;
  94866. /** Billboard on using position instead of orientation */
  94867. static readonly BILLBOARDMODE_USE_POSITION: number;
  94868. /** @hidden */
  94869. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  94870. /**
  94871. * The culling strategy to use to check whether the mesh must be rendered or not.
  94872. * This value can be changed at any time and will be used on the next render mesh selection.
  94873. * The possible values are :
  94874. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  94875. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  94876. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  94877. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  94878. * Please read each static variable documentation to get details about the culling process.
  94879. * */
  94880. cullingStrategy: number;
  94881. /**
  94882. * Gets the number of facets in the mesh
  94883. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  94884. */
  94885. readonly facetNb: number;
  94886. /**
  94887. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  94888. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  94889. */
  94890. partitioningSubdivisions: number;
  94891. /**
  94892. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  94893. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  94894. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  94895. */
  94896. partitioningBBoxRatio: number;
  94897. /**
  94898. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  94899. * Works only for updatable meshes.
  94900. * Doesn't work with multi-materials
  94901. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  94902. */
  94903. mustDepthSortFacets: boolean;
  94904. /**
  94905. * The location (Vector3) where the facet depth sort must be computed from.
  94906. * By default, the active camera position.
  94907. * Used only when facet depth sort is enabled
  94908. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  94909. */
  94910. facetDepthSortFrom: Vector3;
  94911. /**
  94912. * gets a boolean indicating if facetData is enabled
  94913. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  94914. */
  94915. readonly isFacetDataEnabled: boolean;
  94916. /** @hidden */
  94917. _updateNonUniformScalingState(value: boolean): boolean;
  94918. /**
  94919. * An event triggered when this mesh collides with another one
  94920. */
  94921. onCollideObservable: Observable<AbstractMesh>;
  94922. /** Set a function to call when this mesh collides with another one */
  94923. onCollide: () => void;
  94924. /**
  94925. * An event triggered when the collision's position changes
  94926. */
  94927. onCollisionPositionChangeObservable: Observable<Vector3>;
  94928. /** Set a function to call when the collision's position changes */
  94929. onCollisionPositionChange: () => void;
  94930. /**
  94931. * An event triggered when material is changed
  94932. */
  94933. onMaterialChangedObservable: Observable<AbstractMesh>;
  94934. /**
  94935. * Gets or sets the orientation for POV movement & rotation
  94936. */
  94937. definedFacingForward: boolean;
  94938. /** @hidden */
  94939. _occlusionQuery: Nullable<WebGLQuery>;
  94940. /** @hidden */
  94941. _renderingGroup: Nullable<RenderingGroup>;
  94942. /**
  94943. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  94944. */
  94945. /**
  94946. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  94947. */
  94948. visibility: number;
  94949. /** Gets or sets the alpha index used to sort transparent meshes
  94950. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  94951. */
  94952. alphaIndex: number;
  94953. /**
  94954. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  94955. */
  94956. isVisible: boolean;
  94957. /**
  94958. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  94959. */
  94960. isPickable: boolean;
  94961. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  94962. showSubMeshesBoundingBox: boolean;
  94963. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  94964. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  94965. */
  94966. isBlocker: boolean;
  94967. /**
  94968. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  94969. */
  94970. enablePointerMoveEvents: boolean;
  94971. /**
  94972. * Specifies the rendering group id for this mesh (0 by default)
  94973. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  94974. */
  94975. renderingGroupId: number;
  94976. private _material;
  94977. /** Gets or sets current material */
  94978. material: Nullable<Material>;
  94979. /**
  94980. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  94981. * @see http://doc.babylonjs.com/babylon101/shadows
  94982. */
  94983. receiveShadows: boolean;
  94984. /** Defines color to use when rendering outline */
  94985. outlineColor: Color3;
  94986. /** Define width to use when rendering outline */
  94987. outlineWidth: number;
  94988. /** Defines color to use when rendering overlay */
  94989. overlayColor: Color3;
  94990. /** Defines alpha to use when rendering overlay */
  94991. overlayAlpha: number;
  94992. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  94993. hasVertexAlpha: boolean;
  94994. /** 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) */
  94995. useVertexColors: boolean;
  94996. /**
  94997. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  94998. */
  94999. computeBonesUsingShaders: boolean;
  95000. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  95001. numBoneInfluencers: number;
  95002. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  95003. applyFog: boolean;
  95004. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  95005. useOctreeForRenderingSelection: boolean;
  95006. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  95007. useOctreeForPicking: boolean;
  95008. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  95009. useOctreeForCollisions: boolean;
  95010. /**
  95011. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  95012. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  95013. */
  95014. layerMask: number;
  95015. /**
  95016. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  95017. */
  95018. alwaysSelectAsActiveMesh: boolean;
  95019. /**
  95020. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  95021. */
  95022. doNotSyncBoundingInfo: boolean;
  95023. /**
  95024. * Gets or sets the current action manager
  95025. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  95026. */
  95027. actionManager: Nullable<AbstractActionManager>;
  95028. private _meshCollisionData;
  95029. /**
  95030. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  95031. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  95032. */
  95033. ellipsoid: Vector3;
  95034. /**
  95035. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  95036. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  95037. */
  95038. ellipsoidOffset: Vector3;
  95039. /**
  95040. * Gets or sets a collision mask used to mask collisions (default is -1).
  95041. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  95042. */
  95043. collisionMask: number;
  95044. /**
  95045. * Gets or sets the current collision group mask (-1 by default).
  95046. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  95047. */
  95048. collisionGroup: number;
  95049. /**
  95050. * Defines edge width used when edgesRenderer is enabled
  95051. * @see https://www.babylonjs-playground.com/#10OJSG#13
  95052. */
  95053. edgesWidth: number;
  95054. /**
  95055. * Defines edge color used when edgesRenderer is enabled
  95056. * @see https://www.babylonjs-playground.com/#10OJSG#13
  95057. */
  95058. edgesColor: Color4;
  95059. /** @hidden */
  95060. _edgesRenderer: Nullable<IEdgesRenderer>;
  95061. /** @hidden */
  95062. _masterMesh: Nullable<AbstractMesh>;
  95063. /** @hidden */
  95064. _boundingInfo: Nullable<BoundingInfo>;
  95065. /** @hidden */
  95066. _renderId: number;
  95067. /**
  95068. * Gets or sets the list of subMeshes
  95069. * @see http://doc.babylonjs.com/how_to/multi_materials
  95070. */
  95071. subMeshes: SubMesh[];
  95072. /** @hidden */
  95073. _intersectionsInProgress: AbstractMesh[];
  95074. /** @hidden */
  95075. _unIndexed: boolean;
  95076. /** @hidden */
  95077. _lightSources: Light[];
  95078. /** Gets the list of lights affecting that mesh */
  95079. readonly lightSources: Light[];
  95080. /** @hidden */
  95081. readonly _positions: Nullable<Vector3[]>;
  95082. /** @hidden */
  95083. _waitingData: {
  95084. lods: Nullable<any>;
  95085. actions: Nullable<any>;
  95086. freezeWorldMatrix: Nullable<boolean>;
  95087. };
  95088. /** @hidden */
  95089. _bonesTransformMatrices: Nullable<Float32Array>;
  95090. /** @hidden */
  95091. _transformMatrixTexture: Nullable<RawTexture>;
  95092. /**
  95093. * Gets or sets a skeleton to apply skining transformations
  95094. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  95095. */
  95096. skeleton: Nullable<Skeleton>;
  95097. /**
  95098. * An event triggered when the mesh is rebuilt.
  95099. */
  95100. onRebuildObservable: Observable<AbstractMesh>;
  95101. /**
  95102. * Creates a new AbstractMesh
  95103. * @param name defines the name of the mesh
  95104. * @param scene defines the hosting scene
  95105. */
  95106. constructor(name: string, scene?: Nullable<Scene>);
  95107. /**
  95108. * Returns the string "AbstractMesh"
  95109. * @returns "AbstractMesh"
  95110. */
  95111. getClassName(): string;
  95112. /**
  95113. * Gets a string representation of the current mesh
  95114. * @param fullDetails defines a boolean indicating if full details must be included
  95115. * @returns a string representation of the current mesh
  95116. */
  95117. toString(fullDetails?: boolean): string;
  95118. /**
  95119. * @hidden
  95120. */
  95121. protected _getEffectiveParent(): Nullable<Node>;
  95122. /** @hidden */
  95123. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  95124. /** @hidden */
  95125. _rebuild(): void;
  95126. /** @hidden */
  95127. _resyncLightSources(): void;
  95128. /** @hidden */
  95129. _resyncLighSource(light: Light): void;
  95130. /** @hidden */
  95131. _unBindEffect(): void;
  95132. /** @hidden */
  95133. _removeLightSource(light: Light, dispose: boolean): void;
  95134. private _markSubMeshesAsDirty;
  95135. /** @hidden */
  95136. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  95137. /** @hidden */
  95138. _markSubMeshesAsAttributesDirty(): void;
  95139. /** @hidden */
  95140. _markSubMeshesAsMiscDirty(): void;
  95141. /**
  95142. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  95143. */
  95144. scaling: Vector3;
  95145. /**
  95146. * Returns true if the mesh is blocked. Implemented by child classes
  95147. */
  95148. readonly isBlocked: boolean;
  95149. /**
  95150. * Returns the mesh itself by default. Implemented by child classes
  95151. * @param camera defines the camera to use to pick the right LOD level
  95152. * @returns the currentAbstractMesh
  95153. */
  95154. getLOD(camera: Camera): Nullable<AbstractMesh>;
  95155. /**
  95156. * Returns 0 by default. Implemented by child classes
  95157. * @returns an integer
  95158. */
  95159. getTotalVertices(): number;
  95160. /**
  95161. * Returns a positive integer : the total number of indices in this mesh geometry.
  95162. * @returns the numner of indices or zero if the mesh has no geometry.
  95163. */
  95164. getTotalIndices(): number;
  95165. /**
  95166. * Returns null by default. Implemented by child classes
  95167. * @returns null
  95168. */
  95169. getIndices(): Nullable<IndicesArray>;
  95170. /**
  95171. * Returns the array of the requested vertex data kind. Implemented by child classes
  95172. * @param kind defines the vertex data kind to use
  95173. * @returns null
  95174. */
  95175. getVerticesData(kind: string): Nullable<FloatArray>;
  95176. /**
  95177. * Sets the vertex data of the mesh geometry for the requested `kind`.
  95178. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  95179. * Note that a new underlying VertexBuffer object is created each call.
  95180. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  95181. * @param kind defines vertex data kind:
  95182. * * VertexBuffer.PositionKind
  95183. * * VertexBuffer.UVKind
  95184. * * VertexBuffer.UV2Kind
  95185. * * VertexBuffer.UV3Kind
  95186. * * VertexBuffer.UV4Kind
  95187. * * VertexBuffer.UV5Kind
  95188. * * VertexBuffer.UV6Kind
  95189. * * VertexBuffer.ColorKind
  95190. * * VertexBuffer.MatricesIndicesKind
  95191. * * VertexBuffer.MatricesIndicesExtraKind
  95192. * * VertexBuffer.MatricesWeightsKind
  95193. * * VertexBuffer.MatricesWeightsExtraKind
  95194. * @param data defines the data source
  95195. * @param updatable defines if the data must be flagged as updatable (or static)
  95196. * @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
  95197. * @returns the current mesh
  95198. */
  95199. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  95200. /**
  95201. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  95202. * If the mesh has no geometry, it is simply returned as it is.
  95203. * @param kind defines vertex data kind:
  95204. * * VertexBuffer.PositionKind
  95205. * * VertexBuffer.UVKind
  95206. * * VertexBuffer.UV2Kind
  95207. * * VertexBuffer.UV3Kind
  95208. * * VertexBuffer.UV4Kind
  95209. * * VertexBuffer.UV5Kind
  95210. * * VertexBuffer.UV6Kind
  95211. * * VertexBuffer.ColorKind
  95212. * * VertexBuffer.MatricesIndicesKind
  95213. * * VertexBuffer.MatricesIndicesExtraKind
  95214. * * VertexBuffer.MatricesWeightsKind
  95215. * * VertexBuffer.MatricesWeightsExtraKind
  95216. * @param data defines the data source
  95217. * @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
  95218. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  95219. * @returns the current mesh
  95220. */
  95221. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  95222. /**
  95223. * Sets the mesh indices,
  95224. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  95225. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  95226. * @param totalVertices Defines the total number of vertices
  95227. * @returns the current mesh
  95228. */
  95229. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  95230. /**
  95231. * Gets a boolean indicating if specific vertex data is present
  95232. * @param kind defines the vertex data kind to use
  95233. * @returns true is data kind is present
  95234. */
  95235. isVerticesDataPresent(kind: string): boolean;
  95236. /**
  95237. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  95238. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  95239. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  95240. * @returns a BoundingInfo
  95241. */
  95242. getBoundingInfo(): BoundingInfo;
  95243. /**
  95244. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  95245. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  95246. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  95247. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  95248. * @returns the current mesh
  95249. */
  95250. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  95251. /**
  95252. * Overwrite the current bounding info
  95253. * @param boundingInfo defines the new bounding info
  95254. * @returns the current mesh
  95255. */
  95256. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  95257. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  95258. readonly useBones: boolean;
  95259. /** @hidden */
  95260. _preActivate(): void;
  95261. /** @hidden */
  95262. _preActivateForIntermediateRendering(renderId: number): void;
  95263. /** @hidden */
  95264. _activate(renderId: number, intermediateRendering: boolean): boolean;
  95265. /** @hidden */
  95266. _postActivate(): void;
  95267. /** @hidden */
  95268. _freeze(): void;
  95269. /** @hidden */
  95270. _unFreeze(): void;
  95271. /**
  95272. * Gets the current world matrix
  95273. * @returns a Matrix
  95274. */
  95275. getWorldMatrix(): Matrix;
  95276. /** @hidden */
  95277. _getWorldMatrixDeterminant(): number;
  95278. /**
  95279. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  95280. */
  95281. readonly isAnInstance: boolean;
  95282. /**
  95283. * Gets a boolean indicating if this mesh has instances
  95284. */
  95285. readonly hasInstances: boolean;
  95286. /**
  95287. * Perform relative position change from the point of view of behind the front of the mesh.
  95288. * This is performed taking into account the meshes current rotation, so you do not have to care.
  95289. * Supports definition of mesh facing forward or backward
  95290. * @param amountRight defines the distance on the right axis
  95291. * @param amountUp defines the distance on the up axis
  95292. * @param amountForward defines the distance on the forward axis
  95293. * @returns the current mesh
  95294. */
  95295. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  95296. /**
  95297. * Calculate relative position change from the point of view of behind the front of the mesh.
  95298. * This is performed taking into account the meshes current rotation, so you do not have to care.
  95299. * Supports definition of mesh facing forward or backward
  95300. * @param amountRight defines the distance on the right axis
  95301. * @param amountUp defines the distance on the up axis
  95302. * @param amountForward defines the distance on the forward axis
  95303. * @returns the new displacement vector
  95304. */
  95305. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  95306. /**
  95307. * Perform relative rotation change from the point of view of behind the front of the mesh.
  95308. * Supports definition of mesh facing forward or backward
  95309. * @param flipBack defines the flip
  95310. * @param twirlClockwise defines the twirl
  95311. * @param tiltRight defines the tilt
  95312. * @returns the current mesh
  95313. */
  95314. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  95315. /**
  95316. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  95317. * Supports definition of mesh facing forward or backward.
  95318. * @param flipBack defines the flip
  95319. * @param twirlClockwise defines the twirl
  95320. * @param tiltRight defines the tilt
  95321. * @returns the new rotation vector
  95322. */
  95323. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  95324. /**
  95325. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  95326. * This means the mesh underlying bounding box and sphere are recomputed.
  95327. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  95328. * @returns the current mesh
  95329. */
  95330. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  95331. /** @hidden */
  95332. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  95333. /** @hidden */
  95334. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  95335. /** @hidden */
  95336. _updateBoundingInfo(): AbstractMesh;
  95337. /** @hidden */
  95338. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  95339. /** @hidden */
  95340. protected _afterComputeWorldMatrix(): void;
  95341. /** @hidden */
  95342. readonly _effectiveMesh: AbstractMesh;
  95343. /**
  95344. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  95345. * A mesh is in the frustum if its bounding box intersects the frustum
  95346. * @param frustumPlanes defines the frustum to test
  95347. * @returns true if the mesh is in the frustum planes
  95348. */
  95349. isInFrustum(frustumPlanes: Plane[]): boolean;
  95350. /**
  95351. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  95352. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  95353. * @param frustumPlanes defines the frustum to test
  95354. * @returns true if the mesh is completely in the frustum planes
  95355. */
  95356. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  95357. /**
  95358. * True if the mesh intersects another mesh or a SolidParticle object
  95359. * @param mesh defines a target mesh or SolidParticle to test
  95360. * @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)
  95361. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  95362. * @returns true if there is an intersection
  95363. */
  95364. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  95365. /**
  95366. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  95367. * @param point defines the point to test
  95368. * @returns true if there is an intersection
  95369. */
  95370. intersectsPoint(point: Vector3): boolean;
  95371. /**
  95372. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  95373. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  95374. */
  95375. checkCollisions: boolean;
  95376. /**
  95377. * Gets Collider object used to compute collisions (not physics)
  95378. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  95379. */
  95380. readonly collider: Nullable<Collider>;
  95381. /**
  95382. * Move the mesh using collision engine
  95383. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  95384. * @param displacement defines the requested displacement vector
  95385. * @returns the current mesh
  95386. */
  95387. moveWithCollisions(displacement: Vector3): AbstractMesh;
  95388. private _onCollisionPositionChange;
  95389. /** @hidden */
  95390. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  95391. /** @hidden */
  95392. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  95393. /** @hidden */
  95394. _checkCollision(collider: Collider): AbstractMesh;
  95395. /** @hidden */
  95396. _generatePointsArray(): boolean;
  95397. /**
  95398. * Checks if the passed Ray intersects with the mesh
  95399. * @param ray defines the ray to use
  95400. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  95401. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  95402. * @returns the picking info
  95403. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  95404. */
  95405. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  95406. /**
  95407. * Clones the current mesh
  95408. * @param name defines the mesh name
  95409. * @param newParent defines the new mesh parent
  95410. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  95411. * @returns the new mesh
  95412. */
  95413. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  95414. /**
  95415. * Disposes all the submeshes of the current meshnp
  95416. * @returns the current mesh
  95417. */
  95418. releaseSubMeshes(): AbstractMesh;
  95419. /**
  95420. * Releases resources associated with this abstract mesh.
  95421. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  95422. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  95423. */
  95424. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  95425. /**
  95426. * Adds the passed mesh as a child to the current mesh
  95427. * @param mesh defines the child mesh
  95428. * @returns the current mesh
  95429. */
  95430. addChild(mesh: AbstractMesh): AbstractMesh;
  95431. /**
  95432. * Removes the passed mesh from the current mesh children list
  95433. * @param mesh defines the child mesh
  95434. * @returns the current mesh
  95435. */
  95436. removeChild(mesh: AbstractMesh): AbstractMesh;
  95437. /** @hidden */
  95438. private _initFacetData;
  95439. /**
  95440. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  95441. * This method can be called within the render loop.
  95442. * 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
  95443. * @returns the current mesh
  95444. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  95445. */
  95446. updateFacetData(): AbstractMesh;
  95447. /**
  95448. * Returns the facetLocalNormals array.
  95449. * The normals are expressed in the mesh local spac
  95450. * @returns an array of Vector3
  95451. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  95452. */
  95453. getFacetLocalNormals(): Vector3[];
  95454. /**
  95455. * Returns the facetLocalPositions array.
  95456. * The facet positions are expressed in the mesh local space
  95457. * @returns an array of Vector3
  95458. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  95459. */
  95460. getFacetLocalPositions(): Vector3[];
  95461. /**
  95462. * Returns the facetLocalPartioning array
  95463. * @returns an array of array of numbers
  95464. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  95465. */
  95466. getFacetLocalPartitioning(): number[][];
  95467. /**
  95468. * Returns the i-th facet position in the world system.
  95469. * This method allocates a new Vector3 per call
  95470. * @param i defines the facet index
  95471. * @returns a new Vector3
  95472. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  95473. */
  95474. getFacetPosition(i: number): Vector3;
  95475. /**
  95476. * Sets the reference Vector3 with the i-th facet position in the world system
  95477. * @param i defines the facet index
  95478. * @param ref defines the target vector
  95479. * @returns the current mesh
  95480. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  95481. */
  95482. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  95483. /**
  95484. * Returns the i-th facet normal in the world system.
  95485. * This method allocates a new Vector3 per call
  95486. * @param i defines the facet index
  95487. * @returns a new Vector3
  95488. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  95489. */
  95490. getFacetNormal(i: number): Vector3;
  95491. /**
  95492. * Sets the reference Vector3 with the i-th facet normal in the world system
  95493. * @param i defines the facet index
  95494. * @param ref defines the target vector
  95495. * @returns the current mesh
  95496. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  95497. */
  95498. getFacetNormalToRef(i: number, ref: Vector3): this;
  95499. /**
  95500. * 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)
  95501. * @param x defines x coordinate
  95502. * @param y defines y coordinate
  95503. * @param z defines z coordinate
  95504. * @returns the array of facet indexes
  95505. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  95506. */
  95507. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  95508. /**
  95509. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  95510. * @param projected sets as the (x,y,z) world projection on the facet
  95511. * @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
  95512. * @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
  95513. * @param x defines x coordinate
  95514. * @param y defines y coordinate
  95515. * @param z defines z coordinate
  95516. * @returns the face index if found (or null instead)
  95517. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  95518. */
  95519. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  95520. /**
  95521. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  95522. * @param projected sets as the (x,y,z) local projection on the facet
  95523. * @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
  95524. * @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
  95525. * @param x defines x coordinate
  95526. * @param y defines y coordinate
  95527. * @param z defines z coordinate
  95528. * @returns the face index if found (or null instead)
  95529. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  95530. */
  95531. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  95532. /**
  95533. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  95534. * @returns the parameters
  95535. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  95536. */
  95537. getFacetDataParameters(): any;
  95538. /**
  95539. * Disables the feature FacetData and frees the related memory
  95540. * @returns the current mesh
  95541. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  95542. */
  95543. disableFacetData(): AbstractMesh;
  95544. /**
  95545. * Updates the AbstractMesh indices array
  95546. * @param indices defines the data source
  95547. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  95548. * @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)
  95549. * @returns the current mesh
  95550. */
  95551. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  95552. /**
  95553. * Creates new normals data for the mesh
  95554. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  95555. * @returns the current mesh
  95556. */
  95557. createNormals(updatable: boolean): AbstractMesh;
  95558. /**
  95559. * Align the mesh with a normal
  95560. * @param normal defines the normal to use
  95561. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  95562. * @returns the current mesh
  95563. */
  95564. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  95565. /** @hidden */
  95566. _checkOcclusionQuery(): boolean;
  95567. /**
  95568. * Disables the mesh edge rendering mode
  95569. * @returns the currentAbstractMesh
  95570. */
  95571. disableEdgesRendering(): AbstractMesh;
  95572. /**
  95573. * Enables the edge rendering mode on the mesh.
  95574. * This mode makes the mesh edges visible
  95575. * @param epsilon defines the maximal distance between two angles to detect a face
  95576. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  95577. * @returns the currentAbstractMesh
  95578. * @see https://www.babylonjs-playground.com/#19O9TU#0
  95579. */
  95580. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  95581. }
  95582. }
  95583. declare module BABYLON {
  95584. /**
  95585. * Interface used to define ActionEvent
  95586. */
  95587. export interface IActionEvent {
  95588. /** The mesh or sprite that triggered the action */
  95589. source: any;
  95590. /** The X mouse cursor position at the time of the event */
  95591. pointerX: number;
  95592. /** The Y mouse cursor position at the time of the event */
  95593. pointerY: number;
  95594. /** The mesh that is currently pointed at (can be null) */
  95595. meshUnderPointer: Nullable<AbstractMesh>;
  95596. /** the original (browser) event that triggered the ActionEvent */
  95597. sourceEvent?: any;
  95598. /** additional data for the event */
  95599. additionalData?: any;
  95600. }
  95601. /**
  95602. * ActionEvent is the event being sent when an action is triggered.
  95603. */
  95604. export class ActionEvent implements IActionEvent {
  95605. /** The mesh or sprite that triggered the action */
  95606. source: any;
  95607. /** The X mouse cursor position at the time of the event */
  95608. pointerX: number;
  95609. /** The Y mouse cursor position at the time of the event */
  95610. pointerY: number;
  95611. /** The mesh that is currently pointed at (can be null) */
  95612. meshUnderPointer: Nullable<AbstractMesh>;
  95613. /** the original (browser) event that triggered the ActionEvent */
  95614. sourceEvent?: any;
  95615. /** additional data for the event */
  95616. additionalData?: any;
  95617. /**
  95618. * Creates a new ActionEvent
  95619. * @param source The mesh or sprite that triggered the action
  95620. * @param pointerX The X mouse cursor position at the time of the event
  95621. * @param pointerY The Y mouse cursor position at the time of the event
  95622. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  95623. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  95624. * @param additionalData additional data for the event
  95625. */
  95626. constructor(
  95627. /** The mesh or sprite that triggered the action */
  95628. source: any,
  95629. /** The X mouse cursor position at the time of the event */
  95630. pointerX: number,
  95631. /** The Y mouse cursor position at the time of the event */
  95632. pointerY: number,
  95633. /** The mesh that is currently pointed at (can be null) */
  95634. meshUnderPointer: Nullable<AbstractMesh>,
  95635. /** the original (browser) event that triggered the ActionEvent */
  95636. sourceEvent?: any,
  95637. /** additional data for the event */
  95638. additionalData?: any);
  95639. /**
  95640. * Helper function to auto-create an ActionEvent from a source mesh.
  95641. * @param source The source mesh that triggered the event
  95642. * @param evt The original (browser) event
  95643. * @param additionalData additional data for the event
  95644. * @returns the new ActionEvent
  95645. */
  95646. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  95647. /**
  95648. * Helper function to auto-create an ActionEvent from a source sprite
  95649. * @param source The source sprite that triggered the event
  95650. * @param scene Scene associated with the sprite
  95651. * @param evt The original (browser) event
  95652. * @param additionalData additional data for the event
  95653. * @returns the new ActionEvent
  95654. */
  95655. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  95656. /**
  95657. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  95658. * @param scene the scene where the event occurred
  95659. * @param evt The original (browser) event
  95660. * @returns the new ActionEvent
  95661. */
  95662. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  95663. /**
  95664. * Helper function to auto-create an ActionEvent from a primitive
  95665. * @param prim defines the target primitive
  95666. * @param pointerPos defines the pointer position
  95667. * @param evt The original (browser) event
  95668. * @param additionalData additional data for the event
  95669. * @returns the new ActionEvent
  95670. */
  95671. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  95672. }
  95673. }
  95674. declare module BABYLON {
  95675. /**
  95676. * Abstract class used to decouple action Manager from scene and meshes.
  95677. * Do not instantiate.
  95678. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  95679. */
  95680. export abstract class AbstractActionManager implements IDisposable {
  95681. /** Gets the list of active triggers */
  95682. static Triggers: {
  95683. [key: string]: number;
  95684. };
  95685. /** Gets the cursor to use when hovering items */
  95686. hoverCursor: string;
  95687. /** Gets the list of actions */
  95688. actions: IAction[];
  95689. /**
  95690. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  95691. */
  95692. isRecursive: boolean;
  95693. /**
  95694. * Releases all associated resources
  95695. */
  95696. abstract dispose(): void;
  95697. /**
  95698. * Does this action manager has pointer triggers
  95699. */
  95700. abstract readonly hasPointerTriggers: boolean;
  95701. /**
  95702. * Does this action manager has pick triggers
  95703. */
  95704. abstract readonly hasPickTriggers: boolean;
  95705. /**
  95706. * Process a specific trigger
  95707. * @param trigger defines the trigger to process
  95708. * @param evt defines the event details to be processed
  95709. */
  95710. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  95711. /**
  95712. * Does this action manager handles actions of any of the given triggers
  95713. * @param triggers defines the triggers to be tested
  95714. * @return a boolean indicating whether one (or more) of the triggers is handled
  95715. */
  95716. abstract hasSpecificTriggers(triggers: number[]): boolean;
  95717. /**
  95718. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  95719. * speed.
  95720. * @param triggerA defines the trigger to be tested
  95721. * @param triggerB defines the trigger to be tested
  95722. * @return a boolean indicating whether one (or more) of the triggers is handled
  95723. */
  95724. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  95725. /**
  95726. * Does this action manager handles actions of a given trigger
  95727. * @param trigger defines the trigger to be tested
  95728. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  95729. * @return whether the trigger is handled
  95730. */
  95731. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  95732. /**
  95733. * Serialize this manager to a JSON object
  95734. * @param name defines the property name to store this manager
  95735. * @returns a JSON representation of this manager
  95736. */
  95737. abstract serialize(name: string): any;
  95738. /**
  95739. * Registers an action to this action manager
  95740. * @param action defines the action to be registered
  95741. * @return the action amended (prepared) after registration
  95742. */
  95743. abstract registerAction(action: IAction): Nullable<IAction>;
  95744. /**
  95745. * Unregisters an action to this action manager
  95746. * @param action defines the action to be unregistered
  95747. * @return a boolean indicating whether the action has been unregistered
  95748. */
  95749. abstract unregisterAction(action: IAction): Boolean;
  95750. /**
  95751. * Does exist one action manager with at least one trigger
  95752. **/
  95753. static readonly HasTriggers: boolean;
  95754. /**
  95755. * Does exist one action manager with at least one pick trigger
  95756. **/
  95757. static readonly HasPickTriggers: boolean;
  95758. /**
  95759. * Does exist one action manager that handles actions of a given trigger
  95760. * @param trigger defines the trigger to be tested
  95761. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  95762. **/
  95763. static HasSpecificTrigger(trigger: number): boolean;
  95764. }
  95765. }
  95766. declare module BABYLON {
  95767. /**
  95768. * Defines how a node can be built from a string name.
  95769. */
  95770. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  95771. /**
  95772. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  95773. */
  95774. export class Node implements IBehaviorAware<Node> {
  95775. /** @hidden */
  95776. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  95777. private static _NodeConstructors;
  95778. /**
  95779. * Add a new node constructor
  95780. * @param type defines the type name of the node to construct
  95781. * @param constructorFunc defines the constructor function
  95782. */
  95783. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  95784. /**
  95785. * Returns a node constructor based on type name
  95786. * @param type defines the type name
  95787. * @param name defines the new node name
  95788. * @param scene defines the hosting scene
  95789. * @param options defines optional options to transmit to constructors
  95790. * @returns the new constructor or null
  95791. */
  95792. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  95793. /**
  95794. * Gets or sets the name of the node
  95795. */
  95796. name: string;
  95797. /**
  95798. * Gets or sets the id of the node
  95799. */
  95800. id: string;
  95801. /**
  95802. * Gets or sets the unique id of the node
  95803. */
  95804. uniqueId: number;
  95805. /**
  95806. * Gets or sets a string used to store user defined state for the node
  95807. */
  95808. state: string;
  95809. /**
  95810. * Gets or sets an object used to store user defined information for the node
  95811. */
  95812. metadata: any;
  95813. /**
  95814. * For internal use only. Please do not use.
  95815. */
  95816. reservedDataStore: any;
  95817. /**
  95818. * List of inspectable custom properties (used by the Inspector)
  95819. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  95820. */
  95821. inspectableCustomProperties: IInspectable[];
  95822. private _doNotSerialize;
  95823. /**
  95824. * Gets or sets a boolean used to define if the node must be serialized
  95825. */
  95826. doNotSerialize: boolean;
  95827. /** @hidden */
  95828. _isDisposed: boolean;
  95829. /**
  95830. * Gets a list of Animations associated with the node
  95831. */
  95832. animations: Animation[];
  95833. protected _ranges: {
  95834. [name: string]: Nullable<AnimationRange>;
  95835. };
  95836. /**
  95837. * Callback raised when the node is ready to be used
  95838. */
  95839. onReady: Nullable<(node: Node) => void>;
  95840. private _isEnabled;
  95841. private _isParentEnabled;
  95842. private _isReady;
  95843. /** @hidden */
  95844. _currentRenderId: number;
  95845. private _parentUpdateId;
  95846. /** @hidden */
  95847. _childUpdateId: number;
  95848. /** @hidden */
  95849. _waitingParentId: Nullable<string>;
  95850. /** @hidden */
  95851. _scene: Scene;
  95852. /** @hidden */
  95853. _cache: any;
  95854. private _parentNode;
  95855. private _children;
  95856. /** @hidden */
  95857. _worldMatrix: Matrix;
  95858. /** @hidden */
  95859. _worldMatrixDeterminant: number;
  95860. /** @hidden */
  95861. _worldMatrixDeterminantIsDirty: boolean;
  95862. /** @hidden */
  95863. private _sceneRootNodesIndex;
  95864. /**
  95865. * Gets a boolean indicating if the node has been disposed
  95866. * @returns true if the node was disposed
  95867. */
  95868. isDisposed(): boolean;
  95869. /**
  95870. * Gets or sets the parent of the node (without keeping the current position in the scene)
  95871. * @see https://doc.babylonjs.com/how_to/parenting
  95872. */
  95873. parent: Nullable<Node>;
  95874. /** @hidden */
  95875. _addToSceneRootNodes(): void;
  95876. /** @hidden */
  95877. _removeFromSceneRootNodes(): void;
  95878. private _animationPropertiesOverride;
  95879. /**
  95880. * Gets or sets the animation properties override
  95881. */
  95882. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  95883. /**
  95884. * Gets a string idenfifying the name of the class
  95885. * @returns "Node" string
  95886. */
  95887. getClassName(): string;
  95888. /** @hidden */
  95889. readonly _isNode: boolean;
  95890. /**
  95891. * An event triggered when the mesh is disposed
  95892. */
  95893. onDisposeObservable: Observable<Node>;
  95894. private _onDisposeObserver;
  95895. /**
  95896. * Sets a callback that will be raised when the node will be disposed
  95897. */
  95898. onDispose: () => void;
  95899. /**
  95900. * Creates a new Node
  95901. * @param name the name and id to be given to this node
  95902. * @param scene the scene this node will be added to
  95903. */
  95904. constructor(name: string, scene?: Nullable<Scene>);
  95905. /**
  95906. * Gets the scene of the node
  95907. * @returns a scene
  95908. */
  95909. getScene(): Scene;
  95910. /**
  95911. * Gets the engine of the node
  95912. * @returns a Engine
  95913. */
  95914. getEngine(): Engine;
  95915. private _behaviors;
  95916. /**
  95917. * Attach a behavior to the node
  95918. * @see http://doc.babylonjs.com/features/behaviour
  95919. * @param behavior defines the behavior to attach
  95920. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  95921. * @returns the current Node
  95922. */
  95923. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  95924. /**
  95925. * Remove an attached behavior
  95926. * @see http://doc.babylonjs.com/features/behaviour
  95927. * @param behavior defines the behavior to attach
  95928. * @returns the current Node
  95929. */
  95930. removeBehavior(behavior: Behavior<Node>): Node;
  95931. /**
  95932. * Gets the list of attached behaviors
  95933. * @see http://doc.babylonjs.com/features/behaviour
  95934. */
  95935. readonly behaviors: Behavior<Node>[];
  95936. /**
  95937. * Gets an attached behavior by name
  95938. * @param name defines the name of the behavior to look for
  95939. * @see http://doc.babylonjs.com/features/behaviour
  95940. * @returns null if behavior was not found else the requested behavior
  95941. */
  95942. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  95943. /**
  95944. * Returns the latest update of the World matrix
  95945. * @returns a Matrix
  95946. */
  95947. getWorldMatrix(): Matrix;
  95948. /** @hidden */
  95949. _getWorldMatrixDeterminant(): number;
  95950. /**
  95951. * Returns directly the latest state of the mesh World matrix.
  95952. * A Matrix is returned.
  95953. */
  95954. readonly worldMatrixFromCache: Matrix;
  95955. /** @hidden */
  95956. _initCache(): void;
  95957. /** @hidden */
  95958. updateCache(force?: boolean): void;
  95959. /** @hidden */
  95960. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  95961. /** @hidden */
  95962. _updateCache(ignoreParentClass?: boolean): void;
  95963. /** @hidden */
  95964. _isSynchronized(): boolean;
  95965. /** @hidden */
  95966. _markSyncedWithParent(): void;
  95967. /** @hidden */
  95968. isSynchronizedWithParent(): boolean;
  95969. /** @hidden */
  95970. isSynchronized(): boolean;
  95971. /**
  95972. * Is this node ready to be used/rendered
  95973. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  95974. * @return true if the node is ready
  95975. */
  95976. isReady(completeCheck?: boolean): boolean;
  95977. /**
  95978. * Is this node enabled?
  95979. * 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
  95980. * @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
  95981. * @return whether this node (and its parent) is enabled
  95982. */
  95983. isEnabled(checkAncestors?: boolean): boolean;
  95984. /** @hidden */
  95985. protected _syncParentEnabledState(): void;
  95986. /**
  95987. * Set the enabled state of this node
  95988. * @param value defines the new enabled state
  95989. */
  95990. setEnabled(value: boolean): void;
  95991. /**
  95992. * Is this node a descendant of the given node?
  95993. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  95994. * @param ancestor defines the parent node to inspect
  95995. * @returns a boolean indicating if this node is a descendant of the given node
  95996. */
  95997. isDescendantOf(ancestor: Node): boolean;
  95998. /** @hidden */
  95999. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  96000. /**
  96001. * Will return all nodes that have this node as ascendant
  96002. * @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
  96003. * @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
  96004. * @return all children nodes of all types
  96005. */
  96006. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  96007. /**
  96008. * Get all child-meshes of this node
  96009. * @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)
  96010. * @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
  96011. * @returns an array of AbstractMesh
  96012. */
  96013. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  96014. /**
  96015. * Get all direct children of this node
  96016. * @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
  96017. * @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)
  96018. * @returns an array of Node
  96019. */
  96020. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  96021. /** @hidden */
  96022. _setReady(state: boolean): void;
  96023. /**
  96024. * Get an animation by name
  96025. * @param name defines the name of the animation to look for
  96026. * @returns null if not found else the requested animation
  96027. */
  96028. getAnimationByName(name: string): Nullable<Animation>;
  96029. /**
  96030. * Creates an animation range for this node
  96031. * @param name defines the name of the range
  96032. * @param from defines the starting key
  96033. * @param to defines the end key
  96034. */
  96035. createAnimationRange(name: string, from: number, to: number): void;
  96036. /**
  96037. * Delete a specific animation range
  96038. * @param name defines the name of the range to delete
  96039. * @param deleteFrames defines if animation frames from the range must be deleted as well
  96040. */
  96041. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  96042. /**
  96043. * Get an animation range by name
  96044. * @param name defines the name of the animation range to look for
  96045. * @returns null if not found else the requested animation range
  96046. */
  96047. getAnimationRange(name: string): Nullable<AnimationRange>;
  96048. /**
  96049. * Gets the list of all animation ranges defined on this node
  96050. * @returns an array
  96051. */
  96052. getAnimationRanges(): Nullable<AnimationRange>[];
  96053. /**
  96054. * Will start the animation sequence
  96055. * @param name defines the range frames for animation sequence
  96056. * @param loop defines if the animation should loop (false by default)
  96057. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  96058. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  96059. * @returns the object created for this animation. If range does not exist, it will return null
  96060. */
  96061. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  96062. /**
  96063. * Serialize animation ranges into a JSON compatible object
  96064. * @returns serialization object
  96065. */
  96066. serializeAnimationRanges(): any;
  96067. /**
  96068. * Computes the world matrix of the node
  96069. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  96070. * @returns the world matrix
  96071. */
  96072. computeWorldMatrix(force?: boolean): Matrix;
  96073. /**
  96074. * Releases resources associated with this node.
  96075. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  96076. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  96077. */
  96078. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  96079. /**
  96080. * Parse animation range data from a serialization object and store them into a given node
  96081. * @param node defines where to store the animation ranges
  96082. * @param parsedNode defines the serialization object to read data from
  96083. * @param scene defines the hosting scene
  96084. */
  96085. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  96086. /**
  96087. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  96088. * @param includeDescendants Include bounding info from descendants as well (true by default)
  96089. * @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
  96090. * @returns the new bounding vectors
  96091. */
  96092. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  96093. min: Vector3;
  96094. max: Vector3;
  96095. };
  96096. }
  96097. }
  96098. declare module BABYLON {
  96099. /**
  96100. * @hidden
  96101. */
  96102. export class _IAnimationState {
  96103. key: number;
  96104. repeatCount: number;
  96105. workValue?: any;
  96106. loopMode?: number;
  96107. offsetValue?: any;
  96108. highLimitValue?: any;
  96109. }
  96110. /**
  96111. * Class used to store any kind of animation
  96112. */
  96113. export class Animation {
  96114. /**Name of the animation */
  96115. name: string;
  96116. /**Property to animate */
  96117. targetProperty: string;
  96118. /**The frames per second of the animation */
  96119. framePerSecond: number;
  96120. /**The data type of the animation */
  96121. dataType: number;
  96122. /**The loop mode of the animation */
  96123. loopMode?: number | undefined;
  96124. /**Specifies if blending should be enabled */
  96125. enableBlending?: boolean | undefined;
  96126. /**
  96127. * Use matrix interpolation instead of using direct key value when animating matrices
  96128. */
  96129. static AllowMatricesInterpolation: boolean;
  96130. /**
  96131. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  96132. */
  96133. static AllowMatrixDecomposeForInterpolation: boolean;
  96134. /**
  96135. * Stores the key frames of the animation
  96136. */
  96137. private _keys;
  96138. /**
  96139. * Stores the easing function of the animation
  96140. */
  96141. private _easingFunction;
  96142. /**
  96143. * @hidden Internal use only
  96144. */
  96145. _runtimeAnimations: RuntimeAnimation[];
  96146. /**
  96147. * The set of event that will be linked to this animation
  96148. */
  96149. private _events;
  96150. /**
  96151. * Stores an array of target property paths
  96152. */
  96153. targetPropertyPath: string[];
  96154. /**
  96155. * Stores the blending speed of the animation
  96156. */
  96157. blendingSpeed: number;
  96158. /**
  96159. * Stores the animation ranges for the animation
  96160. */
  96161. private _ranges;
  96162. /**
  96163. * @hidden Internal use
  96164. */
  96165. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  96166. /**
  96167. * Sets up an animation
  96168. * @param property The property to animate
  96169. * @param animationType The animation type to apply
  96170. * @param framePerSecond The frames per second of the animation
  96171. * @param easingFunction The easing function used in the animation
  96172. * @returns The created animation
  96173. */
  96174. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  96175. /**
  96176. * Create and start an animation on a node
  96177. * @param name defines the name of the global animation that will be run on all nodes
  96178. * @param node defines the root node where the animation will take place
  96179. * @param targetProperty defines property to animate
  96180. * @param framePerSecond defines the number of frame per second yo use
  96181. * @param totalFrame defines the number of frames in total
  96182. * @param from defines the initial value
  96183. * @param to defines the final value
  96184. * @param loopMode defines which loop mode you want to use (off by default)
  96185. * @param easingFunction defines the easing function to use (linear by default)
  96186. * @param onAnimationEnd defines the callback to call when animation end
  96187. * @returns the animatable created for this animation
  96188. */
  96189. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  96190. /**
  96191. * Create and start an animation on a node and its descendants
  96192. * @param name defines the name of the global animation that will be run on all nodes
  96193. * @param node defines the root node where the animation will take place
  96194. * @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
  96195. * @param targetProperty defines property to animate
  96196. * @param framePerSecond defines the number of frame per second to use
  96197. * @param totalFrame defines the number of frames in total
  96198. * @param from defines the initial value
  96199. * @param to defines the final value
  96200. * @param loopMode defines which loop mode you want to use (off by default)
  96201. * @param easingFunction defines the easing function to use (linear by default)
  96202. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  96203. * @returns the list of animatables created for all nodes
  96204. * @example https://www.babylonjs-playground.com/#MH0VLI
  96205. */
  96206. 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[]>;
  96207. /**
  96208. * Creates a new animation, merges it with the existing animations and starts it
  96209. * @param name Name of the animation
  96210. * @param node Node which contains the scene that begins the animations
  96211. * @param targetProperty Specifies which property to animate
  96212. * @param framePerSecond The frames per second of the animation
  96213. * @param totalFrame The total number of frames
  96214. * @param from The frame at the beginning of the animation
  96215. * @param to The frame at the end of the animation
  96216. * @param loopMode Specifies the loop mode of the animation
  96217. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  96218. * @param onAnimationEnd Callback to run once the animation is complete
  96219. * @returns Nullable animation
  96220. */
  96221. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  96222. /**
  96223. * Transition property of an host to the target Value
  96224. * @param property The property to transition
  96225. * @param targetValue The target Value of the property
  96226. * @param host The object where the property to animate belongs
  96227. * @param scene Scene used to run the animation
  96228. * @param frameRate Framerate (in frame/s) to use
  96229. * @param transition The transition type we want to use
  96230. * @param duration The duration of the animation, in milliseconds
  96231. * @param onAnimationEnd Callback trigger at the end of the animation
  96232. * @returns Nullable animation
  96233. */
  96234. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  96235. /**
  96236. * Return the array of runtime animations currently using this animation
  96237. */
  96238. readonly runtimeAnimations: RuntimeAnimation[];
  96239. /**
  96240. * Specifies if any of the runtime animations are currently running
  96241. */
  96242. readonly hasRunningRuntimeAnimations: boolean;
  96243. /**
  96244. * Initializes the animation
  96245. * @param name Name of the animation
  96246. * @param targetProperty Property to animate
  96247. * @param framePerSecond The frames per second of the animation
  96248. * @param dataType The data type of the animation
  96249. * @param loopMode The loop mode of the animation
  96250. * @param enableBlending Specifies if blending should be enabled
  96251. */
  96252. constructor(
  96253. /**Name of the animation */
  96254. name: string,
  96255. /**Property to animate */
  96256. targetProperty: string,
  96257. /**The frames per second of the animation */
  96258. framePerSecond: number,
  96259. /**The data type of the animation */
  96260. dataType: number,
  96261. /**The loop mode of the animation */
  96262. loopMode?: number | undefined,
  96263. /**Specifies if blending should be enabled */
  96264. enableBlending?: boolean | undefined);
  96265. /**
  96266. * Converts the animation to a string
  96267. * @param fullDetails support for multiple levels of logging within scene loading
  96268. * @returns String form of the animation
  96269. */
  96270. toString(fullDetails?: boolean): string;
  96271. /**
  96272. * Add an event to this animation
  96273. * @param event Event to add
  96274. */
  96275. addEvent(event: AnimationEvent): void;
  96276. /**
  96277. * Remove all events found at the given frame
  96278. * @param frame The frame to remove events from
  96279. */
  96280. removeEvents(frame: number): void;
  96281. /**
  96282. * Retrieves all the events from the animation
  96283. * @returns Events from the animation
  96284. */
  96285. getEvents(): AnimationEvent[];
  96286. /**
  96287. * Creates an animation range
  96288. * @param name Name of the animation range
  96289. * @param from Starting frame of the animation range
  96290. * @param to Ending frame of the animation
  96291. */
  96292. createRange(name: string, from: number, to: number): void;
  96293. /**
  96294. * Deletes an animation range by name
  96295. * @param name Name of the animation range to delete
  96296. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  96297. */
  96298. deleteRange(name: string, deleteFrames?: boolean): void;
  96299. /**
  96300. * Gets the animation range by name, or null if not defined
  96301. * @param name Name of the animation range
  96302. * @returns Nullable animation range
  96303. */
  96304. getRange(name: string): Nullable<AnimationRange>;
  96305. /**
  96306. * Gets the key frames from the animation
  96307. * @returns The key frames of the animation
  96308. */
  96309. getKeys(): Array<IAnimationKey>;
  96310. /**
  96311. * Gets the highest frame rate of the animation
  96312. * @returns Highest frame rate of the animation
  96313. */
  96314. getHighestFrame(): number;
  96315. /**
  96316. * Gets the easing function of the animation
  96317. * @returns Easing function of the animation
  96318. */
  96319. getEasingFunction(): IEasingFunction;
  96320. /**
  96321. * Sets the easing function of the animation
  96322. * @param easingFunction A custom mathematical formula for animation
  96323. */
  96324. setEasingFunction(easingFunction: EasingFunction): void;
  96325. /**
  96326. * Interpolates a scalar linearly
  96327. * @param startValue Start value of the animation curve
  96328. * @param endValue End value of the animation curve
  96329. * @param gradient Scalar amount to interpolate
  96330. * @returns Interpolated scalar value
  96331. */
  96332. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  96333. /**
  96334. * Interpolates a scalar cubically
  96335. * @param startValue Start value of the animation curve
  96336. * @param outTangent End tangent of the animation
  96337. * @param endValue End value of the animation curve
  96338. * @param inTangent Start tangent of the animation curve
  96339. * @param gradient Scalar amount to interpolate
  96340. * @returns Interpolated scalar value
  96341. */
  96342. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  96343. /**
  96344. * Interpolates a quaternion using a spherical linear interpolation
  96345. * @param startValue Start value of the animation curve
  96346. * @param endValue End value of the animation curve
  96347. * @param gradient Scalar amount to interpolate
  96348. * @returns Interpolated quaternion value
  96349. */
  96350. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  96351. /**
  96352. * Interpolates a quaternion cubically
  96353. * @param startValue Start value of the animation curve
  96354. * @param outTangent End tangent of the animation curve
  96355. * @param endValue End value of the animation curve
  96356. * @param inTangent Start tangent of the animation curve
  96357. * @param gradient Scalar amount to interpolate
  96358. * @returns Interpolated quaternion value
  96359. */
  96360. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  96361. /**
  96362. * Interpolates a Vector3 linearl
  96363. * @param startValue Start value of the animation curve
  96364. * @param endValue End value of the animation curve
  96365. * @param gradient Scalar amount to interpolate
  96366. * @returns Interpolated scalar value
  96367. */
  96368. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  96369. /**
  96370. * Interpolates a Vector3 cubically
  96371. * @param startValue Start value of the animation curve
  96372. * @param outTangent End tangent of the animation
  96373. * @param endValue End value of the animation curve
  96374. * @param inTangent Start tangent of the animation curve
  96375. * @param gradient Scalar amount to interpolate
  96376. * @returns InterpolatedVector3 value
  96377. */
  96378. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  96379. /**
  96380. * Interpolates a Vector2 linearly
  96381. * @param startValue Start value of the animation curve
  96382. * @param endValue End value of the animation curve
  96383. * @param gradient Scalar amount to interpolate
  96384. * @returns Interpolated Vector2 value
  96385. */
  96386. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  96387. /**
  96388. * Interpolates a Vector2 cubically
  96389. * @param startValue Start value of the animation curve
  96390. * @param outTangent End tangent of the animation
  96391. * @param endValue End value of the animation curve
  96392. * @param inTangent Start tangent of the animation curve
  96393. * @param gradient Scalar amount to interpolate
  96394. * @returns Interpolated Vector2 value
  96395. */
  96396. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  96397. /**
  96398. * Interpolates a size linearly
  96399. * @param startValue Start value of the animation curve
  96400. * @param endValue End value of the animation curve
  96401. * @param gradient Scalar amount to interpolate
  96402. * @returns Interpolated Size value
  96403. */
  96404. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  96405. /**
  96406. * Interpolates a Color3 linearly
  96407. * @param startValue Start value of the animation curve
  96408. * @param endValue End value of the animation curve
  96409. * @param gradient Scalar amount to interpolate
  96410. * @returns Interpolated Color3 value
  96411. */
  96412. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  96413. /**
  96414. * Interpolates a Color4 linearly
  96415. * @param startValue Start value of the animation curve
  96416. * @param endValue End value of the animation curve
  96417. * @param gradient Scalar amount to interpolate
  96418. * @returns Interpolated Color3 value
  96419. */
  96420. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  96421. /**
  96422. * @hidden Internal use only
  96423. */
  96424. _getKeyValue(value: any): any;
  96425. /**
  96426. * @hidden Internal use only
  96427. */
  96428. _interpolate(currentFrame: number, state: _IAnimationState): any;
  96429. /**
  96430. * Defines the function to use to interpolate matrices
  96431. * @param startValue defines the start matrix
  96432. * @param endValue defines the end matrix
  96433. * @param gradient defines the gradient between both matrices
  96434. * @param result defines an optional target matrix where to store the interpolation
  96435. * @returns the interpolated matrix
  96436. */
  96437. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  96438. /**
  96439. * Makes a copy of the animation
  96440. * @returns Cloned animation
  96441. */
  96442. clone(): Animation;
  96443. /**
  96444. * Sets the key frames of the animation
  96445. * @param values The animation key frames to set
  96446. */
  96447. setKeys(values: Array<IAnimationKey>): void;
  96448. /**
  96449. * Serializes the animation to an object
  96450. * @returns Serialized object
  96451. */
  96452. serialize(): any;
  96453. /**
  96454. * Float animation type
  96455. */
  96456. static readonly ANIMATIONTYPE_FLOAT: number;
  96457. /**
  96458. * Vector3 animation type
  96459. */
  96460. static readonly ANIMATIONTYPE_VECTOR3: number;
  96461. /**
  96462. * Quaternion animation type
  96463. */
  96464. static readonly ANIMATIONTYPE_QUATERNION: number;
  96465. /**
  96466. * Matrix animation type
  96467. */
  96468. static readonly ANIMATIONTYPE_MATRIX: number;
  96469. /**
  96470. * Color3 animation type
  96471. */
  96472. static readonly ANIMATIONTYPE_COLOR3: number;
  96473. /**
  96474. * Color3 animation type
  96475. */
  96476. static readonly ANIMATIONTYPE_COLOR4: number;
  96477. /**
  96478. * Vector2 animation type
  96479. */
  96480. static readonly ANIMATIONTYPE_VECTOR2: number;
  96481. /**
  96482. * Size animation type
  96483. */
  96484. static readonly ANIMATIONTYPE_SIZE: number;
  96485. /**
  96486. * Relative Loop Mode
  96487. */
  96488. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  96489. /**
  96490. * Cycle Loop Mode
  96491. */
  96492. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  96493. /**
  96494. * Constant Loop Mode
  96495. */
  96496. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  96497. /** @hidden */
  96498. static _UniversalLerp(left: any, right: any, amount: number): any;
  96499. /**
  96500. * Parses an animation object and creates an animation
  96501. * @param parsedAnimation Parsed animation object
  96502. * @returns Animation object
  96503. */
  96504. static Parse(parsedAnimation: any): Animation;
  96505. /**
  96506. * Appends the serialized animations from the source animations
  96507. * @param source Source containing the animations
  96508. * @param destination Target to store the animations
  96509. */
  96510. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  96511. }
  96512. }
  96513. declare module BABYLON {
  96514. /**
  96515. * Interface containing an array of animations
  96516. */
  96517. export interface IAnimatable {
  96518. /**
  96519. * Array of animations
  96520. */
  96521. animations: Nullable<Array<Animation>>;
  96522. }
  96523. }
  96524. declare module BABYLON {
  96525. /**
  96526. * This represents all the required information to add a fresnel effect on a material:
  96527. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  96528. */
  96529. export class FresnelParameters {
  96530. private _isEnabled;
  96531. /**
  96532. * Define if the fresnel effect is enable or not.
  96533. */
  96534. isEnabled: boolean;
  96535. /**
  96536. * Define the color used on edges (grazing angle)
  96537. */
  96538. leftColor: Color3;
  96539. /**
  96540. * Define the color used on center
  96541. */
  96542. rightColor: Color3;
  96543. /**
  96544. * Define bias applied to computed fresnel term
  96545. */
  96546. bias: number;
  96547. /**
  96548. * Defined the power exponent applied to fresnel term
  96549. */
  96550. power: number;
  96551. /**
  96552. * Clones the current fresnel and its valuues
  96553. * @returns a clone fresnel configuration
  96554. */
  96555. clone(): FresnelParameters;
  96556. /**
  96557. * Serializes the current fresnel parameters to a JSON representation.
  96558. * @return the JSON serialization
  96559. */
  96560. serialize(): any;
  96561. /**
  96562. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  96563. * @param parsedFresnelParameters Define the JSON representation
  96564. * @returns the parsed parameters
  96565. */
  96566. static Parse(parsedFresnelParameters: any): FresnelParameters;
  96567. }
  96568. }
  96569. declare module BABYLON {
  96570. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  96571. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  96572. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  96573. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  96574. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  96575. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  96576. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  96577. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  96578. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  96579. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  96580. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  96581. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  96582. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  96583. /**
  96584. * Decorator used to define property that can be serialized as reference to a camera
  96585. * @param sourceName defines the name of the property to decorate
  96586. */
  96587. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  96588. /**
  96589. * Class used to help serialization objects
  96590. */
  96591. export class SerializationHelper {
  96592. /** @hidden */
  96593. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  96594. /** @hidden */
  96595. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  96596. /** @hidden */
  96597. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  96598. /** @hidden */
  96599. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  96600. /**
  96601. * Appends the serialized animations from the source animations
  96602. * @param source Source containing the animations
  96603. * @param destination Target to store the animations
  96604. */
  96605. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  96606. /**
  96607. * Static function used to serialized a specific entity
  96608. * @param entity defines the entity to serialize
  96609. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  96610. * @returns a JSON compatible object representing the serialization of the entity
  96611. */
  96612. static Serialize<T>(entity: T, serializationObject?: any): any;
  96613. /**
  96614. * Creates a new entity from a serialization data object
  96615. * @param creationFunction defines a function used to instanciated the new entity
  96616. * @param source defines the source serialization data
  96617. * @param scene defines the hosting scene
  96618. * @param rootUrl defines the root url for resources
  96619. * @returns a new entity
  96620. */
  96621. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  96622. /**
  96623. * Clones an object
  96624. * @param creationFunction defines the function used to instanciate the new object
  96625. * @param source defines the source object
  96626. * @returns the cloned object
  96627. */
  96628. static Clone<T>(creationFunction: () => T, source: T): T;
  96629. /**
  96630. * Instanciates a new object based on a source one (some data will be shared between both object)
  96631. * @param creationFunction defines the function used to instanciate the new object
  96632. * @param source defines the source object
  96633. * @returns the new object
  96634. */
  96635. static Instanciate<T>(creationFunction: () => T, source: T): T;
  96636. }
  96637. }
  96638. declare module BABYLON {
  96639. /**
  96640. * Class used to manipulate GUIDs
  96641. */
  96642. export class GUID {
  96643. /**
  96644. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  96645. * Be aware Math.random() could cause collisions, but:
  96646. * "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"
  96647. * @returns a pseudo random id
  96648. */
  96649. static RandomId(): string;
  96650. }
  96651. }
  96652. declare module BABYLON {
  96653. /**
  96654. * Base class of all the textures in babylon.
  96655. * It groups all the common properties the materials, post process, lights... might need
  96656. * in order to make a correct use of the texture.
  96657. */
  96658. export class BaseTexture implements IAnimatable {
  96659. /**
  96660. * Default anisotropic filtering level for the application.
  96661. * It is set to 4 as a good tradeoff between perf and quality.
  96662. */
  96663. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  96664. /**
  96665. * Gets or sets the unique id of the texture
  96666. */
  96667. uniqueId: number;
  96668. /**
  96669. * Define the name of the texture.
  96670. */
  96671. name: string;
  96672. /**
  96673. * Gets or sets an object used to store user defined information.
  96674. */
  96675. metadata: any;
  96676. /**
  96677. * For internal use only. Please do not use.
  96678. */
  96679. reservedDataStore: any;
  96680. private _hasAlpha;
  96681. /**
  96682. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  96683. */
  96684. hasAlpha: boolean;
  96685. /**
  96686. * Defines if the alpha value should be determined via the rgb values.
  96687. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  96688. */
  96689. getAlphaFromRGB: boolean;
  96690. /**
  96691. * Intensity or strength of the texture.
  96692. * It is commonly used by materials to fine tune the intensity of the texture
  96693. */
  96694. level: number;
  96695. /**
  96696. * Define the UV chanel to use starting from 0 and defaulting to 0.
  96697. * This is part of the texture as textures usually maps to one uv set.
  96698. */
  96699. coordinatesIndex: number;
  96700. private _coordinatesMode;
  96701. /**
  96702. * How a texture is mapped.
  96703. *
  96704. * | Value | Type | Description |
  96705. * | ----- | ----------------------------------- | ----------- |
  96706. * | 0 | EXPLICIT_MODE | |
  96707. * | 1 | SPHERICAL_MODE | |
  96708. * | 2 | PLANAR_MODE | |
  96709. * | 3 | CUBIC_MODE | |
  96710. * | 4 | PROJECTION_MODE | |
  96711. * | 5 | SKYBOX_MODE | |
  96712. * | 6 | INVCUBIC_MODE | |
  96713. * | 7 | EQUIRECTANGULAR_MODE | |
  96714. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  96715. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  96716. */
  96717. coordinatesMode: number;
  96718. /**
  96719. * | Value | Type | Description |
  96720. * | ----- | ------------------ | ----------- |
  96721. * | 0 | CLAMP_ADDRESSMODE | |
  96722. * | 1 | WRAP_ADDRESSMODE | |
  96723. * | 2 | MIRROR_ADDRESSMODE | |
  96724. */
  96725. wrapU: number;
  96726. /**
  96727. * | Value | Type | Description |
  96728. * | ----- | ------------------ | ----------- |
  96729. * | 0 | CLAMP_ADDRESSMODE | |
  96730. * | 1 | WRAP_ADDRESSMODE | |
  96731. * | 2 | MIRROR_ADDRESSMODE | |
  96732. */
  96733. wrapV: number;
  96734. /**
  96735. * | Value | Type | Description |
  96736. * | ----- | ------------------ | ----------- |
  96737. * | 0 | CLAMP_ADDRESSMODE | |
  96738. * | 1 | WRAP_ADDRESSMODE | |
  96739. * | 2 | MIRROR_ADDRESSMODE | |
  96740. */
  96741. wrapR: number;
  96742. /**
  96743. * With compliant hardware and browser (supporting anisotropic filtering)
  96744. * this defines the level of anisotropic filtering in the texture.
  96745. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  96746. */
  96747. anisotropicFilteringLevel: number;
  96748. /**
  96749. * Define if the texture is a cube texture or if false a 2d texture.
  96750. */
  96751. isCube: boolean;
  96752. /**
  96753. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  96754. */
  96755. is3D: boolean;
  96756. /**
  96757. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  96758. */
  96759. is2DArray: boolean;
  96760. /**
  96761. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  96762. * HDR texture are usually stored in linear space.
  96763. * This only impacts the PBR and Background materials
  96764. */
  96765. gammaSpace: boolean;
  96766. /**
  96767. * Gets or sets whether or not the texture contains RGBD data.
  96768. */
  96769. isRGBD: boolean;
  96770. /**
  96771. * Is Z inverted in the texture (useful in a cube texture).
  96772. */
  96773. invertZ: boolean;
  96774. /**
  96775. * Are mip maps generated for this texture or not.
  96776. */
  96777. readonly noMipmap: boolean;
  96778. /**
  96779. * @hidden
  96780. */
  96781. lodLevelInAlpha: boolean;
  96782. /**
  96783. * With prefiltered texture, defined the offset used during the prefiltering steps.
  96784. */
  96785. lodGenerationOffset: number;
  96786. /**
  96787. * With prefiltered texture, defined the scale used during the prefiltering steps.
  96788. */
  96789. lodGenerationScale: number;
  96790. /**
  96791. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  96792. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  96793. * average roughness values.
  96794. */
  96795. linearSpecularLOD: boolean;
  96796. /**
  96797. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  96798. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  96799. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  96800. */
  96801. irradianceTexture: Nullable<BaseTexture>;
  96802. /**
  96803. * Define if the texture is a render target.
  96804. */
  96805. isRenderTarget: boolean;
  96806. /**
  96807. * Define the unique id of the texture in the scene.
  96808. */
  96809. readonly uid: string;
  96810. /**
  96811. * Return a string representation of the texture.
  96812. * @returns the texture as a string
  96813. */
  96814. toString(): string;
  96815. /**
  96816. * Get the class name of the texture.
  96817. * @returns "BaseTexture"
  96818. */
  96819. getClassName(): string;
  96820. /**
  96821. * Define the list of animation attached to the texture.
  96822. */
  96823. animations: Animation[];
  96824. /**
  96825. * An event triggered when the texture is disposed.
  96826. */
  96827. onDisposeObservable: Observable<BaseTexture>;
  96828. private _onDisposeObserver;
  96829. /**
  96830. * Callback triggered when the texture has been disposed.
  96831. * Kept for back compatibility, you can use the onDisposeObservable instead.
  96832. */
  96833. onDispose: () => void;
  96834. /**
  96835. * Define the current state of the loading sequence when in delayed load mode.
  96836. */
  96837. delayLoadState: number;
  96838. private _scene;
  96839. /** @hidden */
  96840. _texture: Nullable<InternalTexture>;
  96841. private _uid;
  96842. /**
  96843. * Define if the texture is preventinga material to render or not.
  96844. * If not and the texture is not ready, the engine will use a default black texture instead.
  96845. */
  96846. readonly isBlocking: boolean;
  96847. /**
  96848. * Instantiates a new BaseTexture.
  96849. * Base class of all the textures in babylon.
  96850. * It groups all the common properties the materials, post process, lights... might need
  96851. * in order to make a correct use of the texture.
  96852. * @param scene Define the scene the texture blongs to
  96853. */
  96854. constructor(scene: Nullable<Scene>);
  96855. /**
  96856. * Get the scene the texture belongs to.
  96857. * @returns the scene or null if undefined
  96858. */
  96859. getScene(): Nullable<Scene>;
  96860. /**
  96861. * Get the texture transform matrix used to offset tile the texture for istance.
  96862. * @returns the transformation matrix
  96863. */
  96864. getTextureMatrix(): Matrix;
  96865. /**
  96866. * Get the texture reflection matrix used to rotate/transform the reflection.
  96867. * @returns the reflection matrix
  96868. */
  96869. getReflectionTextureMatrix(): Matrix;
  96870. /**
  96871. * Get the underlying lower level texture from Babylon.
  96872. * @returns the insternal texture
  96873. */
  96874. getInternalTexture(): Nullable<InternalTexture>;
  96875. /**
  96876. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  96877. * @returns true if ready or not blocking
  96878. */
  96879. isReadyOrNotBlocking(): boolean;
  96880. /**
  96881. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  96882. * @returns true if fully ready
  96883. */
  96884. isReady(): boolean;
  96885. private _cachedSize;
  96886. /**
  96887. * Get the size of the texture.
  96888. * @returns the texture size.
  96889. */
  96890. getSize(): ISize;
  96891. /**
  96892. * Get the base size of the texture.
  96893. * It can be different from the size if the texture has been resized for POT for instance
  96894. * @returns the base size
  96895. */
  96896. getBaseSize(): ISize;
  96897. /**
  96898. * Update the sampling mode of the texture.
  96899. * Default is Trilinear mode.
  96900. *
  96901. * | Value | Type | Description |
  96902. * | ----- | ------------------ | ----------- |
  96903. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  96904. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  96905. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  96906. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  96907. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  96908. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  96909. * | 7 | NEAREST_LINEAR | |
  96910. * | 8 | NEAREST_NEAREST | |
  96911. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  96912. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  96913. * | 11 | LINEAR_LINEAR | |
  96914. * | 12 | LINEAR_NEAREST | |
  96915. *
  96916. * > _mag_: magnification filter (close to the viewer)
  96917. * > _min_: minification filter (far from the viewer)
  96918. * > _mip_: filter used between mip map levels
  96919. *@param samplingMode Define the new sampling mode of the texture
  96920. */
  96921. updateSamplingMode(samplingMode: number): void;
  96922. /**
  96923. * Scales the texture if is `canRescale()`
  96924. * @param ratio the resize factor we want to use to rescale
  96925. */
  96926. scale(ratio: number): void;
  96927. /**
  96928. * Get if the texture can rescale.
  96929. */
  96930. readonly canRescale: boolean;
  96931. /** @hidden */
  96932. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  96933. /** @hidden */
  96934. _rebuild(): void;
  96935. /**
  96936. * Triggers the load sequence in delayed load mode.
  96937. */
  96938. delayLoad(): void;
  96939. /**
  96940. * Clones the texture.
  96941. * @returns the cloned texture
  96942. */
  96943. clone(): Nullable<BaseTexture>;
  96944. /**
  96945. * Get the texture underlying type (INT, FLOAT...)
  96946. */
  96947. readonly textureType: number;
  96948. /**
  96949. * Get the texture underlying format (RGB, RGBA...)
  96950. */
  96951. readonly textureFormat: number;
  96952. /**
  96953. * Indicates that textures need to be re-calculated for all materials
  96954. */
  96955. protected _markAllSubMeshesAsTexturesDirty(): void;
  96956. /**
  96957. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  96958. * This will returns an RGBA array buffer containing either in values (0-255) or
  96959. * float values (0-1) depending of the underlying buffer type.
  96960. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  96961. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  96962. * @param buffer defines a user defined buffer to fill with data (can be null)
  96963. * @returns The Array buffer containing the pixels data.
  96964. */
  96965. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  96966. /**
  96967. * Release and destroy the underlying lower level texture aka internalTexture.
  96968. */
  96969. releaseInternalTexture(): void;
  96970. /** @hidden */
  96971. readonly _lodTextureHigh: Nullable<BaseTexture>;
  96972. /** @hidden */
  96973. readonly _lodTextureMid: Nullable<BaseTexture>;
  96974. /** @hidden */
  96975. readonly _lodTextureLow: Nullable<BaseTexture>;
  96976. /**
  96977. * Dispose the texture and release its associated resources.
  96978. */
  96979. dispose(): void;
  96980. /**
  96981. * Serialize the texture into a JSON representation that can be parsed later on.
  96982. * @returns the JSON representation of the texture
  96983. */
  96984. serialize(): any;
  96985. /**
  96986. * Helper function to be called back once a list of texture contains only ready textures.
  96987. * @param textures Define the list of textures to wait for
  96988. * @param callback Define the callback triggered once the entire list will be ready
  96989. */
  96990. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  96991. }
  96992. }
  96993. declare module BABYLON {
  96994. /**
  96995. * Options to be used when creating an effect.
  96996. */
  96997. export interface IEffectCreationOptions {
  96998. /**
  96999. * Atrributes that will be used in the shader.
  97000. */
  97001. attributes: string[];
  97002. /**
  97003. * Uniform varible names that will be set in the shader.
  97004. */
  97005. uniformsNames: string[];
  97006. /**
  97007. * Uniform buffer variable names that will be set in the shader.
  97008. */
  97009. uniformBuffersNames: string[];
  97010. /**
  97011. * Sampler texture variable names that will be set in the shader.
  97012. */
  97013. samplers: string[];
  97014. /**
  97015. * Define statements that will be set in the shader.
  97016. */
  97017. defines: any;
  97018. /**
  97019. * Possible fallbacks for this effect to improve performance when needed.
  97020. */
  97021. fallbacks: Nullable<IEffectFallbacks>;
  97022. /**
  97023. * Callback that will be called when the shader is compiled.
  97024. */
  97025. onCompiled: Nullable<(effect: Effect) => void>;
  97026. /**
  97027. * Callback that will be called if an error occurs during shader compilation.
  97028. */
  97029. onError: Nullable<(effect: Effect, errors: string) => void>;
  97030. /**
  97031. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  97032. */
  97033. indexParameters?: any;
  97034. /**
  97035. * Max number of lights that can be used in the shader.
  97036. */
  97037. maxSimultaneousLights?: number;
  97038. /**
  97039. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  97040. */
  97041. transformFeedbackVaryings?: Nullable<string[]>;
  97042. }
  97043. /**
  97044. * Effect containing vertex and fragment shader that can be executed on an object.
  97045. */
  97046. export class Effect implements IDisposable {
  97047. /**
  97048. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  97049. */
  97050. static ShadersRepository: string;
  97051. /**
  97052. * Name of the effect.
  97053. */
  97054. name: any;
  97055. /**
  97056. * String container all the define statements that should be set on the shader.
  97057. */
  97058. defines: string;
  97059. /**
  97060. * Callback that will be called when the shader is compiled.
  97061. */
  97062. onCompiled: Nullable<(effect: Effect) => void>;
  97063. /**
  97064. * Callback that will be called if an error occurs during shader compilation.
  97065. */
  97066. onError: Nullable<(effect: Effect, errors: string) => void>;
  97067. /**
  97068. * Callback that will be called when effect is bound.
  97069. */
  97070. onBind: Nullable<(effect: Effect) => void>;
  97071. /**
  97072. * Unique ID of the effect.
  97073. */
  97074. uniqueId: number;
  97075. /**
  97076. * Observable that will be called when the shader is compiled.
  97077. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  97078. */
  97079. onCompileObservable: Observable<Effect>;
  97080. /**
  97081. * Observable that will be called if an error occurs during shader compilation.
  97082. */
  97083. onErrorObservable: Observable<Effect>;
  97084. /** @hidden */
  97085. _onBindObservable: Nullable<Observable<Effect>>;
  97086. /**
  97087. * Observable that will be called when effect is bound.
  97088. */
  97089. readonly onBindObservable: Observable<Effect>;
  97090. /** @hidden */
  97091. _bonesComputationForcedToCPU: boolean;
  97092. private static _uniqueIdSeed;
  97093. private _engine;
  97094. private _uniformBuffersNames;
  97095. private _uniformsNames;
  97096. private _samplerList;
  97097. private _samplers;
  97098. private _isReady;
  97099. private _compilationError;
  97100. private _allFallbacksProcessed;
  97101. private _attributesNames;
  97102. private _attributes;
  97103. private _uniforms;
  97104. /**
  97105. * Key for the effect.
  97106. * @hidden
  97107. */
  97108. _key: string;
  97109. private _indexParameters;
  97110. private _fallbacks;
  97111. private _vertexSourceCode;
  97112. private _fragmentSourceCode;
  97113. private _vertexSourceCodeOverride;
  97114. private _fragmentSourceCodeOverride;
  97115. private _transformFeedbackVaryings;
  97116. /**
  97117. * Compiled shader to webGL program.
  97118. * @hidden
  97119. */
  97120. _pipelineContext: Nullable<IPipelineContext>;
  97121. private _valueCache;
  97122. private static _baseCache;
  97123. /**
  97124. * Instantiates an effect.
  97125. * An effect can be used to create/manage/execute vertex and fragment shaders.
  97126. * @param baseName Name of the effect.
  97127. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  97128. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  97129. * @param samplers List of sampler variables that will be passed to the shader.
  97130. * @param engine Engine to be used to render the effect
  97131. * @param defines Define statements to be added to the shader.
  97132. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  97133. * @param onCompiled Callback that will be called when the shader is compiled.
  97134. * @param onError Callback that will be called if an error occurs during shader compilation.
  97135. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  97136. */
  97137. 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);
  97138. private _useFinalCode;
  97139. /**
  97140. * Unique key for this effect
  97141. */
  97142. readonly key: string;
  97143. /**
  97144. * If the effect has been compiled and prepared.
  97145. * @returns if the effect is compiled and prepared.
  97146. */
  97147. isReady(): boolean;
  97148. private _isReadyInternal;
  97149. /**
  97150. * The engine the effect was initialized with.
  97151. * @returns the engine.
  97152. */
  97153. getEngine(): Engine;
  97154. /**
  97155. * The pipeline context for this effect
  97156. * @returns the associated pipeline context
  97157. */
  97158. getPipelineContext(): Nullable<IPipelineContext>;
  97159. /**
  97160. * The set of names of attribute variables for the shader.
  97161. * @returns An array of attribute names.
  97162. */
  97163. getAttributesNames(): string[];
  97164. /**
  97165. * Returns the attribute at the given index.
  97166. * @param index The index of the attribute.
  97167. * @returns The location of the attribute.
  97168. */
  97169. getAttributeLocation(index: number): number;
  97170. /**
  97171. * Returns the attribute based on the name of the variable.
  97172. * @param name of the attribute to look up.
  97173. * @returns the attribute location.
  97174. */
  97175. getAttributeLocationByName(name: string): number;
  97176. /**
  97177. * The number of attributes.
  97178. * @returns the numnber of attributes.
  97179. */
  97180. getAttributesCount(): number;
  97181. /**
  97182. * Gets the index of a uniform variable.
  97183. * @param uniformName of the uniform to look up.
  97184. * @returns the index.
  97185. */
  97186. getUniformIndex(uniformName: string): number;
  97187. /**
  97188. * Returns the attribute based on the name of the variable.
  97189. * @param uniformName of the uniform to look up.
  97190. * @returns the location of the uniform.
  97191. */
  97192. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  97193. /**
  97194. * Returns an array of sampler variable names
  97195. * @returns The array of sampler variable neames.
  97196. */
  97197. getSamplers(): string[];
  97198. /**
  97199. * The error from the last compilation.
  97200. * @returns the error string.
  97201. */
  97202. getCompilationError(): string;
  97203. /**
  97204. * Gets a boolean indicating that all fallbacks were used during compilation
  97205. * @returns true if all fallbacks were used
  97206. */
  97207. allFallbacksProcessed(): boolean;
  97208. /**
  97209. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  97210. * @param func The callback to be used.
  97211. */
  97212. executeWhenCompiled(func: (effect: Effect) => void): void;
  97213. private _checkIsReady;
  97214. private _loadShader;
  97215. /**
  97216. * Recompiles the webGL program
  97217. * @param vertexSourceCode The source code for the vertex shader.
  97218. * @param fragmentSourceCode The source code for the fragment shader.
  97219. * @param onCompiled Callback called when completed.
  97220. * @param onError Callback called on error.
  97221. * @hidden
  97222. */
  97223. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  97224. /**
  97225. * Prepares the effect
  97226. * @hidden
  97227. */
  97228. _prepareEffect(): void;
  97229. private _processCompilationErrors;
  97230. /**
  97231. * Checks if the effect is supported. (Must be called after compilation)
  97232. */
  97233. readonly isSupported: boolean;
  97234. /**
  97235. * Binds a texture to the engine to be used as output of the shader.
  97236. * @param channel Name of the output variable.
  97237. * @param texture Texture to bind.
  97238. * @hidden
  97239. */
  97240. _bindTexture(channel: string, texture: InternalTexture): void;
  97241. /**
  97242. * Sets a texture on the engine to be used in the shader.
  97243. * @param channel Name of the sampler variable.
  97244. * @param texture Texture to set.
  97245. */
  97246. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  97247. /**
  97248. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  97249. * @param channel Name of the sampler variable.
  97250. * @param texture Texture to set.
  97251. */
  97252. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  97253. /**
  97254. * Sets an array of textures on the engine to be used in the shader.
  97255. * @param channel Name of the variable.
  97256. * @param textures Textures to set.
  97257. */
  97258. setTextureArray(channel: string, textures: BaseTexture[]): void;
  97259. /**
  97260. * 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)
  97261. * @param channel Name of the sampler variable.
  97262. * @param postProcess Post process to get the input texture from.
  97263. */
  97264. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  97265. /**
  97266. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  97267. * 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)
  97268. * @param channel Name of the sampler variable.
  97269. * @param postProcess Post process to get the output texture from.
  97270. */
  97271. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  97272. /** @hidden */
  97273. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  97274. /** @hidden */
  97275. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  97276. /** @hidden */
  97277. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  97278. /** @hidden */
  97279. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  97280. /**
  97281. * Binds a buffer to a uniform.
  97282. * @param buffer Buffer to bind.
  97283. * @param name Name of the uniform variable to bind to.
  97284. */
  97285. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  97286. /**
  97287. * Binds block to a uniform.
  97288. * @param blockName Name of the block to bind.
  97289. * @param index Index to bind.
  97290. */
  97291. bindUniformBlock(blockName: string, index: number): void;
  97292. /**
  97293. * Sets an interger value on a uniform variable.
  97294. * @param uniformName Name of the variable.
  97295. * @param value Value to be set.
  97296. * @returns this effect.
  97297. */
  97298. setInt(uniformName: string, value: number): Effect;
  97299. /**
  97300. * Sets an int array on a uniform variable.
  97301. * @param uniformName Name of the variable.
  97302. * @param array array to be set.
  97303. * @returns this effect.
  97304. */
  97305. setIntArray(uniformName: string, array: Int32Array): Effect;
  97306. /**
  97307. * 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)
  97308. * @param uniformName Name of the variable.
  97309. * @param array array to be set.
  97310. * @returns this effect.
  97311. */
  97312. setIntArray2(uniformName: string, array: Int32Array): Effect;
  97313. /**
  97314. * 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)
  97315. * @param uniformName Name of the variable.
  97316. * @param array array to be set.
  97317. * @returns this effect.
  97318. */
  97319. setIntArray3(uniformName: string, array: Int32Array): Effect;
  97320. /**
  97321. * 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)
  97322. * @param uniformName Name of the variable.
  97323. * @param array array to be set.
  97324. * @returns this effect.
  97325. */
  97326. setIntArray4(uniformName: string, array: Int32Array): Effect;
  97327. /**
  97328. * Sets an float array on a uniform variable.
  97329. * @param uniformName Name of the variable.
  97330. * @param array array to be set.
  97331. * @returns this effect.
  97332. */
  97333. setFloatArray(uniformName: string, array: Float32Array): Effect;
  97334. /**
  97335. * 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)
  97336. * @param uniformName Name of the variable.
  97337. * @param array array to be set.
  97338. * @returns this effect.
  97339. */
  97340. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  97341. /**
  97342. * 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)
  97343. * @param uniformName Name of the variable.
  97344. * @param array array to be set.
  97345. * @returns this effect.
  97346. */
  97347. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  97348. /**
  97349. * 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)
  97350. * @param uniformName Name of the variable.
  97351. * @param array array to be set.
  97352. * @returns this effect.
  97353. */
  97354. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  97355. /**
  97356. * Sets an array on a uniform variable.
  97357. * @param uniformName Name of the variable.
  97358. * @param array array to be set.
  97359. * @returns this effect.
  97360. */
  97361. setArray(uniformName: string, array: number[]): Effect;
  97362. /**
  97363. * 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)
  97364. * @param uniformName Name of the variable.
  97365. * @param array array to be set.
  97366. * @returns this effect.
  97367. */
  97368. setArray2(uniformName: string, array: number[]): Effect;
  97369. /**
  97370. * 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)
  97371. * @param uniformName Name of the variable.
  97372. * @param array array to be set.
  97373. * @returns this effect.
  97374. */
  97375. setArray3(uniformName: string, array: number[]): Effect;
  97376. /**
  97377. * 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)
  97378. * @param uniformName Name of the variable.
  97379. * @param array array to be set.
  97380. * @returns this effect.
  97381. */
  97382. setArray4(uniformName: string, array: number[]): Effect;
  97383. /**
  97384. * Sets matrices on a uniform variable.
  97385. * @param uniformName Name of the variable.
  97386. * @param matrices matrices to be set.
  97387. * @returns this effect.
  97388. */
  97389. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  97390. /**
  97391. * Sets matrix on a uniform variable.
  97392. * @param uniformName Name of the variable.
  97393. * @param matrix matrix to be set.
  97394. * @returns this effect.
  97395. */
  97396. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  97397. /**
  97398. * 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)
  97399. * @param uniformName Name of the variable.
  97400. * @param matrix matrix to be set.
  97401. * @returns this effect.
  97402. */
  97403. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  97404. /**
  97405. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  97406. * @param uniformName Name of the variable.
  97407. * @param matrix matrix to be set.
  97408. * @returns this effect.
  97409. */
  97410. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  97411. /**
  97412. * Sets a float on a uniform variable.
  97413. * @param uniformName Name of the variable.
  97414. * @param value value to be set.
  97415. * @returns this effect.
  97416. */
  97417. setFloat(uniformName: string, value: number): Effect;
  97418. /**
  97419. * Sets a boolean on a uniform variable.
  97420. * @param uniformName Name of the variable.
  97421. * @param bool value to be set.
  97422. * @returns this effect.
  97423. */
  97424. setBool(uniformName: string, bool: boolean): Effect;
  97425. /**
  97426. * Sets a Vector2 on a uniform variable.
  97427. * @param uniformName Name of the variable.
  97428. * @param vector2 vector2 to be set.
  97429. * @returns this effect.
  97430. */
  97431. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  97432. /**
  97433. * Sets a float2 on a uniform variable.
  97434. * @param uniformName Name of the variable.
  97435. * @param x First float in float2.
  97436. * @param y Second float in float2.
  97437. * @returns this effect.
  97438. */
  97439. setFloat2(uniformName: string, x: number, y: number): Effect;
  97440. /**
  97441. * Sets a Vector3 on a uniform variable.
  97442. * @param uniformName Name of the variable.
  97443. * @param vector3 Value to be set.
  97444. * @returns this effect.
  97445. */
  97446. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  97447. /**
  97448. * Sets a float3 on a uniform variable.
  97449. * @param uniformName Name of the variable.
  97450. * @param x First float in float3.
  97451. * @param y Second float in float3.
  97452. * @param z Third float in float3.
  97453. * @returns this effect.
  97454. */
  97455. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  97456. /**
  97457. * Sets a Vector4 on a uniform variable.
  97458. * @param uniformName Name of the variable.
  97459. * @param vector4 Value to be set.
  97460. * @returns this effect.
  97461. */
  97462. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  97463. /**
  97464. * Sets a float4 on a uniform variable.
  97465. * @param uniformName Name of the variable.
  97466. * @param x First float in float4.
  97467. * @param y Second float in float4.
  97468. * @param z Third float in float4.
  97469. * @param w Fourth float in float4.
  97470. * @returns this effect.
  97471. */
  97472. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  97473. /**
  97474. * Sets a Color3 on a uniform variable.
  97475. * @param uniformName Name of the variable.
  97476. * @param color3 Value to be set.
  97477. * @returns this effect.
  97478. */
  97479. setColor3(uniformName: string, color3: IColor3Like): Effect;
  97480. /**
  97481. * Sets a Color4 on a uniform variable.
  97482. * @param uniformName Name of the variable.
  97483. * @param color3 Value to be set.
  97484. * @param alpha Alpha value to be set.
  97485. * @returns this effect.
  97486. */
  97487. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  97488. /**
  97489. * Sets a Color4 on a uniform variable
  97490. * @param uniformName defines the name of the variable
  97491. * @param color4 defines the value to be set
  97492. * @returns this effect.
  97493. */
  97494. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  97495. /** Release all associated resources */
  97496. dispose(): void;
  97497. /**
  97498. * This function will add a new shader to the shader store
  97499. * @param name the name of the shader
  97500. * @param pixelShader optional pixel shader content
  97501. * @param vertexShader optional vertex shader content
  97502. */
  97503. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  97504. /**
  97505. * Store of each shader (The can be looked up using effect.key)
  97506. */
  97507. static ShadersStore: {
  97508. [key: string]: string;
  97509. };
  97510. /**
  97511. * Store of each included file for a shader (The can be looked up using effect.key)
  97512. */
  97513. static IncludesShadersStore: {
  97514. [key: string]: string;
  97515. };
  97516. /**
  97517. * Resets the cache of effects.
  97518. */
  97519. static ResetCache(): void;
  97520. }
  97521. }
  97522. declare module BABYLON {
  97523. /**
  97524. * Interface used to describe the capabilities of the engine relatively to the current browser
  97525. */
  97526. export interface EngineCapabilities {
  97527. /** Maximum textures units per fragment shader */
  97528. maxTexturesImageUnits: number;
  97529. /** Maximum texture units per vertex shader */
  97530. maxVertexTextureImageUnits: number;
  97531. /** Maximum textures units in the entire pipeline */
  97532. maxCombinedTexturesImageUnits: number;
  97533. /** Maximum texture size */
  97534. maxTextureSize: number;
  97535. /** Maximum texture samples */
  97536. maxSamples?: number;
  97537. /** Maximum cube texture size */
  97538. maxCubemapTextureSize: number;
  97539. /** Maximum render texture size */
  97540. maxRenderTextureSize: number;
  97541. /** Maximum number of vertex attributes */
  97542. maxVertexAttribs: number;
  97543. /** Maximum number of varyings */
  97544. maxVaryingVectors: number;
  97545. /** Maximum number of uniforms per vertex shader */
  97546. maxVertexUniformVectors: number;
  97547. /** Maximum number of uniforms per fragment shader */
  97548. maxFragmentUniformVectors: number;
  97549. /** Defines if standard derivates (dx/dy) are supported */
  97550. standardDerivatives: boolean;
  97551. /** Defines if s3tc texture compression is supported */
  97552. s3tc?: WEBGL_compressed_texture_s3tc;
  97553. /** Defines if pvrtc texture compression is supported */
  97554. pvrtc: any;
  97555. /** Defines if etc1 texture compression is supported */
  97556. etc1: any;
  97557. /** Defines if etc2 texture compression is supported */
  97558. etc2: any;
  97559. /** Defines if astc texture compression is supported */
  97560. astc: any;
  97561. /** Defines if float textures are supported */
  97562. textureFloat: boolean;
  97563. /** Defines if vertex array objects are supported */
  97564. vertexArrayObject: boolean;
  97565. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  97566. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  97567. /** Gets the maximum level of anisotropy supported */
  97568. maxAnisotropy: number;
  97569. /** Defines if instancing is supported */
  97570. instancedArrays: boolean;
  97571. /** Defines if 32 bits indices are supported */
  97572. uintIndices: boolean;
  97573. /** Defines if high precision shaders are supported */
  97574. highPrecisionShaderSupported: boolean;
  97575. /** Defines if depth reading in the fragment shader is supported */
  97576. fragmentDepthSupported: boolean;
  97577. /** Defines if float texture linear filtering is supported*/
  97578. textureFloatLinearFiltering: boolean;
  97579. /** Defines if rendering to float textures is supported */
  97580. textureFloatRender: boolean;
  97581. /** Defines if half float textures are supported*/
  97582. textureHalfFloat: boolean;
  97583. /** Defines if half float texture linear filtering is supported*/
  97584. textureHalfFloatLinearFiltering: boolean;
  97585. /** Defines if rendering to half float textures is supported */
  97586. textureHalfFloatRender: boolean;
  97587. /** Defines if textureLOD shader command is supported */
  97588. textureLOD: boolean;
  97589. /** Defines if draw buffers extension is supported */
  97590. drawBuffersExtension: boolean;
  97591. /** Defines if depth textures are supported */
  97592. depthTextureExtension: boolean;
  97593. /** Defines if float color buffer are supported */
  97594. colorBufferFloat: boolean;
  97595. /** Gets disjoint timer query extension (null if not supported) */
  97596. timerQuery?: EXT_disjoint_timer_query;
  97597. /** Defines if timestamp can be used with timer query */
  97598. canUseTimestampForTimerQuery: boolean;
  97599. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  97600. multiview?: any;
  97601. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  97602. oculusMultiview?: any;
  97603. /** Function used to let the system compiles shaders in background */
  97604. parallelShaderCompile?: {
  97605. COMPLETION_STATUS_KHR: number;
  97606. };
  97607. /** Max number of texture samples for MSAA */
  97608. maxMSAASamples: number;
  97609. /** Defines if the blend min max extension is supported */
  97610. blendMinMax: boolean;
  97611. }
  97612. }
  97613. declare module BABYLON {
  97614. /**
  97615. * @hidden
  97616. **/
  97617. export class DepthCullingState {
  97618. private _isDepthTestDirty;
  97619. private _isDepthMaskDirty;
  97620. private _isDepthFuncDirty;
  97621. private _isCullFaceDirty;
  97622. private _isCullDirty;
  97623. private _isZOffsetDirty;
  97624. private _isFrontFaceDirty;
  97625. private _depthTest;
  97626. private _depthMask;
  97627. private _depthFunc;
  97628. private _cull;
  97629. private _cullFace;
  97630. private _zOffset;
  97631. private _frontFace;
  97632. /**
  97633. * Initializes the state.
  97634. */
  97635. constructor();
  97636. readonly isDirty: boolean;
  97637. zOffset: number;
  97638. cullFace: Nullable<number>;
  97639. cull: Nullable<boolean>;
  97640. depthFunc: Nullable<number>;
  97641. depthMask: boolean;
  97642. depthTest: boolean;
  97643. frontFace: Nullable<number>;
  97644. reset(): void;
  97645. apply(gl: WebGLRenderingContext): void;
  97646. }
  97647. }
  97648. declare module BABYLON {
  97649. /**
  97650. * @hidden
  97651. **/
  97652. export class StencilState {
  97653. /** 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 */
  97654. static readonly ALWAYS: number;
  97655. /** Passed to stencilOperation to specify that stencil value must be kept */
  97656. static readonly KEEP: number;
  97657. /** Passed to stencilOperation to specify that stencil value must be replaced */
  97658. static readonly REPLACE: number;
  97659. private _isStencilTestDirty;
  97660. private _isStencilMaskDirty;
  97661. private _isStencilFuncDirty;
  97662. private _isStencilOpDirty;
  97663. private _stencilTest;
  97664. private _stencilMask;
  97665. private _stencilFunc;
  97666. private _stencilFuncRef;
  97667. private _stencilFuncMask;
  97668. private _stencilOpStencilFail;
  97669. private _stencilOpDepthFail;
  97670. private _stencilOpStencilDepthPass;
  97671. readonly isDirty: boolean;
  97672. stencilFunc: number;
  97673. stencilFuncRef: number;
  97674. stencilFuncMask: number;
  97675. stencilOpStencilFail: number;
  97676. stencilOpDepthFail: number;
  97677. stencilOpStencilDepthPass: number;
  97678. stencilMask: number;
  97679. stencilTest: boolean;
  97680. constructor();
  97681. reset(): void;
  97682. apply(gl: WebGLRenderingContext): void;
  97683. }
  97684. }
  97685. declare module BABYLON {
  97686. /**
  97687. * @hidden
  97688. **/
  97689. export class AlphaState {
  97690. private _isAlphaBlendDirty;
  97691. private _isBlendFunctionParametersDirty;
  97692. private _isBlendEquationParametersDirty;
  97693. private _isBlendConstantsDirty;
  97694. private _alphaBlend;
  97695. private _blendFunctionParameters;
  97696. private _blendEquationParameters;
  97697. private _blendConstants;
  97698. /**
  97699. * Initializes the state.
  97700. */
  97701. constructor();
  97702. readonly isDirty: boolean;
  97703. alphaBlend: boolean;
  97704. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  97705. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  97706. setAlphaEquationParameters(rgb: number, alpha: number): void;
  97707. reset(): void;
  97708. apply(gl: WebGLRenderingContext): void;
  97709. }
  97710. }
  97711. declare module BABYLON {
  97712. /** @hidden */
  97713. export class WebGL2ShaderProcessor implements IShaderProcessor {
  97714. attributeProcessor(attribute: string): string;
  97715. varyingProcessor(varying: string, isFragment: boolean): string;
  97716. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  97717. }
  97718. }
  97719. declare module BABYLON {
  97720. /**
  97721. * Interface for attribute information associated with buffer instanciation
  97722. */
  97723. export interface InstancingAttributeInfo {
  97724. /**
  97725. * Index/offset of the attribute in the vertex shader
  97726. */
  97727. index: number;
  97728. /**
  97729. * size of the attribute, 1, 2, 3 or 4
  97730. */
  97731. attributeSize: number;
  97732. /**
  97733. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  97734. * default is FLOAT
  97735. */
  97736. attributeType: number;
  97737. /**
  97738. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  97739. */
  97740. normalized: boolean;
  97741. /**
  97742. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  97743. */
  97744. offset: number;
  97745. /**
  97746. * Name of the GLSL attribute, for debugging purpose only
  97747. */
  97748. attributeName: string;
  97749. }
  97750. }
  97751. declare module BABYLON {
  97752. interface ThinEngine {
  97753. /**
  97754. * Update a video texture
  97755. * @param texture defines the texture to update
  97756. * @param video defines the video element to use
  97757. * @param invertY defines if data must be stored with Y axis inverted
  97758. */
  97759. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  97760. }
  97761. }
  97762. declare module BABYLON {
  97763. /**
  97764. * Settings for finer control over video usage
  97765. */
  97766. export interface VideoTextureSettings {
  97767. /**
  97768. * Applies `autoplay` to video, if specified
  97769. */
  97770. autoPlay?: boolean;
  97771. /**
  97772. * Applies `loop` to video, if specified
  97773. */
  97774. loop?: boolean;
  97775. /**
  97776. * Automatically updates internal texture from video at every frame in the render loop
  97777. */
  97778. autoUpdateTexture: boolean;
  97779. /**
  97780. * Image src displayed during the video loading or until the user interacts with the video.
  97781. */
  97782. poster?: string;
  97783. }
  97784. /**
  97785. * If you want to display a video in your scene, this is the special texture for that.
  97786. * This special texture works similar to other textures, with the exception of a few parameters.
  97787. * @see https://doc.babylonjs.com/how_to/video_texture
  97788. */
  97789. export class VideoTexture extends Texture {
  97790. /**
  97791. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  97792. */
  97793. readonly autoUpdateTexture: boolean;
  97794. /**
  97795. * The video instance used by the texture internally
  97796. */
  97797. readonly video: HTMLVideoElement;
  97798. private _onUserActionRequestedObservable;
  97799. /**
  97800. * Event triggerd when a dom action is required by the user to play the video.
  97801. * This happens due to recent changes in browser policies preventing video to auto start.
  97802. */
  97803. readonly onUserActionRequestedObservable: Observable<Texture>;
  97804. private _generateMipMaps;
  97805. private _engine;
  97806. private _stillImageCaptured;
  97807. private _displayingPosterTexture;
  97808. private _settings;
  97809. private _createInternalTextureOnEvent;
  97810. private _frameId;
  97811. /**
  97812. * Creates a video texture.
  97813. * If you want to display a video in your scene, this is the special texture for that.
  97814. * This special texture works similar to other textures, with the exception of a few parameters.
  97815. * @see https://doc.babylonjs.com/how_to/video_texture
  97816. * @param name optional name, will detect from video source, if not defined
  97817. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  97818. * @param scene is obviously the current scene.
  97819. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  97820. * @param invertY is false by default but can be used to invert video on Y axis
  97821. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  97822. * @param settings allows finer control over video usage
  97823. */
  97824. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  97825. private _getName;
  97826. private _getVideo;
  97827. private _createInternalTexture;
  97828. private reset;
  97829. /**
  97830. * @hidden Internal method to initiate `update`.
  97831. */
  97832. _rebuild(): void;
  97833. /**
  97834. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  97835. */
  97836. update(): void;
  97837. /**
  97838. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  97839. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  97840. */
  97841. updateTexture(isVisible: boolean): void;
  97842. protected _updateInternalTexture: () => void;
  97843. /**
  97844. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  97845. * @param url New url.
  97846. */
  97847. updateURL(url: string): void;
  97848. /**
  97849. * Dispose the texture and release its associated resources.
  97850. */
  97851. dispose(): void;
  97852. /**
  97853. * Creates a video texture straight from a stream.
  97854. * @param scene Define the scene the texture should be created in
  97855. * @param stream Define the stream the texture should be created from
  97856. * @returns The created video texture as a promise
  97857. */
  97858. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  97859. /**
  97860. * Creates a video texture straight from your WebCam video feed.
  97861. * @param scene Define the scene the texture should be created in
  97862. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  97863. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  97864. * @returns The created video texture as a promise
  97865. */
  97866. static CreateFromWebCamAsync(scene: Scene, constraints: {
  97867. minWidth: number;
  97868. maxWidth: number;
  97869. minHeight: number;
  97870. maxHeight: number;
  97871. deviceId: string;
  97872. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  97873. /**
  97874. * Creates a video texture straight from your WebCam video feed.
  97875. * @param scene Define the scene the texture should be created in
  97876. * @param onReady Define a callback to triggered once the texture will be ready
  97877. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  97878. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  97879. */
  97880. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  97881. minWidth: number;
  97882. maxWidth: number;
  97883. minHeight: number;
  97884. maxHeight: number;
  97885. deviceId: string;
  97886. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  97887. }
  97888. }
  97889. declare module BABYLON {
  97890. /**
  97891. * Defines the interface used by objects working like Scene
  97892. * @hidden
  97893. */
  97894. interface ISceneLike {
  97895. _addPendingData(data: any): void;
  97896. _removePendingData(data: any): void;
  97897. offlineProvider: IOfflineProvider;
  97898. }
  97899. /** Interface defining initialization parameters for Engine class */
  97900. export interface EngineOptions extends WebGLContextAttributes {
  97901. /**
  97902. * Defines if the engine should no exceed a specified device ratio
  97903. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  97904. */
  97905. limitDeviceRatio?: number;
  97906. /**
  97907. * Defines if webvr should be enabled automatically
  97908. * @see http://doc.babylonjs.com/how_to/webvr_camera
  97909. */
  97910. autoEnableWebVR?: boolean;
  97911. /**
  97912. * Defines if webgl2 should be turned off even if supported
  97913. * @see http://doc.babylonjs.com/features/webgl2
  97914. */
  97915. disableWebGL2Support?: boolean;
  97916. /**
  97917. * Defines if webaudio should be initialized as well
  97918. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  97919. */
  97920. audioEngine?: boolean;
  97921. /**
  97922. * Defines if animations should run using a deterministic lock step
  97923. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  97924. */
  97925. deterministicLockstep?: boolean;
  97926. /** Defines the maximum steps to use with deterministic lock step mode */
  97927. lockstepMaxSteps?: number;
  97928. /** Defines the seconds between each deterministic lock step */
  97929. timeStep?: number;
  97930. /**
  97931. * Defines that engine should ignore context lost events
  97932. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  97933. */
  97934. doNotHandleContextLost?: boolean;
  97935. /**
  97936. * Defines that engine should ignore modifying touch action attribute and style
  97937. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  97938. */
  97939. doNotHandleTouchAction?: boolean;
  97940. /**
  97941. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  97942. */
  97943. useHighPrecisionFloats?: boolean;
  97944. }
  97945. /**
  97946. * The base engine class (root of all engines)
  97947. */
  97948. export class ThinEngine {
  97949. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  97950. static ExceptionList: ({
  97951. key: string;
  97952. capture: string;
  97953. captureConstraint: number;
  97954. targets: string[];
  97955. } | {
  97956. key: string;
  97957. capture: null;
  97958. captureConstraint: null;
  97959. targets: string[];
  97960. })[];
  97961. /** @hidden */
  97962. static _TextureLoaders: IInternalTextureLoader[];
  97963. /**
  97964. * Returns the current npm package of the sdk
  97965. */
  97966. static readonly NpmPackage: string;
  97967. /**
  97968. * Returns the current version of the framework
  97969. */
  97970. static readonly Version: string;
  97971. /**
  97972. * Returns a string describing the current engine
  97973. */
  97974. readonly description: string;
  97975. /**
  97976. * Gets or sets the epsilon value used by collision engine
  97977. */
  97978. static CollisionsEpsilon: number;
  97979. /**
  97980. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  97981. */
  97982. static ShadersRepository: string;
  97983. /** @hidden */
  97984. _shaderProcessor: IShaderProcessor;
  97985. /**
  97986. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  97987. */
  97988. forcePOTTextures: boolean;
  97989. /**
  97990. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  97991. */
  97992. isFullscreen: boolean;
  97993. /**
  97994. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  97995. */
  97996. cullBackFaces: boolean;
  97997. /**
  97998. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  97999. */
  98000. renderEvenInBackground: boolean;
  98001. /**
  98002. * Gets or sets a boolean indicating that cache can be kept between frames
  98003. */
  98004. preventCacheWipeBetweenFrames: boolean;
  98005. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  98006. validateShaderPrograms: boolean;
  98007. /**
  98008. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  98009. * This can provide greater z depth for distant objects.
  98010. */
  98011. useReverseDepthBuffer: boolean;
  98012. /**
  98013. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  98014. */
  98015. disableUniformBuffers: boolean;
  98016. /** @hidden */
  98017. _uniformBuffers: UniformBuffer[];
  98018. /**
  98019. * Gets a boolean indicating that the engine supports uniform buffers
  98020. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  98021. */
  98022. readonly supportsUniformBuffers: boolean;
  98023. /** @hidden */
  98024. _gl: WebGLRenderingContext;
  98025. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  98026. protected _windowIsBackground: boolean;
  98027. protected _webGLVersion: number;
  98028. protected _creationOptions: EngineOptions;
  98029. protected _highPrecisionShadersAllowed: boolean;
  98030. /** @hidden */
  98031. readonly _shouldUseHighPrecisionShader: boolean;
  98032. /**
  98033. * Gets a boolean indicating that only power of 2 textures are supported
  98034. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  98035. */
  98036. readonly needPOTTextures: boolean;
  98037. /** @hidden */
  98038. _badOS: boolean;
  98039. /** @hidden */
  98040. _badDesktopOS: boolean;
  98041. private _hardwareScalingLevel;
  98042. /** @hidden */
  98043. _caps: EngineCapabilities;
  98044. private _isStencilEnable;
  98045. protected _colorWrite: boolean;
  98046. private _glVersion;
  98047. private _glRenderer;
  98048. private _glVendor;
  98049. /** @hidden */
  98050. _videoTextureSupported: boolean;
  98051. protected _renderingQueueLaunched: boolean;
  98052. protected _activeRenderLoops: (() => void)[];
  98053. /**
  98054. * Observable signaled when a context lost event is raised
  98055. */
  98056. onContextLostObservable: Observable<ThinEngine>;
  98057. /**
  98058. * Observable signaled when a context restored event is raised
  98059. */
  98060. onContextRestoredObservable: Observable<ThinEngine>;
  98061. private _onContextLost;
  98062. private _onContextRestored;
  98063. protected _contextWasLost: boolean;
  98064. /** @hidden */
  98065. _doNotHandleContextLost: boolean;
  98066. /**
  98067. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  98068. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  98069. */
  98070. doNotHandleContextLost: boolean;
  98071. /**
  98072. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  98073. */
  98074. disableVertexArrayObjects: boolean;
  98075. /** @hidden */
  98076. protected _depthCullingState: DepthCullingState;
  98077. /** @hidden */
  98078. protected _stencilState: StencilState;
  98079. /** @hidden */
  98080. protected _alphaState: AlphaState;
  98081. /** @hidden */
  98082. _internalTexturesCache: InternalTexture[];
  98083. /** @hidden */
  98084. protected _activeChannel: number;
  98085. private _currentTextureChannel;
  98086. /** @hidden */
  98087. protected _boundTexturesCache: {
  98088. [key: string]: Nullable<InternalTexture>;
  98089. };
  98090. /** @hidden */
  98091. protected _currentEffect: Nullable<Effect>;
  98092. /** @hidden */
  98093. protected _currentProgram: Nullable<WebGLProgram>;
  98094. private _compiledEffects;
  98095. private _vertexAttribArraysEnabled;
  98096. /** @hidden */
  98097. protected _cachedViewport: Nullable<IViewportLike>;
  98098. private _cachedVertexArrayObject;
  98099. /** @hidden */
  98100. protected _cachedVertexBuffers: any;
  98101. /** @hidden */
  98102. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  98103. /** @hidden */
  98104. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  98105. /** @hidden */
  98106. _currentRenderTarget: Nullable<InternalTexture>;
  98107. private _uintIndicesCurrentlySet;
  98108. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  98109. /** @hidden */
  98110. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  98111. private _currentBufferPointers;
  98112. private _currentInstanceLocations;
  98113. private _currentInstanceBuffers;
  98114. private _textureUnits;
  98115. /** @hidden */
  98116. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  98117. /** @hidden */
  98118. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  98119. /** @hidden */
  98120. _boundRenderFunction: any;
  98121. private _vaoRecordInProgress;
  98122. private _mustWipeVertexAttributes;
  98123. private _emptyTexture;
  98124. private _emptyCubeTexture;
  98125. private _emptyTexture3D;
  98126. private _emptyTexture2DArray;
  98127. /** @hidden */
  98128. _frameHandler: number;
  98129. private _nextFreeTextureSlots;
  98130. private _maxSimultaneousTextures;
  98131. private _activeRequests;
  98132. protected _texturesSupported: string[];
  98133. /** @hidden */
  98134. _textureFormatInUse: Nullable<string>;
  98135. protected readonly _supportsHardwareTextureRescaling: boolean;
  98136. /**
  98137. * Gets the list of texture formats supported
  98138. */
  98139. readonly texturesSupported: Array<string>;
  98140. /**
  98141. * Gets the list of texture formats in use
  98142. */
  98143. readonly textureFormatInUse: Nullable<string>;
  98144. /**
  98145. * Gets the current viewport
  98146. */
  98147. readonly currentViewport: Nullable<IViewportLike>;
  98148. /**
  98149. * Gets the default empty texture
  98150. */
  98151. readonly emptyTexture: InternalTexture;
  98152. /**
  98153. * Gets the default empty 3D texture
  98154. */
  98155. readonly emptyTexture3D: InternalTexture;
  98156. /**
  98157. * Gets the default empty 2D array texture
  98158. */
  98159. readonly emptyTexture2DArray: InternalTexture;
  98160. /**
  98161. * Gets the default empty cube texture
  98162. */
  98163. readonly emptyCubeTexture: InternalTexture;
  98164. /**
  98165. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  98166. */
  98167. readonly premultipliedAlpha: boolean;
  98168. /**
  98169. * Observable event triggered before each texture is initialized
  98170. */
  98171. onBeforeTextureInitObservable: Observable<Texture>;
  98172. /**
  98173. * Creates a new engine
  98174. * @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
  98175. * @param antialias defines enable antialiasing (default: false)
  98176. * @param options defines further options to be sent to the getContext() function
  98177. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  98178. */
  98179. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  98180. private _rebuildInternalTextures;
  98181. private _rebuildEffects;
  98182. /**
  98183. * Gets a boolean indicating if all created effects are ready
  98184. * @returns true if all effects are ready
  98185. */
  98186. areAllEffectsReady(): boolean;
  98187. protected _rebuildBuffers(): void;
  98188. private _initGLContext;
  98189. /**
  98190. * Gets version of the current webGL context
  98191. */
  98192. readonly webGLVersion: number;
  98193. /**
  98194. * Gets a string idenfifying the name of the class
  98195. * @returns "Engine" string
  98196. */
  98197. getClassName(): string;
  98198. /**
  98199. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  98200. */
  98201. readonly isStencilEnable: boolean;
  98202. /** @hidden */
  98203. _prepareWorkingCanvas(): void;
  98204. /**
  98205. * Reset the texture cache to empty state
  98206. */
  98207. resetTextureCache(): void;
  98208. /**
  98209. * Gets an object containing information about the current webGL context
  98210. * @returns an object containing the vender, the renderer and the version of the current webGL context
  98211. */
  98212. getGlInfo(): {
  98213. vendor: string;
  98214. renderer: string;
  98215. version: string;
  98216. };
  98217. /**
  98218. * Defines the hardware scaling level.
  98219. * By default the hardware scaling level is computed from the window device ratio.
  98220. * 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.
  98221. * @param level defines the level to use
  98222. */
  98223. setHardwareScalingLevel(level: number): void;
  98224. /**
  98225. * Gets the current hardware scaling level.
  98226. * By default the hardware scaling level is computed from the window device ratio.
  98227. * 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.
  98228. * @returns a number indicating the current hardware scaling level
  98229. */
  98230. getHardwareScalingLevel(): number;
  98231. /**
  98232. * Gets the list of loaded textures
  98233. * @returns an array containing all loaded textures
  98234. */
  98235. getLoadedTexturesCache(): InternalTexture[];
  98236. /**
  98237. * Gets the object containing all engine capabilities
  98238. * @returns the EngineCapabilities object
  98239. */
  98240. getCaps(): EngineCapabilities;
  98241. /**
  98242. * stop executing a render loop function and remove it from the execution array
  98243. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  98244. */
  98245. stopRenderLoop(renderFunction?: () => void): void;
  98246. /** @hidden */
  98247. _renderLoop(): void;
  98248. /**
  98249. * Gets the HTML canvas attached with the current webGL context
  98250. * @returns a HTML canvas
  98251. */
  98252. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  98253. /**
  98254. * Gets host window
  98255. * @returns the host window object
  98256. */
  98257. getHostWindow(): Nullable<Window>;
  98258. /**
  98259. * Gets the current render width
  98260. * @param useScreen defines if screen size must be used (or the current render target if any)
  98261. * @returns a number defining the current render width
  98262. */
  98263. getRenderWidth(useScreen?: boolean): number;
  98264. /**
  98265. * Gets the current render height
  98266. * @param useScreen defines if screen size must be used (or the current render target if any)
  98267. * @returns a number defining the current render height
  98268. */
  98269. getRenderHeight(useScreen?: boolean): number;
  98270. /**
  98271. * Can be used to override the current requestAnimationFrame requester.
  98272. * @hidden
  98273. */
  98274. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  98275. /**
  98276. * Register and execute a render loop. The engine can have more than one render function
  98277. * @param renderFunction defines the function to continuously execute
  98278. */
  98279. runRenderLoop(renderFunction: () => void): void;
  98280. /**
  98281. * Clear the current render buffer or the current render target (if any is set up)
  98282. * @param color defines the color to use
  98283. * @param backBuffer defines if the back buffer must be cleared
  98284. * @param depth defines if the depth buffer must be cleared
  98285. * @param stencil defines if the stencil buffer must be cleared
  98286. */
  98287. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  98288. private _viewportCached;
  98289. /** @hidden */
  98290. _viewport(x: number, y: number, width: number, height: number): void;
  98291. /**
  98292. * Set the WebGL's viewport
  98293. * @param viewport defines the viewport element to be used
  98294. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  98295. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  98296. */
  98297. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  98298. /**
  98299. * Begin a new frame
  98300. */
  98301. beginFrame(): void;
  98302. /**
  98303. * Enf the current frame
  98304. */
  98305. endFrame(): void;
  98306. /**
  98307. * Resize the view according to the canvas' size
  98308. */
  98309. resize(): void;
  98310. /**
  98311. * Force a specific size of the canvas
  98312. * @param width defines the new canvas' width
  98313. * @param height defines the new canvas' height
  98314. */
  98315. setSize(width: number, height: number): void;
  98316. /**
  98317. * Binds the frame buffer to the specified texture.
  98318. * @param texture The texture to render to or null for the default canvas
  98319. * @param faceIndex The face of the texture to render to in case of cube texture
  98320. * @param requiredWidth The width of the target to render to
  98321. * @param requiredHeight The height of the target to render to
  98322. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  98323. * @param depthStencilTexture The depth stencil texture to use to render
  98324. * @param lodLevel defines le lod level to bind to the frame buffer
  98325. */
  98326. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  98327. /** @hidden */
  98328. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  98329. /**
  98330. * Unbind the current render target texture from the webGL context
  98331. * @param texture defines the render target texture to unbind
  98332. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  98333. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  98334. */
  98335. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  98336. /**
  98337. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  98338. */
  98339. flushFramebuffer(): void;
  98340. /**
  98341. * Unbind the current render target and bind the default framebuffer
  98342. */
  98343. restoreDefaultFramebuffer(): void;
  98344. /** @hidden */
  98345. protected _resetVertexBufferBinding(): void;
  98346. /**
  98347. * Creates a vertex buffer
  98348. * @param data the data for the vertex buffer
  98349. * @returns the new WebGL static buffer
  98350. */
  98351. createVertexBuffer(data: DataArray): DataBuffer;
  98352. private _createVertexBuffer;
  98353. /**
  98354. * Creates a dynamic vertex buffer
  98355. * @param data the data for the dynamic vertex buffer
  98356. * @returns the new WebGL dynamic buffer
  98357. */
  98358. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  98359. protected _resetIndexBufferBinding(): void;
  98360. /**
  98361. * Creates a new index buffer
  98362. * @param indices defines the content of the index buffer
  98363. * @param updatable defines if the index buffer must be updatable
  98364. * @returns a new webGL buffer
  98365. */
  98366. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  98367. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  98368. /**
  98369. * Bind a webGL buffer to the webGL context
  98370. * @param buffer defines the buffer to bind
  98371. */
  98372. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  98373. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  98374. private bindBuffer;
  98375. /**
  98376. * update the bound buffer with the given data
  98377. * @param data defines the data to update
  98378. */
  98379. updateArrayBuffer(data: Float32Array): void;
  98380. private _vertexAttribPointer;
  98381. private _bindIndexBufferWithCache;
  98382. private _bindVertexBuffersAttributes;
  98383. /**
  98384. * Records a vertex array object
  98385. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  98386. * @param vertexBuffers defines the list of vertex buffers to store
  98387. * @param indexBuffer defines the index buffer to store
  98388. * @param effect defines the effect to store
  98389. * @returns the new vertex array object
  98390. */
  98391. recordVertexArrayObject(vertexBuffers: {
  98392. [key: string]: VertexBuffer;
  98393. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  98394. /**
  98395. * Bind a specific vertex array object
  98396. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  98397. * @param vertexArrayObject defines the vertex array object to bind
  98398. * @param indexBuffer defines the index buffer to bind
  98399. */
  98400. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  98401. /**
  98402. * Bind webGl buffers directly to the webGL context
  98403. * @param vertexBuffer defines the vertex buffer to bind
  98404. * @param indexBuffer defines the index buffer to bind
  98405. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  98406. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  98407. * @param effect defines the effect associated with the vertex buffer
  98408. */
  98409. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  98410. private _unbindVertexArrayObject;
  98411. /**
  98412. * Bind a list of vertex buffers to the webGL context
  98413. * @param vertexBuffers defines the list of vertex buffers to bind
  98414. * @param indexBuffer defines the index buffer to bind
  98415. * @param effect defines the effect associated with the vertex buffers
  98416. */
  98417. bindBuffers(vertexBuffers: {
  98418. [key: string]: Nullable<VertexBuffer>;
  98419. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  98420. /**
  98421. * Unbind all instance attributes
  98422. */
  98423. unbindInstanceAttributes(): void;
  98424. /**
  98425. * Release and free the memory of a vertex array object
  98426. * @param vao defines the vertex array object to delete
  98427. */
  98428. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  98429. /** @hidden */
  98430. _releaseBuffer(buffer: DataBuffer): boolean;
  98431. protected _deleteBuffer(buffer: DataBuffer): void;
  98432. /**
  98433. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  98434. * @param instancesBuffer defines the webGL buffer to update and bind
  98435. * @param data defines the data to store in the buffer
  98436. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  98437. */
  98438. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  98439. /**
  98440. * Apply all cached states (depth, culling, stencil and alpha)
  98441. */
  98442. applyStates(): void;
  98443. /**
  98444. * Send a draw order
  98445. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  98446. * @param indexStart defines the starting index
  98447. * @param indexCount defines the number of index to draw
  98448. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  98449. */
  98450. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  98451. /**
  98452. * Draw a list of points
  98453. * @param verticesStart defines the index of first vertex to draw
  98454. * @param verticesCount defines the count of vertices to draw
  98455. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  98456. */
  98457. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  98458. /**
  98459. * Draw a list of unindexed primitives
  98460. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  98461. * @param verticesStart defines the index of first vertex to draw
  98462. * @param verticesCount defines the count of vertices to draw
  98463. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  98464. */
  98465. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  98466. /**
  98467. * Draw a list of indexed primitives
  98468. * @param fillMode defines the primitive to use
  98469. * @param indexStart defines the starting index
  98470. * @param indexCount defines the number of index to draw
  98471. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  98472. */
  98473. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  98474. /**
  98475. * Draw a list of unindexed primitives
  98476. * @param fillMode defines the primitive to use
  98477. * @param verticesStart defines the index of first vertex to draw
  98478. * @param verticesCount defines the count of vertices to draw
  98479. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  98480. */
  98481. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  98482. private _drawMode;
  98483. /** @hidden */
  98484. protected _reportDrawCall(): void;
  98485. /** @hidden */
  98486. _releaseEffect(effect: Effect): void;
  98487. /** @hidden */
  98488. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  98489. /**
  98490. * Create a new effect (used to store vertex/fragment shaders)
  98491. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  98492. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  98493. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  98494. * @param samplers defines an array of string used to represent textures
  98495. * @param defines defines the string containing the defines to use to compile the shaders
  98496. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  98497. * @param onCompiled defines a function to call when the effect creation is successful
  98498. * @param onError defines a function to call when the effect creation has failed
  98499. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  98500. * @returns the new Effect
  98501. */
  98502. 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;
  98503. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  98504. private _compileShader;
  98505. private _compileRawShader;
  98506. /**
  98507. * Directly creates a webGL program
  98508. * @param pipelineContext defines the pipeline context to attach to
  98509. * @param vertexCode defines the vertex shader code to use
  98510. * @param fragmentCode defines the fragment shader code to use
  98511. * @param context defines the webGL context to use (if not set, the current one will be used)
  98512. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  98513. * @returns the new webGL program
  98514. */
  98515. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  98516. /**
  98517. * Creates a webGL program
  98518. * @param pipelineContext defines the pipeline context to attach to
  98519. * @param vertexCode defines the vertex shader code to use
  98520. * @param fragmentCode defines the fragment shader code to use
  98521. * @param defines defines the string containing the defines to use to compile the shaders
  98522. * @param context defines the webGL context to use (if not set, the current one will be used)
  98523. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  98524. * @returns the new webGL program
  98525. */
  98526. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  98527. /**
  98528. * Creates a new pipeline context
  98529. * @returns the new pipeline
  98530. */
  98531. createPipelineContext(): IPipelineContext;
  98532. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  98533. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  98534. /** @hidden */
  98535. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  98536. /** @hidden */
  98537. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  98538. /** @hidden */
  98539. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  98540. /**
  98541. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  98542. * @param pipelineContext defines the pipeline context to use
  98543. * @param uniformsNames defines the list of uniform names
  98544. * @returns an array of webGL uniform locations
  98545. */
  98546. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  98547. /**
  98548. * Gets the lsit of active attributes for a given webGL program
  98549. * @param pipelineContext defines the pipeline context to use
  98550. * @param attributesNames defines the list of attribute names to get
  98551. * @returns an array of indices indicating the offset of each attribute
  98552. */
  98553. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  98554. /**
  98555. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  98556. * @param effect defines the effect to activate
  98557. */
  98558. enableEffect(effect: Nullable<Effect>): void;
  98559. /**
  98560. * Set the value of an uniform to a number (int)
  98561. * @param uniform defines the webGL uniform location where to store the value
  98562. * @param value defines the int number to store
  98563. */
  98564. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  98565. /**
  98566. * Set the value of an uniform to an array of int32
  98567. * @param uniform defines the webGL uniform location where to store the value
  98568. * @param array defines the array of int32 to store
  98569. */
  98570. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  98571. /**
  98572. * Set the value of an uniform to an array of int32 (stored as vec2)
  98573. * @param uniform defines the webGL uniform location where to store the value
  98574. * @param array defines the array of int32 to store
  98575. */
  98576. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  98577. /**
  98578. * Set the value of an uniform to an array of int32 (stored as vec3)
  98579. * @param uniform defines the webGL uniform location where to store the value
  98580. * @param array defines the array of int32 to store
  98581. */
  98582. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  98583. /**
  98584. * Set the value of an uniform to an array of int32 (stored as vec4)
  98585. * @param uniform defines the webGL uniform location where to store the value
  98586. * @param array defines the array of int32 to store
  98587. */
  98588. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  98589. /**
  98590. * Set the value of an uniform to an array of number
  98591. * @param uniform defines the webGL uniform location where to store the value
  98592. * @param array defines the array of number to store
  98593. */
  98594. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  98595. /**
  98596. * Set the value of an uniform to an array of number (stored as vec2)
  98597. * @param uniform defines the webGL uniform location where to store the value
  98598. * @param array defines the array of number to store
  98599. */
  98600. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  98601. /**
  98602. * Set the value of an uniform to an array of number (stored as vec3)
  98603. * @param uniform defines the webGL uniform location where to store the value
  98604. * @param array defines the array of number to store
  98605. */
  98606. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  98607. /**
  98608. * Set the value of an uniform to an array of number (stored as vec4)
  98609. * @param uniform defines the webGL uniform location where to store the value
  98610. * @param array defines the array of number to store
  98611. */
  98612. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  98613. /**
  98614. * Set the value of an uniform to an array of float32 (stored as matrices)
  98615. * @param uniform defines the webGL uniform location where to store the value
  98616. * @param matrices defines the array of float32 to store
  98617. */
  98618. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  98619. /**
  98620. * Set the value of an uniform to a matrix (3x3)
  98621. * @param uniform defines the webGL uniform location where to store the value
  98622. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  98623. */
  98624. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  98625. /**
  98626. * Set the value of an uniform to a matrix (2x2)
  98627. * @param uniform defines the webGL uniform location where to store the value
  98628. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  98629. */
  98630. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  98631. /**
  98632. * Set the value of an uniform to a number (float)
  98633. * @param uniform defines the webGL uniform location where to store the value
  98634. * @param value defines the float number to store
  98635. */
  98636. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  98637. /**
  98638. * Set the value of an uniform to a vec2
  98639. * @param uniform defines the webGL uniform location where to store the value
  98640. * @param x defines the 1st component of the value
  98641. * @param y defines the 2nd component of the value
  98642. */
  98643. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  98644. /**
  98645. * Set the value of an uniform to a vec3
  98646. * @param uniform defines the webGL uniform location where to store the value
  98647. * @param x defines the 1st component of the value
  98648. * @param y defines the 2nd component of the value
  98649. * @param z defines the 3rd component of the value
  98650. */
  98651. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  98652. /**
  98653. * Set the value of an uniform to a vec4
  98654. * @param uniform defines the webGL uniform location where to store the value
  98655. * @param x defines the 1st component of the value
  98656. * @param y defines the 2nd component of the value
  98657. * @param z defines the 3rd component of the value
  98658. * @param w defines the 4th component of the value
  98659. */
  98660. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  98661. /**
  98662. * Gets the depth culling state manager
  98663. */
  98664. readonly depthCullingState: DepthCullingState;
  98665. /**
  98666. * Gets the alpha state manager
  98667. */
  98668. readonly alphaState: AlphaState;
  98669. /**
  98670. * Gets the stencil state manager
  98671. */
  98672. readonly stencilState: StencilState;
  98673. /**
  98674. * Clears the list of texture accessible through engine.
  98675. * This can help preventing texture load conflict due to name collision.
  98676. */
  98677. clearInternalTexturesCache(): void;
  98678. /**
  98679. * Force the entire cache to be cleared
  98680. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  98681. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  98682. */
  98683. wipeCaches(bruteForce?: boolean): void;
  98684. /** @hidden */
  98685. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  98686. min: number;
  98687. mag: number;
  98688. };
  98689. /** @hidden */
  98690. _createTexture(): WebGLTexture;
  98691. /**
  98692. * Usually called from Texture.ts.
  98693. * Passed information to create a WebGLTexture
  98694. * @param urlArg defines a value which contains one of the following:
  98695. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  98696. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  98697. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  98698. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  98699. * @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)
  98700. * @param scene needed for loading to the correct scene
  98701. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  98702. * @param onLoad optional callback to be called upon successful completion
  98703. * @param onError optional callback to be called upon failure
  98704. * @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
  98705. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  98706. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  98707. * @param forcedExtension defines the extension to use to pick the right loader
  98708. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  98709. * @param mimeType defines an optional mime type
  98710. * @returns a InternalTexture for assignment back into BABYLON.Texture
  98711. */
  98712. 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;
  98713. /**
  98714. * @hidden
  98715. */
  98716. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  98717. /**
  98718. * Creates a raw texture
  98719. * @param data defines the data to store in the texture
  98720. * @param width defines the width of the texture
  98721. * @param height defines the height of the texture
  98722. * @param format defines the format of the data
  98723. * @param generateMipMaps defines if the engine should generate the mip levels
  98724. * @param invertY defines if data must be stored with Y axis inverted
  98725. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  98726. * @param compression defines the compression used (null by default)
  98727. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  98728. * @returns the raw texture inside an InternalTexture
  98729. */
  98730. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  98731. /**
  98732. * Creates a new raw cube texture
  98733. * @param data defines the array of data to use to create each face
  98734. * @param size defines the size of the textures
  98735. * @param format defines the format of the data
  98736. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  98737. * @param generateMipMaps defines if the engine should generate the mip levels
  98738. * @param invertY defines if data must be stored with Y axis inverted
  98739. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  98740. * @param compression defines the compression used (null by default)
  98741. * @returns the cube texture as an InternalTexture
  98742. */
  98743. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  98744. /**
  98745. * Creates a new raw 3D texture
  98746. * @param data defines the data used to create the texture
  98747. * @param width defines the width of the texture
  98748. * @param height defines the height of the texture
  98749. * @param depth defines the depth of the texture
  98750. * @param format defines the format of the texture
  98751. * @param generateMipMaps defines if the engine must generate mip levels
  98752. * @param invertY defines if data must be stored with Y axis inverted
  98753. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  98754. * @param compression defines the compressed used (can be null)
  98755. * @param textureType defines the compressed used (can be null)
  98756. * @returns a new raw 3D texture (stored in an InternalTexture)
  98757. */
  98758. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  98759. /**
  98760. * Creates a new raw 2D array texture
  98761. * @param data defines the data used to create the texture
  98762. * @param width defines the width of the texture
  98763. * @param height defines the height of the texture
  98764. * @param depth defines the number of layers of the texture
  98765. * @param format defines the format of the texture
  98766. * @param generateMipMaps defines if the engine must generate mip levels
  98767. * @param invertY defines if data must be stored with Y axis inverted
  98768. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  98769. * @param compression defines the compressed used (can be null)
  98770. * @param textureType defines the compressed used (can be null)
  98771. * @returns a new raw 2D array texture (stored in an InternalTexture)
  98772. */
  98773. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  98774. private _unpackFlipYCached;
  98775. /**
  98776. * In case you are sharing the context with other applications, it might
  98777. * be interested to not cache the unpack flip y state to ensure a consistent
  98778. * value would be set.
  98779. */
  98780. enableUnpackFlipYCached: boolean;
  98781. /** @hidden */
  98782. _unpackFlipY(value: boolean): void;
  98783. /** @hidden */
  98784. _getUnpackAlignement(): number;
  98785. /**
  98786. * Update the sampling mode of a given texture
  98787. * @param samplingMode defines the required sampling mode
  98788. * @param texture defines the texture to update
  98789. */
  98790. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  98791. /** @hidden */
  98792. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  98793. width: number;
  98794. height: number;
  98795. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  98796. /** @hidden */
  98797. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  98798. /** @hidden */
  98799. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  98800. /** @hidden */
  98801. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  98802. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  98803. private _prepareWebGLTexture;
  98804. /** @hidden */
  98805. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  98806. /** @hidden */
  98807. _releaseFramebufferObjects(texture: InternalTexture): void;
  98808. /** @hidden */
  98809. _releaseTexture(texture: InternalTexture): void;
  98810. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  98811. protected _setProgram(program: WebGLProgram): void;
  98812. protected _boundUniforms: {
  98813. [key: number]: WebGLUniformLocation;
  98814. };
  98815. /**
  98816. * Binds an effect to the webGL context
  98817. * @param effect defines the effect to bind
  98818. */
  98819. bindSamplers(effect: Effect): void;
  98820. private _activateCurrentTexture;
  98821. /** @hidden */
  98822. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  98823. /** @hidden */
  98824. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  98825. /**
  98826. * Unbind all textures from the webGL context
  98827. */
  98828. unbindAllTextures(): void;
  98829. /**
  98830. * Sets a texture to the according uniform.
  98831. * @param channel The texture channel
  98832. * @param uniform The uniform to set
  98833. * @param texture The texture to apply
  98834. */
  98835. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  98836. private _bindSamplerUniformToChannel;
  98837. private _getTextureWrapMode;
  98838. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  98839. /**
  98840. * Sets an array of texture to the webGL context
  98841. * @param channel defines the channel where the texture array must be set
  98842. * @param uniform defines the associated uniform location
  98843. * @param textures defines the array of textures to bind
  98844. */
  98845. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  98846. /** @hidden */
  98847. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  98848. private _setTextureParameterFloat;
  98849. private _setTextureParameterInteger;
  98850. /**
  98851. * Unbind all vertex attributes from the webGL context
  98852. */
  98853. unbindAllAttributes(): void;
  98854. /**
  98855. * 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
  98856. */
  98857. releaseEffects(): void;
  98858. /**
  98859. * Dispose and release all associated resources
  98860. */
  98861. dispose(): void;
  98862. /**
  98863. * Attach a new callback raised when context lost event is fired
  98864. * @param callback defines the callback to call
  98865. */
  98866. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  98867. /**
  98868. * Attach a new callback raised when context restored event is fired
  98869. * @param callback defines the callback to call
  98870. */
  98871. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  98872. /**
  98873. * Get the current error code of the webGL context
  98874. * @returns the error code
  98875. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  98876. */
  98877. getError(): number;
  98878. private _canRenderToFloatFramebuffer;
  98879. private _canRenderToHalfFloatFramebuffer;
  98880. private _canRenderToFramebuffer;
  98881. /** @hidden */
  98882. _getWebGLTextureType(type: number): number;
  98883. /** @hidden */
  98884. _getInternalFormat(format: number): number;
  98885. /** @hidden */
  98886. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  98887. /** @hidden */
  98888. _getRGBAMultiSampleBufferFormat(type: number): number;
  98889. /** @hidden */
  98890. _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;
  98891. /**
  98892. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  98893. * @returns true if the engine can be created
  98894. * @ignorenaming
  98895. */
  98896. static isSupported(): boolean;
  98897. /**
  98898. * Find the next highest power of two.
  98899. * @param x Number to start search from.
  98900. * @return Next highest power of two.
  98901. */
  98902. static CeilingPOT(x: number): number;
  98903. /**
  98904. * Find the next lowest power of two.
  98905. * @param x Number to start search from.
  98906. * @return Next lowest power of two.
  98907. */
  98908. static FloorPOT(x: number): number;
  98909. /**
  98910. * Find the nearest power of two.
  98911. * @param x Number to start search from.
  98912. * @return Next nearest power of two.
  98913. */
  98914. static NearestPOT(x: number): number;
  98915. /**
  98916. * Get the closest exponent of two
  98917. * @param value defines the value to approximate
  98918. * @param max defines the maximum value to return
  98919. * @param mode defines how to define the closest value
  98920. * @returns closest exponent of two of the given value
  98921. */
  98922. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  98923. /**
  98924. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  98925. * @param func - the function to be called
  98926. * @param requester - the object that will request the next frame. Falls back to window.
  98927. * @returns frame number
  98928. */
  98929. static QueueNewFrame(func: () => void, requester?: any): number;
  98930. /**
  98931. * Gets host document
  98932. * @returns the host document object
  98933. */
  98934. getHostDocument(): Document;
  98935. }
  98936. }
  98937. declare module BABYLON {
  98938. /**
  98939. * Class representing spherical harmonics coefficients to the 3rd degree
  98940. */
  98941. export class SphericalHarmonics {
  98942. /**
  98943. * Defines whether or not the harmonics have been prescaled for rendering.
  98944. */
  98945. preScaled: boolean;
  98946. /**
  98947. * The l0,0 coefficients of the spherical harmonics
  98948. */
  98949. l00: Vector3;
  98950. /**
  98951. * The l1,-1 coefficients of the spherical harmonics
  98952. */
  98953. l1_1: Vector3;
  98954. /**
  98955. * The l1,0 coefficients of the spherical harmonics
  98956. */
  98957. l10: Vector3;
  98958. /**
  98959. * The l1,1 coefficients of the spherical harmonics
  98960. */
  98961. l11: Vector3;
  98962. /**
  98963. * The l2,-2 coefficients of the spherical harmonics
  98964. */
  98965. l2_2: Vector3;
  98966. /**
  98967. * The l2,-1 coefficients of the spherical harmonics
  98968. */
  98969. l2_1: Vector3;
  98970. /**
  98971. * The l2,0 coefficients of the spherical harmonics
  98972. */
  98973. l20: Vector3;
  98974. /**
  98975. * The l2,1 coefficients of the spherical harmonics
  98976. */
  98977. l21: Vector3;
  98978. /**
  98979. * The l2,2 coefficients of the spherical harmonics
  98980. */
  98981. l22: Vector3;
  98982. /**
  98983. * Adds a light to the spherical harmonics
  98984. * @param direction the direction of the light
  98985. * @param color the color of the light
  98986. * @param deltaSolidAngle the delta solid angle of the light
  98987. */
  98988. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  98989. /**
  98990. * Scales the spherical harmonics by the given amount
  98991. * @param scale the amount to scale
  98992. */
  98993. scaleInPlace(scale: number): void;
  98994. /**
  98995. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  98996. *
  98997. * ```
  98998. * E_lm = A_l * L_lm
  98999. * ```
  99000. *
  99001. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  99002. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  99003. * the scaling factors are given in equation 9.
  99004. */
  99005. convertIncidentRadianceToIrradiance(): void;
  99006. /**
  99007. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  99008. *
  99009. * ```
  99010. * L = (1/pi) * E * rho
  99011. * ```
  99012. *
  99013. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  99014. */
  99015. convertIrradianceToLambertianRadiance(): void;
  99016. /**
  99017. * Integrates the reconstruction coefficients directly in to the SH preventing further
  99018. * required operations at run time.
  99019. *
  99020. * This is simply done by scaling back the SH with Ylm constants parameter.
  99021. * The trigonometric part being applied by the shader at run time.
  99022. */
  99023. preScaleForRendering(): void;
  99024. /**
  99025. * Constructs a spherical harmonics from an array.
  99026. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  99027. * @returns the spherical harmonics
  99028. */
  99029. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  99030. /**
  99031. * Gets the spherical harmonics from polynomial
  99032. * @param polynomial the spherical polynomial
  99033. * @returns the spherical harmonics
  99034. */
  99035. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  99036. }
  99037. /**
  99038. * Class representing spherical polynomial coefficients to the 3rd degree
  99039. */
  99040. export class SphericalPolynomial {
  99041. private _harmonics;
  99042. /**
  99043. * The spherical harmonics used to create the polynomials.
  99044. */
  99045. readonly preScaledHarmonics: SphericalHarmonics;
  99046. /**
  99047. * The x coefficients of the spherical polynomial
  99048. */
  99049. x: Vector3;
  99050. /**
  99051. * The y coefficients of the spherical polynomial
  99052. */
  99053. y: Vector3;
  99054. /**
  99055. * The z coefficients of the spherical polynomial
  99056. */
  99057. z: Vector3;
  99058. /**
  99059. * The xx coefficients of the spherical polynomial
  99060. */
  99061. xx: Vector3;
  99062. /**
  99063. * The yy coefficients of the spherical polynomial
  99064. */
  99065. yy: Vector3;
  99066. /**
  99067. * The zz coefficients of the spherical polynomial
  99068. */
  99069. zz: Vector3;
  99070. /**
  99071. * The xy coefficients of the spherical polynomial
  99072. */
  99073. xy: Vector3;
  99074. /**
  99075. * The yz coefficients of the spherical polynomial
  99076. */
  99077. yz: Vector3;
  99078. /**
  99079. * The zx coefficients of the spherical polynomial
  99080. */
  99081. zx: Vector3;
  99082. /**
  99083. * Adds an ambient color to the spherical polynomial
  99084. * @param color the color to add
  99085. */
  99086. addAmbient(color: Color3): void;
  99087. /**
  99088. * Scales the spherical polynomial by the given amount
  99089. * @param scale the amount to scale
  99090. */
  99091. scaleInPlace(scale: number): void;
  99092. /**
  99093. * Gets the spherical polynomial from harmonics
  99094. * @param harmonics the spherical harmonics
  99095. * @returns the spherical polynomial
  99096. */
  99097. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  99098. /**
  99099. * Constructs a spherical polynomial from an array.
  99100. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  99101. * @returns the spherical polynomial
  99102. */
  99103. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  99104. }
  99105. }
  99106. declare module BABYLON {
  99107. /**
  99108. * Defines the source of the internal texture
  99109. */
  99110. export enum InternalTextureSource {
  99111. /**
  99112. * The source of the texture data is unknown
  99113. */
  99114. Unknown = 0,
  99115. /**
  99116. * Texture data comes from an URL
  99117. */
  99118. Url = 1,
  99119. /**
  99120. * Texture data is only used for temporary storage
  99121. */
  99122. Temp = 2,
  99123. /**
  99124. * Texture data comes from raw data (ArrayBuffer)
  99125. */
  99126. Raw = 3,
  99127. /**
  99128. * Texture content is dynamic (video or dynamic texture)
  99129. */
  99130. Dynamic = 4,
  99131. /**
  99132. * Texture content is generated by rendering to it
  99133. */
  99134. RenderTarget = 5,
  99135. /**
  99136. * Texture content is part of a multi render target process
  99137. */
  99138. MultiRenderTarget = 6,
  99139. /**
  99140. * Texture data comes from a cube data file
  99141. */
  99142. Cube = 7,
  99143. /**
  99144. * Texture data comes from a raw cube data
  99145. */
  99146. CubeRaw = 8,
  99147. /**
  99148. * Texture data come from a prefiltered cube data file
  99149. */
  99150. CubePrefiltered = 9,
  99151. /**
  99152. * Texture content is raw 3D data
  99153. */
  99154. Raw3D = 10,
  99155. /**
  99156. * Texture content is raw 2D array data
  99157. */
  99158. Raw2DArray = 11,
  99159. /**
  99160. * Texture content is a depth texture
  99161. */
  99162. Depth = 12,
  99163. /**
  99164. * Texture data comes from a raw cube data encoded with RGBD
  99165. */
  99166. CubeRawRGBD = 13
  99167. }
  99168. /**
  99169. * Class used to store data associated with WebGL texture data for the engine
  99170. * This class should not be used directly
  99171. */
  99172. export class InternalTexture {
  99173. /** @hidden */
  99174. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  99175. /**
  99176. * Defines if the texture is ready
  99177. */
  99178. isReady: boolean;
  99179. /**
  99180. * Defines if the texture is a cube texture
  99181. */
  99182. isCube: boolean;
  99183. /**
  99184. * Defines if the texture contains 3D data
  99185. */
  99186. is3D: boolean;
  99187. /**
  99188. * Defines if the texture contains 2D array data
  99189. */
  99190. is2DArray: boolean;
  99191. /**
  99192. * Defines if the texture contains multiview data
  99193. */
  99194. isMultiview: boolean;
  99195. /**
  99196. * Gets the URL used to load this texture
  99197. */
  99198. url: string;
  99199. /**
  99200. * Gets the sampling mode of the texture
  99201. */
  99202. samplingMode: number;
  99203. /**
  99204. * Gets a boolean indicating if the texture needs mipmaps generation
  99205. */
  99206. generateMipMaps: boolean;
  99207. /**
  99208. * Gets the number of samples used by the texture (WebGL2+ only)
  99209. */
  99210. samples: number;
  99211. /**
  99212. * Gets the type of the texture (int, float...)
  99213. */
  99214. type: number;
  99215. /**
  99216. * Gets the format of the texture (RGB, RGBA...)
  99217. */
  99218. format: number;
  99219. /**
  99220. * Observable called when the texture is loaded
  99221. */
  99222. onLoadedObservable: Observable<InternalTexture>;
  99223. /**
  99224. * Gets the width of the texture
  99225. */
  99226. width: number;
  99227. /**
  99228. * Gets the height of the texture
  99229. */
  99230. height: number;
  99231. /**
  99232. * Gets the depth of the texture
  99233. */
  99234. depth: number;
  99235. /**
  99236. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  99237. */
  99238. baseWidth: number;
  99239. /**
  99240. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  99241. */
  99242. baseHeight: number;
  99243. /**
  99244. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  99245. */
  99246. baseDepth: number;
  99247. /**
  99248. * Gets a boolean indicating if the texture is inverted on Y axis
  99249. */
  99250. invertY: boolean;
  99251. /** @hidden */
  99252. _invertVScale: boolean;
  99253. /** @hidden */
  99254. _associatedChannel: number;
  99255. /** @hidden */
  99256. _source: InternalTextureSource;
  99257. /** @hidden */
  99258. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  99259. /** @hidden */
  99260. _bufferView: Nullable<ArrayBufferView>;
  99261. /** @hidden */
  99262. _bufferViewArray: Nullable<ArrayBufferView[]>;
  99263. /** @hidden */
  99264. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  99265. /** @hidden */
  99266. _size: number;
  99267. /** @hidden */
  99268. _extension: string;
  99269. /** @hidden */
  99270. _files: Nullable<string[]>;
  99271. /** @hidden */
  99272. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  99273. /** @hidden */
  99274. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  99275. /** @hidden */
  99276. _framebuffer: Nullable<WebGLFramebuffer>;
  99277. /** @hidden */
  99278. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  99279. /** @hidden */
  99280. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  99281. /** @hidden */
  99282. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  99283. /** @hidden */
  99284. _attachments: Nullable<number[]>;
  99285. /** @hidden */
  99286. _cachedCoordinatesMode: Nullable<number>;
  99287. /** @hidden */
  99288. _cachedWrapU: Nullable<number>;
  99289. /** @hidden */
  99290. _cachedWrapV: Nullable<number>;
  99291. /** @hidden */
  99292. _cachedWrapR: Nullable<number>;
  99293. /** @hidden */
  99294. _cachedAnisotropicFilteringLevel: Nullable<number>;
  99295. /** @hidden */
  99296. _isDisabled: boolean;
  99297. /** @hidden */
  99298. _compression: Nullable<string>;
  99299. /** @hidden */
  99300. _generateStencilBuffer: boolean;
  99301. /** @hidden */
  99302. _generateDepthBuffer: boolean;
  99303. /** @hidden */
  99304. _comparisonFunction: number;
  99305. /** @hidden */
  99306. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  99307. /** @hidden */
  99308. _lodGenerationScale: number;
  99309. /** @hidden */
  99310. _lodGenerationOffset: number;
  99311. /** @hidden */
  99312. _colorTextureArray: Nullable<WebGLTexture>;
  99313. /** @hidden */
  99314. _depthStencilTextureArray: Nullable<WebGLTexture>;
  99315. /** @hidden */
  99316. _lodTextureHigh: Nullable<BaseTexture>;
  99317. /** @hidden */
  99318. _lodTextureMid: Nullable<BaseTexture>;
  99319. /** @hidden */
  99320. _lodTextureLow: Nullable<BaseTexture>;
  99321. /** @hidden */
  99322. _isRGBD: boolean;
  99323. /** @hidden */
  99324. _linearSpecularLOD: boolean;
  99325. /** @hidden */
  99326. _irradianceTexture: Nullable<BaseTexture>;
  99327. /** @hidden */
  99328. _webGLTexture: Nullable<WebGLTexture>;
  99329. /** @hidden */
  99330. _references: number;
  99331. private _engine;
  99332. /**
  99333. * Gets the Engine the texture belongs to.
  99334. * @returns The babylon engine
  99335. */
  99336. getEngine(): ThinEngine;
  99337. /**
  99338. * Gets the data source type of the texture
  99339. */
  99340. readonly source: InternalTextureSource;
  99341. /**
  99342. * Creates a new InternalTexture
  99343. * @param engine defines the engine to use
  99344. * @param source defines the type of data that will be used
  99345. * @param delayAllocation if the texture allocation should be delayed (default: false)
  99346. */
  99347. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  99348. /**
  99349. * Increments the number of references (ie. the number of Texture that point to it)
  99350. */
  99351. incrementReferences(): void;
  99352. /**
  99353. * Change the size of the texture (not the size of the content)
  99354. * @param width defines the new width
  99355. * @param height defines the new height
  99356. * @param depth defines the new depth (1 by default)
  99357. */
  99358. updateSize(width: int, height: int, depth?: int): void;
  99359. /** @hidden */
  99360. _rebuild(): void;
  99361. /** @hidden */
  99362. _swapAndDie(target: InternalTexture): void;
  99363. /**
  99364. * Dispose the current allocated resources
  99365. */
  99366. dispose(): void;
  99367. }
  99368. }
  99369. declare module BABYLON {
  99370. /**
  99371. * Class used to work with sound analyzer using fast fourier transform (FFT)
  99372. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  99373. */
  99374. export class Analyser {
  99375. /**
  99376. * Gets or sets the smoothing
  99377. * @ignorenaming
  99378. */
  99379. SMOOTHING: number;
  99380. /**
  99381. * Gets or sets the FFT table size
  99382. * @ignorenaming
  99383. */
  99384. FFT_SIZE: number;
  99385. /**
  99386. * Gets or sets the bar graph amplitude
  99387. * @ignorenaming
  99388. */
  99389. BARGRAPHAMPLITUDE: number;
  99390. /**
  99391. * Gets or sets the position of the debug canvas
  99392. * @ignorenaming
  99393. */
  99394. DEBUGCANVASPOS: {
  99395. x: number;
  99396. y: number;
  99397. };
  99398. /**
  99399. * Gets or sets the debug canvas size
  99400. * @ignorenaming
  99401. */
  99402. DEBUGCANVASSIZE: {
  99403. width: number;
  99404. height: number;
  99405. };
  99406. private _byteFreqs;
  99407. private _byteTime;
  99408. private _floatFreqs;
  99409. private _webAudioAnalyser;
  99410. private _debugCanvas;
  99411. private _debugCanvasContext;
  99412. private _scene;
  99413. private _registerFunc;
  99414. private _audioEngine;
  99415. /**
  99416. * Creates a new analyser
  99417. * @param scene defines hosting scene
  99418. */
  99419. constructor(scene: Scene);
  99420. /**
  99421. * Get the number of data values you will have to play with for the visualization
  99422. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  99423. * @returns a number
  99424. */
  99425. getFrequencyBinCount(): number;
  99426. /**
  99427. * Gets the current frequency data as a byte array
  99428. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  99429. * @returns a Uint8Array
  99430. */
  99431. getByteFrequencyData(): Uint8Array;
  99432. /**
  99433. * Gets the current waveform as a byte array
  99434. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  99435. * @returns a Uint8Array
  99436. */
  99437. getByteTimeDomainData(): Uint8Array;
  99438. /**
  99439. * Gets the current frequency data as a float array
  99440. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  99441. * @returns a Float32Array
  99442. */
  99443. getFloatFrequencyData(): Float32Array;
  99444. /**
  99445. * Renders the debug canvas
  99446. */
  99447. drawDebugCanvas(): void;
  99448. /**
  99449. * Stops rendering the debug canvas and removes it
  99450. */
  99451. stopDebugCanvas(): void;
  99452. /**
  99453. * Connects two audio nodes
  99454. * @param inputAudioNode defines first node to connect
  99455. * @param outputAudioNode defines second node to connect
  99456. */
  99457. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  99458. /**
  99459. * Releases all associated resources
  99460. */
  99461. dispose(): void;
  99462. }
  99463. }
  99464. declare module BABYLON {
  99465. /**
  99466. * This represents an audio engine and it is responsible
  99467. * to play, synchronize and analyse sounds throughout the application.
  99468. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  99469. */
  99470. export interface IAudioEngine extends IDisposable {
  99471. /**
  99472. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  99473. */
  99474. readonly canUseWebAudio: boolean;
  99475. /**
  99476. * Gets the current AudioContext if available.
  99477. */
  99478. readonly audioContext: Nullable<AudioContext>;
  99479. /**
  99480. * The master gain node defines the global audio volume of your audio engine.
  99481. */
  99482. readonly masterGain: GainNode;
  99483. /**
  99484. * Gets whether or not mp3 are supported by your browser.
  99485. */
  99486. readonly isMP3supported: boolean;
  99487. /**
  99488. * Gets whether or not ogg are supported by your browser.
  99489. */
  99490. readonly isOGGsupported: boolean;
  99491. /**
  99492. * Defines if Babylon should emit a warning if WebAudio is not supported.
  99493. * @ignoreNaming
  99494. */
  99495. WarnedWebAudioUnsupported: boolean;
  99496. /**
  99497. * Defines if the audio engine relies on a custom unlocked button.
  99498. * In this case, the embedded button will not be displayed.
  99499. */
  99500. useCustomUnlockedButton: boolean;
  99501. /**
  99502. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  99503. */
  99504. readonly unlocked: boolean;
  99505. /**
  99506. * Event raised when audio has been unlocked on the browser.
  99507. */
  99508. onAudioUnlockedObservable: Observable<AudioEngine>;
  99509. /**
  99510. * Event raised when audio has been locked on the browser.
  99511. */
  99512. onAudioLockedObservable: Observable<AudioEngine>;
  99513. /**
  99514. * Flags the audio engine in Locked state.
  99515. * This happens due to new browser policies preventing audio to autoplay.
  99516. */
  99517. lock(): void;
  99518. /**
  99519. * Unlocks the audio engine once a user action has been done on the dom.
  99520. * This is helpful to resume play once browser policies have been satisfied.
  99521. */
  99522. unlock(): void;
  99523. }
  99524. /**
  99525. * This represents the default audio engine used in babylon.
  99526. * It is responsible to play, synchronize and analyse sounds throughout the application.
  99527. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  99528. */
  99529. export class AudioEngine implements IAudioEngine {
  99530. private _audioContext;
  99531. private _audioContextInitialized;
  99532. private _muteButton;
  99533. private _hostElement;
  99534. /**
  99535. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  99536. */
  99537. canUseWebAudio: boolean;
  99538. /**
  99539. * The master gain node defines the global audio volume of your audio engine.
  99540. */
  99541. masterGain: GainNode;
  99542. /**
  99543. * Defines if Babylon should emit a warning if WebAudio is not supported.
  99544. * @ignoreNaming
  99545. */
  99546. WarnedWebAudioUnsupported: boolean;
  99547. /**
  99548. * Gets whether or not mp3 are supported by your browser.
  99549. */
  99550. isMP3supported: boolean;
  99551. /**
  99552. * Gets whether or not ogg are supported by your browser.
  99553. */
  99554. isOGGsupported: boolean;
  99555. /**
  99556. * Gets whether audio has been unlocked on the device.
  99557. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  99558. * a user interaction has happened.
  99559. */
  99560. unlocked: boolean;
  99561. /**
  99562. * Defines if the audio engine relies on a custom unlocked button.
  99563. * In this case, the embedded button will not be displayed.
  99564. */
  99565. useCustomUnlockedButton: boolean;
  99566. /**
  99567. * Event raised when audio has been unlocked on the browser.
  99568. */
  99569. onAudioUnlockedObservable: Observable<AudioEngine>;
  99570. /**
  99571. * Event raised when audio has been locked on the browser.
  99572. */
  99573. onAudioLockedObservable: Observable<AudioEngine>;
  99574. /**
  99575. * Gets the current AudioContext if available.
  99576. */
  99577. readonly audioContext: Nullable<AudioContext>;
  99578. private _connectedAnalyser;
  99579. /**
  99580. * Instantiates a new audio engine.
  99581. *
  99582. * There should be only one per page as some browsers restrict the number
  99583. * of audio contexts you can create.
  99584. * @param hostElement defines the host element where to display the mute icon if necessary
  99585. */
  99586. constructor(hostElement?: Nullable<HTMLElement>);
  99587. /**
  99588. * Flags the audio engine in Locked state.
  99589. * This happens due to new browser policies preventing audio to autoplay.
  99590. */
  99591. lock(): void;
  99592. /**
  99593. * Unlocks the audio engine once a user action has been done on the dom.
  99594. * This is helpful to resume play once browser policies have been satisfied.
  99595. */
  99596. unlock(): void;
  99597. private _resumeAudioContext;
  99598. private _initializeAudioContext;
  99599. private _tryToRun;
  99600. private _triggerRunningState;
  99601. private _triggerSuspendedState;
  99602. private _displayMuteButton;
  99603. private _moveButtonToTopLeft;
  99604. private _onResize;
  99605. private _hideMuteButton;
  99606. /**
  99607. * Destroy and release the resources associated with the audio ccontext.
  99608. */
  99609. dispose(): void;
  99610. /**
  99611. * Gets the global volume sets on the master gain.
  99612. * @returns the global volume if set or -1 otherwise
  99613. */
  99614. getGlobalVolume(): number;
  99615. /**
  99616. * Sets the global volume of your experience (sets on the master gain).
  99617. * @param newVolume Defines the new global volume of the application
  99618. */
  99619. setGlobalVolume(newVolume: number): void;
  99620. /**
  99621. * Connect the audio engine to an audio analyser allowing some amazing
  99622. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  99623. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  99624. * @param analyser The analyser to connect to the engine
  99625. */
  99626. connectToAnalyser(analyser: Analyser): void;
  99627. }
  99628. }
  99629. declare module BABYLON {
  99630. /**
  99631. * Interface used to present a loading screen while loading a scene
  99632. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  99633. */
  99634. export interface ILoadingScreen {
  99635. /**
  99636. * Function called to display the loading screen
  99637. */
  99638. displayLoadingUI: () => void;
  99639. /**
  99640. * Function called to hide the loading screen
  99641. */
  99642. hideLoadingUI: () => void;
  99643. /**
  99644. * Gets or sets the color to use for the background
  99645. */
  99646. loadingUIBackgroundColor: string;
  99647. /**
  99648. * Gets or sets the text to display while loading
  99649. */
  99650. loadingUIText: string;
  99651. }
  99652. /**
  99653. * Class used for the default loading screen
  99654. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  99655. */
  99656. export class DefaultLoadingScreen implements ILoadingScreen {
  99657. private _renderingCanvas;
  99658. private _loadingText;
  99659. private _loadingDivBackgroundColor;
  99660. private _loadingDiv;
  99661. private _loadingTextDiv;
  99662. /** Gets or sets the logo url to use for the default loading screen */
  99663. static DefaultLogoUrl: string;
  99664. /** Gets or sets the spinner url to use for the default loading screen */
  99665. static DefaultSpinnerUrl: string;
  99666. /**
  99667. * Creates a new default loading screen
  99668. * @param _renderingCanvas defines the canvas used to render the scene
  99669. * @param _loadingText defines the default text to display
  99670. * @param _loadingDivBackgroundColor defines the default background color
  99671. */
  99672. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  99673. /**
  99674. * Function called to display the loading screen
  99675. */
  99676. displayLoadingUI(): void;
  99677. /**
  99678. * Function called to hide the loading screen
  99679. */
  99680. hideLoadingUI(): void;
  99681. /**
  99682. * Gets or sets the text to display while loading
  99683. */
  99684. loadingUIText: string;
  99685. /**
  99686. * Gets or sets the color to use for the background
  99687. */
  99688. loadingUIBackgroundColor: string;
  99689. private _resizeLoadingUI;
  99690. }
  99691. }
  99692. declare module BABYLON {
  99693. /**
  99694. * Interface for any object that can request an animation frame
  99695. */
  99696. export interface ICustomAnimationFrameRequester {
  99697. /**
  99698. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  99699. */
  99700. renderFunction?: Function;
  99701. /**
  99702. * Called to request the next frame to render to
  99703. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  99704. */
  99705. requestAnimationFrame: Function;
  99706. /**
  99707. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  99708. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  99709. */
  99710. requestID?: number;
  99711. }
  99712. }
  99713. declare module BABYLON {
  99714. /**
  99715. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  99716. */
  99717. export class PerformanceMonitor {
  99718. private _enabled;
  99719. private _rollingFrameTime;
  99720. private _lastFrameTimeMs;
  99721. /**
  99722. * constructor
  99723. * @param frameSampleSize The number of samples required to saturate the sliding window
  99724. */
  99725. constructor(frameSampleSize?: number);
  99726. /**
  99727. * Samples current frame
  99728. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  99729. */
  99730. sampleFrame(timeMs?: number): void;
  99731. /**
  99732. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  99733. */
  99734. readonly averageFrameTime: number;
  99735. /**
  99736. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  99737. */
  99738. readonly averageFrameTimeVariance: number;
  99739. /**
  99740. * Returns the frame time of the most recent frame
  99741. */
  99742. readonly instantaneousFrameTime: number;
  99743. /**
  99744. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  99745. */
  99746. readonly averageFPS: number;
  99747. /**
  99748. * Returns the average framerate in frames per second using the most recent frame time
  99749. */
  99750. readonly instantaneousFPS: number;
  99751. /**
  99752. * Returns true if enough samples have been taken to completely fill the sliding window
  99753. */
  99754. readonly isSaturated: boolean;
  99755. /**
  99756. * Enables contributions to the sliding window sample set
  99757. */
  99758. enable(): void;
  99759. /**
  99760. * Disables contributions to the sliding window sample set
  99761. * Samples will not be interpolated over the disabled period
  99762. */
  99763. disable(): void;
  99764. /**
  99765. * Returns true if sampling is enabled
  99766. */
  99767. readonly isEnabled: boolean;
  99768. /**
  99769. * Resets performance monitor
  99770. */
  99771. reset(): void;
  99772. }
  99773. /**
  99774. * RollingAverage
  99775. *
  99776. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  99777. */
  99778. export class RollingAverage {
  99779. /**
  99780. * Current average
  99781. */
  99782. average: number;
  99783. /**
  99784. * Current variance
  99785. */
  99786. variance: number;
  99787. protected _samples: Array<number>;
  99788. protected _sampleCount: number;
  99789. protected _pos: number;
  99790. protected _m2: number;
  99791. /**
  99792. * constructor
  99793. * @param length The number of samples required to saturate the sliding window
  99794. */
  99795. constructor(length: number);
  99796. /**
  99797. * Adds a sample to the sample set
  99798. * @param v The sample value
  99799. */
  99800. add(v: number): void;
  99801. /**
  99802. * Returns previously added values or null if outside of history or outside the sliding window domain
  99803. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  99804. * @return Value previously recorded with add() or null if outside of range
  99805. */
  99806. history(i: number): number;
  99807. /**
  99808. * Returns true if enough samples have been taken to completely fill the sliding window
  99809. * @return true if sample-set saturated
  99810. */
  99811. isSaturated(): boolean;
  99812. /**
  99813. * Resets the rolling average (equivalent to 0 samples taken so far)
  99814. */
  99815. reset(): void;
  99816. /**
  99817. * Wraps a value around the sample range boundaries
  99818. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  99819. * @return Wrapped position in sample range
  99820. */
  99821. protected _wrapPosition(i: number): number;
  99822. }
  99823. }
  99824. declare module BABYLON {
  99825. /**
  99826. * This class is used to track a performance counter which is number based.
  99827. * The user has access to many properties which give statistics of different nature.
  99828. *
  99829. * The implementer can track two kinds of Performance Counter: time and count.
  99830. * 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.
  99831. * 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.
  99832. */
  99833. export class PerfCounter {
  99834. /**
  99835. * Gets or sets a global boolean to turn on and off all the counters
  99836. */
  99837. static Enabled: boolean;
  99838. /**
  99839. * Returns the smallest value ever
  99840. */
  99841. readonly min: number;
  99842. /**
  99843. * Returns the biggest value ever
  99844. */
  99845. readonly max: number;
  99846. /**
  99847. * Returns the average value since the performance counter is running
  99848. */
  99849. readonly average: number;
  99850. /**
  99851. * Returns the average value of the last second the counter was monitored
  99852. */
  99853. readonly lastSecAverage: number;
  99854. /**
  99855. * Returns the current value
  99856. */
  99857. readonly current: number;
  99858. /**
  99859. * Gets the accumulated total
  99860. */
  99861. readonly total: number;
  99862. /**
  99863. * Gets the total value count
  99864. */
  99865. readonly count: number;
  99866. /**
  99867. * Creates a new counter
  99868. */
  99869. constructor();
  99870. /**
  99871. * Call this method to start monitoring a new frame.
  99872. * 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.
  99873. */
  99874. fetchNewFrame(): void;
  99875. /**
  99876. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  99877. * @param newCount the count value to add to the monitored count
  99878. * @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.
  99879. */
  99880. addCount(newCount: number, fetchResult: boolean): void;
  99881. /**
  99882. * Start monitoring this performance counter
  99883. */
  99884. beginMonitoring(): void;
  99885. /**
  99886. * Compute the time lapsed since the previous beginMonitoring() call.
  99887. * @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
  99888. */
  99889. endMonitoring(newFrame?: boolean): void;
  99890. private _fetchResult;
  99891. private _startMonitoringTime;
  99892. private _min;
  99893. private _max;
  99894. private _average;
  99895. private _current;
  99896. private _totalValueCount;
  99897. private _totalAccumulated;
  99898. private _lastSecAverage;
  99899. private _lastSecAccumulated;
  99900. private _lastSecTime;
  99901. private _lastSecValueCount;
  99902. }
  99903. }
  99904. declare module BABYLON {
  99905. /**
  99906. * Defines the interface used by display changed events
  99907. */
  99908. export interface IDisplayChangedEventArgs {
  99909. /** Gets the vrDisplay object (if any) */
  99910. vrDisplay: Nullable<any>;
  99911. /** Gets a boolean indicating if webVR is supported */
  99912. vrSupported: boolean;
  99913. }
  99914. /**
  99915. * Defines the interface used by objects containing a viewport (like a camera)
  99916. */
  99917. interface IViewportOwnerLike {
  99918. /**
  99919. * Gets or sets the viewport
  99920. */
  99921. viewport: IViewportLike;
  99922. }
  99923. /**
  99924. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  99925. */
  99926. export class Engine extends ThinEngine {
  99927. /** Defines that alpha blending is disabled */
  99928. static readonly ALPHA_DISABLE: number;
  99929. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  99930. static readonly ALPHA_ADD: number;
  99931. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  99932. static readonly ALPHA_COMBINE: number;
  99933. /** Defines that alpha blending to DEST - SRC * DEST */
  99934. static readonly ALPHA_SUBTRACT: number;
  99935. /** Defines that alpha blending to SRC * DEST */
  99936. static readonly ALPHA_MULTIPLY: number;
  99937. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  99938. static readonly ALPHA_MAXIMIZED: number;
  99939. /** Defines that alpha blending to SRC + DEST */
  99940. static readonly ALPHA_ONEONE: number;
  99941. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  99942. static readonly ALPHA_PREMULTIPLIED: number;
  99943. /**
  99944. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  99945. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  99946. */
  99947. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  99948. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  99949. static readonly ALPHA_INTERPOLATE: number;
  99950. /**
  99951. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  99952. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  99953. */
  99954. static readonly ALPHA_SCREENMODE: number;
  99955. /** Defines that the ressource is not delayed*/
  99956. static readonly DELAYLOADSTATE_NONE: number;
  99957. /** Defines that the ressource was successfully delay loaded */
  99958. static readonly DELAYLOADSTATE_LOADED: number;
  99959. /** Defines that the ressource is currently delay loading */
  99960. static readonly DELAYLOADSTATE_LOADING: number;
  99961. /** Defines that the ressource is delayed and has not started loading */
  99962. static readonly DELAYLOADSTATE_NOTLOADED: number;
  99963. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  99964. static readonly NEVER: number;
  99965. /** 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 */
  99966. static readonly ALWAYS: number;
  99967. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  99968. static readonly LESS: number;
  99969. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  99970. static readonly EQUAL: number;
  99971. /** 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 */
  99972. static readonly LEQUAL: number;
  99973. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  99974. static readonly GREATER: number;
  99975. /** 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 */
  99976. static readonly GEQUAL: number;
  99977. /** 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 */
  99978. static readonly NOTEQUAL: number;
  99979. /** Passed to stencilOperation to specify that stencil value must be kept */
  99980. static readonly KEEP: number;
  99981. /** Passed to stencilOperation to specify that stencil value must be replaced */
  99982. static readonly REPLACE: number;
  99983. /** Passed to stencilOperation to specify that stencil value must be incremented */
  99984. static readonly INCR: number;
  99985. /** Passed to stencilOperation to specify that stencil value must be decremented */
  99986. static readonly DECR: number;
  99987. /** Passed to stencilOperation to specify that stencil value must be inverted */
  99988. static readonly INVERT: number;
  99989. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  99990. static readonly INCR_WRAP: number;
  99991. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  99992. static readonly DECR_WRAP: number;
  99993. /** Texture is not repeating outside of 0..1 UVs */
  99994. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  99995. /** Texture is repeating outside of 0..1 UVs */
  99996. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  99997. /** Texture is repeating and mirrored */
  99998. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  99999. /** ALPHA */
  100000. static readonly TEXTUREFORMAT_ALPHA: number;
  100001. /** LUMINANCE */
  100002. static readonly TEXTUREFORMAT_LUMINANCE: number;
  100003. /** LUMINANCE_ALPHA */
  100004. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  100005. /** RGB */
  100006. static readonly TEXTUREFORMAT_RGB: number;
  100007. /** RGBA */
  100008. static readonly TEXTUREFORMAT_RGBA: number;
  100009. /** RED */
  100010. static readonly TEXTUREFORMAT_RED: number;
  100011. /** RED (2nd reference) */
  100012. static readonly TEXTUREFORMAT_R: number;
  100013. /** RG */
  100014. static readonly TEXTUREFORMAT_RG: number;
  100015. /** RED_INTEGER */
  100016. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  100017. /** RED_INTEGER (2nd reference) */
  100018. static readonly TEXTUREFORMAT_R_INTEGER: number;
  100019. /** RG_INTEGER */
  100020. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  100021. /** RGB_INTEGER */
  100022. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  100023. /** RGBA_INTEGER */
  100024. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  100025. /** UNSIGNED_BYTE */
  100026. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  100027. /** UNSIGNED_BYTE (2nd reference) */
  100028. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  100029. /** FLOAT */
  100030. static readonly TEXTURETYPE_FLOAT: number;
  100031. /** HALF_FLOAT */
  100032. static readonly TEXTURETYPE_HALF_FLOAT: number;
  100033. /** BYTE */
  100034. static readonly TEXTURETYPE_BYTE: number;
  100035. /** SHORT */
  100036. static readonly TEXTURETYPE_SHORT: number;
  100037. /** UNSIGNED_SHORT */
  100038. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  100039. /** INT */
  100040. static readonly TEXTURETYPE_INT: number;
  100041. /** UNSIGNED_INT */
  100042. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  100043. /** UNSIGNED_SHORT_4_4_4_4 */
  100044. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  100045. /** UNSIGNED_SHORT_5_5_5_1 */
  100046. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  100047. /** UNSIGNED_SHORT_5_6_5 */
  100048. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  100049. /** UNSIGNED_INT_2_10_10_10_REV */
  100050. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  100051. /** UNSIGNED_INT_24_8 */
  100052. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  100053. /** UNSIGNED_INT_10F_11F_11F_REV */
  100054. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  100055. /** UNSIGNED_INT_5_9_9_9_REV */
  100056. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  100057. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  100058. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  100059. /** nearest is mag = nearest and min = nearest and mip = linear */
  100060. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  100061. /** Bilinear is mag = linear and min = linear and mip = nearest */
  100062. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  100063. /** Trilinear is mag = linear and min = linear and mip = linear */
  100064. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  100065. /** nearest is mag = nearest and min = nearest and mip = linear */
  100066. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  100067. /** Bilinear is mag = linear and min = linear and mip = nearest */
  100068. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  100069. /** Trilinear is mag = linear and min = linear and mip = linear */
  100070. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  100071. /** mag = nearest and min = nearest and mip = nearest */
  100072. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  100073. /** mag = nearest and min = linear and mip = nearest */
  100074. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  100075. /** mag = nearest and min = linear and mip = linear */
  100076. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  100077. /** mag = nearest and min = linear and mip = none */
  100078. static readonly TEXTURE_NEAREST_LINEAR: number;
  100079. /** mag = nearest and min = nearest and mip = none */
  100080. static readonly TEXTURE_NEAREST_NEAREST: number;
  100081. /** mag = linear and min = nearest and mip = nearest */
  100082. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  100083. /** mag = linear and min = nearest and mip = linear */
  100084. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  100085. /** mag = linear and min = linear and mip = none */
  100086. static readonly TEXTURE_LINEAR_LINEAR: number;
  100087. /** mag = linear and min = nearest and mip = none */
  100088. static readonly TEXTURE_LINEAR_NEAREST: number;
  100089. /** Explicit coordinates mode */
  100090. static readonly TEXTURE_EXPLICIT_MODE: number;
  100091. /** Spherical coordinates mode */
  100092. static readonly TEXTURE_SPHERICAL_MODE: number;
  100093. /** Planar coordinates mode */
  100094. static readonly TEXTURE_PLANAR_MODE: number;
  100095. /** Cubic coordinates mode */
  100096. static readonly TEXTURE_CUBIC_MODE: number;
  100097. /** Projection coordinates mode */
  100098. static readonly TEXTURE_PROJECTION_MODE: number;
  100099. /** Skybox coordinates mode */
  100100. static readonly TEXTURE_SKYBOX_MODE: number;
  100101. /** Inverse Cubic coordinates mode */
  100102. static readonly TEXTURE_INVCUBIC_MODE: number;
  100103. /** Equirectangular coordinates mode */
  100104. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  100105. /** Equirectangular Fixed coordinates mode */
  100106. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  100107. /** Equirectangular Fixed Mirrored coordinates mode */
  100108. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  100109. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  100110. static readonly SCALEMODE_FLOOR: number;
  100111. /** Defines that texture rescaling will look for the nearest power of 2 size */
  100112. static readonly SCALEMODE_NEAREST: number;
  100113. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  100114. static readonly SCALEMODE_CEILING: number;
  100115. /**
  100116. * Returns the current npm package of the sdk
  100117. */
  100118. static readonly NpmPackage: string;
  100119. /**
  100120. * Returns the current version of the framework
  100121. */
  100122. static readonly Version: string;
  100123. /** Gets the list of created engines */
  100124. static readonly Instances: Engine[];
  100125. /**
  100126. * Gets the latest created engine
  100127. */
  100128. static readonly LastCreatedEngine: Nullable<Engine>;
  100129. /**
  100130. * Gets the latest created scene
  100131. */
  100132. static readonly LastCreatedScene: Nullable<Scene>;
  100133. /**
  100134. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  100135. * @param flag defines which part of the materials must be marked as dirty
  100136. * @param predicate defines a predicate used to filter which materials should be affected
  100137. */
  100138. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  100139. /**
  100140. * Method called to create the default loading screen.
  100141. * This can be overriden in your own app.
  100142. * @param canvas The rendering canvas element
  100143. * @returns The loading screen
  100144. */
  100145. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  100146. /**
  100147. * Method called to create the default rescale post process on each engine.
  100148. */
  100149. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  100150. /**
  100151. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  100152. **/
  100153. enableOfflineSupport: boolean;
  100154. /**
  100155. * 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)
  100156. **/
  100157. disableManifestCheck: boolean;
  100158. /**
  100159. * Gets the list of created scenes
  100160. */
  100161. scenes: Scene[];
  100162. /**
  100163. * Event raised when a new scene is created
  100164. */
  100165. onNewSceneAddedObservable: Observable<Scene>;
  100166. /**
  100167. * Gets the list of created postprocesses
  100168. */
  100169. postProcesses: PostProcess[];
  100170. /**
  100171. * Gets a boolean indicating if the pointer is currently locked
  100172. */
  100173. isPointerLock: boolean;
  100174. /**
  100175. * Observable event triggered each time the rendering canvas is resized
  100176. */
  100177. onResizeObservable: Observable<Engine>;
  100178. /**
  100179. * Observable event triggered each time the canvas loses focus
  100180. */
  100181. onCanvasBlurObservable: Observable<Engine>;
  100182. /**
  100183. * Observable event triggered each time the canvas gains focus
  100184. */
  100185. onCanvasFocusObservable: Observable<Engine>;
  100186. /**
  100187. * Observable event triggered each time the canvas receives pointerout event
  100188. */
  100189. onCanvasPointerOutObservable: Observable<PointerEvent>;
  100190. /**
  100191. * Observable raised when the engine begins a new frame
  100192. */
  100193. onBeginFrameObservable: Observable<Engine>;
  100194. /**
  100195. * If set, will be used to request the next animation frame for the render loop
  100196. */
  100197. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  100198. /**
  100199. * Observable raised when the engine ends the current frame
  100200. */
  100201. onEndFrameObservable: Observable<Engine>;
  100202. /**
  100203. * Observable raised when the engine is about to compile a shader
  100204. */
  100205. onBeforeShaderCompilationObservable: Observable<Engine>;
  100206. /**
  100207. * Observable raised when the engine has jsut compiled a shader
  100208. */
  100209. onAfterShaderCompilationObservable: Observable<Engine>;
  100210. /**
  100211. * Gets the audio engine
  100212. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  100213. * @ignorenaming
  100214. */
  100215. static audioEngine: IAudioEngine;
  100216. /**
  100217. * Default AudioEngine factory responsible of creating the Audio Engine.
  100218. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  100219. */
  100220. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  100221. /**
  100222. * Default offline support factory responsible of creating a tool used to store data locally.
  100223. * By default, this will create a Database object if the workload has been embedded.
  100224. */
  100225. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  100226. private _loadingScreen;
  100227. private _pointerLockRequested;
  100228. private _dummyFramebuffer;
  100229. private _rescalePostProcess;
  100230. /** @hidden */
  100231. protected _alphaMode: number;
  100232. /** @hidden */
  100233. protected _alphaEquation: number;
  100234. private _deterministicLockstep;
  100235. private _lockstepMaxSteps;
  100236. private _timeStep;
  100237. protected readonly _supportsHardwareTextureRescaling: boolean;
  100238. private _fps;
  100239. private _deltaTime;
  100240. /** @hidden */
  100241. _drawCalls: PerfCounter;
  100242. /**
  100243. * Turn this value on if you want to pause FPS computation when in background
  100244. */
  100245. disablePerformanceMonitorInBackground: boolean;
  100246. private _performanceMonitor;
  100247. /**
  100248. * Gets the performance monitor attached to this engine
  100249. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  100250. */
  100251. readonly performanceMonitor: PerformanceMonitor;
  100252. private _onFocus;
  100253. private _onBlur;
  100254. private _onCanvasPointerOut;
  100255. private _onCanvasBlur;
  100256. private _onCanvasFocus;
  100257. private _onFullscreenChange;
  100258. private _onPointerLockChange;
  100259. /**
  100260. * Gets the HTML element used to attach event listeners
  100261. * @returns a HTML element
  100262. */
  100263. getInputElement(): Nullable<HTMLElement>;
  100264. /**
  100265. * Creates a new engine
  100266. * @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
  100267. * @param antialias defines enable antialiasing (default: false)
  100268. * @param options defines further options to be sent to the getContext() function
  100269. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  100270. */
  100271. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  100272. /**
  100273. * Gets current aspect ratio
  100274. * @param viewportOwner defines the camera to use to get the aspect ratio
  100275. * @param useScreen defines if screen size must be used (or the current render target if any)
  100276. * @returns a number defining the aspect ratio
  100277. */
  100278. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  100279. /**
  100280. * Gets current screen aspect ratio
  100281. * @returns a number defining the aspect ratio
  100282. */
  100283. getScreenAspectRatio(): number;
  100284. /**
  100285. * Gets the client rect of the HTML canvas attached with the current webGL context
  100286. * @returns a client rectanglee
  100287. */
  100288. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  100289. /**
  100290. * Gets the client rect of the HTML element used for events
  100291. * @returns a client rectanglee
  100292. */
  100293. getInputElementClientRect(): Nullable<ClientRect>;
  100294. /**
  100295. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  100296. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  100297. * @returns true if engine is in deterministic lock step mode
  100298. */
  100299. isDeterministicLockStep(): boolean;
  100300. /**
  100301. * Gets the max steps when engine is running in deterministic lock step
  100302. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  100303. * @returns the max steps
  100304. */
  100305. getLockstepMaxSteps(): number;
  100306. /**
  100307. * Returns the time in ms between steps when using deterministic lock step.
  100308. * @returns time step in (ms)
  100309. */
  100310. getTimeStep(): number;
  100311. /**
  100312. * Force the mipmap generation for the given render target texture
  100313. * @param texture defines the render target texture to use
  100314. */
  100315. generateMipMapsForCubemap(texture: InternalTexture): void;
  100316. /** States */
  100317. /**
  100318. * Set various states to the webGL context
  100319. * @param culling defines backface culling state
  100320. * @param zOffset defines the value to apply to zOffset (0 by default)
  100321. * @param force defines if states must be applied even if cache is up to date
  100322. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  100323. */
  100324. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  100325. /**
  100326. * Set the z offset to apply to current rendering
  100327. * @param value defines the offset to apply
  100328. */
  100329. setZOffset(value: number): void;
  100330. /**
  100331. * Gets the current value of the zOffset
  100332. * @returns the current zOffset state
  100333. */
  100334. getZOffset(): number;
  100335. /**
  100336. * Enable or disable depth buffering
  100337. * @param enable defines the state to set
  100338. */
  100339. setDepthBuffer(enable: boolean): void;
  100340. /**
  100341. * Gets a boolean indicating if depth writing is enabled
  100342. * @returns the current depth writing state
  100343. */
  100344. getDepthWrite(): boolean;
  100345. /**
  100346. * Enable or disable depth writing
  100347. * @param enable defines the state to set
  100348. */
  100349. setDepthWrite(enable: boolean): void;
  100350. /**
  100351. * Enable or disable color writing
  100352. * @param enable defines the state to set
  100353. */
  100354. setColorWrite(enable: boolean): void;
  100355. /**
  100356. * Gets a boolean indicating if color writing is enabled
  100357. * @returns the current color writing state
  100358. */
  100359. getColorWrite(): boolean;
  100360. /**
  100361. * Sets alpha constants used by some alpha blending modes
  100362. * @param r defines the red component
  100363. * @param g defines the green component
  100364. * @param b defines the blue component
  100365. * @param a defines the alpha component
  100366. */
  100367. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  100368. /**
  100369. * Sets the current alpha mode
  100370. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  100371. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  100372. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  100373. */
  100374. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  100375. /**
  100376. * Gets the current alpha mode
  100377. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  100378. * @returns the current alpha mode
  100379. */
  100380. getAlphaMode(): number;
  100381. /**
  100382. * Sets the current alpha equation
  100383. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  100384. */
  100385. setAlphaEquation(equation: number): void;
  100386. /**
  100387. * Gets the current alpha equation.
  100388. * @returns the current alpha equation
  100389. */
  100390. getAlphaEquation(): number;
  100391. /**
  100392. * Gets a boolean indicating if stencil buffer is enabled
  100393. * @returns the current stencil buffer state
  100394. */
  100395. getStencilBuffer(): boolean;
  100396. /**
  100397. * Enable or disable the stencil buffer
  100398. * @param enable defines if the stencil buffer must be enabled or disabled
  100399. */
  100400. setStencilBuffer(enable: boolean): void;
  100401. /**
  100402. * Gets the current stencil mask
  100403. * @returns a number defining the new stencil mask to use
  100404. */
  100405. getStencilMask(): number;
  100406. /**
  100407. * Sets the current stencil mask
  100408. * @param mask defines the new stencil mask to use
  100409. */
  100410. setStencilMask(mask: number): void;
  100411. /**
  100412. * Gets the current stencil function
  100413. * @returns a number defining the stencil function to use
  100414. */
  100415. getStencilFunction(): number;
  100416. /**
  100417. * Gets the current stencil reference value
  100418. * @returns a number defining the stencil reference value to use
  100419. */
  100420. getStencilFunctionReference(): number;
  100421. /**
  100422. * Gets the current stencil mask
  100423. * @returns a number defining the stencil mask to use
  100424. */
  100425. getStencilFunctionMask(): number;
  100426. /**
  100427. * Sets the current stencil function
  100428. * @param stencilFunc defines the new stencil function to use
  100429. */
  100430. setStencilFunction(stencilFunc: number): void;
  100431. /**
  100432. * Sets the current stencil reference
  100433. * @param reference defines the new stencil reference to use
  100434. */
  100435. setStencilFunctionReference(reference: number): void;
  100436. /**
  100437. * Sets the current stencil mask
  100438. * @param mask defines the new stencil mask to use
  100439. */
  100440. setStencilFunctionMask(mask: number): void;
  100441. /**
  100442. * Gets the current stencil operation when stencil fails
  100443. * @returns a number defining stencil operation to use when stencil fails
  100444. */
  100445. getStencilOperationFail(): number;
  100446. /**
  100447. * Gets the current stencil operation when depth fails
  100448. * @returns a number defining stencil operation to use when depth fails
  100449. */
  100450. getStencilOperationDepthFail(): number;
  100451. /**
  100452. * Gets the current stencil operation when stencil passes
  100453. * @returns a number defining stencil operation to use when stencil passes
  100454. */
  100455. getStencilOperationPass(): number;
  100456. /**
  100457. * Sets the stencil operation to use when stencil fails
  100458. * @param operation defines the stencil operation to use when stencil fails
  100459. */
  100460. setStencilOperationFail(operation: number): void;
  100461. /**
  100462. * Sets the stencil operation to use when depth fails
  100463. * @param operation defines the stencil operation to use when depth fails
  100464. */
  100465. setStencilOperationDepthFail(operation: number): void;
  100466. /**
  100467. * Sets the stencil operation to use when stencil passes
  100468. * @param operation defines the stencil operation to use when stencil passes
  100469. */
  100470. setStencilOperationPass(operation: number): void;
  100471. /**
  100472. * Sets a boolean indicating if the dithering state is enabled or disabled
  100473. * @param value defines the dithering state
  100474. */
  100475. setDitheringState(value: boolean): void;
  100476. /**
  100477. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  100478. * @param value defines the rasterizer state
  100479. */
  100480. setRasterizerState(value: boolean): void;
  100481. /**
  100482. * Gets the current depth function
  100483. * @returns a number defining the depth function
  100484. */
  100485. getDepthFunction(): Nullable<number>;
  100486. /**
  100487. * Sets the current depth function
  100488. * @param depthFunc defines the function to use
  100489. */
  100490. setDepthFunction(depthFunc: number): void;
  100491. /**
  100492. * Sets the current depth function to GREATER
  100493. */
  100494. setDepthFunctionToGreater(): void;
  100495. /**
  100496. * Sets the current depth function to GEQUAL
  100497. */
  100498. setDepthFunctionToGreaterOrEqual(): void;
  100499. /**
  100500. * Sets the current depth function to LESS
  100501. */
  100502. setDepthFunctionToLess(): void;
  100503. /**
  100504. * Sets the current depth function to LEQUAL
  100505. */
  100506. setDepthFunctionToLessOrEqual(): void;
  100507. private _cachedStencilBuffer;
  100508. private _cachedStencilFunction;
  100509. private _cachedStencilMask;
  100510. private _cachedStencilOperationPass;
  100511. private _cachedStencilOperationFail;
  100512. private _cachedStencilOperationDepthFail;
  100513. private _cachedStencilReference;
  100514. /**
  100515. * Caches the the state of the stencil buffer
  100516. */
  100517. cacheStencilState(): void;
  100518. /**
  100519. * Restores the state of the stencil buffer
  100520. */
  100521. restoreStencilState(): void;
  100522. /**
  100523. * Directly set the WebGL Viewport
  100524. * @param x defines the x coordinate of the viewport (in screen space)
  100525. * @param y defines the y coordinate of the viewport (in screen space)
  100526. * @param width defines the width of the viewport (in screen space)
  100527. * @param height defines the height of the viewport (in screen space)
  100528. * @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
  100529. */
  100530. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  100531. /**
  100532. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  100533. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  100534. * @param y defines the y-coordinate of the corner of the clear rectangle
  100535. * @param width defines the width of the clear rectangle
  100536. * @param height defines the height of the clear rectangle
  100537. * @param clearColor defines the clear color
  100538. */
  100539. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  100540. /**
  100541. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  100542. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  100543. * @param y defines the y-coordinate of the corner of the clear rectangle
  100544. * @param width defines the width of the clear rectangle
  100545. * @param height defines the height of the clear rectangle
  100546. */
  100547. enableScissor(x: number, y: number, width: number, height: number): void;
  100548. /**
  100549. * Disable previously set scissor test rectangle
  100550. */
  100551. disableScissor(): void;
  100552. protected _reportDrawCall(): void;
  100553. /**
  100554. * Initializes a webVR display and starts listening to display change events
  100555. * The onVRDisplayChangedObservable will be notified upon these changes
  100556. * @returns The onVRDisplayChangedObservable
  100557. */
  100558. initWebVR(): Observable<IDisplayChangedEventArgs>;
  100559. /** @hidden */
  100560. _prepareVRComponent(): void;
  100561. /** @hidden */
  100562. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  100563. /** @hidden */
  100564. _submitVRFrame(): void;
  100565. /**
  100566. * Call this function to leave webVR mode
  100567. * Will do nothing if webVR is not supported or if there is no webVR device
  100568. * @see http://doc.babylonjs.com/how_to/webvr_camera
  100569. */
  100570. disableVR(): void;
  100571. /**
  100572. * Gets a boolean indicating that the system is in VR mode and is presenting
  100573. * @returns true if VR mode is engaged
  100574. */
  100575. isVRPresenting(): boolean;
  100576. /** @hidden */
  100577. _requestVRFrame(): void;
  100578. /** @hidden */
  100579. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  100580. /**
  100581. * Gets the source code of the vertex shader associated with a specific webGL program
  100582. * @param program defines the program to use
  100583. * @returns a string containing the source code of the vertex shader associated with the program
  100584. */
  100585. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  100586. /**
  100587. * Gets the source code of the fragment shader associated with a specific webGL program
  100588. * @param program defines the program to use
  100589. * @returns a string containing the source code of the fragment shader associated with the program
  100590. */
  100591. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  100592. /**
  100593. * Reads pixels from the current frame buffer. Please note that this function can be slow
  100594. * @param x defines the x coordinate of the rectangle where pixels must be read
  100595. * @param y defines the y coordinate of the rectangle where pixels must be read
  100596. * @param width defines the width of the rectangle where pixels must be read
  100597. * @param height defines the height of the rectangle where pixels must be read
  100598. * @returns a Uint8Array containing RGBA colors
  100599. */
  100600. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  100601. /**
  100602. * Sets a depth stencil texture from a render target to the according uniform.
  100603. * @param channel The texture channel
  100604. * @param uniform The uniform to set
  100605. * @param texture The render target texture containing the depth stencil texture to apply
  100606. */
  100607. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  100608. /**
  100609. * Sets a texture to the webGL context from a postprocess
  100610. * @param channel defines the channel to use
  100611. * @param postProcess defines the source postprocess
  100612. */
  100613. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  100614. /**
  100615. * Binds the output of the passed in post process to the texture channel specified
  100616. * @param channel The channel the texture should be bound to
  100617. * @param postProcess The post process which's output should be bound
  100618. */
  100619. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  100620. /** @hidden */
  100621. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  100622. protected _rebuildBuffers(): void;
  100623. /** @hidden */
  100624. _renderFrame(): void;
  100625. _renderLoop(): void;
  100626. /** @hidden */
  100627. _renderViews(): boolean;
  100628. /**
  100629. * Toggle full screen mode
  100630. * @param requestPointerLock defines if a pointer lock should be requested from the user
  100631. */
  100632. switchFullscreen(requestPointerLock: boolean): void;
  100633. /**
  100634. * Enters full screen mode
  100635. * @param requestPointerLock defines if a pointer lock should be requested from the user
  100636. */
  100637. enterFullscreen(requestPointerLock: boolean): void;
  100638. /**
  100639. * Exits full screen mode
  100640. */
  100641. exitFullscreen(): void;
  100642. /**
  100643. * Enters Pointerlock mode
  100644. */
  100645. enterPointerlock(): void;
  100646. /**
  100647. * Exits Pointerlock mode
  100648. */
  100649. exitPointerlock(): void;
  100650. /**
  100651. * Begin a new frame
  100652. */
  100653. beginFrame(): void;
  100654. /**
  100655. * Enf the current frame
  100656. */
  100657. endFrame(): void;
  100658. resize(): void;
  100659. /**
  100660. * Set the compressed texture format to use, based on the formats you have, and the formats
  100661. * supported by the hardware / browser.
  100662. *
  100663. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  100664. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  100665. * to API arguments needed to compressed textures. This puts the burden on the container
  100666. * generator to house the arcane code for determining these for current & future formats.
  100667. *
  100668. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  100669. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  100670. *
  100671. * Note: The result of this call is not taken into account when a texture is base64.
  100672. *
  100673. * @param formatsAvailable defines the list of those format families you have created
  100674. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  100675. *
  100676. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  100677. * @returns The extension selected.
  100678. */
  100679. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  100680. /**
  100681. * Force a specific size of the canvas
  100682. * @param width defines the new canvas' width
  100683. * @param height defines the new canvas' height
  100684. */
  100685. setSize(width: number, height: number): void;
  100686. /**
  100687. * Updates a dynamic vertex buffer.
  100688. * @param vertexBuffer the vertex buffer to update
  100689. * @param data the data used to update the vertex buffer
  100690. * @param byteOffset the byte offset of the data
  100691. * @param byteLength the byte length of the data
  100692. */
  100693. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  100694. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  100695. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  100696. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  100697. _releaseTexture(texture: InternalTexture): void;
  100698. /**
  100699. * @hidden
  100700. * Rescales a texture
  100701. * @param source input texutre
  100702. * @param destination destination texture
  100703. * @param scene scene to use to render the resize
  100704. * @param internalFormat format to use when resizing
  100705. * @param onComplete callback to be called when resize has completed
  100706. */
  100707. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  100708. /**
  100709. * Gets the current framerate
  100710. * @returns a number representing the framerate
  100711. */
  100712. getFps(): number;
  100713. /**
  100714. * Gets the time spent between current and previous frame
  100715. * @returns a number representing the delta time in ms
  100716. */
  100717. getDeltaTime(): number;
  100718. private _measureFps;
  100719. /** @hidden */
  100720. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  100721. /**
  100722. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  100723. * @param renderTarget The render target to set the frame buffer for
  100724. */
  100725. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  100726. /**
  100727. * Update a dynamic index buffer
  100728. * @param indexBuffer defines the target index buffer
  100729. * @param indices defines the data to update
  100730. * @param offset defines the offset in the target index buffer where update should start
  100731. */
  100732. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  100733. /**
  100734. * Updates the sample count of a render target texture
  100735. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  100736. * @param texture defines the texture to update
  100737. * @param samples defines the sample count to set
  100738. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  100739. */
  100740. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  100741. /**
  100742. * Updates a depth texture Comparison Mode and Function.
  100743. * If the comparison Function is equal to 0, the mode will be set to none.
  100744. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  100745. * @param texture The texture to set the comparison function for
  100746. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  100747. */
  100748. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  100749. /**
  100750. * Creates a webGL buffer to use with instanciation
  100751. * @param capacity defines the size of the buffer
  100752. * @returns the webGL buffer
  100753. */
  100754. createInstancesBuffer(capacity: number): DataBuffer;
  100755. /**
  100756. * Delete a webGL buffer used with instanciation
  100757. * @param buffer defines the webGL buffer to delete
  100758. */
  100759. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  100760. /** @hidden */
  100761. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  100762. dispose(): void;
  100763. private _disableTouchAction;
  100764. /**
  100765. * Display the loading screen
  100766. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  100767. */
  100768. displayLoadingUI(): void;
  100769. /**
  100770. * Hide the loading screen
  100771. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  100772. */
  100773. hideLoadingUI(): void;
  100774. /**
  100775. * Gets the current loading screen object
  100776. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  100777. */
  100778. /**
  100779. * Sets the current loading screen object
  100780. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  100781. */
  100782. loadingScreen: ILoadingScreen;
  100783. /**
  100784. * Sets the current loading screen text
  100785. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  100786. */
  100787. loadingUIText: string;
  100788. /**
  100789. * Sets the current loading screen background color
  100790. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  100791. */
  100792. loadingUIBackgroundColor: string;
  100793. /** Pointerlock and fullscreen */
  100794. /**
  100795. * Ask the browser to promote the current element to pointerlock mode
  100796. * @param element defines the DOM element to promote
  100797. */
  100798. static _RequestPointerlock(element: HTMLElement): void;
  100799. /**
  100800. * Asks the browser to exit pointerlock mode
  100801. */
  100802. static _ExitPointerlock(): void;
  100803. /**
  100804. * Ask the browser to promote the current element to fullscreen rendering mode
  100805. * @param element defines the DOM element to promote
  100806. */
  100807. static _RequestFullscreen(element: HTMLElement): void;
  100808. /**
  100809. * Asks the browser to exit fullscreen mode
  100810. */
  100811. static _ExitFullscreen(): void;
  100812. }
  100813. }
  100814. declare module BABYLON {
  100815. /**
  100816. * The engine store class is responsible to hold all the instances of Engine and Scene created
  100817. * during the life time of the application.
  100818. */
  100819. export class EngineStore {
  100820. /** Gets the list of created engines */
  100821. static Instances: Engine[];
  100822. /** @hidden */
  100823. static _LastCreatedScene: Nullable<Scene>;
  100824. /**
  100825. * Gets the latest created engine
  100826. */
  100827. static readonly LastCreatedEngine: Nullable<Engine>;
  100828. /**
  100829. * Gets the latest created scene
  100830. */
  100831. static readonly LastCreatedScene: Nullable<Scene>;
  100832. /**
  100833. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  100834. * @ignorenaming
  100835. */
  100836. static UseFallbackTexture: boolean;
  100837. /**
  100838. * Texture content used if a texture cannot loaded
  100839. * @ignorenaming
  100840. */
  100841. static FallbackTexture: string;
  100842. }
  100843. }
  100844. declare module BABYLON {
  100845. /**
  100846. * Helper class that provides a small promise polyfill
  100847. */
  100848. export class PromisePolyfill {
  100849. /**
  100850. * Static function used to check if the polyfill is required
  100851. * If this is the case then the function will inject the polyfill to window.Promise
  100852. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  100853. */
  100854. static Apply(force?: boolean): void;
  100855. }
  100856. }
  100857. declare module BABYLON {
  100858. /**
  100859. * Interface for screenshot methods with describe argument called `size` as object with options
  100860. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  100861. */
  100862. export interface IScreenshotSize {
  100863. /**
  100864. * number in pixels for canvas height
  100865. */
  100866. height?: number;
  100867. /**
  100868. * multiplier allowing render at a higher or lower resolution
  100869. * If value is defined then height and width will be ignored and taken from camera
  100870. */
  100871. precision?: number;
  100872. /**
  100873. * number in pixels for canvas width
  100874. */
  100875. width?: number;
  100876. }
  100877. }
  100878. declare module BABYLON {
  100879. interface IColor4Like {
  100880. r: float;
  100881. g: float;
  100882. b: float;
  100883. a: float;
  100884. }
  100885. /**
  100886. * Class containing a set of static utilities functions
  100887. */
  100888. export class Tools {
  100889. /**
  100890. * Gets or sets the base URL to use to load assets
  100891. */
  100892. static BaseUrl: string;
  100893. /**
  100894. * Enable/Disable Custom HTTP Request Headers globally.
  100895. * default = false
  100896. * @see CustomRequestHeaders
  100897. */
  100898. static UseCustomRequestHeaders: boolean;
  100899. /**
  100900. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  100901. * i.e. when loading files, where the server/service expects an Authorization header
  100902. */
  100903. static CustomRequestHeaders: {
  100904. [key: string]: string;
  100905. };
  100906. /**
  100907. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  100908. */
  100909. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  100910. /**
  100911. * Default behaviour for cors in the application.
  100912. * It can be a string if the expected behavior is identical in the entire app.
  100913. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  100914. */
  100915. static CorsBehavior: string | ((url: string | string[]) => string);
  100916. /**
  100917. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  100918. * @ignorenaming
  100919. */
  100920. static UseFallbackTexture: boolean;
  100921. /**
  100922. * Use this object to register external classes like custom textures or material
  100923. * to allow the laoders to instantiate them
  100924. */
  100925. static RegisteredExternalClasses: {
  100926. [key: string]: Object;
  100927. };
  100928. /**
  100929. * Texture content used if a texture cannot loaded
  100930. * @ignorenaming
  100931. */
  100932. static fallbackTexture: string;
  100933. /**
  100934. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  100935. * @param u defines the coordinate on X axis
  100936. * @param v defines the coordinate on Y axis
  100937. * @param width defines the width of the source data
  100938. * @param height defines the height of the source data
  100939. * @param pixels defines the source byte array
  100940. * @param color defines the output color
  100941. */
  100942. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  100943. /**
  100944. * Interpolates between a and b via alpha
  100945. * @param a The lower value (returned when alpha = 0)
  100946. * @param b The upper value (returned when alpha = 1)
  100947. * @param alpha The interpolation-factor
  100948. * @return The mixed value
  100949. */
  100950. static Mix(a: number, b: number, alpha: number): number;
  100951. /**
  100952. * Tries to instantiate a new object from a given class name
  100953. * @param className defines the class name to instantiate
  100954. * @returns the new object or null if the system was not able to do the instantiation
  100955. */
  100956. static Instantiate(className: string): any;
  100957. /**
  100958. * Provides a slice function that will work even on IE
  100959. * @param data defines the array to slice
  100960. * @param start defines the start of the data (optional)
  100961. * @param end defines the end of the data (optional)
  100962. * @returns the new sliced array
  100963. */
  100964. static Slice<T>(data: T, start?: number, end?: number): T;
  100965. /**
  100966. * Polyfill for setImmediate
  100967. * @param action defines the action to execute after the current execution block
  100968. */
  100969. static SetImmediate(action: () => void): void;
  100970. /**
  100971. * Function indicating if a number is an exponent of 2
  100972. * @param value defines the value to test
  100973. * @returns true if the value is an exponent of 2
  100974. */
  100975. static IsExponentOfTwo(value: number): boolean;
  100976. private static _tmpFloatArray;
  100977. /**
  100978. * Returns the nearest 32-bit single precision float representation of a Number
  100979. * @param value A Number. If the parameter is of a different type, it will get converted
  100980. * to a number or to NaN if it cannot be converted
  100981. * @returns number
  100982. */
  100983. static FloatRound(value: number): number;
  100984. /**
  100985. * Extracts the filename from a path
  100986. * @param path defines the path to use
  100987. * @returns the filename
  100988. */
  100989. static GetFilename(path: string): string;
  100990. /**
  100991. * Extracts the "folder" part of a path (everything before the filename).
  100992. * @param uri The URI to extract the info from
  100993. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  100994. * @returns The "folder" part of the path
  100995. */
  100996. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  100997. /**
  100998. * Extracts text content from a DOM element hierarchy
  100999. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  101000. */
  101001. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  101002. /**
  101003. * Convert an angle in radians to degrees
  101004. * @param angle defines the angle to convert
  101005. * @returns the angle in degrees
  101006. */
  101007. static ToDegrees(angle: number): number;
  101008. /**
  101009. * Convert an angle in degrees to radians
  101010. * @param angle defines the angle to convert
  101011. * @returns the angle in radians
  101012. */
  101013. static ToRadians(angle: number): number;
  101014. /**
  101015. * Returns an array if obj is not an array
  101016. * @param obj defines the object to evaluate as an array
  101017. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  101018. * @returns either obj directly if obj is an array or a new array containing obj
  101019. */
  101020. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  101021. /**
  101022. * Gets the pointer prefix to use
  101023. * @returns "pointer" if touch is enabled. Else returns "mouse"
  101024. */
  101025. static GetPointerPrefix(): string;
  101026. /**
  101027. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  101028. * @param url define the url we are trying
  101029. * @param element define the dom element where to configure the cors policy
  101030. */
  101031. static SetCorsBehavior(url: string | string[], element: {
  101032. crossOrigin: string | null;
  101033. }): void;
  101034. /**
  101035. * Removes unwanted characters from an url
  101036. * @param url defines the url to clean
  101037. * @returns the cleaned url
  101038. */
  101039. static CleanUrl(url: string): string;
  101040. /**
  101041. * Gets or sets a function used to pre-process url before using them to load assets
  101042. */
  101043. static PreprocessUrl: (url: string) => string;
  101044. /**
  101045. * Loads an image as an HTMLImageElement.
  101046. * @param input url string, ArrayBuffer, or Blob to load
  101047. * @param onLoad callback called when the image successfully loads
  101048. * @param onError callback called when the image fails to load
  101049. * @param offlineProvider offline provider for caching
  101050. * @param mimeType optional mime type
  101051. * @returns the HTMLImageElement of the loaded image
  101052. */
  101053. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  101054. /**
  101055. * Loads a file from a url
  101056. * @param url url string, ArrayBuffer, or Blob to load
  101057. * @param onSuccess callback called when the file successfully loads
  101058. * @param onProgress callback called while file is loading (if the server supports this mode)
  101059. * @param offlineProvider defines the offline provider for caching
  101060. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  101061. * @param onError callback called when the file fails to load
  101062. * @returns a file request object
  101063. */
  101064. 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;
  101065. /**
  101066. * Loads a file from a url
  101067. * @param url the file url to load
  101068. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  101069. */
  101070. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  101071. /**
  101072. * Load a script (identified by an url). When the url returns, the
  101073. * content of this file is added into a new script element, attached to the DOM (body element)
  101074. * @param scriptUrl defines the url of the script to laod
  101075. * @param onSuccess defines the callback called when the script is loaded
  101076. * @param onError defines the callback to call if an error occurs
  101077. * @param scriptId defines the id of the script element
  101078. */
  101079. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  101080. /**
  101081. * Load an asynchronous script (identified by an url). When the url returns, the
  101082. * content of this file is added into a new script element, attached to the DOM (body element)
  101083. * @param scriptUrl defines the url of the script to laod
  101084. * @param scriptId defines the id of the script element
  101085. * @returns a promise request object
  101086. */
  101087. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  101088. /**
  101089. * Loads a file from a blob
  101090. * @param fileToLoad defines the blob to use
  101091. * @param callback defines the callback to call when data is loaded
  101092. * @param progressCallback defines the callback to call during loading process
  101093. * @returns a file request object
  101094. */
  101095. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  101096. /**
  101097. * Reads a file from a File object
  101098. * @param file defines the file to load
  101099. * @param onSuccess defines the callback to call when data is loaded
  101100. * @param onProgress defines the callback to call during loading process
  101101. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  101102. * @param onError defines the callback to call when an error occurs
  101103. * @returns a file request object
  101104. */
  101105. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  101106. /**
  101107. * Creates a data url from a given string content
  101108. * @param content defines the content to convert
  101109. * @returns the new data url link
  101110. */
  101111. static FileAsURL(content: string): string;
  101112. /**
  101113. * Format the given number to a specific decimal format
  101114. * @param value defines the number to format
  101115. * @param decimals defines the number of decimals to use
  101116. * @returns the formatted string
  101117. */
  101118. static Format(value: number, decimals?: number): string;
  101119. /**
  101120. * Tries to copy an object by duplicating every property
  101121. * @param source defines the source object
  101122. * @param destination defines the target object
  101123. * @param doNotCopyList defines a list of properties to avoid
  101124. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  101125. */
  101126. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  101127. /**
  101128. * Gets a boolean indicating if the given object has no own property
  101129. * @param obj defines the object to test
  101130. * @returns true if object has no own property
  101131. */
  101132. static IsEmpty(obj: any): boolean;
  101133. /**
  101134. * Function used to register events at window level
  101135. * @param windowElement defines the Window object to use
  101136. * @param events defines the events to register
  101137. */
  101138. static RegisterTopRootEvents(windowElement: Window, events: {
  101139. name: string;
  101140. handler: Nullable<(e: FocusEvent) => any>;
  101141. }[]): void;
  101142. /**
  101143. * Function used to unregister events from window level
  101144. * @param windowElement defines the Window object to use
  101145. * @param events defines the events to unregister
  101146. */
  101147. static UnregisterTopRootEvents(windowElement: Window, events: {
  101148. name: string;
  101149. handler: Nullable<(e: FocusEvent) => any>;
  101150. }[]): void;
  101151. /**
  101152. * @ignore
  101153. */
  101154. static _ScreenshotCanvas: HTMLCanvasElement;
  101155. /**
  101156. * Dumps the current bound framebuffer
  101157. * @param width defines the rendering width
  101158. * @param height defines the rendering height
  101159. * @param engine defines the hosting engine
  101160. * @param successCallback defines the callback triggered once the data are available
  101161. * @param mimeType defines the mime type of the result
  101162. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  101163. */
  101164. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  101165. /**
  101166. * Converts the canvas data to blob.
  101167. * This acts as a polyfill for browsers not supporting the to blob function.
  101168. * @param canvas Defines the canvas to extract the data from
  101169. * @param successCallback Defines the callback triggered once the data are available
  101170. * @param mimeType Defines the mime type of the result
  101171. */
  101172. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  101173. /**
  101174. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  101175. * @param successCallback defines the callback triggered once the data are available
  101176. * @param mimeType defines the mime type of the result
  101177. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  101178. */
  101179. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  101180. /**
  101181. * Downloads a blob in the browser
  101182. * @param blob defines the blob to download
  101183. * @param fileName defines the name of the downloaded file
  101184. */
  101185. static Download(blob: Blob, fileName: string): void;
  101186. /**
  101187. * Captures a screenshot of the current rendering
  101188. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  101189. * @param engine defines the rendering engine
  101190. * @param camera defines the source camera
  101191. * @param size This parameter can be set to a single number or to an object with the
  101192. * following (optional) properties: precision, width, height. If a single number is passed,
  101193. * it will be used for both width and height. If an object is passed, the screenshot size
  101194. * will be derived from the parameters. The precision property is a multiplier allowing
  101195. * rendering at a higher or lower resolution
  101196. * @param successCallback defines the callback receives a single parameter which contains the
  101197. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  101198. * src parameter of an <img> to display it
  101199. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  101200. * Check your browser for supported MIME types
  101201. */
  101202. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  101203. /**
  101204. * Captures a screenshot of the current rendering
  101205. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  101206. * @param engine defines the rendering engine
  101207. * @param camera defines the source camera
  101208. * @param size This parameter can be set to a single number or to an object with the
  101209. * following (optional) properties: precision, width, height. If a single number is passed,
  101210. * it will be used for both width and height. If an object is passed, the screenshot size
  101211. * will be derived from the parameters. The precision property is a multiplier allowing
  101212. * rendering at a higher or lower resolution
  101213. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  101214. * Check your browser for supported MIME types
  101215. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  101216. * to the src parameter of an <img> to display it
  101217. */
  101218. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  101219. /**
  101220. * Generates an image screenshot from the specified camera.
  101221. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  101222. * @param engine The engine to use for rendering
  101223. * @param camera The camera to use for rendering
  101224. * @param size This parameter can be set to a single number or to an object with the
  101225. * following (optional) properties: precision, width, height. If a single number is passed,
  101226. * it will be used for both width and height. If an object is passed, the screenshot size
  101227. * will be derived from the parameters. The precision property is a multiplier allowing
  101228. * rendering at a higher or lower resolution
  101229. * @param successCallback The callback receives a single parameter which contains the
  101230. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  101231. * src parameter of an <img> to display it
  101232. * @param mimeType The MIME type of the screenshot image (default: image/png).
  101233. * Check your browser for supported MIME types
  101234. * @param samples Texture samples (default: 1)
  101235. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  101236. * @param fileName A name for for the downloaded file.
  101237. */
  101238. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  101239. /**
  101240. * Generates an image screenshot from the specified camera.
  101241. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  101242. * @param engine The engine to use for rendering
  101243. * @param camera The camera to use for rendering
  101244. * @param size This parameter can be set to a single number or to an object with the
  101245. * following (optional) properties: precision, width, height. If a single number is passed,
  101246. * it will be used for both width and height. If an object is passed, the screenshot size
  101247. * will be derived from the parameters. The precision property is a multiplier allowing
  101248. * rendering at a higher or lower resolution
  101249. * @param mimeType The MIME type of the screenshot image (default: image/png).
  101250. * Check your browser for supported MIME types
  101251. * @param samples Texture samples (default: 1)
  101252. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  101253. * @param fileName A name for for the downloaded file.
  101254. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  101255. * to the src parameter of an <img> to display it
  101256. */
  101257. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  101258. /**
  101259. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  101260. * Be aware Math.random() could cause collisions, but:
  101261. * "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"
  101262. * @returns a pseudo random id
  101263. */
  101264. static RandomId(): string;
  101265. /**
  101266. * Test if the given uri is a base64 string
  101267. * @param uri The uri to test
  101268. * @return True if the uri is a base64 string or false otherwise
  101269. */
  101270. static IsBase64(uri: string): boolean;
  101271. /**
  101272. * Decode the given base64 uri.
  101273. * @param uri The uri to decode
  101274. * @return The decoded base64 data.
  101275. */
  101276. static DecodeBase64(uri: string): ArrayBuffer;
  101277. /**
  101278. * Gets the absolute url.
  101279. * @param url the input url
  101280. * @return the absolute url
  101281. */
  101282. static GetAbsoluteUrl(url: string): string;
  101283. /**
  101284. * No log
  101285. */
  101286. static readonly NoneLogLevel: number;
  101287. /**
  101288. * Only message logs
  101289. */
  101290. static readonly MessageLogLevel: number;
  101291. /**
  101292. * Only warning logs
  101293. */
  101294. static readonly WarningLogLevel: number;
  101295. /**
  101296. * Only error logs
  101297. */
  101298. static readonly ErrorLogLevel: number;
  101299. /**
  101300. * All logs
  101301. */
  101302. static readonly AllLogLevel: number;
  101303. /**
  101304. * Gets a value indicating the number of loading errors
  101305. * @ignorenaming
  101306. */
  101307. static readonly errorsCount: number;
  101308. /**
  101309. * Callback called when a new log is added
  101310. */
  101311. static OnNewCacheEntry: (entry: string) => void;
  101312. /**
  101313. * Log a message to the console
  101314. * @param message defines the message to log
  101315. */
  101316. static Log(message: string): void;
  101317. /**
  101318. * Write a warning message to the console
  101319. * @param message defines the message to log
  101320. */
  101321. static Warn(message: string): void;
  101322. /**
  101323. * Write an error message to the console
  101324. * @param message defines the message to log
  101325. */
  101326. static Error(message: string): void;
  101327. /**
  101328. * Gets current log cache (list of logs)
  101329. */
  101330. static readonly LogCache: string;
  101331. /**
  101332. * Clears the log cache
  101333. */
  101334. static ClearLogCache(): void;
  101335. /**
  101336. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  101337. */
  101338. static LogLevels: number;
  101339. /**
  101340. * Checks if the window object exists
  101341. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  101342. */
  101343. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  101344. /**
  101345. * No performance log
  101346. */
  101347. static readonly PerformanceNoneLogLevel: number;
  101348. /**
  101349. * Use user marks to log performance
  101350. */
  101351. static readonly PerformanceUserMarkLogLevel: number;
  101352. /**
  101353. * Log performance to the console
  101354. */
  101355. static readonly PerformanceConsoleLogLevel: number;
  101356. private static _performance;
  101357. /**
  101358. * Sets the current performance log level
  101359. */
  101360. static PerformanceLogLevel: number;
  101361. private static _StartPerformanceCounterDisabled;
  101362. private static _EndPerformanceCounterDisabled;
  101363. private static _StartUserMark;
  101364. private static _EndUserMark;
  101365. private static _StartPerformanceConsole;
  101366. private static _EndPerformanceConsole;
  101367. /**
  101368. * Starts a performance counter
  101369. */
  101370. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  101371. /**
  101372. * Ends a specific performance coutner
  101373. */
  101374. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  101375. /**
  101376. * Gets either window.performance.now() if supported or Date.now() else
  101377. */
  101378. static readonly Now: number;
  101379. /**
  101380. * This method will return the name of the class used to create the instance of the given object.
  101381. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  101382. * @param object the object to get the class name from
  101383. * @param isType defines if the object is actually a type
  101384. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  101385. */
  101386. static GetClassName(object: any, isType?: boolean): string;
  101387. /**
  101388. * Gets the first element of an array satisfying a given predicate
  101389. * @param array defines the array to browse
  101390. * @param predicate defines the predicate to use
  101391. * @returns null if not found or the element
  101392. */
  101393. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  101394. /**
  101395. * This method will return the name of the full name of the class, including its owning module (if any).
  101396. * 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).
  101397. * @param object the object to get the class name from
  101398. * @param isType defines if the object is actually a type
  101399. * @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.
  101400. * @ignorenaming
  101401. */
  101402. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  101403. /**
  101404. * Returns a promise that resolves after the given amount of time.
  101405. * @param delay Number of milliseconds to delay
  101406. * @returns Promise that resolves after the given amount of time
  101407. */
  101408. static DelayAsync(delay: number): Promise<void>;
  101409. }
  101410. /**
  101411. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  101412. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  101413. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  101414. * @param name The name of the class, case should be preserved
  101415. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  101416. */
  101417. export function className(name: string, module?: string): (target: Object) => void;
  101418. /**
  101419. * An implementation of a loop for asynchronous functions.
  101420. */
  101421. export class AsyncLoop {
  101422. /**
  101423. * Defines the number of iterations for the loop
  101424. */
  101425. iterations: number;
  101426. /**
  101427. * Defines the current index of the loop.
  101428. */
  101429. index: number;
  101430. private _done;
  101431. private _fn;
  101432. private _successCallback;
  101433. /**
  101434. * Constructor.
  101435. * @param iterations the number of iterations.
  101436. * @param func the function to run each iteration
  101437. * @param successCallback the callback that will be called upon succesful execution
  101438. * @param offset starting offset.
  101439. */
  101440. constructor(
  101441. /**
  101442. * Defines the number of iterations for the loop
  101443. */
  101444. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  101445. /**
  101446. * Execute the next iteration. Must be called after the last iteration was finished.
  101447. */
  101448. executeNext(): void;
  101449. /**
  101450. * Break the loop and run the success callback.
  101451. */
  101452. breakLoop(): void;
  101453. /**
  101454. * Create and run an async loop.
  101455. * @param iterations the number of iterations.
  101456. * @param fn the function to run each iteration
  101457. * @param successCallback the callback that will be called upon succesful execution
  101458. * @param offset starting offset.
  101459. * @returns the created async loop object
  101460. */
  101461. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  101462. /**
  101463. * A for-loop that will run a given number of iterations synchronous and the rest async.
  101464. * @param iterations total number of iterations
  101465. * @param syncedIterations number of synchronous iterations in each async iteration.
  101466. * @param fn the function to call each iteration.
  101467. * @param callback a success call back that will be called when iterating stops.
  101468. * @param breakFunction a break condition (optional)
  101469. * @param timeout timeout settings for the setTimeout function. default - 0.
  101470. * @returns the created async loop object
  101471. */
  101472. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  101473. }
  101474. }
  101475. declare module BABYLON {
  101476. /**
  101477. * This class implement a typical dictionary using a string as key and the generic type T as value.
  101478. * The underlying implementation relies on an associative array to ensure the best performances.
  101479. * The value can be anything including 'null' but except 'undefined'
  101480. */
  101481. export class StringDictionary<T> {
  101482. /**
  101483. * This will clear this dictionary and copy the content from the 'source' one.
  101484. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  101485. * @param source the dictionary to take the content from and copy to this dictionary
  101486. */
  101487. copyFrom(source: StringDictionary<T>): void;
  101488. /**
  101489. * Get a value based from its key
  101490. * @param key the given key to get the matching value from
  101491. * @return the value if found, otherwise undefined is returned
  101492. */
  101493. get(key: string): T | undefined;
  101494. /**
  101495. * Get a value from its key or add it if it doesn't exist.
  101496. * This method will ensure you that a given key/data will be present in the dictionary.
  101497. * @param key the given key to get the matching value from
  101498. * @param factory the factory that will create the value if the key is not present in the dictionary.
  101499. * The factory will only be invoked if there's no data for the given key.
  101500. * @return the value corresponding to the key.
  101501. */
  101502. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  101503. /**
  101504. * Get a value from its key if present in the dictionary otherwise add it
  101505. * @param key the key to get the value from
  101506. * @param val if there's no such key/value pair in the dictionary add it with this value
  101507. * @return the value corresponding to the key
  101508. */
  101509. getOrAdd(key: string, val: T): T;
  101510. /**
  101511. * Check if there's a given key in the dictionary
  101512. * @param key the key to check for
  101513. * @return true if the key is present, false otherwise
  101514. */
  101515. contains(key: string): boolean;
  101516. /**
  101517. * Add a new key and its corresponding value
  101518. * @param key the key to add
  101519. * @param value the value corresponding to the key
  101520. * @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
  101521. */
  101522. add(key: string, value: T): boolean;
  101523. /**
  101524. * Update a specific value associated to a key
  101525. * @param key defines the key to use
  101526. * @param value defines the value to store
  101527. * @returns true if the value was updated (or false if the key was not found)
  101528. */
  101529. set(key: string, value: T): boolean;
  101530. /**
  101531. * Get the element of the given key and remove it from the dictionary
  101532. * @param key defines the key to search
  101533. * @returns the value associated with the key or null if not found
  101534. */
  101535. getAndRemove(key: string): Nullable<T>;
  101536. /**
  101537. * Remove a key/value from the dictionary.
  101538. * @param key the key to remove
  101539. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  101540. */
  101541. remove(key: string): boolean;
  101542. /**
  101543. * Clear the whole content of the dictionary
  101544. */
  101545. clear(): void;
  101546. /**
  101547. * Gets the current count
  101548. */
  101549. readonly count: number;
  101550. /**
  101551. * Execute a callback on each key/val of the dictionary.
  101552. * Note that you can remove any element in this dictionary in the callback implementation
  101553. * @param callback the callback to execute on a given key/value pair
  101554. */
  101555. forEach(callback: (key: string, val: T) => void): void;
  101556. /**
  101557. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  101558. * If the callback returns null or undefined the method will iterate to the next key/value pair
  101559. * Note that you can remove any element in this dictionary in the callback implementation
  101560. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  101561. * @returns the first item
  101562. */
  101563. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  101564. private _count;
  101565. private _data;
  101566. }
  101567. }
  101568. declare module BABYLON {
  101569. /** @hidden */
  101570. export interface ICollisionCoordinator {
  101571. createCollider(): Collider;
  101572. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  101573. init(scene: Scene): void;
  101574. }
  101575. /** @hidden */
  101576. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  101577. private _scene;
  101578. private _scaledPosition;
  101579. private _scaledVelocity;
  101580. private _finalPosition;
  101581. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  101582. createCollider(): Collider;
  101583. init(scene: Scene): void;
  101584. private _collideWithWorld;
  101585. }
  101586. }
  101587. declare module BABYLON {
  101588. /**
  101589. * Class used to manage all inputs for the scene.
  101590. */
  101591. export class InputManager {
  101592. /** The distance in pixel that you have to move to prevent some events */
  101593. static DragMovementThreshold: number;
  101594. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  101595. static LongPressDelay: number;
  101596. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  101597. static DoubleClickDelay: number;
  101598. /** If you need to check double click without raising a single click at first click, enable this flag */
  101599. static ExclusiveDoubleClickMode: boolean;
  101600. private _wheelEventName;
  101601. private _onPointerMove;
  101602. private _onPointerDown;
  101603. private _onPointerUp;
  101604. private _initClickEvent;
  101605. private _initActionManager;
  101606. private _delayedSimpleClick;
  101607. private _delayedSimpleClickTimeout;
  101608. private _previousDelayedSimpleClickTimeout;
  101609. private _meshPickProceed;
  101610. private _previousButtonPressed;
  101611. private _currentPickResult;
  101612. private _previousPickResult;
  101613. private _totalPointersPressed;
  101614. private _doubleClickOccured;
  101615. private _pointerOverMesh;
  101616. private _pickedDownMesh;
  101617. private _pickedUpMesh;
  101618. private _pointerX;
  101619. private _pointerY;
  101620. private _unTranslatedPointerX;
  101621. private _unTranslatedPointerY;
  101622. private _startingPointerPosition;
  101623. private _previousStartingPointerPosition;
  101624. private _startingPointerTime;
  101625. private _previousStartingPointerTime;
  101626. private _pointerCaptures;
  101627. private _onKeyDown;
  101628. private _onKeyUp;
  101629. private _onCanvasFocusObserver;
  101630. private _onCanvasBlurObserver;
  101631. private _scene;
  101632. /**
  101633. * Creates a new InputManager
  101634. * @param scene defines the hosting scene
  101635. */
  101636. constructor(scene: Scene);
  101637. /**
  101638. * Gets the mesh that is currently under the pointer
  101639. */
  101640. readonly meshUnderPointer: Nullable<AbstractMesh>;
  101641. /**
  101642. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  101643. */
  101644. readonly unTranslatedPointer: Vector2;
  101645. /**
  101646. * Gets or sets the current on-screen X position of the pointer
  101647. */
  101648. pointerX: number;
  101649. /**
  101650. * Gets or sets the current on-screen Y position of the pointer
  101651. */
  101652. pointerY: number;
  101653. private _updatePointerPosition;
  101654. private _processPointerMove;
  101655. private _setRayOnPointerInfo;
  101656. private _checkPrePointerObservable;
  101657. /**
  101658. * Use this method to simulate a pointer move on a mesh
  101659. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  101660. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  101661. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  101662. */
  101663. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  101664. /**
  101665. * Use this method to simulate a pointer down on a mesh
  101666. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  101667. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  101668. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  101669. */
  101670. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  101671. private _processPointerDown;
  101672. /** @hidden */
  101673. _isPointerSwiping(): boolean;
  101674. /**
  101675. * Use this method to simulate a pointer up on a mesh
  101676. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  101677. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  101678. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  101679. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  101680. */
  101681. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  101682. private _processPointerUp;
  101683. /**
  101684. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  101685. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  101686. * @returns true if the pointer was captured
  101687. */
  101688. isPointerCaptured(pointerId?: number): boolean;
  101689. /**
  101690. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  101691. * @param attachUp defines if you want to attach events to pointerup
  101692. * @param attachDown defines if you want to attach events to pointerdown
  101693. * @param attachMove defines if you want to attach events to pointermove
  101694. */
  101695. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  101696. /**
  101697. * Detaches all event handlers
  101698. */
  101699. detachControl(): void;
  101700. /**
  101701. * Force the value of meshUnderPointer
  101702. * @param mesh defines the mesh to use
  101703. */
  101704. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  101705. /**
  101706. * Gets the mesh under the pointer
  101707. * @returns a Mesh or null if no mesh is under the pointer
  101708. */
  101709. getPointerOverMesh(): Nullable<AbstractMesh>;
  101710. }
  101711. }
  101712. declare module BABYLON {
  101713. /**
  101714. * Helper class used to generate session unique ID
  101715. */
  101716. export class UniqueIdGenerator {
  101717. private static _UniqueIdCounter;
  101718. /**
  101719. * Gets an unique (relatively to the current scene) Id
  101720. */
  101721. static readonly UniqueId: number;
  101722. }
  101723. }
  101724. declare module BABYLON {
  101725. /**
  101726. * This class defines the direct association between an animation and a target
  101727. */
  101728. export class TargetedAnimation {
  101729. /**
  101730. * Animation to perform
  101731. */
  101732. animation: Animation;
  101733. /**
  101734. * Target to animate
  101735. */
  101736. target: any;
  101737. /**
  101738. * Serialize the object
  101739. * @returns the JSON object representing the current entity
  101740. */
  101741. serialize(): any;
  101742. }
  101743. /**
  101744. * Use this class to create coordinated animations on multiple targets
  101745. */
  101746. export class AnimationGroup implements IDisposable {
  101747. /** The name of the animation group */
  101748. name: string;
  101749. private _scene;
  101750. private _targetedAnimations;
  101751. private _animatables;
  101752. private _from;
  101753. private _to;
  101754. private _isStarted;
  101755. private _isPaused;
  101756. private _speedRatio;
  101757. private _loopAnimation;
  101758. /**
  101759. * Gets or sets the unique id of the node
  101760. */
  101761. uniqueId: number;
  101762. /**
  101763. * This observable will notify when one animation have ended
  101764. */
  101765. onAnimationEndObservable: Observable<TargetedAnimation>;
  101766. /**
  101767. * Observer raised when one animation loops
  101768. */
  101769. onAnimationLoopObservable: Observable<TargetedAnimation>;
  101770. /**
  101771. * Observer raised when all animations have looped
  101772. */
  101773. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  101774. /**
  101775. * This observable will notify when all animations have ended.
  101776. */
  101777. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  101778. /**
  101779. * This observable will notify when all animations have paused.
  101780. */
  101781. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  101782. /**
  101783. * This observable will notify when all animations are playing.
  101784. */
  101785. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  101786. /**
  101787. * Gets the first frame
  101788. */
  101789. readonly from: number;
  101790. /**
  101791. * Gets the last frame
  101792. */
  101793. readonly to: number;
  101794. /**
  101795. * Define if the animations are started
  101796. */
  101797. readonly isStarted: boolean;
  101798. /**
  101799. * Gets a value indicating that the current group is playing
  101800. */
  101801. readonly isPlaying: boolean;
  101802. /**
  101803. * Gets or sets the speed ratio to use for all animations
  101804. */
  101805. /**
  101806. * Gets or sets the speed ratio to use for all animations
  101807. */
  101808. speedRatio: number;
  101809. /**
  101810. * Gets or sets if all animations should loop or not
  101811. */
  101812. loopAnimation: boolean;
  101813. /**
  101814. * Gets the targeted animations for this animation group
  101815. */
  101816. readonly targetedAnimations: Array<TargetedAnimation>;
  101817. /**
  101818. * returning the list of animatables controlled by this animation group.
  101819. */
  101820. readonly animatables: Array<Animatable>;
  101821. /**
  101822. * Instantiates a new Animation Group.
  101823. * This helps managing several animations at once.
  101824. * @see http://doc.babylonjs.com/how_to/group
  101825. * @param name Defines the name of the group
  101826. * @param scene Defines the scene the group belongs to
  101827. */
  101828. constructor(
  101829. /** The name of the animation group */
  101830. name: string, scene?: Nullable<Scene>);
  101831. /**
  101832. * Add an animation (with its target) in the group
  101833. * @param animation defines the animation we want to add
  101834. * @param target defines the target of the animation
  101835. * @returns the TargetedAnimation object
  101836. */
  101837. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  101838. /**
  101839. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  101840. * It can add constant keys at begin or end
  101841. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  101842. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  101843. * @returns the animation group
  101844. */
  101845. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  101846. private _animationLoopCount;
  101847. private _animationLoopFlags;
  101848. private _processLoop;
  101849. /**
  101850. * Start all animations on given targets
  101851. * @param loop defines if animations must loop
  101852. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  101853. * @param from defines the from key (optional)
  101854. * @param to defines the to key (optional)
  101855. * @returns the current animation group
  101856. */
  101857. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  101858. /**
  101859. * Pause all animations
  101860. * @returns the animation group
  101861. */
  101862. pause(): AnimationGroup;
  101863. /**
  101864. * Play all animations to initial state
  101865. * This function will start() the animations if they were not started or will restart() them if they were paused
  101866. * @param loop defines if animations must loop
  101867. * @returns the animation group
  101868. */
  101869. play(loop?: boolean): AnimationGroup;
  101870. /**
  101871. * Reset all animations to initial state
  101872. * @returns the animation group
  101873. */
  101874. reset(): AnimationGroup;
  101875. /**
  101876. * Restart animations from key 0
  101877. * @returns the animation group
  101878. */
  101879. restart(): AnimationGroup;
  101880. /**
  101881. * Stop all animations
  101882. * @returns the animation group
  101883. */
  101884. stop(): AnimationGroup;
  101885. /**
  101886. * Set animation weight for all animatables
  101887. * @param weight defines the weight to use
  101888. * @return the animationGroup
  101889. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  101890. */
  101891. setWeightForAllAnimatables(weight: number): AnimationGroup;
  101892. /**
  101893. * Synchronize and normalize all animatables with a source animatable
  101894. * @param root defines the root animatable to synchronize with
  101895. * @return the animationGroup
  101896. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  101897. */
  101898. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  101899. /**
  101900. * Goes to a specific frame in this animation group
  101901. * @param frame the frame number to go to
  101902. * @return the animationGroup
  101903. */
  101904. goToFrame(frame: number): AnimationGroup;
  101905. /**
  101906. * Dispose all associated resources
  101907. */
  101908. dispose(): void;
  101909. private _checkAnimationGroupEnded;
  101910. /**
  101911. * Clone the current animation group and returns a copy
  101912. * @param newName defines the name of the new group
  101913. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  101914. * @returns the new aniamtion group
  101915. */
  101916. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  101917. /**
  101918. * Serializes the animationGroup to an object
  101919. * @returns Serialized object
  101920. */
  101921. serialize(): any;
  101922. /**
  101923. * Returns a new AnimationGroup object parsed from the source provided.
  101924. * @param parsedAnimationGroup defines the source
  101925. * @param scene defines the scene that will receive the animationGroup
  101926. * @returns a new AnimationGroup
  101927. */
  101928. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  101929. /**
  101930. * Returns the string "AnimationGroup"
  101931. * @returns "AnimationGroup"
  101932. */
  101933. getClassName(): string;
  101934. /**
  101935. * Creates a detailled string about the object
  101936. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  101937. * @returns a string representing the object
  101938. */
  101939. toString(fullDetails?: boolean): string;
  101940. }
  101941. }
  101942. declare module BABYLON {
  101943. /**
  101944. * Define an interface for all classes that will hold resources
  101945. */
  101946. export interface IDisposable {
  101947. /**
  101948. * Releases all held resources
  101949. */
  101950. dispose(): void;
  101951. }
  101952. /** Interface defining initialization parameters for Scene class */
  101953. export interface SceneOptions {
  101954. /**
  101955. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  101956. * It will improve performance when the number of geometries becomes important.
  101957. */
  101958. useGeometryUniqueIdsMap?: boolean;
  101959. /**
  101960. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  101961. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  101962. */
  101963. useMaterialMeshMap?: boolean;
  101964. /**
  101965. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  101966. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  101967. */
  101968. useClonedMeshhMap?: boolean;
  101969. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  101970. virtual?: boolean;
  101971. }
  101972. /**
  101973. * Represents a scene to be rendered by the engine.
  101974. * @see http://doc.babylonjs.com/features/scene
  101975. */
  101976. export class Scene extends AbstractScene implements IAnimatable {
  101977. /** The fog is deactivated */
  101978. static readonly FOGMODE_NONE: number;
  101979. /** The fog density is following an exponential function */
  101980. static readonly FOGMODE_EXP: number;
  101981. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  101982. static readonly FOGMODE_EXP2: number;
  101983. /** The fog density is following a linear function. */
  101984. static readonly FOGMODE_LINEAR: number;
  101985. /**
  101986. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  101987. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  101988. */
  101989. static MinDeltaTime: number;
  101990. /**
  101991. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  101992. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  101993. */
  101994. static MaxDeltaTime: number;
  101995. /**
  101996. * Factory used to create the default material.
  101997. * @param name The name of the material to create
  101998. * @param scene The scene to create the material for
  101999. * @returns The default material
  102000. */
  102001. static DefaultMaterialFactory(scene: Scene): Material;
  102002. /**
  102003. * Factory used to create the a collision coordinator.
  102004. * @returns The collision coordinator
  102005. */
  102006. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  102007. /** @hidden */
  102008. _inputManager: InputManager;
  102009. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  102010. cameraToUseForPointers: Nullable<Camera>;
  102011. /** @hidden */
  102012. readonly _isScene: boolean;
  102013. /**
  102014. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  102015. */
  102016. autoClear: boolean;
  102017. /**
  102018. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  102019. */
  102020. autoClearDepthAndStencil: boolean;
  102021. /**
  102022. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  102023. */
  102024. clearColor: Color4;
  102025. /**
  102026. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  102027. */
  102028. ambientColor: Color3;
  102029. /**
  102030. * This is use to store the default BRDF lookup for PBR materials in your scene.
  102031. * It should only be one of the following (if not the default embedded one):
  102032. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  102033. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  102034. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  102035. * The material properties need to be setup according to the type of texture in use.
  102036. */
  102037. environmentBRDFTexture: BaseTexture;
  102038. /** @hidden */
  102039. protected _environmentTexture: Nullable<BaseTexture>;
  102040. /**
  102041. * Texture used in all pbr material as the reflection texture.
  102042. * As in the majority of the scene they are the same (exception for multi room and so on),
  102043. * this is easier to reference from here than from all the materials.
  102044. */
  102045. /**
  102046. * Texture used in all pbr material as the reflection texture.
  102047. * As in the majority of the scene they are the same (exception for multi room and so on),
  102048. * this is easier to set here than in all the materials.
  102049. */
  102050. environmentTexture: Nullable<BaseTexture>;
  102051. /** @hidden */
  102052. protected _environmentIntensity: number;
  102053. /**
  102054. * Intensity of the environment in all pbr material.
  102055. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  102056. * As in the majority of the scene they are the same (exception for multi room and so on),
  102057. * this is easier to reference from here than from all the materials.
  102058. */
  102059. /**
  102060. * Intensity of the environment in all pbr material.
  102061. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  102062. * As in the majority of the scene they are the same (exception for multi room and so on),
  102063. * this is easier to set here than in all the materials.
  102064. */
  102065. environmentIntensity: number;
  102066. /** @hidden */
  102067. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  102068. /**
  102069. * Default image processing configuration used either in the rendering
  102070. * Forward main pass or through the imageProcessingPostProcess if present.
  102071. * As in the majority of the scene they are the same (exception for multi camera),
  102072. * this is easier to reference from here than from all the materials and post process.
  102073. *
  102074. * No setter as we it is a shared configuration, you can set the values instead.
  102075. */
  102076. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  102077. private _forceWireframe;
  102078. /**
  102079. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  102080. */
  102081. forceWireframe: boolean;
  102082. private _forcePointsCloud;
  102083. /**
  102084. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  102085. */
  102086. forcePointsCloud: boolean;
  102087. /**
  102088. * Gets or sets the active clipplane 1
  102089. */
  102090. clipPlane: Nullable<Plane>;
  102091. /**
  102092. * Gets or sets the active clipplane 2
  102093. */
  102094. clipPlane2: Nullable<Plane>;
  102095. /**
  102096. * Gets or sets the active clipplane 3
  102097. */
  102098. clipPlane3: Nullable<Plane>;
  102099. /**
  102100. * Gets or sets the active clipplane 4
  102101. */
  102102. clipPlane4: Nullable<Plane>;
  102103. /**
  102104. * Gets or sets a boolean indicating if animations are enabled
  102105. */
  102106. animationsEnabled: boolean;
  102107. private _animationPropertiesOverride;
  102108. /**
  102109. * Gets or sets the animation properties override
  102110. */
  102111. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  102112. /**
  102113. * Gets or sets a boolean indicating if a constant deltatime has to be used
  102114. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  102115. */
  102116. useConstantAnimationDeltaTime: boolean;
  102117. /**
  102118. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  102119. * Please note that it requires to run a ray cast through the scene on every frame
  102120. */
  102121. constantlyUpdateMeshUnderPointer: boolean;
  102122. /**
  102123. * Defines the HTML cursor to use when hovering over interactive elements
  102124. */
  102125. hoverCursor: string;
  102126. /**
  102127. * Defines the HTML default cursor to use (empty by default)
  102128. */
  102129. defaultCursor: string;
  102130. /**
  102131. * Defines wether cursors are handled by the scene.
  102132. */
  102133. doNotHandleCursors: boolean;
  102134. /**
  102135. * This is used to call preventDefault() on pointer down
  102136. * in order to block unwanted artifacts like system double clicks
  102137. */
  102138. preventDefaultOnPointerDown: boolean;
  102139. /**
  102140. * This is used to call preventDefault() on pointer up
  102141. * in order to block unwanted artifacts like system double clicks
  102142. */
  102143. preventDefaultOnPointerUp: boolean;
  102144. /**
  102145. * Gets or sets user defined metadata
  102146. */
  102147. metadata: any;
  102148. /**
  102149. * For internal use only. Please do not use.
  102150. */
  102151. reservedDataStore: any;
  102152. /**
  102153. * Gets the name of the plugin used to load this scene (null by default)
  102154. */
  102155. loadingPluginName: string;
  102156. /**
  102157. * Use this array to add regular expressions used to disable offline support for specific urls
  102158. */
  102159. disableOfflineSupportExceptionRules: RegExp[];
  102160. /**
  102161. * An event triggered when the scene is disposed.
  102162. */
  102163. onDisposeObservable: Observable<Scene>;
  102164. private _onDisposeObserver;
  102165. /** Sets a function to be executed when this scene is disposed. */
  102166. onDispose: () => void;
  102167. /**
  102168. * An event triggered before rendering the scene (right after animations and physics)
  102169. */
  102170. onBeforeRenderObservable: Observable<Scene>;
  102171. private _onBeforeRenderObserver;
  102172. /** Sets a function to be executed before rendering this scene */
  102173. beforeRender: Nullable<() => void>;
  102174. /**
  102175. * An event triggered after rendering the scene
  102176. */
  102177. onAfterRenderObservable: Observable<Scene>;
  102178. /**
  102179. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  102180. */
  102181. onAfterRenderCameraObservable: Observable<Camera>;
  102182. private _onAfterRenderObserver;
  102183. /** Sets a function to be executed after rendering this scene */
  102184. afterRender: Nullable<() => void>;
  102185. /**
  102186. * An event triggered before animating the scene
  102187. */
  102188. onBeforeAnimationsObservable: Observable<Scene>;
  102189. /**
  102190. * An event triggered after animations processing
  102191. */
  102192. onAfterAnimationsObservable: Observable<Scene>;
  102193. /**
  102194. * An event triggered before draw calls are ready to be sent
  102195. */
  102196. onBeforeDrawPhaseObservable: Observable<Scene>;
  102197. /**
  102198. * An event triggered after draw calls have been sent
  102199. */
  102200. onAfterDrawPhaseObservable: Observable<Scene>;
  102201. /**
  102202. * An event triggered when the scene is ready
  102203. */
  102204. onReadyObservable: Observable<Scene>;
  102205. /**
  102206. * An event triggered before rendering a camera
  102207. */
  102208. onBeforeCameraRenderObservable: Observable<Camera>;
  102209. private _onBeforeCameraRenderObserver;
  102210. /** Sets a function to be executed before rendering a camera*/
  102211. beforeCameraRender: () => void;
  102212. /**
  102213. * An event triggered after rendering a camera
  102214. */
  102215. onAfterCameraRenderObservable: Observable<Camera>;
  102216. private _onAfterCameraRenderObserver;
  102217. /** Sets a function to be executed after rendering a camera*/
  102218. afterCameraRender: () => void;
  102219. /**
  102220. * An event triggered when active meshes evaluation is about to start
  102221. */
  102222. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  102223. /**
  102224. * An event triggered when active meshes evaluation is done
  102225. */
  102226. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  102227. /**
  102228. * An event triggered when particles rendering is about to start
  102229. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  102230. */
  102231. onBeforeParticlesRenderingObservable: Observable<Scene>;
  102232. /**
  102233. * An event triggered when particles rendering is done
  102234. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  102235. */
  102236. onAfterParticlesRenderingObservable: Observable<Scene>;
  102237. /**
  102238. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  102239. */
  102240. onDataLoadedObservable: Observable<Scene>;
  102241. /**
  102242. * An event triggered when a camera is created
  102243. */
  102244. onNewCameraAddedObservable: Observable<Camera>;
  102245. /**
  102246. * An event triggered when a camera is removed
  102247. */
  102248. onCameraRemovedObservable: Observable<Camera>;
  102249. /**
  102250. * An event triggered when a light is created
  102251. */
  102252. onNewLightAddedObservable: Observable<Light>;
  102253. /**
  102254. * An event triggered when a light is removed
  102255. */
  102256. onLightRemovedObservable: Observable<Light>;
  102257. /**
  102258. * An event triggered when a geometry is created
  102259. */
  102260. onNewGeometryAddedObservable: Observable<Geometry>;
  102261. /**
  102262. * An event triggered when a geometry is removed
  102263. */
  102264. onGeometryRemovedObservable: Observable<Geometry>;
  102265. /**
  102266. * An event triggered when a transform node is created
  102267. */
  102268. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  102269. /**
  102270. * An event triggered when a transform node is removed
  102271. */
  102272. onTransformNodeRemovedObservable: Observable<TransformNode>;
  102273. /**
  102274. * An event triggered when a mesh is created
  102275. */
  102276. onNewMeshAddedObservable: Observable<AbstractMesh>;
  102277. /**
  102278. * An event triggered when a mesh is removed
  102279. */
  102280. onMeshRemovedObservable: Observable<AbstractMesh>;
  102281. /**
  102282. * An event triggered when a skeleton is created
  102283. */
  102284. onNewSkeletonAddedObservable: Observable<Skeleton>;
  102285. /**
  102286. * An event triggered when a skeleton is removed
  102287. */
  102288. onSkeletonRemovedObservable: Observable<Skeleton>;
  102289. /**
  102290. * An event triggered when a material is created
  102291. */
  102292. onNewMaterialAddedObservable: Observable<Material>;
  102293. /**
  102294. * An event triggered when a material is removed
  102295. */
  102296. onMaterialRemovedObservable: Observable<Material>;
  102297. /**
  102298. * An event triggered when a texture is created
  102299. */
  102300. onNewTextureAddedObservable: Observable<BaseTexture>;
  102301. /**
  102302. * An event triggered when a texture is removed
  102303. */
  102304. onTextureRemovedObservable: Observable<BaseTexture>;
  102305. /**
  102306. * An event triggered when render targets are about to be rendered
  102307. * Can happen multiple times per frame.
  102308. */
  102309. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  102310. /**
  102311. * An event triggered when render targets were rendered.
  102312. * Can happen multiple times per frame.
  102313. */
  102314. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  102315. /**
  102316. * An event triggered before calculating deterministic simulation step
  102317. */
  102318. onBeforeStepObservable: Observable<Scene>;
  102319. /**
  102320. * An event triggered after calculating deterministic simulation step
  102321. */
  102322. onAfterStepObservable: Observable<Scene>;
  102323. /**
  102324. * An event triggered when the activeCamera property is updated
  102325. */
  102326. onActiveCameraChanged: Observable<Scene>;
  102327. /**
  102328. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  102329. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  102330. * 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)
  102331. */
  102332. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  102333. /**
  102334. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  102335. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  102336. * 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)
  102337. */
  102338. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  102339. /**
  102340. * This Observable will when a mesh has been imported into the scene.
  102341. */
  102342. onMeshImportedObservable: Observable<AbstractMesh>;
  102343. /**
  102344. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  102345. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  102346. */
  102347. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  102348. /** @hidden */
  102349. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  102350. /**
  102351. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  102352. */
  102353. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  102354. /**
  102355. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  102356. */
  102357. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  102358. /**
  102359. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  102360. */
  102361. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  102362. /** Callback called when a pointer move is detected */
  102363. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  102364. /** Callback called when a pointer down is detected */
  102365. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  102366. /** Callback called when a pointer up is detected */
  102367. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  102368. /** Callback called when a pointer pick is detected */
  102369. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  102370. /**
  102371. * 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).
  102372. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  102373. */
  102374. onPrePointerObservable: Observable<PointerInfoPre>;
  102375. /**
  102376. * Observable event triggered each time an input event is received from the rendering canvas
  102377. */
  102378. onPointerObservable: Observable<PointerInfo>;
  102379. /**
  102380. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  102381. */
  102382. readonly unTranslatedPointer: Vector2;
  102383. /**
  102384. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  102385. */
  102386. static DragMovementThreshold: number;
  102387. /**
  102388. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  102389. */
  102390. static LongPressDelay: number;
  102391. /**
  102392. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  102393. */
  102394. static DoubleClickDelay: number;
  102395. /** If you need to check double click without raising a single click at first click, enable this flag */
  102396. static ExclusiveDoubleClickMode: boolean;
  102397. /** @hidden */
  102398. _mirroredCameraPosition: Nullable<Vector3>;
  102399. /**
  102400. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  102401. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  102402. */
  102403. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  102404. /**
  102405. * Observable event triggered each time an keyboard event is received from the hosting window
  102406. */
  102407. onKeyboardObservable: Observable<KeyboardInfo>;
  102408. private _useRightHandedSystem;
  102409. /**
  102410. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  102411. */
  102412. useRightHandedSystem: boolean;
  102413. private _timeAccumulator;
  102414. private _currentStepId;
  102415. private _currentInternalStep;
  102416. /**
  102417. * Sets the step Id used by deterministic lock step
  102418. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  102419. * @param newStepId defines the step Id
  102420. */
  102421. setStepId(newStepId: number): void;
  102422. /**
  102423. * Gets the step Id used by deterministic lock step
  102424. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  102425. * @returns the step Id
  102426. */
  102427. getStepId(): number;
  102428. /**
  102429. * Gets the internal step used by deterministic lock step
  102430. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  102431. * @returns the internal step
  102432. */
  102433. getInternalStep(): number;
  102434. private _fogEnabled;
  102435. /**
  102436. * Gets or sets a boolean indicating if fog is enabled on this scene
  102437. * @see http://doc.babylonjs.com/babylon101/environment#fog
  102438. * (Default is true)
  102439. */
  102440. fogEnabled: boolean;
  102441. private _fogMode;
  102442. /**
  102443. * Gets or sets the fog mode to use
  102444. * @see http://doc.babylonjs.com/babylon101/environment#fog
  102445. * | mode | value |
  102446. * | --- | --- |
  102447. * | FOGMODE_NONE | 0 |
  102448. * | FOGMODE_EXP | 1 |
  102449. * | FOGMODE_EXP2 | 2 |
  102450. * | FOGMODE_LINEAR | 3 |
  102451. */
  102452. fogMode: number;
  102453. /**
  102454. * Gets or sets the fog color to use
  102455. * @see http://doc.babylonjs.com/babylon101/environment#fog
  102456. * (Default is Color3(0.2, 0.2, 0.3))
  102457. */
  102458. fogColor: Color3;
  102459. /**
  102460. * Gets or sets the fog density to use
  102461. * @see http://doc.babylonjs.com/babylon101/environment#fog
  102462. * (Default is 0.1)
  102463. */
  102464. fogDensity: number;
  102465. /**
  102466. * Gets or sets the fog start distance to use
  102467. * @see http://doc.babylonjs.com/babylon101/environment#fog
  102468. * (Default is 0)
  102469. */
  102470. fogStart: number;
  102471. /**
  102472. * Gets or sets the fog end distance to use
  102473. * @see http://doc.babylonjs.com/babylon101/environment#fog
  102474. * (Default is 1000)
  102475. */
  102476. fogEnd: number;
  102477. private _shadowsEnabled;
  102478. /**
  102479. * Gets or sets a boolean indicating if shadows are enabled on this scene
  102480. */
  102481. shadowsEnabled: boolean;
  102482. private _lightsEnabled;
  102483. /**
  102484. * Gets or sets a boolean indicating if lights are enabled on this scene
  102485. */
  102486. lightsEnabled: boolean;
  102487. /** All of the active cameras added to this scene. */
  102488. activeCameras: Camera[];
  102489. /** @hidden */
  102490. _activeCamera: Nullable<Camera>;
  102491. /** Gets or sets the current active camera */
  102492. activeCamera: Nullable<Camera>;
  102493. private _defaultMaterial;
  102494. /** The default material used on meshes when no material is affected */
  102495. /** The default material used on meshes when no material is affected */
  102496. defaultMaterial: Material;
  102497. private _texturesEnabled;
  102498. /**
  102499. * Gets or sets a boolean indicating if textures are enabled on this scene
  102500. */
  102501. texturesEnabled: boolean;
  102502. /**
  102503. * Gets or sets a boolean indicating if particles are enabled on this scene
  102504. */
  102505. particlesEnabled: boolean;
  102506. /**
  102507. * Gets or sets a boolean indicating if sprites are enabled on this scene
  102508. */
  102509. spritesEnabled: boolean;
  102510. private _skeletonsEnabled;
  102511. /**
  102512. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  102513. */
  102514. skeletonsEnabled: boolean;
  102515. /**
  102516. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  102517. */
  102518. lensFlaresEnabled: boolean;
  102519. /**
  102520. * Gets or sets a boolean indicating if collisions are enabled on this scene
  102521. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  102522. */
  102523. collisionsEnabled: boolean;
  102524. private _collisionCoordinator;
  102525. /** @hidden */
  102526. readonly collisionCoordinator: ICollisionCoordinator;
  102527. /**
  102528. * Defines the gravity applied to this scene (used only for collisions)
  102529. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  102530. */
  102531. gravity: Vector3;
  102532. /**
  102533. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  102534. */
  102535. postProcessesEnabled: boolean;
  102536. /**
  102537. * The list of postprocesses added to the scene
  102538. */
  102539. postProcesses: PostProcess[];
  102540. /**
  102541. * Gets the current postprocess manager
  102542. */
  102543. postProcessManager: PostProcessManager;
  102544. /**
  102545. * Gets or sets a boolean indicating if render targets are enabled on this scene
  102546. */
  102547. renderTargetsEnabled: boolean;
  102548. /**
  102549. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  102550. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  102551. */
  102552. dumpNextRenderTargets: boolean;
  102553. /**
  102554. * The list of user defined render targets added to the scene
  102555. */
  102556. customRenderTargets: RenderTargetTexture[];
  102557. /**
  102558. * Defines if texture loading must be delayed
  102559. * If true, textures will only be loaded when they need to be rendered
  102560. */
  102561. useDelayedTextureLoading: boolean;
  102562. /**
  102563. * Gets the list of meshes imported to the scene through SceneLoader
  102564. */
  102565. importedMeshesFiles: String[];
  102566. /**
  102567. * Gets or sets a boolean indicating if probes are enabled on this scene
  102568. */
  102569. probesEnabled: boolean;
  102570. /**
  102571. * Gets or sets the current offline provider to use to store scene data
  102572. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  102573. */
  102574. offlineProvider: IOfflineProvider;
  102575. /**
  102576. * Gets or sets the action manager associated with the scene
  102577. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  102578. */
  102579. actionManager: AbstractActionManager;
  102580. private _meshesForIntersections;
  102581. /**
  102582. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  102583. */
  102584. proceduralTexturesEnabled: boolean;
  102585. private _engine;
  102586. private _totalVertices;
  102587. /** @hidden */
  102588. _activeIndices: PerfCounter;
  102589. /** @hidden */
  102590. _activeParticles: PerfCounter;
  102591. /** @hidden */
  102592. _activeBones: PerfCounter;
  102593. private _animationRatio;
  102594. /** @hidden */
  102595. _animationTimeLast: number;
  102596. /** @hidden */
  102597. _animationTime: number;
  102598. /**
  102599. * Gets or sets a general scale for animation speed
  102600. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  102601. */
  102602. animationTimeScale: number;
  102603. /** @hidden */
  102604. _cachedMaterial: Nullable<Material>;
  102605. /** @hidden */
  102606. _cachedEffect: Nullable<Effect>;
  102607. /** @hidden */
  102608. _cachedVisibility: Nullable<number>;
  102609. private _renderId;
  102610. private _frameId;
  102611. private _executeWhenReadyTimeoutId;
  102612. private _intermediateRendering;
  102613. private _viewUpdateFlag;
  102614. private _projectionUpdateFlag;
  102615. /** @hidden */
  102616. _toBeDisposed: Nullable<IDisposable>[];
  102617. private _activeRequests;
  102618. /** @hidden */
  102619. _pendingData: any[];
  102620. private _isDisposed;
  102621. /**
  102622. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  102623. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  102624. */
  102625. dispatchAllSubMeshesOfActiveMeshes: boolean;
  102626. private _activeMeshes;
  102627. private _processedMaterials;
  102628. private _renderTargets;
  102629. /** @hidden */
  102630. _activeParticleSystems: SmartArray<IParticleSystem>;
  102631. private _activeSkeletons;
  102632. private _softwareSkinnedMeshes;
  102633. private _renderingManager;
  102634. /** @hidden */
  102635. _activeAnimatables: Animatable[];
  102636. private _transformMatrix;
  102637. private _sceneUbo;
  102638. /** @hidden */
  102639. _viewMatrix: Matrix;
  102640. private _projectionMatrix;
  102641. /** @hidden */
  102642. _forcedViewPosition: Nullable<Vector3>;
  102643. /** @hidden */
  102644. _frustumPlanes: Plane[];
  102645. /**
  102646. * Gets the list of frustum planes (built from the active camera)
  102647. */
  102648. readonly frustumPlanes: Plane[];
  102649. /**
  102650. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  102651. * This is useful if there are more lights that the maximum simulteanous authorized
  102652. */
  102653. requireLightSorting: boolean;
  102654. /** @hidden */
  102655. readonly useMaterialMeshMap: boolean;
  102656. /** @hidden */
  102657. readonly useClonedMeshhMap: boolean;
  102658. private _externalData;
  102659. private _uid;
  102660. /**
  102661. * @hidden
  102662. * Backing store of defined scene components.
  102663. */
  102664. _components: ISceneComponent[];
  102665. /**
  102666. * @hidden
  102667. * Backing store of defined scene components.
  102668. */
  102669. _serializableComponents: ISceneSerializableComponent[];
  102670. /**
  102671. * List of components to register on the next registration step.
  102672. */
  102673. private _transientComponents;
  102674. /**
  102675. * Registers the transient components if needed.
  102676. */
  102677. private _registerTransientComponents;
  102678. /**
  102679. * @hidden
  102680. * Add a component to the scene.
  102681. * Note that the ccomponent could be registered on th next frame if this is called after
  102682. * the register component stage.
  102683. * @param component Defines the component to add to the scene
  102684. */
  102685. _addComponent(component: ISceneComponent): void;
  102686. /**
  102687. * @hidden
  102688. * Gets a component from the scene.
  102689. * @param name defines the name of the component to retrieve
  102690. * @returns the component or null if not present
  102691. */
  102692. _getComponent(name: string): Nullable<ISceneComponent>;
  102693. /**
  102694. * @hidden
  102695. * Defines the actions happening before camera updates.
  102696. */
  102697. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  102698. /**
  102699. * @hidden
  102700. * Defines the actions happening before clear the canvas.
  102701. */
  102702. _beforeClearStage: Stage<SimpleStageAction>;
  102703. /**
  102704. * @hidden
  102705. * Defines the actions when collecting render targets for the frame.
  102706. */
  102707. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  102708. /**
  102709. * @hidden
  102710. * Defines the actions happening for one camera in the frame.
  102711. */
  102712. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  102713. /**
  102714. * @hidden
  102715. * Defines the actions happening during the per mesh ready checks.
  102716. */
  102717. _isReadyForMeshStage: Stage<MeshStageAction>;
  102718. /**
  102719. * @hidden
  102720. * Defines the actions happening before evaluate active mesh checks.
  102721. */
  102722. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  102723. /**
  102724. * @hidden
  102725. * Defines the actions happening during the evaluate sub mesh checks.
  102726. */
  102727. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  102728. /**
  102729. * @hidden
  102730. * Defines the actions happening during the active mesh stage.
  102731. */
  102732. _activeMeshStage: Stage<ActiveMeshStageAction>;
  102733. /**
  102734. * @hidden
  102735. * Defines the actions happening during the per camera render target step.
  102736. */
  102737. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  102738. /**
  102739. * @hidden
  102740. * Defines the actions happening just before the active camera is drawing.
  102741. */
  102742. _beforeCameraDrawStage: Stage<CameraStageAction>;
  102743. /**
  102744. * @hidden
  102745. * Defines the actions happening just before a render target is drawing.
  102746. */
  102747. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  102748. /**
  102749. * @hidden
  102750. * Defines the actions happening just before a rendering group is drawing.
  102751. */
  102752. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  102753. /**
  102754. * @hidden
  102755. * Defines the actions happening just before a mesh is drawing.
  102756. */
  102757. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  102758. /**
  102759. * @hidden
  102760. * Defines the actions happening just after a mesh has been drawn.
  102761. */
  102762. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  102763. /**
  102764. * @hidden
  102765. * Defines the actions happening just after a rendering group has been drawn.
  102766. */
  102767. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  102768. /**
  102769. * @hidden
  102770. * Defines the actions happening just after the active camera has been drawn.
  102771. */
  102772. _afterCameraDrawStage: Stage<CameraStageAction>;
  102773. /**
  102774. * @hidden
  102775. * Defines the actions happening just after a render target has been drawn.
  102776. */
  102777. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  102778. /**
  102779. * @hidden
  102780. * Defines the actions happening just after rendering all cameras and computing intersections.
  102781. */
  102782. _afterRenderStage: Stage<SimpleStageAction>;
  102783. /**
  102784. * @hidden
  102785. * Defines the actions happening when a pointer move event happens.
  102786. */
  102787. _pointerMoveStage: Stage<PointerMoveStageAction>;
  102788. /**
  102789. * @hidden
  102790. * Defines the actions happening when a pointer down event happens.
  102791. */
  102792. _pointerDownStage: Stage<PointerUpDownStageAction>;
  102793. /**
  102794. * @hidden
  102795. * Defines the actions happening when a pointer up event happens.
  102796. */
  102797. _pointerUpStage: Stage<PointerUpDownStageAction>;
  102798. /**
  102799. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  102800. */
  102801. private geometriesByUniqueId;
  102802. /**
  102803. * Creates a new Scene
  102804. * @param engine defines the engine to use to render this scene
  102805. * @param options defines the scene options
  102806. */
  102807. constructor(engine: Engine, options?: SceneOptions);
  102808. /**
  102809. * Gets a string idenfifying the name of the class
  102810. * @returns "Scene" string
  102811. */
  102812. getClassName(): string;
  102813. private _defaultMeshCandidates;
  102814. /**
  102815. * @hidden
  102816. */
  102817. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  102818. private _defaultSubMeshCandidates;
  102819. /**
  102820. * @hidden
  102821. */
  102822. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  102823. /**
  102824. * Sets the default candidate providers for the scene.
  102825. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  102826. * and getCollidingSubMeshCandidates to their default function
  102827. */
  102828. setDefaultCandidateProviders(): void;
  102829. /**
  102830. * Gets the mesh that is currently under the pointer
  102831. */
  102832. readonly meshUnderPointer: Nullable<AbstractMesh>;
  102833. /**
  102834. * Gets or sets the current on-screen X position of the pointer
  102835. */
  102836. pointerX: number;
  102837. /**
  102838. * Gets or sets the current on-screen Y position of the pointer
  102839. */
  102840. pointerY: number;
  102841. /**
  102842. * Gets the cached material (ie. the latest rendered one)
  102843. * @returns the cached material
  102844. */
  102845. getCachedMaterial(): Nullable<Material>;
  102846. /**
  102847. * Gets the cached effect (ie. the latest rendered one)
  102848. * @returns the cached effect
  102849. */
  102850. getCachedEffect(): Nullable<Effect>;
  102851. /**
  102852. * Gets the cached visibility state (ie. the latest rendered one)
  102853. * @returns the cached visibility state
  102854. */
  102855. getCachedVisibility(): Nullable<number>;
  102856. /**
  102857. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  102858. * @param material defines the current material
  102859. * @param effect defines the current effect
  102860. * @param visibility defines the current visibility state
  102861. * @returns true if one parameter is not cached
  102862. */
  102863. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  102864. /**
  102865. * Gets the engine associated with the scene
  102866. * @returns an Engine
  102867. */
  102868. getEngine(): Engine;
  102869. /**
  102870. * Gets the total number of vertices rendered per frame
  102871. * @returns the total number of vertices rendered per frame
  102872. */
  102873. getTotalVertices(): number;
  102874. /**
  102875. * Gets the performance counter for total vertices
  102876. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  102877. */
  102878. readonly totalVerticesPerfCounter: PerfCounter;
  102879. /**
  102880. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  102881. * @returns the total number of active indices rendered per frame
  102882. */
  102883. getActiveIndices(): number;
  102884. /**
  102885. * Gets the performance counter for active indices
  102886. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  102887. */
  102888. readonly totalActiveIndicesPerfCounter: PerfCounter;
  102889. /**
  102890. * Gets the total number of active particles rendered per frame
  102891. * @returns the total number of active particles rendered per frame
  102892. */
  102893. getActiveParticles(): number;
  102894. /**
  102895. * Gets the performance counter for active particles
  102896. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  102897. */
  102898. readonly activeParticlesPerfCounter: PerfCounter;
  102899. /**
  102900. * Gets the total number of active bones rendered per frame
  102901. * @returns the total number of active bones rendered per frame
  102902. */
  102903. getActiveBones(): number;
  102904. /**
  102905. * Gets the performance counter for active bones
  102906. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  102907. */
  102908. readonly activeBonesPerfCounter: PerfCounter;
  102909. /**
  102910. * Gets the array of active meshes
  102911. * @returns an array of AbstractMesh
  102912. */
  102913. getActiveMeshes(): SmartArray<AbstractMesh>;
  102914. /**
  102915. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  102916. * @returns a number
  102917. */
  102918. getAnimationRatio(): number;
  102919. /**
  102920. * Gets an unique Id for the current render phase
  102921. * @returns a number
  102922. */
  102923. getRenderId(): number;
  102924. /**
  102925. * Gets an unique Id for the current frame
  102926. * @returns a number
  102927. */
  102928. getFrameId(): number;
  102929. /** Call this function if you want to manually increment the render Id*/
  102930. incrementRenderId(): void;
  102931. private _createUbo;
  102932. /**
  102933. * Use this method to simulate a pointer move on a mesh
  102934. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  102935. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  102936. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  102937. * @returns the current scene
  102938. */
  102939. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  102940. /**
  102941. * Use this method to simulate a pointer down on a mesh
  102942. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  102943. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  102944. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  102945. * @returns the current scene
  102946. */
  102947. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  102948. /**
  102949. * Use this method to simulate a pointer up on a mesh
  102950. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  102951. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  102952. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  102953. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  102954. * @returns the current scene
  102955. */
  102956. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  102957. /**
  102958. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  102959. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  102960. * @returns true if the pointer was captured
  102961. */
  102962. isPointerCaptured(pointerId?: number): boolean;
  102963. /**
  102964. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  102965. * @param attachUp defines if you want to attach events to pointerup
  102966. * @param attachDown defines if you want to attach events to pointerdown
  102967. * @param attachMove defines if you want to attach events to pointermove
  102968. */
  102969. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  102970. /** Detaches all event handlers*/
  102971. detachControl(): void;
  102972. /**
  102973. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  102974. * Delay loaded resources are not taking in account
  102975. * @return true if all required resources are ready
  102976. */
  102977. isReady(): boolean;
  102978. /** Resets all cached information relative to material (including effect and visibility) */
  102979. resetCachedMaterial(): void;
  102980. /**
  102981. * Registers a function to be called before every frame render
  102982. * @param func defines the function to register
  102983. */
  102984. registerBeforeRender(func: () => void): void;
  102985. /**
  102986. * Unregisters a function called before every frame render
  102987. * @param func defines the function to unregister
  102988. */
  102989. unregisterBeforeRender(func: () => void): void;
  102990. /**
  102991. * Registers a function to be called after every frame render
  102992. * @param func defines the function to register
  102993. */
  102994. registerAfterRender(func: () => void): void;
  102995. /**
  102996. * Unregisters a function called after every frame render
  102997. * @param func defines the function to unregister
  102998. */
  102999. unregisterAfterRender(func: () => void): void;
  103000. private _executeOnceBeforeRender;
  103001. /**
  103002. * The provided function will run before render once and will be disposed afterwards.
  103003. * A timeout delay can be provided so that the function will be executed in N ms.
  103004. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  103005. * @param func The function to be executed.
  103006. * @param timeout optional delay in ms
  103007. */
  103008. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  103009. /** @hidden */
  103010. _addPendingData(data: any): void;
  103011. /** @hidden */
  103012. _removePendingData(data: any): void;
  103013. /**
  103014. * Returns the number of items waiting to be loaded
  103015. * @returns the number of items waiting to be loaded
  103016. */
  103017. getWaitingItemsCount(): number;
  103018. /**
  103019. * Returns a boolean indicating if the scene is still loading data
  103020. */
  103021. readonly isLoading: boolean;
  103022. /**
  103023. * Registers a function to be executed when the scene is ready
  103024. * @param {Function} func - the function to be executed
  103025. */
  103026. executeWhenReady(func: () => void): void;
  103027. /**
  103028. * Returns a promise that resolves when the scene is ready
  103029. * @returns A promise that resolves when the scene is ready
  103030. */
  103031. whenReadyAsync(): Promise<void>;
  103032. /** @hidden */
  103033. _checkIsReady(): void;
  103034. /**
  103035. * Gets all animatable attached to the scene
  103036. */
  103037. readonly animatables: Animatable[];
  103038. /**
  103039. * Resets the last animation time frame.
  103040. * Useful to override when animations start running when loading a scene for the first time.
  103041. */
  103042. resetLastAnimationTimeFrame(): void;
  103043. /**
  103044. * Gets the current view matrix
  103045. * @returns a Matrix
  103046. */
  103047. getViewMatrix(): Matrix;
  103048. /**
  103049. * Gets the current projection matrix
  103050. * @returns a Matrix
  103051. */
  103052. getProjectionMatrix(): Matrix;
  103053. /**
  103054. * Gets the current transform matrix
  103055. * @returns a Matrix made of View * Projection
  103056. */
  103057. getTransformMatrix(): Matrix;
  103058. /**
  103059. * Sets the current transform matrix
  103060. * @param viewL defines the View matrix to use
  103061. * @param projectionL defines the Projection matrix to use
  103062. * @param viewR defines the right View matrix to use (if provided)
  103063. * @param projectionR defines the right Projection matrix to use (if provided)
  103064. */
  103065. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  103066. /**
  103067. * Gets the uniform buffer used to store scene data
  103068. * @returns a UniformBuffer
  103069. */
  103070. getSceneUniformBuffer(): UniformBuffer;
  103071. /**
  103072. * Gets an unique (relatively to the current scene) Id
  103073. * @returns an unique number for the scene
  103074. */
  103075. getUniqueId(): number;
  103076. /**
  103077. * Add a mesh to the list of scene's meshes
  103078. * @param newMesh defines the mesh to add
  103079. * @param recursive if all child meshes should also be added to the scene
  103080. */
  103081. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  103082. /**
  103083. * Remove a mesh for the list of scene's meshes
  103084. * @param toRemove defines the mesh to remove
  103085. * @param recursive if all child meshes should also be removed from the scene
  103086. * @returns the index where the mesh was in the mesh list
  103087. */
  103088. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  103089. /**
  103090. * Add a transform node to the list of scene's transform nodes
  103091. * @param newTransformNode defines the transform node to add
  103092. */
  103093. addTransformNode(newTransformNode: TransformNode): void;
  103094. /**
  103095. * Remove a transform node for the list of scene's transform nodes
  103096. * @param toRemove defines the transform node to remove
  103097. * @returns the index where the transform node was in the transform node list
  103098. */
  103099. removeTransformNode(toRemove: TransformNode): number;
  103100. /**
  103101. * Remove a skeleton for the list of scene's skeletons
  103102. * @param toRemove defines the skeleton to remove
  103103. * @returns the index where the skeleton was in the skeleton list
  103104. */
  103105. removeSkeleton(toRemove: Skeleton): number;
  103106. /**
  103107. * Remove a morph target for the list of scene's morph targets
  103108. * @param toRemove defines the morph target to remove
  103109. * @returns the index where the morph target was in the morph target list
  103110. */
  103111. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  103112. /**
  103113. * Remove a light for the list of scene's lights
  103114. * @param toRemove defines the light to remove
  103115. * @returns the index where the light was in the light list
  103116. */
  103117. removeLight(toRemove: Light): number;
  103118. /**
  103119. * Remove a camera for the list of scene's cameras
  103120. * @param toRemove defines the camera to remove
  103121. * @returns the index where the camera was in the camera list
  103122. */
  103123. removeCamera(toRemove: Camera): number;
  103124. /**
  103125. * Remove a particle system for the list of scene's particle systems
  103126. * @param toRemove defines the particle system to remove
  103127. * @returns the index where the particle system was in the particle system list
  103128. */
  103129. removeParticleSystem(toRemove: IParticleSystem): number;
  103130. /**
  103131. * Remove a animation for the list of scene's animations
  103132. * @param toRemove defines the animation to remove
  103133. * @returns the index where the animation was in the animation list
  103134. */
  103135. removeAnimation(toRemove: Animation): number;
  103136. /**
  103137. * Will stop the animation of the given target
  103138. * @param target - the target
  103139. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  103140. * @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)
  103141. */
  103142. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  103143. /**
  103144. * Removes the given animation group from this scene.
  103145. * @param toRemove The animation group to remove
  103146. * @returns The index of the removed animation group
  103147. */
  103148. removeAnimationGroup(toRemove: AnimationGroup): number;
  103149. /**
  103150. * Removes the given multi-material from this scene.
  103151. * @param toRemove The multi-material to remove
  103152. * @returns The index of the removed multi-material
  103153. */
  103154. removeMultiMaterial(toRemove: MultiMaterial): number;
  103155. /**
  103156. * Removes the given material from this scene.
  103157. * @param toRemove The material to remove
  103158. * @returns The index of the removed material
  103159. */
  103160. removeMaterial(toRemove: Material): number;
  103161. /**
  103162. * Removes the given action manager from this scene.
  103163. * @param toRemove The action manager to remove
  103164. * @returns The index of the removed action manager
  103165. */
  103166. removeActionManager(toRemove: AbstractActionManager): number;
  103167. /**
  103168. * Removes the given texture from this scene.
  103169. * @param toRemove The texture to remove
  103170. * @returns The index of the removed texture
  103171. */
  103172. removeTexture(toRemove: BaseTexture): number;
  103173. /**
  103174. * Adds the given light to this scene
  103175. * @param newLight The light to add
  103176. */
  103177. addLight(newLight: Light): void;
  103178. /**
  103179. * Sorts the list list based on light priorities
  103180. */
  103181. sortLightsByPriority(): void;
  103182. /**
  103183. * Adds the given camera to this scene
  103184. * @param newCamera The camera to add
  103185. */
  103186. addCamera(newCamera: Camera): void;
  103187. /**
  103188. * Adds the given skeleton to this scene
  103189. * @param newSkeleton The skeleton to add
  103190. */
  103191. addSkeleton(newSkeleton: Skeleton): void;
  103192. /**
  103193. * Adds the given particle system to this scene
  103194. * @param newParticleSystem The particle system to add
  103195. */
  103196. addParticleSystem(newParticleSystem: IParticleSystem): void;
  103197. /**
  103198. * Adds the given animation to this scene
  103199. * @param newAnimation The animation to add
  103200. */
  103201. addAnimation(newAnimation: Animation): void;
  103202. /**
  103203. * Adds the given animation group to this scene.
  103204. * @param newAnimationGroup The animation group to add
  103205. */
  103206. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  103207. /**
  103208. * Adds the given multi-material to this scene
  103209. * @param newMultiMaterial The multi-material to add
  103210. */
  103211. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  103212. /**
  103213. * Adds the given material to this scene
  103214. * @param newMaterial The material to add
  103215. */
  103216. addMaterial(newMaterial: Material): void;
  103217. /**
  103218. * Adds the given morph target to this scene
  103219. * @param newMorphTargetManager The morph target to add
  103220. */
  103221. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  103222. /**
  103223. * Adds the given geometry to this scene
  103224. * @param newGeometry The geometry to add
  103225. */
  103226. addGeometry(newGeometry: Geometry): void;
  103227. /**
  103228. * Adds the given action manager to this scene
  103229. * @param newActionManager The action manager to add
  103230. */
  103231. addActionManager(newActionManager: AbstractActionManager): void;
  103232. /**
  103233. * Adds the given texture to this scene.
  103234. * @param newTexture The texture to add
  103235. */
  103236. addTexture(newTexture: BaseTexture): void;
  103237. /**
  103238. * Switch active camera
  103239. * @param newCamera defines the new active camera
  103240. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  103241. */
  103242. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  103243. /**
  103244. * sets the active camera of the scene using its ID
  103245. * @param id defines the camera's ID
  103246. * @return the new active camera or null if none found.
  103247. */
  103248. setActiveCameraByID(id: string): Nullable<Camera>;
  103249. /**
  103250. * sets the active camera of the scene using its name
  103251. * @param name defines the camera's name
  103252. * @returns the new active camera or null if none found.
  103253. */
  103254. setActiveCameraByName(name: string): Nullable<Camera>;
  103255. /**
  103256. * get an animation group using its name
  103257. * @param name defines the material's name
  103258. * @return the animation group or null if none found.
  103259. */
  103260. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  103261. /**
  103262. * Get a material using its unique id
  103263. * @param uniqueId defines the material's unique id
  103264. * @return the material or null if none found.
  103265. */
  103266. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  103267. /**
  103268. * get a material using its id
  103269. * @param id defines the material's ID
  103270. * @return the material or null if none found.
  103271. */
  103272. getMaterialByID(id: string): Nullable<Material>;
  103273. /**
  103274. * Gets a the last added material using a given id
  103275. * @param id defines the material's ID
  103276. * @return the last material with the given id or null if none found.
  103277. */
  103278. getLastMaterialByID(id: string): Nullable<Material>;
  103279. /**
  103280. * Gets a material using its name
  103281. * @param name defines the material's name
  103282. * @return the material or null if none found.
  103283. */
  103284. getMaterialByName(name: string): Nullable<Material>;
  103285. /**
  103286. * Get a texture using its unique id
  103287. * @param uniqueId defines the texture's unique id
  103288. * @return the texture or null if none found.
  103289. */
  103290. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  103291. /**
  103292. * Gets a camera using its id
  103293. * @param id defines the id to look for
  103294. * @returns the camera or null if not found
  103295. */
  103296. getCameraByID(id: string): Nullable<Camera>;
  103297. /**
  103298. * Gets a camera using its unique id
  103299. * @param uniqueId defines the unique id to look for
  103300. * @returns the camera or null if not found
  103301. */
  103302. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  103303. /**
  103304. * Gets a camera using its name
  103305. * @param name defines the camera's name
  103306. * @return the camera or null if none found.
  103307. */
  103308. getCameraByName(name: string): Nullable<Camera>;
  103309. /**
  103310. * Gets a bone using its id
  103311. * @param id defines the bone's id
  103312. * @return the bone or null if not found
  103313. */
  103314. getBoneByID(id: string): Nullable<Bone>;
  103315. /**
  103316. * Gets a bone using its id
  103317. * @param name defines the bone's name
  103318. * @return the bone or null if not found
  103319. */
  103320. getBoneByName(name: string): Nullable<Bone>;
  103321. /**
  103322. * Gets a light node using its name
  103323. * @param name defines the the light's name
  103324. * @return the light or null if none found.
  103325. */
  103326. getLightByName(name: string): Nullable<Light>;
  103327. /**
  103328. * Gets a light node using its id
  103329. * @param id defines the light's id
  103330. * @return the light or null if none found.
  103331. */
  103332. getLightByID(id: string): Nullable<Light>;
  103333. /**
  103334. * Gets a light node using its scene-generated unique ID
  103335. * @param uniqueId defines the light's unique id
  103336. * @return the light or null if none found.
  103337. */
  103338. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  103339. /**
  103340. * Gets a particle system by id
  103341. * @param id defines the particle system id
  103342. * @return the corresponding system or null if none found
  103343. */
  103344. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  103345. /**
  103346. * Gets a geometry using its ID
  103347. * @param id defines the geometry's id
  103348. * @return the geometry or null if none found.
  103349. */
  103350. getGeometryByID(id: string): Nullable<Geometry>;
  103351. private _getGeometryByUniqueID;
  103352. /**
  103353. * Add a new geometry to this scene
  103354. * @param geometry defines the geometry to be added to the scene.
  103355. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  103356. * @return a boolean defining if the geometry was added or not
  103357. */
  103358. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  103359. /**
  103360. * Removes an existing geometry
  103361. * @param geometry defines the geometry to be removed from the scene
  103362. * @return a boolean defining if the geometry was removed or not
  103363. */
  103364. removeGeometry(geometry: Geometry): boolean;
  103365. /**
  103366. * Gets the list of geometries attached to the scene
  103367. * @returns an array of Geometry
  103368. */
  103369. getGeometries(): Geometry[];
  103370. /**
  103371. * Gets the first added mesh found of a given ID
  103372. * @param id defines the id to search for
  103373. * @return the mesh found or null if not found at all
  103374. */
  103375. getMeshByID(id: string): Nullable<AbstractMesh>;
  103376. /**
  103377. * Gets a list of meshes using their id
  103378. * @param id defines the id to search for
  103379. * @returns a list of meshes
  103380. */
  103381. getMeshesByID(id: string): Array<AbstractMesh>;
  103382. /**
  103383. * Gets the first added transform node found of a given ID
  103384. * @param id defines the id to search for
  103385. * @return the found transform node or null if not found at all.
  103386. */
  103387. getTransformNodeByID(id: string): Nullable<TransformNode>;
  103388. /**
  103389. * Gets a transform node with its auto-generated unique id
  103390. * @param uniqueId efines the unique id to search for
  103391. * @return the found transform node or null if not found at all.
  103392. */
  103393. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  103394. /**
  103395. * Gets a list of transform nodes using their id
  103396. * @param id defines the id to search for
  103397. * @returns a list of transform nodes
  103398. */
  103399. getTransformNodesByID(id: string): Array<TransformNode>;
  103400. /**
  103401. * Gets a mesh with its auto-generated unique id
  103402. * @param uniqueId defines the unique id to search for
  103403. * @return the found mesh or null if not found at all.
  103404. */
  103405. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  103406. /**
  103407. * Gets a the last added mesh using a given id
  103408. * @param id defines the id to search for
  103409. * @return the found mesh or null if not found at all.
  103410. */
  103411. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  103412. /**
  103413. * Gets a the last added node (Mesh, Camera, Light) using a given id
  103414. * @param id defines the id to search for
  103415. * @return the found node or null if not found at all
  103416. */
  103417. getLastEntryByID(id: string): Nullable<Node>;
  103418. /**
  103419. * Gets a node (Mesh, Camera, Light) using a given id
  103420. * @param id defines the id to search for
  103421. * @return the found node or null if not found at all
  103422. */
  103423. getNodeByID(id: string): Nullable<Node>;
  103424. /**
  103425. * Gets a node (Mesh, Camera, Light) using a given name
  103426. * @param name defines the name to search for
  103427. * @return the found node or null if not found at all.
  103428. */
  103429. getNodeByName(name: string): Nullable<Node>;
  103430. /**
  103431. * Gets a mesh using a given name
  103432. * @param name defines the name to search for
  103433. * @return the found mesh or null if not found at all.
  103434. */
  103435. getMeshByName(name: string): Nullable<AbstractMesh>;
  103436. /**
  103437. * Gets a transform node using a given name
  103438. * @param name defines the name to search for
  103439. * @return the found transform node or null if not found at all.
  103440. */
  103441. getTransformNodeByName(name: string): Nullable<TransformNode>;
  103442. /**
  103443. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  103444. * @param id defines the id to search for
  103445. * @return the found skeleton or null if not found at all.
  103446. */
  103447. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  103448. /**
  103449. * Gets a skeleton using a given auto generated unique id
  103450. * @param uniqueId defines the unique id to search for
  103451. * @return the found skeleton or null if not found at all.
  103452. */
  103453. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  103454. /**
  103455. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  103456. * @param id defines the id to search for
  103457. * @return the found skeleton or null if not found at all.
  103458. */
  103459. getSkeletonById(id: string): Nullable<Skeleton>;
  103460. /**
  103461. * Gets a skeleton using a given name
  103462. * @param name defines the name to search for
  103463. * @return the found skeleton or null if not found at all.
  103464. */
  103465. getSkeletonByName(name: string): Nullable<Skeleton>;
  103466. /**
  103467. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  103468. * @param id defines the id to search for
  103469. * @return the found morph target manager or null if not found at all.
  103470. */
  103471. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  103472. /**
  103473. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  103474. * @param id defines the id to search for
  103475. * @return the found morph target or null if not found at all.
  103476. */
  103477. getMorphTargetById(id: string): Nullable<MorphTarget>;
  103478. /**
  103479. * Gets a boolean indicating if the given mesh is active
  103480. * @param mesh defines the mesh to look for
  103481. * @returns true if the mesh is in the active list
  103482. */
  103483. isActiveMesh(mesh: AbstractMesh): boolean;
  103484. /**
  103485. * Return a unique id as a string which can serve as an identifier for the scene
  103486. */
  103487. readonly uid: string;
  103488. /**
  103489. * Add an externaly attached data from its key.
  103490. * This method call will fail and return false, if such key already exists.
  103491. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  103492. * @param key the unique key that identifies the data
  103493. * @param data the data object to associate to the key for this Engine instance
  103494. * @return true if no such key were already present and the data was added successfully, false otherwise
  103495. */
  103496. addExternalData<T>(key: string, data: T): boolean;
  103497. /**
  103498. * Get an externaly attached data from its key
  103499. * @param key the unique key that identifies the data
  103500. * @return the associated data, if present (can be null), or undefined if not present
  103501. */
  103502. getExternalData<T>(key: string): Nullable<T>;
  103503. /**
  103504. * Get an externaly attached data from its key, create it using a factory if it's not already present
  103505. * @param key the unique key that identifies the data
  103506. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  103507. * @return the associated data, can be null if the factory returned null.
  103508. */
  103509. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  103510. /**
  103511. * Remove an externaly attached data from the Engine instance
  103512. * @param key the unique key that identifies the data
  103513. * @return true if the data was successfully removed, false if it doesn't exist
  103514. */
  103515. removeExternalData(key: string): boolean;
  103516. private _evaluateSubMesh;
  103517. /**
  103518. * Clear the processed materials smart array preventing retention point in material dispose.
  103519. */
  103520. freeProcessedMaterials(): void;
  103521. private _preventFreeActiveMeshesAndRenderingGroups;
  103522. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  103523. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  103524. * when disposing several meshes in a row or a hierarchy of meshes.
  103525. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  103526. */
  103527. blockfreeActiveMeshesAndRenderingGroups: boolean;
  103528. /**
  103529. * Clear the active meshes smart array preventing retention point in mesh dispose.
  103530. */
  103531. freeActiveMeshes(): void;
  103532. /**
  103533. * Clear the info related to rendering groups preventing retention points during dispose.
  103534. */
  103535. freeRenderingGroups(): void;
  103536. /** @hidden */
  103537. _isInIntermediateRendering(): boolean;
  103538. /**
  103539. * Lambda returning the list of potentially active meshes.
  103540. */
  103541. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  103542. /**
  103543. * Lambda returning the list of potentially active sub meshes.
  103544. */
  103545. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  103546. /**
  103547. * Lambda returning the list of potentially intersecting sub meshes.
  103548. */
  103549. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  103550. /**
  103551. * Lambda returning the list of potentially colliding sub meshes.
  103552. */
  103553. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  103554. private _activeMeshesFrozen;
  103555. private _skipEvaluateActiveMeshesCompletely;
  103556. /**
  103557. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  103558. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  103559. * @returns the current scene
  103560. */
  103561. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  103562. /**
  103563. * Use this function to restart evaluating active meshes on every frame
  103564. * @returns the current scene
  103565. */
  103566. unfreezeActiveMeshes(): Scene;
  103567. private _evaluateActiveMeshes;
  103568. private _activeMesh;
  103569. /**
  103570. * Update the transform matrix to update from the current active camera
  103571. * @param force defines a boolean used to force the update even if cache is up to date
  103572. */
  103573. updateTransformMatrix(force?: boolean): void;
  103574. private _bindFrameBuffer;
  103575. /** @hidden */
  103576. _allowPostProcessClearColor: boolean;
  103577. /** @hidden */
  103578. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  103579. private _processSubCameras;
  103580. private _checkIntersections;
  103581. /** @hidden */
  103582. _advancePhysicsEngineStep(step: number): void;
  103583. /**
  103584. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  103585. */
  103586. getDeterministicFrameTime: () => number;
  103587. /** @hidden */
  103588. _animate(): void;
  103589. /** Execute all animations (for a frame) */
  103590. animate(): void;
  103591. /**
  103592. * Render the scene
  103593. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  103594. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  103595. */
  103596. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  103597. /**
  103598. * Freeze all materials
  103599. * A frozen material will not be updatable but should be faster to render
  103600. */
  103601. freezeMaterials(): void;
  103602. /**
  103603. * Unfreeze all materials
  103604. * A frozen material will not be updatable but should be faster to render
  103605. */
  103606. unfreezeMaterials(): void;
  103607. /**
  103608. * Releases all held ressources
  103609. */
  103610. dispose(): void;
  103611. /**
  103612. * Gets if the scene is already disposed
  103613. */
  103614. readonly isDisposed: boolean;
  103615. /**
  103616. * Call this function to reduce memory footprint of the scene.
  103617. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  103618. */
  103619. clearCachedVertexData(): void;
  103620. /**
  103621. * This function will remove the local cached buffer data from texture.
  103622. * It will save memory but will prevent the texture from being rebuilt
  103623. */
  103624. cleanCachedTextureBuffer(): void;
  103625. /**
  103626. * Get the world extend vectors with an optional filter
  103627. *
  103628. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  103629. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  103630. */
  103631. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  103632. min: Vector3;
  103633. max: Vector3;
  103634. };
  103635. /**
  103636. * Creates a ray that can be used to pick in the scene
  103637. * @param x defines the x coordinate of the origin (on-screen)
  103638. * @param y defines the y coordinate of the origin (on-screen)
  103639. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  103640. * @param camera defines the camera to use for the picking
  103641. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  103642. * @returns a Ray
  103643. */
  103644. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  103645. /**
  103646. * Creates a ray that can be used to pick in the scene
  103647. * @param x defines the x coordinate of the origin (on-screen)
  103648. * @param y defines the y coordinate of the origin (on-screen)
  103649. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  103650. * @param result defines the ray where to store the picking ray
  103651. * @param camera defines the camera to use for the picking
  103652. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  103653. * @returns the current scene
  103654. */
  103655. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  103656. /**
  103657. * Creates a ray that can be used to pick in the scene
  103658. * @param x defines the x coordinate of the origin (on-screen)
  103659. * @param y defines the y coordinate of the origin (on-screen)
  103660. * @param camera defines the camera to use for the picking
  103661. * @returns a Ray
  103662. */
  103663. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  103664. /**
  103665. * Creates a ray that can be used to pick in the scene
  103666. * @param x defines the x coordinate of the origin (on-screen)
  103667. * @param y defines the y coordinate of the origin (on-screen)
  103668. * @param result defines the ray where to store the picking ray
  103669. * @param camera defines the camera to use for the picking
  103670. * @returns the current scene
  103671. */
  103672. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  103673. /** Launch a ray to try to pick a mesh in the scene
  103674. * @param x position on screen
  103675. * @param y position on screen
  103676. * @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
  103677. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  103678. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  103679. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  103680. * @returns a PickingInfo
  103681. */
  103682. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  103683. /** Use the given ray to pick a mesh in the scene
  103684. * @param ray The ray to use to pick meshes
  103685. * @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
  103686. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  103687. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  103688. * @returns a PickingInfo
  103689. */
  103690. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  103691. /**
  103692. * Launch a ray to try to pick a mesh in the scene
  103693. * @param x X position on screen
  103694. * @param y Y position on screen
  103695. * @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
  103696. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  103697. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  103698. * @returns an array of PickingInfo
  103699. */
  103700. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  103701. /**
  103702. * Launch a ray to try to pick a mesh in the scene
  103703. * @param ray Ray to use
  103704. * @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
  103705. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  103706. * @returns an array of PickingInfo
  103707. */
  103708. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  103709. /**
  103710. * Force the value of meshUnderPointer
  103711. * @param mesh defines the mesh to use
  103712. */
  103713. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  103714. /**
  103715. * Gets the mesh under the pointer
  103716. * @returns a Mesh or null if no mesh is under the pointer
  103717. */
  103718. getPointerOverMesh(): Nullable<AbstractMesh>;
  103719. /** @hidden */
  103720. _rebuildGeometries(): void;
  103721. /** @hidden */
  103722. _rebuildTextures(): void;
  103723. private _getByTags;
  103724. /**
  103725. * Get a list of meshes by tags
  103726. * @param tagsQuery defines the tags query to use
  103727. * @param forEach defines a predicate used to filter results
  103728. * @returns an array of Mesh
  103729. */
  103730. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  103731. /**
  103732. * Get a list of cameras by tags
  103733. * @param tagsQuery defines the tags query to use
  103734. * @param forEach defines a predicate used to filter results
  103735. * @returns an array of Camera
  103736. */
  103737. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  103738. /**
  103739. * Get a list of lights by tags
  103740. * @param tagsQuery defines the tags query to use
  103741. * @param forEach defines a predicate used to filter results
  103742. * @returns an array of Light
  103743. */
  103744. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  103745. /**
  103746. * Get a list of materials by tags
  103747. * @param tagsQuery defines the tags query to use
  103748. * @param forEach defines a predicate used to filter results
  103749. * @returns an array of Material
  103750. */
  103751. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  103752. /**
  103753. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  103754. * This allowed control for front to back rendering or reversly depending of the special needs.
  103755. *
  103756. * @param renderingGroupId The rendering group id corresponding to its index
  103757. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  103758. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  103759. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  103760. */
  103761. 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;
  103762. /**
  103763. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  103764. *
  103765. * @param renderingGroupId The rendering group id corresponding to its index
  103766. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  103767. * @param depth Automatically clears depth between groups if true and autoClear is true.
  103768. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  103769. */
  103770. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  103771. /**
  103772. * Gets the current auto clear configuration for one rendering group of the rendering
  103773. * manager.
  103774. * @param index the rendering group index to get the information for
  103775. * @returns The auto clear setup for the requested rendering group
  103776. */
  103777. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  103778. private _blockMaterialDirtyMechanism;
  103779. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  103780. blockMaterialDirtyMechanism: boolean;
  103781. /**
  103782. * Will flag all materials as dirty to trigger new shader compilation
  103783. * @param flag defines the flag used to specify which material part must be marked as dirty
  103784. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  103785. */
  103786. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  103787. /** @hidden */
  103788. _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;
  103789. /** @hidden */
  103790. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  103791. /** @hidden */
  103792. _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;
  103793. /** @hidden */
  103794. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  103795. /** @hidden */
  103796. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  103797. /** @hidden */
  103798. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  103799. }
  103800. }
  103801. declare module BABYLON {
  103802. /**
  103803. * Set of assets to keep when moving a scene into an asset container.
  103804. */
  103805. export class KeepAssets extends AbstractScene {
  103806. }
  103807. /**
  103808. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  103809. */
  103810. export class InstantiatedEntries {
  103811. /**
  103812. * List of new root nodes (eg. nodes with no parent)
  103813. */
  103814. rootNodes: TransformNode[];
  103815. /**
  103816. * List of new skeletons
  103817. */
  103818. skeletons: Skeleton[];
  103819. /**
  103820. * List of new animation groups
  103821. */
  103822. animationGroups: AnimationGroup[];
  103823. }
  103824. /**
  103825. * Container with a set of assets that can be added or removed from a scene.
  103826. */
  103827. export class AssetContainer extends AbstractScene {
  103828. /**
  103829. * The scene the AssetContainer belongs to.
  103830. */
  103831. scene: Scene;
  103832. /**
  103833. * Instantiates an AssetContainer.
  103834. * @param scene The scene the AssetContainer belongs to.
  103835. */
  103836. constructor(scene: Scene);
  103837. /**
  103838. * Instantiate or clone all meshes and add the new ones to the scene.
  103839. * Skeletons and animation groups will all be cloned
  103840. * @param nameFunction defines an optional function used to get new names for clones
  103841. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  103842. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  103843. */
  103844. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  103845. /**
  103846. * Adds all the assets from the container to the scene.
  103847. */
  103848. addAllToScene(): void;
  103849. /**
  103850. * Removes all the assets in the container from the scene
  103851. */
  103852. removeAllFromScene(): void;
  103853. /**
  103854. * Disposes all the assets in the container
  103855. */
  103856. dispose(): void;
  103857. private _moveAssets;
  103858. /**
  103859. * Removes all the assets contained in the scene and adds them to the container.
  103860. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  103861. */
  103862. moveAllFromScene(keepAssets?: KeepAssets): void;
  103863. /**
  103864. * 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.
  103865. * @returns the root mesh
  103866. */
  103867. createRootMesh(): Mesh;
  103868. }
  103869. }
  103870. declare module BABYLON {
  103871. /**
  103872. * Defines how the parser contract is defined.
  103873. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  103874. */
  103875. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  103876. /**
  103877. * Defines how the individual parser contract is defined.
  103878. * These parser can parse an individual asset
  103879. */
  103880. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  103881. /**
  103882. * Base class of the scene acting as a container for the different elements composing a scene.
  103883. * This class is dynamically extended by the different components of the scene increasing
  103884. * flexibility and reducing coupling
  103885. */
  103886. export abstract class AbstractScene {
  103887. /**
  103888. * Stores the list of available parsers in the application.
  103889. */
  103890. private static _BabylonFileParsers;
  103891. /**
  103892. * Stores the list of available individual parsers in the application.
  103893. */
  103894. private static _IndividualBabylonFileParsers;
  103895. /**
  103896. * Adds a parser in the list of available ones
  103897. * @param name Defines the name of the parser
  103898. * @param parser Defines the parser to add
  103899. */
  103900. static AddParser(name: string, parser: BabylonFileParser): void;
  103901. /**
  103902. * Gets a general parser from the list of avaialble ones
  103903. * @param name Defines the name of the parser
  103904. * @returns the requested parser or null
  103905. */
  103906. static GetParser(name: string): Nullable<BabylonFileParser>;
  103907. /**
  103908. * Adds n individual parser in the list of available ones
  103909. * @param name Defines the name of the parser
  103910. * @param parser Defines the parser to add
  103911. */
  103912. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  103913. /**
  103914. * Gets an individual parser from the list of avaialble ones
  103915. * @param name Defines the name of the parser
  103916. * @returns the requested parser or null
  103917. */
  103918. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  103919. /**
  103920. * Parser json data and populate both a scene and its associated container object
  103921. * @param jsonData Defines the data to parse
  103922. * @param scene Defines the scene to parse the data for
  103923. * @param container Defines the container attached to the parsing sequence
  103924. * @param rootUrl Defines the root url of the data
  103925. */
  103926. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  103927. /**
  103928. * Gets the list of root nodes (ie. nodes with no parent)
  103929. */
  103930. rootNodes: Node[];
  103931. /** All of the cameras added to this scene
  103932. * @see http://doc.babylonjs.com/babylon101/cameras
  103933. */
  103934. cameras: Camera[];
  103935. /**
  103936. * All of the lights added to this scene
  103937. * @see http://doc.babylonjs.com/babylon101/lights
  103938. */
  103939. lights: Light[];
  103940. /**
  103941. * All of the (abstract) meshes added to this scene
  103942. */
  103943. meshes: AbstractMesh[];
  103944. /**
  103945. * The list of skeletons added to the scene
  103946. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  103947. */
  103948. skeletons: Skeleton[];
  103949. /**
  103950. * All of the particle systems added to this scene
  103951. * @see http://doc.babylonjs.com/babylon101/particles
  103952. */
  103953. particleSystems: IParticleSystem[];
  103954. /**
  103955. * Gets a list of Animations associated with the scene
  103956. */
  103957. animations: Animation[];
  103958. /**
  103959. * All of the animation groups added to this scene
  103960. * @see http://doc.babylonjs.com/how_to/group
  103961. */
  103962. animationGroups: AnimationGroup[];
  103963. /**
  103964. * All of the multi-materials added to this scene
  103965. * @see http://doc.babylonjs.com/how_to/multi_materials
  103966. */
  103967. multiMaterials: MultiMaterial[];
  103968. /**
  103969. * All of the materials added to this scene
  103970. * In the context of a Scene, it is not supposed to be modified manually.
  103971. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  103972. * Note also that the order of the Material within the array is not significant and might change.
  103973. * @see http://doc.babylonjs.com/babylon101/materials
  103974. */
  103975. materials: Material[];
  103976. /**
  103977. * The list of morph target managers added to the scene
  103978. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  103979. */
  103980. morphTargetManagers: MorphTargetManager[];
  103981. /**
  103982. * The list of geometries used in the scene.
  103983. */
  103984. geometries: Geometry[];
  103985. /**
  103986. * All of the tranform nodes added to this scene
  103987. * In the context of a Scene, it is not supposed to be modified manually.
  103988. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  103989. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  103990. * @see http://doc.babylonjs.com/how_to/transformnode
  103991. */
  103992. transformNodes: TransformNode[];
  103993. /**
  103994. * ActionManagers available on the scene.
  103995. */
  103996. actionManagers: AbstractActionManager[];
  103997. /**
  103998. * Textures to keep.
  103999. */
  104000. textures: BaseTexture[];
  104001. /**
  104002. * Environment texture for the scene
  104003. */
  104004. environmentTexture: Nullable<BaseTexture>;
  104005. }
  104006. }
  104007. declare module BABYLON {
  104008. /**
  104009. * Interface used to define options for Sound class
  104010. */
  104011. export interface ISoundOptions {
  104012. /**
  104013. * Does the sound autoplay once loaded.
  104014. */
  104015. autoplay?: boolean;
  104016. /**
  104017. * Does the sound loop after it finishes playing once.
  104018. */
  104019. loop?: boolean;
  104020. /**
  104021. * Sound's volume
  104022. */
  104023. volume?: number;
  104024. /**
  104025. * Is it a spatial sound?
  104026. */
  104027. spatialSound?: boolean;
  104028. /**
  104029. * Maximum distance to hear that sound
  104030. */
  104031. maxDistance?: number;
  104032. /**
  104033. * Uses user defined attenuation function
  104034. */
  104035. useCustomAttenuation?: boolean;
  104036. /**
  104037. * Define the roll off factor of spatial sounds.
  104038. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  104039. */
  104040. rolloffFactor?: number;
  104041. /**
  104042. * Define the reference distance the sound should be heard perfectly.
  104043. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  104044. */
  104045. refDistance?: number;
  104046. /**
  104047. * Define the distance attenuation model the sound will follow.
  104048. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  104049. */
  104050. distanceModel?: string;
  104051. /**
  104052. * Defines the playback speed (1 by default)
  104053. */
  104054. playbackRate?: number;
  104055. /**
  104056. * Defines if the sound is from a streaming source
  104057. */
  104058. streaming?: boolean;
  104059. /**
  104060. * Defines an optional length (in seconds) inside the sound file
  104061. */
  104062. length?: number;
  104063. /**
  104064. * Defines an optional offset (in seconds) inside the sound file
  104065. */
  104066. offset?: number;
  104067. /**
  104068. * If true, URLs will not be required to state the audio file codec to use.
  104069. */
  104070. skipCodecCheck?: boolean;
  104071. }
  104072. /**
  104073. * Defines a sound that can be played in the application.
  104074. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  104075. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  104076. */
  104077. export class Sound {
  104078. /**
  104079. * The name of the sound in the scene.
  104080. */
  104081. name: string;
  104082. /**
  104083. * Does the sound autoplay once loaded.
  104084. */
  104085. autoplay: boolean;
  104086. /**
  104087. * Does the sound loop after it finishes playing once.
  104088. */
  104089. loop: boolean;
  104090. /**
  104091. * Does the sound use a custom attenuation curve to simulate the falloff
  104092. * happening when the source gets further away from the camera.
  104093. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  104094. */
  104095. useCustomAttenuation: boolean;
  104096. /**
  104097. * The sound track id this sound belongs to.
  104098. */
  104099. soundTrackId: number;
  104100. /**
  104101. * Is this sound currently played.
  104102. */
  104103. isPlaying: boolean;
  104104. /**
  104105. * Is this sound currently paused.
  104106. */
  104107. isPaused: boolean;
  104108. /**
  104109. * Does this sound enables spatial sound.
  104110. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  104111. */
  104112. spatialSound: boolean;
  104113. /**
  104114. * Define the reference distance the sound should be heard perfectly.
  104115. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  104116. */
  104117. refDistance: number;
  104118. /**
  104119. * Define the roll off factor of spatial sounds.
  104120. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  104121. */
  104122. rolloffFactor: number;
  104123. /**
  104124. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  104125. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  104126. */
  104127. maxDistance: number;
  104128. /**
  104129. * Define the distance attenuation model the sound will follow.
  104130. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  104131. */
  104132. distanceModel: string;
  104133. /**
  104134. * @hidden
  104135. * Back Compat
  104136. **/
  104137. onended: () => any;
  104138. /**
  104139. * Observable event when the current playing sound finishes.
  104140. */
  104141. onEndedObservable: Observable<Sound>;
  104142. private _panningModel;
  104143. private _playbackRate;
  104144. private _streaming;
  104145. private _startTime;
  104146. private _startOffset;
  104147. private _position;
  104148. /** @hidden */
  104149. _positionInEmitterSpace: boolean;
  104150. private _localDirection;
  104151. private _volume;
  104152. private _isReadyToPlay;
  104153. private _isDirectional;
  104154. private _readyToPlayCallback;
  104155. private _audioBuffer;
  104156. private _soundSource;
  104157. private _streamingSource;
  104158. private _soundPanner;
  104159. private _soundGain;
  104160. private _inputAudioNode;
  104161. private _outputAudioNode;
  104162. private _coneInnerAngle;
  104163. private _coneOuterAngle;
  104164. private _coneOuterGain;
  104165. private _scene;
  104166. private _connectedTransformNode;
  104167. private _customAttenuationFunction;
  104168. private _registerFunc;
  104169. private _isOutputConnected;
  104170. private _htmlAudioElement;
  104171. private _urlType;
  104172. private _length?;
  104173. private _offset?;
  104174. /** @hidden */
  104175. static _SceneComponentInitialization: (scene: Scene) => void;
  104176. /**
  104177. * Create a sound and attach it to a scene
  104178. * @param name Name of your sound
  104179. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  104180. * @param scene defines the scene the sound belongs to
  104181. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  104182. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  104183. */
  104184. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  104185. /**
  104186. * Release the sound and its associated resources
  104187. */
  104188. dispose(): void;
  104189. /**
  104190. * Gets if the sounds is ready to be played or not.
  104191. * @returns true if ready, otherwise false
  104192. */
  104193. isReady(): boolean;
  104194. private _soundLoaded;
  104195. /**
  104196. * Sets the data of the sound from an audiobuffer
  104197. * @param audioBuffer The audioBuffer containing the data
  104198. */
  104199. setAudioBuffer(audioBuffer: AudioBuffer): void;
  104200. /**
  104201. * Updates the current sounds options such as maxdistance, loop...
  104202. * @param options A JSON object containing values named as the object properties
  104203. */
  104204. updateOptions(options: ISoundOptions): void;
  104205. private _createSpatialParameters;
  104206. private _updateSpatialParameters;
  104207. /**
  104208. * Switch the panning model to HRTF:
  104209. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  104210. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  104211. */
  104212. switchPanningModelToHRTF(): void;
  104213. /**
  104214. * Switch the panning model to Equal Power:
  104215. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  104216. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  104217. */
  104218. switchPanningModelToEqualPower(): void;
  104219. private _switchPanningModel;
  104220. /**
  104221. * Connect this sound to a sound track audio node like gain...
  104222. * @param soundTrackAudioNode the sound track audio node to connect to
  104223. */
  104224. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  104225. /**
  104226. * Transform this sound into a directional source
  104227. * @param coneInnerAngle Size of the inner cone in degree
  104228. * @param coneOuterAngle Size of the outer cone in degree
  104229. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  104230. */
  104231. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  104232. /**
  104233. * Gets or sets the inner angle for the directional cone.
  104234. */
  104235. /**
  104236. * Gets or sets the inner angle for the directional cone.
  104237. */
  104238. directionalConeInnerAngle: number;
  104239. /**
  104240. * Gets or sets the outer angle for the directional cone.
  104241. */
  104242. /**
  104243. * Gets or sets the outer angle for the directional cone.
  104244. */
  104245. directionalConeOuterAngle: number;
  104246. /**
  104247. * Sets the position of the emitter if spatial sound is enabled
  104248. * @param newPosition Defines the new posisiton
  104249. */
  104250. setPosition(newPosition: Vector3): void;
  104251. /**
  104252. * Sets the local direction of the emitter if spatial sound is enabled
  104253. * @param newLocalDirection Defines the new local direction
  104254. */
  104255. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  104256. private _updateDirection;
  104257. /** @hidden */
  104258. updateDistanceFromListener(): void;
  104259. /**
  104260. * Sets a new custom attenuation function for the sound.
  104261. * @param callback Defines the function used for the attenuation
  104262. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  104263. */
  104264. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  104265. /**
  104266. * Play the sound
  104267. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  104268. * @param offset (optional) Start the sound at a specific time in seconds
  104269. * @param length (optional) Sound duration (in seconds)
  104270. */
  104271. play(time?: number, offset?: number, length?: number): void;
  104272. private _onended;
  104273. /**
  104274. * Stop the sound
  104275. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  104276. */
  104277. stop(time?: number): void;
  104278. /**
  104279. * Put the sound in pause
  104280. */
  104281. pause(): void;
  104282. /**
  104283. * Sets a dedicated volume for this sounds
  104284. * @param newVolume Define the new volume of the sound
  104285. * @param time Define time for gradual change to new volume
  104286. */
  104287. setVolume(newVolume: number, time?: number): void;
  104288. /**
  104289. * Set the sound play back rate
  104290. * @param newPlaybackRate Define the playback rate the sound should be played at
  104291. */
  104292. setPlaybackRate(newPlaybackRate: number): void;
  104293. /**
  104294. * Gets the volume of the sound.
  104295. * @returns the volume of the sound
  104296. */
  104297. getVolume(): number;
  104298. /**
  104299. * Attach the sound to a dedicated mesh
  104300. * @param transformNode The transform node to connect the sound with
  104301. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  104302. */
  104303. attachToMesh(transformNode: TransformNode): void;
  104304. /**
  104305. * Detach the sound from the previously attached mesh
  104306. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  104307. */
  104308. detachFromMesh(): void;
  104309. private _onRegisterAfterWorldMatrixUpdate;
  104310. /**
  104311. * Clone the current sound in the scene.
  104312. * @returns the new sound clone
  104313. */
  104314. clone(): Nullable<Sound>;
  104315. /**
  104316. * Gets the current underlying audio buffer containing the data
  104317. * @returns the audio buffer
  104318. */
  104319. getAudioBuffer(): Nullable<AudioBuffer>;
  104320. /**
  104321. * Serializes the Sound in a JSON representation
  104322. * @returns the JSON representation of the sound
  104323. */
  104324. serialize(): any;
  104325. /**
  104326. * Parse a JSON representation of a sound to innstantiate in a given scene
  104327. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  104328. * @param scene Define the scene the new parsed sound should be created in
  104329. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  104330. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  104331. * @returns the newly parsed sound
  104332. */
  104333. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  104334. }
  104335. }
  104336. declare module BABYLON {
  104337. /**
  104338. * This defines an action helpful to play a defined sound on a triggered action.
  104339. */
  104340. export class PlaySoundAction extends Action {
  104341. private _sound;
  104342. /**
  104343. * Instantiate the action
  104344. * @param triggerOptions defines the trigger options
  104345. * @param sound defines the sound to play
  104346. * @param condition defines the trigger related conditions
  104347. */
  104348. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  104349. /** @hidden */
  104350. _prepare(): void;
  104351. /**
  104352. * Execute the action and play the sound.
  104353. */
  104354. execute(): void;
  104355. /**
  104356. * Serializes the actions and its related information.
  104357. * @param parent defines the object to serialize in
  104358. * @returns the serialized object
  104359. */
  104360. serialize(parent: any): any;
  104361. }
  104362. /**
  104363. * This defines an action helpful to stop a defined sound on a triggered action.
  104364. */
  104365. export class StopSoundAction extends Action {
  104366. private _sound;
  104367. /**
  104368. * Instantiate the action
  104369. * @param triggerOptions defines the trigger options
  104370. * @param sound defines the sound to stop
  104371. * @param condition defines the trigger related conditions
  104372. */
  104373. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  104374. /** @hidden */
  104375. _prepare(): void;
  104376. /**
  104377. * Execute the action and stop the sound.
  104378. */
  104379. execute(): void;
  104380. /**
  104381. * Serializes the actions and its related information.
  104382. * @param parent defines the object to serialize in
  104383. * @returns the serialized object
  104384. */
  104385. serialize(parent: any): any;
  104386. }
  104387. }
  104388. declare module BABYLON {
  104389. /**
  104390. * This defines an action responsible to change the value of a property
  104391. * by interpolating between its current value and the newly set one once triggered.
  104392. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  104393. */
  104394. export class InterpolateValueAction extends Action {
  104395. /**
  104396. * Defines the path of the property where the value should be interpolated
  104397. */
  104398. propertyPath: string;
  104399. /**
  104400. * Defines the target value at the end of the interpolation.
  104401. */
  104402. value: any;
  104403. /**
  104404. * Defines the time it will take for the property to interpolate to the value.
  104405. */
  104406. duration: number;
  104407. /**
  104408. * Defines if the other scene animations should be stopped when the action has been triggered
  104409. */
  104410. stopOtherAnimations?: boolean;
  104411. /**
  104412. * Defines a callback raised once the interpolation animation has been done.
  104413. */
  104414. onInterpolationDone?: () => void;
  104415. /**
  104416. * Observable triggered once the interpolation animation has been done.
  104417. */
  104418. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  104419. private _target;
  104420. private _effectiveTarget;
  104421. private _property;
  104422. /**
  104423. * Instantiate the action
  104424. * @param triggerOptions defines the trigger options
  104425. * @param target defines the object containing the value to interpolate
  104426. * @param propertyPath defines the path to the property in the target object
  104427. * @param value defines the target value at the end of the interpolation
  104428. * @param duration deines the time it will take for the property to interpolate to the value.
  104429. * @param condition defines the trigger related conditions
  104430. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  104431. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  104432. */
  104433. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  104434. /** @hidden */
  104435. _prepare(): void;
  104436. /**
  104437. * Execute the action starts the value interpolation.
  104438. */
  104439. execute(): void;
  104440. /**
  104441. * Serializes the actions and its related information.
  104442. * @param parent defines the object to serialize in
  104443. * @returns the serialized object
  104444. */
  104445. serialize(parent: any): any;
  104446. }
  104447. }
  104448. declare module BABYLON {
  104449. /**
  104450. * Options allowed during the creation of a sound track.
  104451. */
  104452. export interface ISoundTrackOptions {
  104453. /**
  104454. * The volume the sound track should take during creation
  104455. */
  104456. volume?: number;
  104457. /**
  104458. * Define if the sound track is the main sound track of the scene
  104459. */
  104460. mainTrack?: boolean;
  104461. }
  104462. /**
  104463. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  104464. * It will be also used in a future release to apply effects on a specific track.
  104465. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  104466. */
  104467. export class SoundTrack {
  104468. /**
  104469. * The unique identifier of the sound track in the scene.
  104470. */
  104471. id: number;
  104472. /**
  104473. * The list of sounds included in the sound track.
  104474. */
  104475. soundCollection: Array<Sound>;
  104476. private _outputAudioNode;
  104477. private _scene;
  104478. private _connectedAnalyser;
  104479. private _options;
  104480. private _isInitialized;
  104481. /**
  104482. * Creates a new sound track.
  104483. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  104484. * @param scene Define the scene the sound track belongs to
  104485. * @param options
  104486. */
  104487. constructor(scene: Scene, options?: ISoundTrackOptions);
  104488. private _initializeSoundTrackAudioGraph;
  104489. /**
  104490. * Release the sound track and its associated resources
  104491. */
  104492. dispose(): void;
  104493. /**
  104494. * Adds a sound to this sound track
  104495. * @param sound define the cound to add
  104496. * @ignoreNaming
  104497. */
  104498. AddSound(sound: Sound): void;
  104499. /**
  104500. * Removes a sound to this sound track
  104501. * @param sound define the cound to remove
  104502. * @ignoreNaming
  104503. */
  104504. RemoveSound(sound: Sound): void;
  104505. /**
  104506. * Set a global volume for the full sound track.
  104507. * @param newVolume Define the new volume of the sound track
  104508. */
  104509. setVolume(newVolume: number): void;
  104510. /**
  104511. * Switch the panning model to HRTF:
  104512. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  104513. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  104514. */
  104515. switchPanningModelToHRTF(): void;
  104516. /**
  104517. * Switch the panning model to Equal Power:
  104518. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  104519. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  104520. */
  104521. switchPanningModelToEqualPower(): void;
  104522. /**
  104523. * Connect the sound track to an audio analyser allowing some amazing
  104524. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  104525. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  104526. * @param analyser The analyser to connect to the engine
  104527. */
  104528. connectToAnalyser(analyser: Analyser): void;
  104529. }
  104530. }
  104531. declare module BABYLON {
  104532. interface AbstractScene {
  104533. /**
  104534. * The list of sounds used in the scene.
  104535. */
  104536. sounds: Nullable<Array<Sound>>;
  104537. }
  104538. interface Scene {
  104539. /**
  104540. * @hidden
  104541. * Backing field
  104542. */
  104543. _mainSoundTrack: SoundTrack;
  104544. /**
  104545. * The main sound track played by the scene.
  104546. * It cotains your primary collection of sounds.
  104547. */
  104548. mainSoundTrack: SoundTrack;
  104549. /**
  104550. * The list of sound tracks added to the scene
  104551. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  104552. */
  104553. soundTracks: Nullable<Array<SoundTrack>>;
  104554. /**
  104555. * Gets a sound using a given name
  104556. * @param name defines the name to search for
  104557. * @return the found sound or null if not found at all.
  104558. */
  104559. getSoundByName(name: string): Nullable<Sound>;
  104560. /**
  104561. * Gets or sets if audio support is enabled
  104562. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  104563. */
  104564. audioEnabled: boolean;
  104565. /**
  104566. * Gets or sets if audio will be output to headphones
  104567. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  104568. */
  104569. headphone: boolean;
  104570. /**
  104571. * Gets or sets custom audio listener position provider
  104572. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  104573. */
  104574. audioListenerPositionProvider: Nullable<() => Vector3>;
  104575. /**
  104576. * Gets or sets a refresh rate when using 3D audio positioning
  104577. */
  104578. audioPositioningRefreshRate: number;
  104579. }
  104580. /**
  104581. * Defines the sound scene component responsible to manage any sounds
  104582. * in a given scene.
  104583. */
  104584. export class AudioSceneComponent implements ISceneSerializableComponent {
  104585. /**
  104586. * The component name helpfull to identify the component in the list of scene components.
  104587. */
  104588. readonly name: string;
  104589. /**
  104590. * The scene the component belongs to.
  104591. */
  104592. scene: Scene;
  104593. private _audioEnabled;
  104594. /**
  104595. * Gets whether audio is enabled or not.
  104596. * Please use related enable/disable method to switch state.
  104597. */
  104598. readonly audioEnabled: boolean;
  104599. private _headphone;
  104600. /**
  104601. * Gets whether audio is outputing to headphone or not.
  104602. * Please use the according Switch methods to change output.
  104603. */
  104604. readonly headphone: boolean;
  104605. /**
  104606. * Gets or sets a refresh rate when using 3D audio positioning
  104607. */
  104608. audioPositioningRefreshRate: number;
  104609. private _audioListenerPositionProvider;
  104610. /**
  104611. * Gets the current audio listener position provider
  104612. */
  104613. /**
  104614. * Sets a custom listener position for all sounds in the scene
  104615. * By default, this is the position of the first active camera
  104616. */
  104617. audioListenerPositionProvider: Nullable<() => Vector3>;
  104618. /**
  104619. * Creates a new instance of the component for the given scene
  104620. * @param scene Defines the scene to register the component in
  104621. */
  104622. constructor(scene: Scene);
  104623. /**
  104624. * Registers the component in a given scene
  104625. */
  104626. register(): void;
  104627. /**
  104628. * Rebuilds the elements related to this component in case of
  104629. * context lost for instance.
  104630. */
  104631. rebuild(): void;
  104632. /**
  104633. * Serializes the component data to the specified json object
  104634. * @param serializationObject The object to serialize to
  104635. */
  104636. serialize(serializationObject: any): void;
  104637. /**
  104638. * Adds all the elements from the container to the scene
  104639. * @param container the container holding the elements
  104640. */
  104641. addFromContainer(container: AbstractScene): void;
  104642. /**
  104643. * Removes all the elements in the container from the scene
  104644. * @param container contains the elements to remove
  104645. * @param dispose if the removed element should be disposed (default: false)
  104646. */
  104647. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  104648. /**
  104649. * Disposes the component and the associated ressources.
  104650. */
  104651. dispose(): void;
  104652. /**
  104653. * Disables audio in the associated scene.
  104654. */
  104655. disableAudio(): void;
  104656. /**
  104657. * Enables audio in the associated scene.
  104658. */
  104659. enableAudio(): void;
  104660. /**
  104661. * Switch audio to headphone output.
  104662. */
  104663. switchAudioModeForHeadphones(): void;
  104664. /**
  104665. * Switch audio to normal speakers.
  104666. */
  104667. switchAudioModeForNormalSpeakers(): void;
  104668. private _cachedCameraDirection;
  104669. private _cachedCameraPosition;
  104670. private _lastCheck;
  104671. private _afterRender;
  104672. }
  104673. }
  104674. declare module BABYLON {
  104675. /**
  104676. * Wraps one or more Sound objects and selects one with random weight for playback.
  104677. */
  104678. export class WeightedSound {
  104679. /** When true a Sound will be selected and played when the current playing Sound completes. */
  104680. loop: boolean;
  104681. private _coneInnerAngle;
  104682. private _coneOuterAngle;
  104683. private _volume;
  104684. /** A Sound is currently playing. */
  104685. isPlaying: boolean;
  104686. /** A Sound is currently paused. */
  104687. isPaused: boolean;
  104688. private _sounds;
  104689. private _weights;
  104690. private _currentIndex?;
  104691. /**
  104692. * Creates a new WeightedSound from the list of sounds given.
  104693. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  104694. * @param sounds Array of Sounds that will be selected from.
  104695. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  104696. */
  104697. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  104698. /**
  104699. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  104700. */
  104701. /**
  104702. * The size of cone in degress for a directional sound in which there will be no attenuation.
  104703. */
  104704. directionalConeInnerAngle: number;
  104705. /**
  104706. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  104707. * Listener angles between innerAngle and outerAngle will falloff linearly.
  104708. */
  104709. /**
  104710. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  104711. * Listener angles between innerAngle and outerAngle will falloff linearly.
  104712. */
  104713. directionalConeOuterAngle: number;
  104714. /**
  104715. * Playback volume.
  104716. */
  104717. /**
  104718. * Playback volume.
  104719. */
  104720. volume: number;
  104721. private _onended;
  104722. /**
  104723. * Suspend playback
  104724. */
  104725. pause(): void;
  104726. /**
  104727. * Stop playback
  104728. */
  104729. stop(): void;
  104730. /**
  104731. * Start playback.
  104732. * @param startOffset Position the clip head at a specific time in seconds.
  104733. */
  104734. play(startOffset?: number): void;
  104735. }
  104736. }
  104737. declare module BABYLON {
  104738. /**
  104739. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  104740. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  104741. */
  104742. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  104743. /**
  104744. * Gets the name of the behavior.
  104745. */
  104746. readonly name: string;
  104747. /**
  104748. * The easing function used by animations
  104749. */
  104750. static EasingFunction: BackEase;
  104751. /**
  104752. * The easing mode used by animations
  104753. */
  104754. static EasingMode: number;
  104755. /**
  104756. * The duration of the animation, in milliseconds
  104757. */
  104758. transitionDuration: number;
  104759. /**
  104760. * Length of the distance animated by the transition when lower radius is reached
  104761. */
  104762. lowerRadiusTransitionRange: number;
  104763. /**
  104764. * Length of the distance animated by the transition when upper radius is reached
  104765. */
  104766. upperRadiusTransitionRange: number;
  104767. private _autoTransitionRange;
  104768. /**
  104769. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  104770. */
  104771. /**
  104772. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  104773. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  104774. */
  104775. autoTransitionRange: boolean;
  104776. private _attachedCamera;
  104777. private _onAfterCheckInputsObserver;
  104778. private _onMeshTargetChangedObserver;
  104779. /**
  104780. * Initializes the behavior.
  104781. */
  104782. init(): void;
  104783. /**
  104784. * Attaches the behavior to its arc rotate camera.
  104785. * @param camera Defines the camera to attach the behavior to
  104786. */
  104787. attach(camera: ArcRotateCamera): void;
  104788. /**
  104789. * Detaches the behavior from its current arc rotate camera.
  104790. */
  104791. detach(): void;
  104792. private _radiusIsAnimating;
  104793. private _radiusBounceTransition;
  104794. private _animatables;
  104795. private _cachedWheelPrecision;
  104796. /**
  104797. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  104798. * @param radiusLimit The limit to check against.
  104799. * @return Bool to indicate if at limit.
  104800. */
  104801. private _isRadiusAtLimit;
  104802. /**
  104803. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  104804. * @param radiusDelta The delta by which to animate to. Can be negative.
  104805. */
  104806. private _applyBoundRadiusAnimation;
  104807. /**
  104808. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  104809. */
  104810. protected _clearAnimationLocks(): void;
  104811. /**
  104812. * Stops and removes all animations that have been applied to the camera
  104813. */
  104814. stopAllAnimations(): void;
  104815. }
  104816. }
  104817. declare module BABYLON {
  104818. /**
  104819. * 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.
  104820. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  104821. */
  104822. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  104823. /**
  104824. * Gets the name of the behavior.
  104825. */
  104826. readonly name: string;
  104827. private _mode;
  104828. private _radiusScale;
  104829. private _positionScale;
  104830. private _defaultElevation;
  104831. private _elevationReturnTime;
  104832. private _elevationReturnWaitTime;
  104833. private _zoomStopsAnimation;
  104834. private _framingTime;
  104835. /**
  104836. * The easing function used by animations
  104837. */
  104838. static EasingFunction: ExponentialEase;
  104839. /**
  104840. * The easing mode used by animations
  104841. */
  104842. static EasingMode: number;
  104843. /**
  104844. * Sets the current mode used by the behavior
  104845. */
  104846. /**
  104847. * Gets current mode used by the behavior.
  104848. */
  104849. mode: number;
  104850. /**
  104851. * Sets the scale applied to the radius (1 by default)
  104852. */
  104853. /**
  104854. * Gets the scale applied to the radius
  104855. */
  104856. radiusScale: number;
  104857. /**
  104858. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  104859. */
  104860. /**
  104861. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  104862. */
  104863. positionScale: number;
  104864. /**
  104865. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  104866. * behaviour is triggered, in radians.
  104867. */
  104868. /**
  104869. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  104870. * behaviour is triggered, in radians.
  104871. */
  104872. defaultElevation: number;
  104873. /**
  104874. * Sets the time (in milliseconds) taken to return to the default beta position.
  104875. * Negative value indicates camera should not return to default.
  104876. */
  104877. /**
  104878. * Gets the time (in milliseconds) taken to return to the default beta position.
  104879. * Negative value indicates camera should not return to default.
  104880. */
  104881. elevationReturnTime: number;
  104882. /**
  104883. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  104884. */
  104885. /**
  104886. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  104887. */
  104888. elevationReturnWaitTime: number;
  104889. /**
  104890. * Sets the flag that indicates if user zooming should stop animation.
  104891. */
  104892. /**
  104893. * Gets the flag that indicates if user zooming should stop animation.
  104894. */
  104895. zoomStopsAnimation: boolean;
  104896. /**
  104897. * Sets the transition time when framing the mesh, in milliseconds
  104898. */
  104899. /**
  104900. * Gets the transition time when framing the mesh, in milliseconds
  104901. */
  104902. framingTime: number;
  104903. /**
  104904. * Define if the behavior should automatically change the configured
  104905. * camera limits and sensibilities.
  104906. */
  104907. autoCorrectCameraLimitsAndSensibility: boolean;
  104908. private _onPrePointerObservableObserver;
  104909. private _onAfterCheckInputsObserver;
  104910. private _onMeshTargetChangedObserver;
  104911. private _attachedCamera;
  104912. private _isPointerDown;
  104913. private _lastInteractionTime;
  104914. /**
  104915. * Initializes the behavior.
  104916. */
  104917. init(): void;
  104918. /**
  104919. * Attaches the behavior to its arc rotate camera.
  104920. * @param camera Defines the camera to attach the behavior to
  104921. */
  104922. attach(camera: ArcRotateCamera): void;
  104923. /**
  104924. * Detaches the behavior from its current arc rotate camera.
  104925. */
  104926. detach(): void;
  104927. private _animatables;
  104928. private _betaIsAnimating;
  104929. private _betaTransition;
  104930. private _radiusTransition;
  104931. private _vectorTransition;
  104932. /**
  104933. * Targets the given mesh and updates zoom level accordingly.
  104934. * @param mesh The mesh to target.
  104935. * @param radius Optional. If a cached radius position already exists, overrides default.
  104936. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  104937. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  104938. * @param onAnimationEnd Callback triggered at the end of the framing animation
  104939. */
  104940. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  104941. /**
  104942. * Targets the given mesh with its children and updates zoom level accordingly.
  104943. * @param mesh The mesh to target.
  104944. * @param radius Optional. If a cached radius position already exists, overrides default.
  104945. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  104946. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  104947. * @param onAnimationEnd Callback triggered at the end of the framing animation
  104948. */
  104949. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  104950. /**
  104951. * Targets the given meshes with their children and updates zoom level accordingly.
  104952. * @param meshes The mesh to target.
  104953. * @param radius Optional. If a cached radius position already exists, overrides default.
  104954. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  104955. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  104956. * @param onAnimationEnd Callback triggered at the end of the framing animation
  104957. */
  104958. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  104959. /**
  104960. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  104961. * @param minimumWorld Determines the smaller position of the bounding box extend
  104962. * @param maximumWorld Determines the bigger position of the bounding box extend
  104963. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  104964. * @param onAnimationEnd Callback triggered at the end of the framing animation
  104965. */
  104966. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  104967. /**
  104968. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  104969. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  104970. * frustum width.
  104971. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  104972. * to fully enclose the mesh in the viewing frustum.
  104973. */
  104974. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  104975. /**
  104976. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  104977. * is automatically returned to its default position (expected to be above ground plane).
  104978. */
  104979. private _maintainCameraAboveGround;
  104980. /**
  104981. * Returns the frustum slope based on the canvas ratio and camera FOV
  104982. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  104983. */
  104984. private _getFrustumSlope;
  104985. /**
  104986. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  104987. */
  104988. private _clearAnimationLocks;
  104989. /**
  104990. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  104991. */
  104992. private _applyUserInteraction;
  104993. /**
  104994. * Stops and removes all animations that have been applied to the camera
  104995. */
  104996. stopAllAnimations(): void;
  104997. /**
  104998. * Gets a value indicating if the user is moving the camera
  104999. */
  105000. readonly isUserIsMoving: boolean;
  105001. /**
  105002. * The camera can move all the way towards the mesh.
  105003. */
  105004. static IgnoreBoundsSizeMode: number;
  105005. /**
  105006. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  105007. */
  105008. static FitFrustumSidesMode: number;
  105009. }
  105010. }
  105011. declare module BABYLON {
  105012. /**
  105013. * Base class for Camera Pointer Inputs.
  105014. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  105015. * for example usage.
  105016. */
  105017. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  105018. /**
  105019. * Defines the camera the input is attached to.
  105020. */
  105021. abstract camera: Camera;
  105022. /**
  105023. * Whether keyboard modifier keys are pressed at time of last mouse event.
  105024. */
  105025. protected _altKey: boolean;
  105026. protected _ctrlKey: boolean;
  105027. protected _metaKey: boolean;
  105028. protected _shiftKey: boolean;
  105029. /**
  105030. * Which mouse buttons were pressed at time of last mouse event.
  105031. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  105032. */
  105033. protected _buttonsPressed: number;
  105034. /**
  105035. * Defines the buttons associated with the input to handle camera move.
  105036. */
  105037. buttons: number[];
  105038. /**
  105039. * Attach the input controls to a specific dom element to get the input from.
  105040. * @param element Defines the element the controls should be listened from
  105041. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  105042. */
  105043. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  105044. /**
  105045. * Detach the current controls from the specified dom element.
  105046. * @param element Defines the element to stop listening the inputs from
  105047. */
  105048. detachControl(element: Nullable<HTMLElement>): void;
  105049. /**
  105050. * Gets the class name of the current input.
  105051. * @returns the class name
  105052. */
  105053. getClassName(): string;
  105054. /**
  105055. * Get the friendly name associated with the input class.
  105056. * @returns the input friendly name
  105057. */
  105058. getSimpleName(): string;
  105059. /**
  105060. * Called on pointer POINTERDOUBLETAP event.
  105061. * Override this method to provide functionality on POINTERDOUBLETAP event.
  105062. */
  105063. protected onDoubleTap(type: string): void;
  105064. /**
  105065. * Called on pointer POINTERMOVE event if only a single touch is active.
  105066. * Override this method to provide functionality.
  105067. */
  105068. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  105069. /**
  105070. * Called on pointer POINTERMOVE event if multiple touches are active.
  105071. * Override this method to provide functionality.
  105072. */
  105073. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  105074. /**
  105075. * Called on JS contextmenu event.
  105076. * Override this method to provide functionality.
  105077. */
  105078. protected onContextMenu(evt: PointerEvent): void;
  105079. /**
  105080. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  105081. * press.
  105082. * Override this method to provide functionality.
  105083. */
  105084. protected onButtonDown(evt: PointerEvent): void;
  105085. /**
  105086. * Called each time a new POINTERUP event occurs. Ie, for each button
  105087. * release.
  105088. * Override this method to provide functionality.
  105089. */
  105090. protected onButtonUp(evt: PointerEvent): void;
  105091. /**
  105092. * Called when window becomes inactive.
  105093. * Override this method to provide functionality.
  105094. */
  105095. protected onLostFocus(): void;
  105096. private _pointerInput;
  105097. private _observer;
  105098. private _onLostFocus;
  105099. private pointA;
  105100. private pointB;
  105101. }
  105102. }
  105103. declare module BABYLON {
  105104. /**
  105105. * Manage the pointers inputs to control an arc rotate camera.
  105106. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  105107. */
  105108. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  105109. /**
  105110. * Defines the camera the input is attached to.
  105111. */
  105112. camera: ArcRotateCamera;
  105113. /**
  105114. * Gets the class name of the current input.
  105115. * @returns the class name
  105116. */
  105117. getClassName(): string;
  105118. /**
  105119. * Defines the buttons associated with the input to handle camera move.
  105120. */
  105121. buttons: number[];
  105122. /**
  105123. * Defines the pointer angular sensibility along the X axis or how fast is
  105124. * the camera rotating.
  105125. */
  105126. angularSensibilityX: number;
  105127. /**
  105128. * Defines the pointer angular sensibility along the Y axis or how fast is
  105129. * the camera rotating.
  105130. */
  105131. angularSensibilityY: number;
  105132. /**
  105133. * Defines the pointer pinch precision or how fast is the camera zooming.
  105134. */
  105135. pinchPrecision: number;
  105136. /**
  105137. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  105138. * from 0.
  105139. * It defines the percentage of current camera.radius to use as delta when
  105140. * pinch zoom is used.
  105141. */
  105142. pinchDeltaPercentage: number;
  105143. /**
  105144. * Defines the pointer panning sensibility or how fast is the camera moving.
  105145. */
  105146. panningSensibility: number;
  105147. /**
  105148. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  105149. */
  105150. multiTouchPanning: boolean;
  105151. /**
  105152. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  105153. * zoom (pinch) through multitouch.
  105154. */
  105155. multiTouchPanAndZoom: boolean;
  105156. /**
  105157. * Revers pinch action direction.
  105158. */
  105159. pinchInwards: boolean;
  105160. private _isPanClick;
  105161. private _twoFingerActivityCount;
  105162. private _isPinching;
  105163. /**
  105164. * Called on pointer POINTERMOVE event if only a single touch is active.
  105165. */
  105166. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  105167. /**
  105168. * Called on pointer POINTERDOUBLETAP event.
  105169. */
  105170. protected onDoubleTap(type: string): void;
  105171. /**
  105172. * Called on pointer POINTERMOVE event if multiple touches are active.
  105173. */
  105174. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  105175. /**
  105176. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  105177. * press.
  105178. */
  105179. protected onButtonDown(evt: PointerEvent): void;
  105180. /**
  105181. * Called each time a new POINTERUP event occurs. Ie, for each button
  105182. * release.
  105183. */
  105184. protected onButtonUp(evt: PointerEvent): void;
  105185. /**
  105186. * Called when window becomes inactive.
  105187. */
  105188. protected onLostFocus(): void;
  105189. }
  105190. }
  105191. declare module BABYLON {
  105192. /**
  105193. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  105194. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  105195. */
  105196. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  105197. /**
  105198. * Defines the camera the input is attached to.
  105199. */
  105200. camera: ArcRotateCamera;
  105201. /**
  105202. * Defines the list of key codes associated with the up action (increase alpha)
  105203. */
  105204. keysUp: number[];
  105205. /**
  105206. * Defines the list of key codes associated with the down action (decrease alpha)
  105207. */
  105208. keysDown: number[];
  105209. /**
  105210. * Defines the list of key codes associated with the left action (increase beta)
  105211. */
  105212. keysLeft: number[];
  105213. /**
  105214. * Defines the list of key codes associated with the right action (decrease beta)
  105215. */
  105216. keysRight: number[];
  105217. /**
  105218. * Defines the list of key codes associated with the reset action.
  105219. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  105220. */
  105221. keysReset: number[];
  105222. /**
  105223. * Defines the panning sensibility of the inputs.
  105224. * (How fast is the camera paning)
  105225. */
  105226. panningSensibility: number;
  105227. /**
  105228. * Defines the zooming sensibility of the inputs.
  105229. * (How fast is the camera zooming)
  105230. */
  105231. zoomingSensibility: number;
  105232. /**
  105233. * Defines wether maintaining the alt key down switch the movement mode from
  105234. * orientation to zoom.
  105235. */
  105236. useAltToZoom: boolean;
  105237. /**
  105238. * Rotation speed of the camera
  105239. */
  105240. angularSpeed: number;
  105241. private _keys;
  105242. private _ctrlPressed;
  105243. private _altPressed;
  105244. private _onCanvasBlurObserver;
  105245. private _onKeyboardObserver;
  105246. private _engine;
  105247. private _scene;
  105248. /**
  105249. * Attach the input controls to a specific dom element to get the input from.
  105250. * @param element Defines the element the controls should be listened from
  105251. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  105252. */
  105253. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  105254. /**
  105255. * Detach the current controls from the specified dom element.
  105256. * @param element Defines the element to stop listening the inputs from
  105257. */
  105258. detachControl(element: Nullable<HTMLElement>): void;
  105259. /**
  105260. * Update the current camera state depending on the inputs that have been used this frame.
  105261. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  105262. */
  105263. checkInputs(): void;
  105264. /**
  105265. * Gets the class name of the current intput.
  105266. * @returns the class name
  105267. */
  105268. getClassName(): string;
  105269. /**
  105270. * Get the friendly name associated with the input class.
  105271. * @returns the input friendly name
  105272. */
  105273. getSimpleName(): string;
  105274. }
  105275. }
  105276. declare module BABYLON {
  105277. /**
  105278. * Manage the mouse wheel inputs to control an arc rotate camera.
  105279. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  105280. */
  105281. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  105282. /**
  105283. * Defines the camera the input is attached to.
  105284. */
  105285. camera: ArcRotateCamera;
  105286. /**
  105287. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  105288. */
  105289. wheelPrecision: number;
  105290. /**
  105291. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  105292. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  105293. */
  105294. wheelDeltaPercentage: number;
  105295. private _wheel;
  105296. private _observer;
  105297. private computeDeltaFromMouseWheelLegacyEvent;
  105298. /**
  105299. * Attach the input controls to a specific dom element to get the input from.
  105300. * @param element Defines the element the controls should be listened from
  105301. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  105302. */
  105303. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  105304. /**
  105305. * Detach the current controls from the specified dom element.
  105306. * @param element Defines the element to stop listening the inputs from
  105307. */
  105308. detachControl(element: Nullable<HTMLElement>): void;
  105309. /**
  105310. * Gets the class name of the current intput.
  105311. * @returns the class name
  105312. */
  105313. getClassName(): string;
  105314. /**
  105315. * Get the friendly name associated with the input class.
  105316. * @returns the input friendly name
  105317. */
  105318. getSimpleName(): string;
  105319. }
  105320. }
  105321. declare module BABYLON {
  105322. /**
  105323. * Default Inputs manager for the ArcRotateCamera.
  105324. * It groups all the default supported inputs for ease of use.
  105325. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  105326. */
  105327. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  105328. /**
  105329. * Instantiates a new ArcRotateCameraInputsManager.
  105330. * @param camera Defines the camera the inputs belong to
  105331. */
  105332. constructor(camera: ArcRotateCamera);
  105333. /**
  105334. * Add mouse wheel input support to the input manager.
  105335. * @returns the current input manager
  105336. */
  105337. addMouseWheel(): ArcRotateCameraInputsManager;
  105338. /**
  105339. * Add pointers input support to the input manager.
  105340. * @returns the current input manager
  105341. */
  105342. addPointers(): ArcRotateCameraInputsManager;
  105343. /**
  105344. * Add keyboard input support to the input manager.
  105345. * @returns the current input manager
  105346. */
  105347. addKeyboard(): ArcRotateCameraInputsManager;
  105348. }
  105349. }
  105350. declare module BABYLON {
  105351. /**
  105352. * This represents an orbital type of camera.
  105353. *
  105354. * 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.
  105355. * 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.
  105356. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  105357. */
  105358. export class ArcRotateCamera extends TargetCamera {
  105359. /**
  105360. * Defines the rotation angle of the camera along the longitudinal axis.
  105361. */
  105362. alpha: number;
  105363. /**
  105364. * Defines the rotation angle of the camera along the latitudinal axis.
  105365. */
  105366. beta: number;
  105367. /**
  105368. * Defines the radius of the camera from it s target point.
  105369. */
  105370. radius: number;
  105371. protected _target: Vector3;
  105372. protected _targetHost: Nullable<AbstractMesh>;
  105373. /**
  105374. * Defines the target point of the camera.
  105375. * The camera looks towards it form the radius distance.
  105376. */
  105377. target: Vector3;
  105378. /**
  105379. * Define the current local position of the camera in the scene
  105380. */
  105381. position: Vector3;
  105382. protected _upVector: Vector3;
  105383. protected _upToYMatrix: Matrix;
  105384. protected _YToUpMatrix: Matrix;
  105385. /**
  105386. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  105387. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  105388. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  105389. */
  105390. upVector: Vector3;
  105391. /**
  105392. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  105393. */
  105394. setMatUp(): void;
  105395. /**
  105396. * Current inertia value on the longitudinal axis.
  105397. * The bigger this number the longer it will take for the camera to stop.
  105398. */
  105399. inertialAlphaOffset: number;
  105400. /**
  105401. * Current inertia value on the latitudinal axis.
  105402. * The bigger this number the longer it will take for the camera to stop.
  105403. */
  105404. inertialBetaOffset: number;
  105405. /**
  105406. * Current inertia value on the radius axis.
  105407. * The bigger this number the longer it will take for the camera to stop.
  105408. */
  105409. inertialRadiusOffset: number;
  105410. /**
  105411. * Minimum allowed angle on the longitudinal axis.
  105412. * This can help limiting how the Camera is able to move in the scene.
  105413. */
  105414. lowerAlphaLimit: Nullable<number>;
  105415. /**
  105416. * Maximum allowed angle on the longitudinal axis.
  105417. * This can help limiting how the Camera is able to move in the scene.
  105418. */
  105419. upperAlphaLimit: Nullable<number>;
  105420. /**
  105421. * Minimum allowed angle on the latitudinal axis.
  105422. * This can help limiting how the Camera is able to move in the scene.
  105423. */
  105424. lowerBetaLimit: number;
  105425. /**
  105426. * Maximum allowed angle on the latitudinal axis.
  105427. * This can help limiting how the Camera is able to move in the scene.
  105428. */
  105429. upperBetaLimit: number;
  105430. /**
  105431. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  105432. * This can help limiting how the Camera is able to move in the scene.
  105433. */
  105434. lowerRadiusLimit: Nullable<number>;
  105435. /**
  105436. * Maximum allowed distance of the camera to the target (The camera can not get further).
  105437. * This can help limiting how the Camera is able to move in the scene.
  105438. */
  105439. upperRadiusLimit: Nullable<number>;
  105440. /**
  105441. * Defines the current inertia value used during panning of the camera along the X axis.
  105442. */
  105443. inertialPanningX: number;
  105444. /**
  105445. * Defines the current inertia value used during panning of the camera along the Y axis.
  105446. */
  105447. inertialPanningY: number;
  105448. /**
  105449. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  105450. * Basically if your fingers moves away from more than this distance you will be considered
  105451. * in pinch mode.
  105452. */
  105453. pinchToPanMaxDistance: number;
  105454. /**
  105455. * Defines the maximum distance the camera can pan.
  105456. * This could help keeping the cammera always in your scene.
  105457. */
  105458. panningDistanceLimit: Nullable<number>;
  105459. /**
  105460. * Defines the target of the camera before paning.
  105461. */
  105462. panningOriginTarget: Vector3;
  105463. /**
  105464. * Defines the value of the inertia used during panning.
  105465. * 0 would mean stop inertia and one would mean no decelleration at all.
  105466. */
  105467. panningInertia: number;
  105468. /**
  105469. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  105470. */
  105471. angularSensibilityX: number;
  105472. /**
  105473. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  105474. */
  105475. angularSensibilityY: number;
  105476. /**
  105477. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  105478. */
  105479. pinchPrecision: number;
  105480. /**
  105481. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  105482. * It will be used instead of pinchDeltaPrecision if different from 0.
  105483. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  105484. */
  105485. pinchDeltaPercentage: number;
  105486. /**
  105487. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  105488. */
  105489. panningSensibility: number;
  105490. /**
  105491. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  105492. */
  105493. keysUp: number[];
  105494. /**
  105495. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  105496. */
  105497. keysDown: number[];
  105498. /**
  105499. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  105500. */
  105501. keysLeft: number[];
  105502. /**
  105503. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  105504. */
  105505. keysRight: number[];
  105506. /**
  105507. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  105508. */
  105509. wheelPrecision: number;
  105510. /**
  105511. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  105512. * It will be used instead of pinchDeltaPrecision if different from 0.
  105513. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  105514. */
  105515. wheelDeltaPercentage: number;
  105516. /**
  105517. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  105518. */
  105519. zoomOnFactor: number;
  105520. /**
  105521. * Defines a screen offset for the camera position.
  105522. */
  105523. targetScreenOffset: Vector2;
  105524. /**
  105525. * Allows the camera to be completely reversed.
  105526. * If false the camera can not arrive upside down.
  105527. */
  105528. allowUpsideDown: boolean;
  105529. /**
  105530. * Define if double tap/click is used to restore the previously saved state of the camera.
  105531. */
  105532. useInputToRestoreState: boolean;
  105533. /** @hidden */
  105534. _viewMatrix: Matrix;
  105535. /** @hidden */
  105536. _useCtrlForPanning: boolean;
  105537. /** @hidden */
  105538. _panningMouseButton: number;
  105539. /**
  105540. * Defines the input associated to the camera.
  105541. */
  105542. inputs: ArcRotateCameraInputsManager;
  105543. /** @hidden */
  105544. _reset: () => void;
  105545. /**
  105546. * Defines the allowed panning axis.
  105547. */
  105548. panningAxis: Vector3;
  105549. protected _localDirection: Vector3;
  105550. protected _transformedDirection: Vector3;
  105551. private _bouncingBehavior;
  105552. /**
  105553. * Gets the bouncing behavior of the camera if it has been enabled.
  105554. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  105555. */
  105556. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  105557. /**
  105558. * Defines if the bouncing behavior of the camera is enabled on the camera.
  105559. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  105560. */
  105561. useBouncingBehavior: boolean;
  105562. private _framingBehavior;
  105563. /**
  105564. * Gets the framing behavior of the camera if it has been enabled.
  105565. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  105566. */
  105567. readonly framingBehavior: Nullable<FramingBehavior>;
  105568. /**
  105569. * Defines if the framing behavior of the camera is enabled on the camera.
  105570. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  105571. */
  105572. useFramingBehavior: boolean;
  105573. private _autoRotationBehavior;
  105574. /**
  105575. * Gets the auto rotation behavior of the camera if it has been enabled.
  105576. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  105577. */
  105578. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  105579. /**
  105580. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  105581. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  105582. */
  105583. useAutoRotationBehavior: boolean;
  105584. /**
  105585. * Observable triggered when the mesh target has been changed on the camera.
  105586. */
  105587. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  105588. /**
  105589. * Event raised when the camera is colliding with a mesh.
  105590. */
  105591. onCollide: (collidedMesh: AbstractMesh) => void;
  105592. /**
  105593. * Defines whether the camera should check collision with the objects oh the scene.
  105594. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  105595. */
  105596. checkCollisions: boolean;
  105597. /**
  105598. * Defines the collision radius of the camera.
  105599. * This simulates a sphere around the camera.
  105600. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  105601. */
  105602. collisionRadius: Vector3;
  105603. protected _collider: Collider;
  105604. protected _previousPosition: Vector3;
  105605. protected _collisionVelocity: Vector3;
  105606. protected _newPosition: Vector3;
  105607. protected _previousAlpha: number;
  105608. protected _previousBeta: number;
  105609. protected _previousRadius: number;
  105610. protected _collisionTriggered: boolean;
  105611. protected _targetBoundingCenter: Nullable<Vector3>;
  105612. private _computationVector;
  105613. /**
  105614. * Instantiates a new ArcRotateCamera in a given scene
  105615. * @param name Defines the name of the camera
  105616. * @param alpha Defines the camera rotation along the logitudinal axis
  105617. * @param beta Defines the camera rotation along the latitudinal axis
  105618. * @param radius Defines the camera distance from its target
  105619. * @param target Defines the camera target
  105620. * @param scene Defines the scene the camera belongs to
  105621. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  105622. */
  105623. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  105624. /** @hidden */
  105625. _initCache(): void;
  105626. /** @hidden */
  105627. _updateCache(ignoreParentClass?: boolean): void;
  105628. protected _getTargetPosition(): Vector3;
  105629. private _storedAlpha;
  105630. private _storedBeta;
  105631. private _storedRadius;
  105632. private _storedTarget;
  105633. private _storedTargetScreenOffset;
  105634. /**
  105635. * Stores the current state of the camera (alpha, beta, radius and target)
  105636. * @returns the camera itself
  105637. */
  105638. storeState(): Camera;
  105639. /**
  105640. * @hidden
  105641. * Restored camera state. You must call storeState() first
  105642. */
  105643. _restoreStateValues(): boolean;
  105644. /** @hidden */
  105645. _isSynchronizedViewMatrix(): boolean;
  105646. /**
  105647. * Attached controls to the current camera.
  105648. * @param element Defines the element the controls should be listened from
  105649. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  105650. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  105651. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  105652. */
  105653. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  105654. /**
  105655. * Detach the current controls from the camera.
  105656. * The camera will stop reacting to inputs.
  105657. * @param element Defines the element to stop listening the inputs from
  105658. */
  105659. detachControl(element: HTMLElement): void;
  105660. /** @hidden */
  105661. _checkInputs(): void;
  105662. protected _checkLimits(): void;
  105663. /**
  105664. * Rebuilds angles (alpha, beta) and radius from the give position and target
  105665. */
  105666. rebuildAnglesAndRadius(): void;
  105667. /**
  105668. * Use a position to define the current camera related information like alpha, beta and radius
  105669. * @param position Defines the position to set the camera at
  105670. */
  105671. setPosition(position: Vector3): void;
  105672. /**
  105673. * Defines the target the camera should look at.
  105674. * This will automatically adapt alpha beta and radius to fit within the new target.
  105675. * @param target Defines the new target as a Vector or a mesh
  105676. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  105677. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  105678. */
  105679. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  105680. /** @hidden */
  105681. _getViewMatrix(): Matrix;
  105682. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  105683. /**
  105684. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  105685. * @param meshes Defines the mesh to zoom on
  105686. * @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)
  105687. */
  105688. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  105689. /**
  105690. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  105691. * The target will be changed but the radius
  105692. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  105693. * @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)
  105694. */
  105695. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  105696. min: Vector3;
  105697. max: Vector3;
  105698. distance: number;
  105699. }, doNotUpdateMaxZ?: boolean): void;
  105700. /**
  105701. * @override
  105702. * Override Camera.createRigCamera
  105703. */
  105704. createRigCamera(name: string, cameraIndex: number): Camera;
  105705. /**
  105706. * @hidden
  105707. * @override
  105708. * Override Camera._updateRigCameras
  105709. */
  105710. _updateRigCameras(): void;
  105711. /**
  105712. * Destroy the camera and release the current resources hold by it.
  105713. */
  105714. dispose(): void;
  105715. /**
  105716. * Gets the current object class name.
  105717. * @return the class name
  105718. */
  105719. getClassName(): string;
  105720. }
  105721. }
  105722. declare module BABYLON {
  105723. /**
  105724. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  105725. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  105726. */
  105727. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  105728. /**
  105729. * Gets the name of the behavior.
  105730. */
  105731. readonly name: string;
  105732. private _zoomStopsAnimation;
  105733. private _idleRotationSpeed;
  105734. private _idleRotationWaitTime;
  105735. private _idleRotationSpinupTime;
  105736. /**
  105737. * Sets the flag that indicates if user zooming should stop animation.
  105738. */
  105739. /**
  105740. * Gets the flag that indicates if user zooming should stop animation.
  105741. */
  105742. zoomStopsAnimation: boolean;
  105743. /**
  105744. * Sets the default speed at which the camera rotates around the model.
  105745. */
  105746. /**
  105747. * Gets the default speed at which the camera rotates around the model.
  105748. */
  105749. idleRotationSpeed: number;
  105750. /**
  105751. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  105752. */
  105753. /**
  105754. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  105755. */
  105756. idleRotationWaitTime: number;
  105757. /**
  105758. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  105759. */
  105760. /**
  105761. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  105762. */
  105763. idleRotationSpinupTime: number;
  105764. /**
  105765. * Gets a value indicating if the camera is currently rotating because of this behavior
  105766. */
  105767. readonly rotationInProgress: boolean;
  105768. private _onPrePointerObservableObserver;
  105769. private _onAfterCheckInputsObserver;
  105770. private _attachedCamera;
  105771. private _isPointerDown;
  105772. private _lastFrameTime;
  105773. private _lastInteractionTime;
  105774. private _cameraRotationSpeed;
  105775. /**
  105776. * Initializes the behavior.
  105777. */
  105778. init(): void;
  105779. /**
  105780. * Attaches the behavior to its arc rotate camera.
  105781. * @param camera Defines the camera to attach the behavior to
  105782. */
  105783. attach(camera: ArcRotateCamera): void;
  105784. /**
  105785. * Detaches the behavior from its current arc rotate camera.
  105786. */
  105787. detach(): void;
  105788. /**
  105789. * Returns true if user is scrolling.
  105790. * @return true if user is scrolling.
  105791. */
  105792. private _userIsZooming;
  105793. private _lastFrameRadius;
  105794. private _shouldAnimationStopForInteraction;
  105795. /**
  105796. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  105797. */
  105798. private _applyUserInteraction;
  105799. private _userIsMoving;
  105800. }
  105801. }
  105802. declare module BABYLON {
  105803. /**
  105804. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  105805. */
  105806. export class AttachToBoxBehavior implements Behavior<Mesh> {
  105807. private ui;
  105808. /**
  105809. * The name of the behavior
  105810. */
  105811. name: string;
  105812. /**
  105813. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  105814. */
  105815. distanceAwayFromFace: number;
  105816. /**
  105817. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  105818. */
  105819. distanceAwayFromBottomOfFace: number;
  105820. private _faceVectors;
  105821. private _target;
  105822. private _scene;
  105823. private _onRenderObserver;
  105824. private _tmpMatrix;
  105825. private _tmpVector;
  105826. /**
  105827. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  105828. * @param ui The transform node that should be attched to the mesh
  105829. */
  105830. constructor(ui: TransformNode);
  105831. /**
  105832. * Initializes the behavior
  105833. */
  105834. init(): void;
  105835. private _closestFace;
  105836. private _zeroVector;
  105837. private _lookAtTmpMatrix;
  105838. private _lookAtToRef;
  105839. /**
  105840. * Attaches the AttachToBoxBehavior to the passed in mesh
  105841. * @param target The mesh that the specified node will be attached to
  105842. */
  105843. attach(target: Mesh): void;
  105844. /**
  105845. * Detaches the behavior from the mesh
  105846. */
  105847. detach(): void;
  105848. }
  105849. }
  105850. declare module BABYLON {
  105851. /**
  105852. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  105853. */
  105854. export class FadeInOutBehavior implements Behavior<Mesh> {
  105855. /**
  105856. * Time in milliseconds to delay before fading in (Default: 0)
  105857. */
  105858. delay: number;
  105859. /**
  105860. * Time in milliseconds for the mesh to fade in (Default: 300)
  105861. */
  105862. fadeInTime: number;
  105863. private _millisecondsPerFrame;
  105864. private _hovered;
  105865. private _hoverValue;
  105866. private _ownerNode;
  105867. /**
  105868. * Instatiates the FadeInOutBehavior
  105869. */
  105870. constructor();
  105871. /**
  105872. * The name of the behavior
  105873. */
  105874. readonly name: string;
  105875. /**
  105876. * Initializes the behavior
  105877. */
  105878. init(): void;
  105879. /**
  105880. * Attaches the fade behavior on the passed in mesh
  105881. * @param ownerNode The mesh that will be faded in/out once attached
  105882. */
  105883. attach(ownerNode: Mesh): void;
  105884. /**
  105885. * Detaches the behavior from the mesh
  105886. */
  105887. detach(): void;
  105888. /**
  105889. * Triggers the mesh to begin fading in or out
  105890. * @param value if the object should fade in or out (true to fade in)
  105891. */
  105892. fadeIn(value: boolean): void;
  105893. private _update;
  105894. private _setAllVisibility;
  105895. }
  105896. }
  105897. declare module BABYLON {
  105898. /**
  105899. * Class containing a set of static utilities functions for managing Pivots
  105900. * @hidden
  105901. */
  105902. export class PivotTools {
  105903. private static _PivotCached;
  105904. private static _OldPivotPoint;
  105905. private static _PivotTranslation;
  105906. private static _PivotTmpVector;
  105907. /** @hidden */
  105908. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  105909. /** @hidden */
  105910. static _RestorePivotPoint(mesh: AbstractMesh): void;
  105911. }
  105912. }
  105913. declare module BABYLON {
  105914. /**
  105915. * Class containing static functions to help procedurally build meshes
  105916. */
  105917. export class PlaneBuilder {
  105918. /**
  105919. * Creates a plane mesh
  105920. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  105921. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  105922. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  105923. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105924. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  105925. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105926. * @param name defines the name of the mesh
  105927. * @param options defines the options used to create the mesh
  105928. * @param scene defines the hosting scene
  105929. * @returns the plane mesh
  105930. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  105931. */
  105932. static CreatePlane(name: string, options: {
  105933. size?: number;
  105934. width?: number;
  105935. height?: number;
  105936. sideOrientation?: number;
  105937. frontUVs?: Vector4;
  105938. backUVs?: Vector4;
  105939. updatable?: boolean;
  105940. sourcePlane?: Plane;
  105941. }, scene?: Nullable<Scene>): Mesh;
  105942. }
  105943. }
  105944. declare module BABYLON {
  105945. /**
  105946. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  105947. */
  105948. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  105949. private static _AnyMouseID;
  105950. /**
  105951. * Abstract mesh the behavior is set on
  105952. */
  105953. attachedNode: AbstractMesh;
  105954. private _dragPlane;
  105955. private _scene;
  105956. private _pointerObserver;
  105957. private _beforeRenderObserver;
  105958. private static _planeScene;
  105959. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  105960. /**
  105961. * 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)
  105962. */
  105963. maxDragAngle: number;
  105964. /**
  105965. * @hidden
  105966. */
  105967. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  105968. /**
  105969. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  105970. */
  105971. currentDraggingPointerID: number;
  105972. /**
  105973. * The last position where the pointer hit the drag plane in world space
  105974. */
  105975. lastDragPosition: Vector3;
  105976. /**
  105977. * If the behavior is currently in a dragging state
  105978. */
  105979. dragging: boolean;
  105980. /**
  105981. * 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)
  105982. */
  105983. dragDeltaRatio: number;
  105984. /**
  105985. * If the drag plane orientation should be updated during the dragging (Default: true)
  105986. */
  105987. updateDragPlane: boolean;
  105988. private _debugMode;
  105989. private _moving;
  105990. /**
  105991. * Fires each time the attached mesh is dragged with the pointer
  105992. * * delta between last drag position and current drag position in world space
  105993. * * dragDistance along the drag axis
  105994. * * dragPlaneNormal normal of the current drag plane used during the drag
  105995. * * dragPlanePoint in world space where the drag intersects the drag plane
  105996. */
  105997. onDragObservable: Observable<{
  105998. delta: Vector3;
  105999. dragPlanePoint: Vector3;
  106000. dragPlaneNormal: Vector3;
  106001. dragDistance: number;
  106002. pointerId: number;
  106003. }>;
  106004. /**
  106005. * Fires each time a drag begins (eg. mouse down on mesh)
  106006. */
  106007. onDragStartObservable: Observable<{
  106008. dragPlanePoint: Vector3;
  106009. pointerId: number;
  106010. }>;
  106011. /**
  106012. * Fires each time a drag ends (eg. mouse release after drag)
  106013. */
  106014. onDragEndObservable: Observable<{
  106015. dragPlanePoint: Vector3;
  106016. pointerId: number;
  106017. }>;
  106018. /**
  106019. * If the attached mesh should be moved when dragged
  106020. */
  106021. moveAttached: boolean;
  106022. /**
  106023. * If the drag behavior will react to drag events (Default: true)
  106024. */
  106025. enabled: boolean;
  106026. /**
  106027. * If pointer events should start and release the drag (Default: true)
  106028. */
  106029. startAndReleaseDragOnPointerEvents: boolean;
  106030. /**
  106031. * If camera controls should be detached during the drag
  106032. */
  106033. detachCameraControls: boolean;
  106034. /**
  106035. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  106036. */
  106037. useObjectOrienationForDragging: boolean;
  106038. private _options;
  106039. /**
  106040. * Creates a pointer drag behavior that can be attached to a mesh
  106041. * @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)
  106042. */
  106043. constructor(options?: {
  106044. dragAxis?: Vector3;
  106045. dragPlaneNormal?: Vector3;
  106046. });
  106047. /**
  106048. * Predicate to determine if it is valid to move the object to a new position when it is moved
  106049. */
  106050. validateDrag: (targetPosition: Vector3) => boolean;
  106051. /**
  106052. * The name of the behavior
  106053. */
  106054. readonly name: string;
  106055. /**
  106056. * Initializes the behavior
  106057. */
  106058. init(): void;
  106059. private _tmpVector;
  106060. private _alternatePickedPoint;
  106061. private _worldDragAxis;
  106062. private _targetPosition;
  106063. private _attachedElement;
  106064. /**
  106065. * Attaches the drag behavior the passed in mesh
  106066. * @param ownerNode The mesh that will be dragged around once attached
  106067. * @param predicate Predicate to use for pick filtering
  106068. */
  106069. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  106070. /**
  106071. * Force relase the drag action by code.
  106072. */
  106073. releaseDrag(): void;
  106074. private _startDragRay;
  106075. private _lastPointerRay;
  106076. /**
  106077. * Simulates the start of a pointer drag event on the behavior
  106078. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  106079. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  106080. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  106081. */
  106082. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  106083. private _startDrag;
  106084. private _dragDelta;
  106085. private _moveDrag;
  106086. private _pickWithRayOnDragPlane;
  106087. private _pointA;
  106088. private _pointB;
  106089. private _pointC;
  106090. private _lineA;
  106091. private _lineB;
  106092. private _localAxis;
  106093. private _lookAt;
  106094. private _updateDragPlanePosition;
  106095. /**
  106096. * Detaches the behavior from the mesh
  106097. */
  106098. detach(): void;
  106099. }
  106100. }
  106101. declare module BABYLON {
  106102. /**
  106103. * A behavior that when attached to a mesh will allow the mesh to be scaled
  106104. */
  106105. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  106106. private _dragBehaviorA;
  106107. private _dragBehaviorB;
  106108. private _startDistance;
  106109. private _initialScale;
  106110. private _targetScale;
  106111. private _ownerNode;
  106112. private _sceneRenderObserver;
  106113. /**
  106114. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  106115. */
  106116. constructor();
  106117. /**
  106118. * The name of the behavior
  106119. */
  106120. readonly name: string;
  106121. /**
  106122. * Initializes the behavior
  106123. */
  106124. init(): void;
  106125. private _getCurrentDistance;
  106126. /**
  106127. * Attaches the scale behavior the passed in mesh
  106128. * @param ownerNode The mesh that will be scaled around once attached
  106129. */
  106130. attach(ownerNode: Mesh): void;
  106131. /**
  106132. * Detaches the behavior from the mesh
  106133. */
  106134. detach(): void;
  106135. }
  106136. }
  106137. declare module BABYLON {
  106138. /**
  106139. * 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
  106140. */
  106141. export class SixDofDragBehavior implements Behavior<Mesh> {
  106142. private static _virtualScene;
  106143. private _ownerNode;
  106144. private _sceneRenderObserver;
  106145. private _scene;
  106146. private _targetPosition;
  106147. private _virtualOriginMesh;
  106148. private _virtualDragMesh;
  106149. private _pointerObserver;
  106150. private _moving;
  106151. private _startingOrientation;
  106152. /**
  106153. * 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)
  106154. */
  106155. private zDragFactor;
  106156. /**
  106157. * If the object should rotate to face the drag origin
  106158. */
  106159. rotateDraggedObject: boolean;
  106160. /**
  106161. * If the behavior is currently in a dragging state
  106162. */
  106163. dragging: boolean;
  106164. /**
  106165. * 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)
  106166. */
  106167. dragDeltaRatio: number;
  106168. /**
  106169. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  106170. */
  106171. currentDraggingPointerID: number;
  106172. /**
  106173. * If camera controls should be detached during the drag
  106174. */
  106175. detachCameraControls: boolean;
  106176. /**
  106177. * Fires each time a drag starts
  106178. */
  106179. onDragStartObservable: Observable<{}>;
  106180. /**
  106181. * Fires each time a drag ends (eg. mouse release after drag)
  106182. */
  106183. onDragEndObservable: Observable<{}>;
  106184. /**
  106185. * 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
  106186. */
  106187. constructor();
  106188. /**
  106189. * The name of the behavior
  106190. */
  106191. readonly name: string;
  106192. /**
  106193. * Initializes the behavior
  106194. */
  106195. init(): void;
  106196. /**
  106197. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  106198. */
  106199. private readonly _pointerCamera;
  106200. /**
  106201. * Attaches the scale behavior the passed in mesh
  106202. * @param ownerNode The mesh that will be scaled around once attached
  106203. */
  106204. attach(ownerNode: Mesh): void;
  106205. /**
  106206. * Detaches the behavior from the mesh
  106207. */
  106208. detach(): void;
  106209. }
  106210. }
  106211. declare module BABYLON {
  106212. /**
  106213. * Class used to apply inverse kinematics to bones
  106214. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  106215. */
  106216. export class BoneIKController {
  106217. private static _tmpVecs;
  106218. private static _tmpQuat;
  106219. private static _tmpMats;
  106220. /**
  106221. * Gets or sets the target mesh
  106222. */
  106223. targetMesh: AbstractMesh;
  106224. /** Gets or sets the mesh used as pole */
  106225. poleTargetMesh: AbstractMesh;
  106226. /**
  106227. * Gets or sets the bone used as pole
  106228. */
  106229. poleTargetBone: Nullable<Bone>;
  106230. /**
  106231. * Gets or sets the target position
  106232. */
  106233. targetPosition: Vector3;
  106234. /**
  106235. * Gets or sets the pole target position
  106236. */
  106237. poleTargetPosition: Vector3;
  106238. /**
  106239. * Gets or sets the pole target local offset
  106240. */
  106241. poleTargetLocalOffset: Vector3;
  106242. /**
  106243. * Gets or sets the pole angle
  106244. */
  106245. poleAngle: number;
  106246. /**
  106247. * Gets or sets the mesh associated with the controller
  106248. */
  106249. mesh: AbstractMesh;
  106250. /**
  106251. * 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)
  106252. */
  106253. slerpAmount: number;
  106254. private _bone1Quat;
  106255. private _bone1Mat;
  106256. private _bone2Ang;
  106257. private _bone1;
  106258. private _bone2;
  106259. private _bone1Length;
  106260. private _bone2Length;
  106261. private _maxAngle;
  106262. private _maxReach;
  106263. private _rightHandedSystem;
  106264. private _bendAxis;
  106265. private _slerping;
  106266. private _adjustRoll;
  106267. /**
  106268. * Gets or sets maximum allowed angle
  106269. */
  106270. maxAngle: number;
  106271. /**
  106272. * Creates a new BoneIKController
  106273. * @param mesh defines the mesh to control
  106274. * @param bone defines the bone to control
  106275. * @param options defines options to set up the controller
  106276. */
  106277. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  106278. targetMesh?: AbstractMesh;
  106279. poleTargetMesh?: AbstractMesh;
  106280. poleTargetBone?: Bone;
  106281. poleTargetLocalOffset?: Vector3;
  106282. poleAngle?: number;
  106283. bendAxis?: Vector3;
  106284. maxAngle?: number;
  106285. slerpAmount?: number;
  106286. });
  106287. private _setMaxAngle;
  106288. /**
  106289. * Force the controller to update the bones
  106290. */
  106291. update(): void;
  106292. }
  106293. }
  106294. declare module BABYLON {
  106295. /**
  106296. * Class used to make a bone look toward a point in space
  106297. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  106298. */
  106299. export class BoneLookController {
  106300. private static _tmpVecs;
  106301. private static _tmpQuat;
  106302. private static _tmpMats;
  106303. /**
  106304. * The target Vector3 that the bone will look at
  106305. */
  106306. target: Vector3;
  106307. /**
  106308. * The mesh that the bone is attached to
  106309. */
  106310. mesh: AbstractMesh;
  106311. /**
  106312. * The bone that will be looking to the target
  106313. */
  106314. bone: Bone;
  106315. /**
  106316. * The up axis of the coordinate system that is used when the bone is rotated
  106317. */
  106318. upAxis: Vector3;
  106319. /**
  106320. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  106321. */
  106322. upAxisSpace: Space;
  106323. /**
  106324. * Used to make an adjustment to the yaw of the bone
  106325. */
  106326. adjustYaw: number;
  106327. /**
  106328. * Used to make an adjustment to the pitch of the bone
  106329. */
  106330. adjustPitch: number;
  106331. /**
  106332. * Used to make an adjustment to the roll of the bone
  106333. */
  106334. adjustRoll: number;
  106335. /**
  106336. * 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)
  106337. */
  106338. slerpAmount: number;
  106339. private _minYaw;
  106340. private _maxYaw;
  106341. private _minPitch;
  106342. private _maxPitch;
  106343. private _minYawSin;
  106344. private _minYawCos;
  106345. private _maxYawSin;
  106346. private _maxYawCos;
  106347. private _midYawConstraint;
  106348. private _minPitchTan;
  106349. private _maxPitchTan;
  106350. private _boneQuat;
  106351. private _slerping;
  106352. private _transformYawPitch;
  106353. private _transformYawPitchInv;
  106354. private _firstFrameSkipped;
  106355. private _yawRange;
  106356. private _fowardAxis;
  106357. /**
  106358. * Gets or sets the minimum yaw angle that the bone can look to
  106359. */
  106360. minYaw: number;
  106361. /**
  106362. * Gets or sets the maximum yaw angle that the bone can look to
  106363. */
  106364. maxYaw: number;
  106365. /**
  106366. * Gets or sets the minimum pitch angle that the bone can look to
  106367. */
  106368. minPitch: number;
  106369. /**
  106370. * Gets or sets the maximum pitch angle that the bone can look to
  106371. */
  106372. maxPitch: number;
  106373. /**
  106374. * Create a BoneLookController
  106375. * @param mesh the mesh that the bone belongs to
  106376. * @param bone the bone that will be looking to the target
  106377. * @param target the target Vector3 to look at
  106378. * @param options optional settings:
  106379. * * maxYaw: the maximum angle the bone will yaw to
  106380. * * minYaw: the minimum angle the bone will yaw to
  106381. * * maxPitch: the maximum angle the bone will pitch to
  106382. * * minPitch: the minimum angle the bone will yaw to
  106383. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  106384. * * upAxis: the up axis of the coordinate system
  106385. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  106386. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  106387. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  106388. * * adjustYaw: used to make an adjustment to the yaw of the bone
  106389. * * adjustPitch: used to make an adjustment to the pitch of the bone
  106390. * * adjustRoll: used to make an adjustment to the roll of the bone
  106391. **/
  106392. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  106393. maxYaw?: number;
  106394. minYaw?: number;
  106395. maxPitch?: number;
  106396. minPitch?: number;
  106397. slerpAmount?: number;
  106398. upAxis?: Vector3;
  106399. upAxisSpace?: Space;
  106400. yawAxis?: Vector3;
  106401. pitchAxis?: Vector3;
  106402. adjustYaw?: number;
  106403. adjustPitch?: number;
  106404. adjustRoll?: number;
  106405. });
  106406. /**
  106407. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  106408. */
  106409. update(): void;
  106410. private _getAngleDiff;
  106411. private _getAngleBetween;
  106412. private _isAngleBetween;
  106413. }
  106414. }
  106415. declare module BABYLON {
  106416. /**
  106417. * Manage the gamepad inputs to control an arc rotate camera.
  106418. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  106419. */
  106420. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  106421. /**
  106422. * Defines the camera the input is attached to.
  106423. */
  106424. camera: ArcRotateCamera;
  106425. /**
  106426. * Defines the gamepad the input is gathering event from.
  106427. */
  106428. gamepad: Nullable<Gamepad>;
  106429. /**
  106430. * Defines the gamepad rotation sensiblity.
  106431. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  106432. */
  106433. gamepadRotationSensibility: number;
  106434. /**
  106435. * Defines the gamepad move sensiblity.
  106436. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  106437. */
  106438. gamepadMoveSensibility: number;
  106439. private _yAxisScale;
  106440. /**
  106441. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  106442. */
  106443. invertYAxis: boolean;
  106444. private _onGamepadConnectedObserver;
  106445. private _onGamepadDisconnectedObserver;
  106446. /**
  106447. * Attach the input controls to a specific dom element to get the input from.
  106448. * @param element Defines the element the controls should be listened from
  106449. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  106450. */
  106451. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  106452. /**
  106453. * Detach the current controls from the specified dom element.
  106454. * @param element Defines the element to stop listening the inputs from
  106455. */
  106456. detachControl(element: Nullable<HTMLElement>): void;
  106457. /**
  106458. * Update the current camera state depending on the inputs that have been used this frame.
  106459. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  106460. */
  106461. checkInputs(): void;
  106462. /**
  106463. * Gets the class name of the current intput.
  106464. * @returns the class name
  106465. */
  106466. getClassName(): string;
  106467. /**
  106468. * Get the friendly name associated with the input class.
  106469. * @returns the input friendly name
  106470. */
  106471. getSimpleName(): string;
  106472. }
  106473. }
  106474. declare module BABYLON {
  106475. interface ArcRotateCameraInputsManager {
  106476. /**
  106477. * Add orientation input support to the input manager.
  106478. * @returns the current input manager
  106479. */
  106480. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  106481. }
  106482. /**
  106483. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  106484. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  106485. */
  106486. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  106487. /**
  106488. * Defines the camera the input is attached to.
  106489. */
  106490. camera: ArcRotateCamera;
  106491. /**
  106492. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  106493. */
  106494. alphaCorrection: number;
  106495. /**
  106496. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  106497. */
  106498. gammaCorrection: number;
  106499. private _alpha;
  106500. private _gamma;
  106501. private _dirty;
  106502. private _deviceOrientationHandler;
  106503. /**
  106504. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  106505. */
  106506. constructor();
  106507. /**
  106508. * Attach the input controls to a specific dom element to get the input from.
  106509. * @param element Defines the element the controls should be listened from
  106510. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  106511. */
  106512. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  106513. /** @hidden */
  106514. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  106515. /**
  106516. * Update the current camera state depending on the inputs that have been used this frame.
  106517. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  106518. */
  106519. checkInputs(): void;
  106520. /**
  106521. * Detach the current controls from the specified dom element.
  106522. * @param element Defines the element to stop listening the inputs from
  106523. */
  106524. detachControl(element: Nullable<HTMLElement>): void;
  106525. /**
  106526. * Gets the class name of the current intput.
  106527. * @returns the class name
  106528. */
  106529. getClassName(): string;
  106530. /**
  106531. * Get the friendly name associated with the input class.
  106532. * @returns the input friendly name
  106533. */
  106534. getSimpleName(): string;
  106535. }
  106536. }
  106537. declare module BABYLON {
  106538. /**
  106539. * Listen to mouse events to control the camera.
  106540. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  106541. */
  106542. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  106543. /**
  106544. * Defines the camera the input is attached to.
  106545. */
  106546. camera: FlyCamera;
  106547. /**
  106548. * Defines if touch is enabled. (Default is true.)
  106549. */
  106550. touchEnabled: boolean;
  106551. /**
  106552. * Defines the buttons associated with the input to handle camera rotation.
  106553. */
  106554. buttons: number[];
  106555. /**
  106556. * Assign buttons for Yaw control.
  106557. */
  106558. buttonsYaw: number[];
  106559. /**
  106560. * Assign buttons for Pitch control.
  106561. */
  106562. buttonsPitch: number[];
  106563. /**
  106564. * Assign buttons for Roll control.
  106565. */
  106566. buttonsRoll: number[];
  106567. /**
  106568. * Detect if any button is being pressed while mouse is moved.
  106569. * -1 = Mouse locked.
  106570. * 0 = Left button.
  106571. * 1 = Middle Button.
  106572. * 2 = Right Button.
  106573. */
  106574. activeButton: number;
  106575. /**
  106576. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  106577. * Higher values reduce its sensitivity.
  106578. */
  106579. angularSensibility: number;
  106580. private _mousemoveCallback;
  106581. private _observer;
  106582. private _rollObserver;
  106583. private previousPosition;
  106584. private noPreventDefault;
  106585. private element;
  106586. /**
  106587. * Listen to mouse events to control the camera.
  106588. * @param touchEnabled Define if touch is enabled. (Default is true.)
  106589. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  106590. */
  106591. constructor(touchEnabled?: boolean);
  106592. /**
  106593. * Attach the mouse control to the HTML DOM element.
  106594. * @param element Defines the element that listens to the input events.
  106595. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  106596. */
  106597. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  106598. /**
  106599. * Detach the current controls from the specified dom element.
  106600. * @param element Defines the element to stop listening the inputs from
  106601. */
  106602. detachControl(element: Nullable<HTMLElement>): void;
  106603. /**
  106604. * Gets the class name of the current input.
  106605. * @returns the class name.
  106606. */
  106607. getClassName(): string;
  106608. /**
  106609. * Get the friendly name associated with the input class.
  106610. * @returns the input's friendly name.
  106611. */
  106612. getSimpleName(): string;
  106613. private _pointerInput;
  106614. private _onMouseMove;
  106615. /**
  106616. * Rotate camera by mouse offset.
  106617. */
  106618. private rotateCamera;
  106619. }
  106620. }
  106621. declare module BABYLON {
  106622. /**
  106623. * Default Inputs manager for the FlyCamera.
  106624. * It groups all the default supported inputs for ease of use.
  106625. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  106626. */
  106627. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  106628. /**
  106629. * Instantiates a new FlyCameraInputsManager.
  106630. * @param camera Defines the camera the inputs belong to.
  106631. */
  106632. constructor(camera: FlyCamera);
  106633. /**
  106634. * Add keyboard input support to the input manager.
  106635. * @returns the new FlyCameraKeyboardMoveInput().
  106636. */
  106637. addKeyboard(): FlyCameraInputsManager;
  106638. /**
  106639. * Add mouse input support to the input manager.
  106640. * @param touchEnabled Enable touch screen support.
  106641. * @returns the new FlyCameraMouseInput().
  106642. */
  106643. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  106644. }
  106645. }
  106646. declare module BABYLON {
  106647. /**
  106648. * This is a flying camera, designed for 3D movement and rotation in all directions,
  106649. * such as in a 3D Space Shooter or a Flight Simulator.
  106650. */
  106651. export class FlyCamera extends TargetCamera {
  106652. /**
  106653. * Define the collision ellipsoid of the camera.
  106654. * This is helpful for simulating a camera body, like a player's body.
  106655. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  106656. */
  106657. ellipsoid: Vector3;
  106658. /**
  106659. * Define an offset for the position of the ellipsoid around the camera.
  106660. * This can be helpful if the camera is attached away from the player's body center,
  106661. * such as at its head.
  106662. */
  106663. ellipsoidOffset: Vector3;
  106664. /**
  106665. * Enable or disable collisions of the camera with the rest of the scene objects.
  106666. */
  106667. checkCollisions: boolean;
  106668. /**
  106669. * Enable or disable gravity on the camera.
  106670. */
  106671. applyGravity: boolean;
  106672. /**
  106673. * Define the current direction the camera is moving to.
  106674. */
  106675. cameraDirection: Vector3;
  106676. /**
  106677. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  106678. * This overrides and empties cameraRotation.
  106679. */
  106680. rotationQuaternion: Quaternion;
  106681. /**
  106682. * Track Roll to maintain the wanted Rolling when looking around.
  106683. */
  106684. _trackRoll: number;
  106685. /**
  106686. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  106687. */
  106688. rollCorrect: number;
  106689. /**
  106690. * Mimic a banked turn, Rolling the camera when Yawing.
  106691. * It's recommended to use rollCorrect = 10 for faster banking correction.
  106692. */
  106693. bankedTurn: boolean;
  106694. /**
  106695. * Limit in radians for how much Roll banking will add. (Default: 90°)
  106696. */
  106697. bankedTurnLimit: number;
  106698. /**
  106699. * Value of 0 disables the banked Roll.
  106700. * Value of 1 is equal to the Yaw angle in radians.
  106701. */
  106702. bankedTurnMultiplier: number;
  106703. /**
  106704. * The inputs manager loads all the input sources, such as keyboard and mouse.
  106705. */
  106706. inputs: FlyCameraInputsManager;
  106707. /**
  106708. * Gets the input sensibility for mouse input.
  106709. * Higher values reduce sensitivity.
  106710. */
  106711. /**
  106712. * Sets the input sensibility for a mouse input.
  106713. * Higher values reduce sensitivity.
  106714. */
  106715. angularSensibility: number;
  106716. /**
  106717. * Get the keys for camera movement forward.
  106718. */
  106719. /**
  106720. * Set the keys for camera movement forward.
  106721. */
  106722. keysForward: number[];
  106723. /**
  106724. * Get the keys for camera movement backward.
  106725. */
  106726. keysBackward: number[];
  106727. /**
  106728. * Get the keys for camera movement up.
  106729. */
  106730. /**
  106731. * Set the keys for camera movement up.
  106732. */
  106733. keysUp: number[];
  106734. /**
  106735. * Get the keys for camera movement down.
  106736. */
  106737. /**
  106738. * Set the keys for camera movement down.
  106739. */
  106740. keysDown: number[];
  106741. /**
  106742. * Get the keys for camera movement left.
  106743. */
  106744. /**
  106745. * Set the keys for camera movement left.
  106746. */
  106747. keysLeft: number[];
  106748. /**
  106749. * Set the keys for camera movement right.
  106750. */
  106751. /**
  106752. * Set the keys for camera movement right.
  106753. */
  106754. keysRight: number[];
  106755. /**
  106756. * Event raised when the camera collides with a mesh in the scene.
  106757. */
  106758. onCollide: (collidedMesh: AbstractMesh) => void;
  106759. private _collider;
  106760. private _needMoveForGravity;
  106761. private _oldPosition;
  106762. private _diffPosition;
  106763. private _newPosition;
  106764. /** @hidden */
  106765. _localDirection: Vector3;
  106766. /** @hidden */
  106767. _transformedDirection: Vector3;
  106768. /**
  106769. * Instantiates a FlyCamera.
  106770. * This is a flying camera, designed for 3D movement and rotation in all directions,
  106771. * such as in a 3D Space Shooter or a Flight Simulator.
  106772. * @param name Define the name of the camera in the scene.
  106773. * @param position Define the starting position of the camera in the scene.
  106774. * @param scene Define the scene the camera belongs to.
  106775. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  106776. */
  106777. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  106778. /**
  106779. * Attach a control to the HTML DOM element.
  106780. * @param element Defines the element that listens to the input events.
  106781. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  106782. */
  106783. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  106784. /**
  106785. * Detach a control from the HTML DOM element.
  106786. * The camera will stop reacting to that input.
  106787. * @param element Defines the element that listens to the input events.
  106788. */
  106789. detachControl(element: HTMLElement): void;
  106790. private _collisionMask;
  106791. /**
  106792. * Get the mask that the camera ignores in collision events.
  106793. */
  106794. /**
  106795. * Set the mask that the camera ignores in collision events.
  106796. */
  106797. collisionMask: number;
  106798. /** @hidden */
  106799. _collideWithWorld(displacement: Vector3): void;
  106800. /** @hidden */
  106801. private _onCollisionPositionChange;
  106802. /** @hidden */
  106803. _checkInputs(): void;
  106804. /** @hidden */
  106805. _decideIfNeedsToMove(): boolean;
  106806. /** @hidden */
  106807. _updatePosition(): void;
  106808. /**
  106809. * Restore the Roll to its target value at the rate specified.
  106810. * @param rate - Higher means slower restoring.
  106811. * @hidden
  106812. */
  106813. restoreRoll(rate: number): void;
  106814. /**
  106815. * Destroy the camera and release the current resources held by it.
  106816. */
  106817. dispose(): void;
  106818. /**
  106819. * Get the current object class name.
  106820. * @returns the class name.
  106821. */
  106822. getClassName(): string;
  106823. }
  106824. }
  106825. declare module BABYLON {
  106826. /**
  106827. * Listen to keyboard events to control the camera.
  106828. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  106829. */
  106830. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  106831. /**
  106832. * Defines the camera the input is attached to.
  106833. */
  106834. camera: FlyCamera;
  106835. /**
  106836. * The list of keyboard keys used to control the forward move of the camera.
  106837. */
  106838. keysForward: number[];
  106839. /**
  106840. * The list of keyboard keys used to control the backward move of the camera.
  106841. */
  106842. keysBackward: number[];
  106843. /**
  106844. * The list of keyboard keys used to control the forward move of the camera.
  106845. */
  106846. keysUp: number[];
  106847. /**
  106848. * The list of keyboard keys used to control the backward move of the camera.
  106849. */
  106850. keysDown: number[];
  106851. /**
  106852. * The list of keyboard keys used to control the right strafe move of the camera.
  106853. */
  106854. keysRight: number[];
  106855. /**
  106856. * The list of keyboard keys used to control the left strafe move of the camera.
  106857. */
  106858. keysLeft: number[];
  106859. private _keys;
  106860. private _onCanvasBlurObserver;
  106861. private _onKeyboardObserver;
  106862. private _engine;
  106863. private _scene;
  106864. /**
  106865. * Attach the input controls to a specific dom element to get the input from.
  106866. * @param element Defines the element the controls should be listened from
  106867. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  106868. */
  106869. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  106870. /**
  106871. * Detach the current controls from the specified dom element.
  106872. * @param element Defines the element to stop listening the inputs from
  106873. */
  106874. detachControl(element: Nullable<HTMLElement>): void;
  106875. /**
  106876. * Gets the class name of the current intput.
  106877. * @returns the class name
  106878. */
  106879. getClassName(): string;
  106880. /** @hidden */
  106881. _onLostFocus(e: FocusEvent): void;
  106882. /**
  106883. * Get the friendly name associated with the input class.
  106884. * @returns the input friendly name
  106885. */
  106886. getSimpleName(): string;
  106887. /**
  106888. * Update the current camera state depending on the inputs that have been used this frame.
  106889. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  106890. */
  106891. checkInputs(): void;
  106892. }
  106893. }
  106894. declare module BABYLON {
  106895. /**
  106896. * Manage the mouse wheel inputs to control a follow camera.
  106897. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  106898. */
  106899. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  106900. /**
  106901. * Defines the camera the input is attached to.
  106902. */
  106903. camera: FollowCamera;
  106904. /**
  106905. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  106906. */
  106907. axisControlRadius: boolean;
  106908. /**
  106909. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  106910. */
  106911. axisControlHeight: boolean;
  106912. /**
  106913. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  106914. */
  106915. axisControlRotation: boolean;
  106916. /**
  106917. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  106918. * relation to mouseWheel events.
  106919. */
  106920. wheelPrecision: number;
  106921. /**
  106922. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  106923. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  106924. */
  106925. wheelDeltaPercentage: number;
  106926. private _wheel;
  106927. private _observer;
  106928. /**
  106929. * Attach the input controls to a specific dom element to get the input from.
  106930. * @param element Defines the element the controls should be listened from
  106931. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  106932. */
  106933. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  106934. /**
  106935. * Detach the current controls from the specified dom element.
  106936. * @param element Defines the element to stop listening the inputs from
  106937. */
  106938. detachControl(element: Nullable<HTMLElement>): void;
  106939. /**
  106940. * Gets the class name of the current intput.
  106941. * @returns the class name
  106942. */
  106943. getClassName(): string;
  106944. /**
  106945. * Get the friendly name associated with the input class.
  106946. * @returns the input friendly name
  106947. */
  106948. getSimpleName(): string;
  106949. }
  106950. }
  106951. declare module BABYLON {
  106952. /**
  106953. * Manage the pointers inputs to control an follow camera.
  106954. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  106955. */
  106956. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  106957. /**
  106958. * Defines the camera the input is attached to.
  106959. */
  106960. camera: FollowCamera;
  106961. /**
  106962. * Gets the class name of the current input.
  106963. * @returns the class name
  106964. */
  106965. getClassName(): string;
  106966. /**
  106967. * Defines the pointer angular sensibility along the X axis or how fast is
  106968. * the camera rotating.
  106969. * A negative number will reverse the axis direction.
  106970. */
  106971. angularSensibilityX: number;
  106972. /**
  106973. * Defines the pointer angular sensibility along the Y axis or how fast is
  106974. * the camera rotating.
  106975. * A negative number will reverse the axis direction.
  106976. */
  106977. angularSensibilityY: number;
  106978. /**
  106979. * Defines the pointer pinch precision or how fast is the camera zooming.
  106980. * A negative number will reverse the axis direction.
  106981. */
  106982. pinchPrecision: number;
  106983. /**
  106984. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  106985. * from 0.
  106986. * It defines the percentage of current camera.radius to use as delta when
  106987. * pinch zoom is used.
  106988. */
  106989. pinchDeltaPercentage: number;
  106990. /**
  106991. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  106992. */
  106993. axisXControlRadius: boolean;
  106994. /**
  106995. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  106996. */
  106997. axisXControlHeight: boolean;
  106998. /**
  106999. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  107000. */
  107001. axisXControlRotation: boolean;
  107002. /**
  107003. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  107004. */
  107005. axisYControlRadius: boolean;
  107006. /**
  107007. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  107008. */
  107009. axisYControlHeight: boolean;
  107010. /**
  107011. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  107012. */
  107013. axisYControlRotation: boolean;
  107014. /**
  107015. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  107016. */
  107017. axisPinchControlRadius: boolean;
  107018. /**
  107019. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  107020. */
  107021. axisPinchControlHeight: boolean;
  107022. /**
  107023. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  107024. */
  107025. axisPinchControlRotation: boolean;
  107026. /**
  107027. * Log error messages if basic misconfiguration has occurred.
  107028. */
  107029. warningEnable: boolean;
  107030. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  107031. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  107032. private _warningCounter;
  107033. private _warning;
  107034. }
  107035. }
  107036. declare module BABYLON {
  107037. /**
  107038. * Default Inputs manager for the FollowCamera.
  107039. * It groups all the default supported inputs for ease of use.
  107040. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  107041. */
  107042. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  107043. /**
  107044. * Instantiates a new FollowCameraInputsManager.
  107045. * @param camera Defines the camera the inputs belong to
  107046. */
  107047. constructor(camera: FollowCamera);
  107048. /**
  107049. * Add keyboard input support to the input manager.
  107050. * @returns the current input manager
  107051. */
  107052. addKeyboard(): FollowCameraInputsManager;
  107053. /**
  107054. * Add mouse wheel input support to the input manager.
  107055. * @returns the current input manager
  107056. */
  107057. addMouseWheel(): FollowCameraInputsManager;
  107058. /**
  107059. * Add pointers input support to the input manager.
  107060. * @returns the current input manager
  107061. */
  107062. addPointers(): FollowCameraInputsManager;
  107063. /**
  107064. * Add orientation input support to the input manager.
  107065. * @returns the current input manager
  107066. */
  107067. addVRDeviceOrientation(): FollowCameraInputsManager;
  107068. }
  107069. }
  107070. declare module BABYLON {
  107071. /**
  107072. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  107073. * an arc rotate version arcFollowCamera are available.
  107074. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  107075. */
  107076. export class FollowCamera extends TargetCamera {
  107077. /**
  107078. * Distance the follow camera should follow an object at
  107079. */
  107080. radius: number;
  107081. /**
  107082. * Minimum allowed distance of the camera to the axis of rotation
  107083. * (The camera can not get closer).
  107084. * This can help limiting how the Camera is able to move in the scene.
  107085. */
  107086. lowerRadiusLimit: Nullable<number>;
  107087. /**
  107088. * Maximum allowed distance of the camera to the axis of rotation
  107089. * (The camera can not get further).
  107090. * This can help limiting how the Camera is able to move in the scene.
  107091. */
  107092. upperRadiusLimit: Nullable<number>;
  107093. /**
  107094. * Define a rotation offset between the camera and the object it follows
  107095. */
  107096. rotationOffset: number;
  107097. /**
  107098. * Minimum allowed angle to camera position relative to target object.
  107099. * This can help limiting how the Camera is able to move in the scene.
  107100. */
  107101. lowerRotationOffsetLimit: Nullable<number>;
  107102. /**
  107103. * Maximum allowed angle to camera position relative to target object.
  107104. * This can help limiting how the Camera is able to move in the scene.
  107105. */
  107106. upperRotationOffsetLimit: Nullable<number>;
  107107. /**
  107108. * Define a height offset between the camera and the object it follows.
  107109. * It can help following an object from the top (like a car chaing a plane)
  107110. */
  107111. heightOffset: number;
  107112. /**
  107113. * Minimum allowed height of camera position relative to target object.
  107114. * This can help limiting how the Camera is able to move in the scene.
  107115. */
  107116. lowerHeightOffsetLimit: Nullable<number>;
  107117. /**
  107118. * Maximum allowed height of camera position relative to target object.
  107119. * This can help limiting how the Camera is able to move in the scene.
  107120. */
  107121. upperHeightOffsetLimit: Nullable<number>;
  107122. /**
  107123. * Define how fast the camera can accelerate to follow it s target.
  107124. */
  107125. cameraAcceleration: number;
  107126. /**
  107127. * Define the speed limit of the camera following an object.
  107128. */
  107129. maxCameraSpeed: number;
  107130. /**
  107131. * Define the target of the camera.
  107132. */
  107133. lockedTarget: Nullable<AbstractMesh>;
  107134. /**
  107135. * Defines the input associated with the camera.
  107136. */
  107137. inputs: FollowCameraInputsManager;
  107138. /**
  107139. * Instantiates the follow camera.
  107140. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  107141. * @param name Define the name of the camera in the scene
  107142. * @param position Define the position of the camera
  107143. * @param scene Define the scene the camera belong to
  107144. * @param lockedTarget Define the target of the camera
  107145. */
  107146. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  107147. private _follow;
  107148. /**
  107149. * Attached controls to the current camera.
  107150. * @param element Defines the element the controls should be listened from
  107151. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  107152. */
  107153. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  107154. /**
  107155. * Detach the current controls from the camera.
  107156. * The camera will stop reacting to inputs.
  107157. * @param element Defines the element to stop listening the inputs from
  107158. */
  107159. detachControl(element: HTMLElement): void;
  107160. /** @hidden */
  107161. _checkInputs(): void;
  107162. private _checkLimits;
  107163. /**
  107164. * Gets the camera class name.
  107165. * @returns the class name
  107166. */
  107167. getClassName(): string;
  107168. }
  107169. /**
  107170. * Arc Rotate version of the follow camera.
  107171. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  107172. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  107173. */
  107174. export class ArcFollowCamera extends TargetCamera {
  107175. /** The longitudinal angle of the camera */
  107176. alpha: number;
  107177. /** The latitudinal angle of the camera */
  107178. beta: number;
  107179. /** The radius of the camera from its target */
  107180. radius: number;
  107181. /** Define the camera target (the messh it should follow) */
  107182. target: Nullable<AbstractMesh>;
  107183. private _cartesianCoordinates;
  107184. /**
  107185. * Instantiates a new ArcFollowCamera
  107186. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  107187. * @param name Define the name of the camera
  107188. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  107189. * @param beta Define the rotation angle of the camera around the elevation axis
  107190. * @param radius Define the radius of the camera from its target point
  107191. * @param target Define the target of the camera
  107192. * @param scene Define the scene the camera belongs to
  107193. */
  107194. constructor(name: string,
  107195. /** The longitudinal angle of the camera */
  107196. alpha: number,
  107197. /** The latitudinal angle of the camera */
  107198. beta: number,
  107199. /** The radius of the camera from its target */
  107200. radius: number,
  107201. /** Define the camera target (the messh it should follow) */
  107202. target: Nullable<AbstractMesh>, scene: Scene);
  107203. private _follow;
  107204. /** @hidden */
  107205. _checkInputs(): void;
  107206. /**
  107207. * Returns the class name of the object.
  107208. * It is mostly used internally for serialization purposes.
  107209. */
  107210. getClassName(): string;
  107211. }
  107212. }
  107213. declare module BABYLON {
  107214. /**
  107215. * Manage the keyboard inputs to control the movement of a follow camera.
  107216. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  107217. */
  107218. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  107219. /**
  107220. * Defines the camera the input is attached to.
  107221. */
  107222. camera: FollowCamera;
  107223. /**
  107224. * Defines the list of key codes associated with the up action (increase heightOffset)
  107225. */
  107226. keysHeightOffsetIncr: number[];
  107227. /**
  107228. * Defines the list of key codes associated with the down action (decrease heightOffset)
  107229. */
  107230. keysHeightOffsetDecr: number[];
  107231. /**
  107232. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  107233. */
  107234. keysHeightOffsetModifierAlt: boolean;
  107235. /**
  107236. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  107237. */
  107238. keysHeightOffsetModifierCtrl: boolean;
  107239. /**
  107240. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  107241. */
  107242. keysHeightOffsetModifierShift: boolean;
  107243. /**
  107244. * Defines the list of key codes associated with the left action (increase rotationOffset)
  107245. */
  107246. keysRotationOffsetIncr: number[];
  107247. /**
  107248. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  107249. */
  107250. keysRotationOffsetDecr: number[];
  107251. /**
  107252. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  107253. */
  107254. keysRotationOffsetModifierAlt: boolean;
  107255. /**
  107256. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  107257. */
  107258. keysRotationOffsetModifierCtrl: boolean;
  107259. /**
  107260. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  107261. */
  107262. keysRotationOffsetModifierShift: boolean;
  107263. /**
  107264. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  107265. */
  107266. keysRadiusIncr: number[];
  107267. /**
  107268. * Defines the list of key codes associated with the zoom-out action (increase radius)
  107269. */
  107270. keysRadiusDecr: number[];
  107271. /**
  107272. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  107273. */
  107274. keysRadiusModifierAlt: boolean;
  107275. /**
  107276. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  107277. */
  107278. keysRadiusModifierCtrl: boolean;
  107279. /**
  107280. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  107281. */
  107282. keysRadiusModifierShift: boolean;
  107283. /**
  107284. * Defines the rate of change of heightOffset.
  107285. */
  107286. heightSensibility: number;
  107287. /**
  107288. * Defines the rate of change of rotationOffset.
  107289. */
  107290. rotationSensibility: number;
  107291. /**
  107292. * Defines the rate of change of radius.
  107293. */
  107294. radiusSensibility: number;
  107295. private _keys;
  107296. private _ctrlPressed;
  107297. private _altPressed;
  107298. private _shiftPressed;
  107299. private _onCanvasBlurObserver;
  107300. private _onKeyboardObserver;
  107301. private _engine;
  107302. private _scene;
  107303. /**
  107304. * Attach the input controls to a specific dom element to get the input from.
  107305. * @param element Defines the element the controls should be listened from
  107306. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  107307. */
  107308. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  107309. /**
  107310. * Detach the current controls from the specified dom element.
  107311. * @param element Defines the element to stop listening the inputs from
  107312. */
  107313. detachControl(element: Nullable<HTMLElement>): void;
  107314. /**
  107315. * Update the current camera state depending on the inputs that have been used this frame.
  107316. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  107317. */
  107318. checkInputs(): void;
  107319. /**
  107320. * Gets the class name of the current input.
  107321. * @returns the class name
  107322. */
  107323. getClassName(): string;
  107324. /**
  107325. * Get the friendly name associated with the input class.
  107326. * @returns the input friendly name
  107327. */
  107328. getSimpleName(): string;
  107329. /**
  107330. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  107331. * allow modification of the heightOffset value.
  107332. */
  107333. private _modifierHeightOffset;
  107334. /**
  107335. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  107336. * allow modification of the rotationOffset value.
  107337. */
  107338. private _modifierRotationOffset;
  107339. /**
  107340. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  107341. * allow modification of the radius value.
  107342. */
  107343. private _modifierRadius;
  107344. }
  107345. }
  107346. declare module BABYLON {
  107347. interface FreeCameraInputsManager {
  107348. /**
  107349. * @hidden
  107350. */
  107351. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  107352. /**
  107353. * Add orientation input support to the input manager.
  107354. * @returns the current input manager
  107355. */
  107356. addDeviceOrientation(): FreeCameraInputsManager;
  107357. }
  107358. /**
  107359. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  107360. * Screen rotation is taken into account.
  107361. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  107362. */
  107363. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  107364. private _camera;
  107365. private _screenOrientationAngle;
  107366. private _constantTranform;
  107367. private _screenQuaternion;
  107368. private _alpha;
  107369. private _beta;
  107370. private _gamma;
  107371. /**
  107372. * Can be used to detect if a device orientation sensor is availible on a device
  107373. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  107374. * @returns a promise that will resolve on orientation change
  107375. */
  107376. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  107377. /**
  107378. * @hidden
  107379. */
  107380. _onDeviceOrientationChangedObservable: Observable<void>;
  107381. /**
  107382. * Instantiates a new input
  107383. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  107384. */
  107385. constructor();
  107386. /**
  107387. * Define the camera controlled by the input.
  107388. */
  107389. camera: FreeCamera;
  107390. /**
  107391. * Attach the input controls to a specific dom element to get the input from.
  107392. * @param element Defines the element the controls should be listened from
  107393. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  107394. */
  107395. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  107396. private _orientationChanged;
  107397. private _deviceOrientation;
  107398. /**
  107399. * Detach the current controls from the specified dom element.
  107400. * @param element Defines the element to stop listening the inputs from
  107401. */
  107402. detachControl(element: Nullable<HTMLElement>): void;
  107403. /**
  107404. * Update the current camera state depending on the inputs that have been used this frame.
  107405. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  107406. */
  107407. checkInputs(): void;
  107408. /**
  107409. * Gets the class name of the current intput.
  107410. * @returns the class name
  107411. */
  107412. getClassName(): string;
  107413. /**
  107414. * Get the friendly name associated with the input class.
  107415. * @returns the input friendly name
  107416. */
  107417. getSimpleName(): string;
  107418. }
  107419. }
  107420. declare module BABYLON {
  107421. /**
  107422. * Manage the gamepad inputs to control a free camera.
  107423. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  107424. */
  107425. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  107426. /**
  107427. * Define the camera the input is attached to.
  107428. */
  107429. camera: FreeCamera;
  107430. /**
  107431. * Define the Gamepad controlling the input
  107432. */
  107433. gamepad: Nullable<Gamepad>;
  107434. /**
  107435. * Defines the gamepad rotation sensiblity.
  107436. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  107437. */
  107438. gamepadAngularSensibility: number;
  107439. /**
  107440. * Defines the gamepad move sensiblity.
  107441. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  107442. */
  107443. gamepadMoveSensibility: number;
  107444. private _yAxisScale;
  107445. /**
  107446. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  107447. */
  107448. invertYAxis: boolean;
  107449. private _onGamepadConnectedObserver;
  107450. private _onGamepadDisconnectedObserver;
  107451. private _cameraTransform;
  107452. private _deltaTransform;
  107453. private _vector3;
  107454. private _vector2;
  107455. /**
  107456. * Attach the input controls to a specific dom element to get the input from.
  107457. * @param element Defines the element the controls should be listened from
  107458. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  107459. */
  107460. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  107461. /**
  107462. * Detach the current controls from the specified dom element.
  107463. * @param element Defines the element to stop listening the inputs from
  107464. */
  107465. detachControl(element: Nullable<HTMLElement>): void;
  107466. /**
  107467. * Update the current camera state depending on the inputs that have been used this frame.
  107468. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  107469. */
  107470. checkInputs(): void;
  107471. /**
  107472. * Gets the class name of the current intput.
  107473. * @returns the class name
  107474. */
  107475. getClassName(): string;
  107476. /**
  107477. * Get the friendly name associated with the input class.
  107478. * @returns the input friendly name
  107479. */
  107480. getSimpleName(): string;
  107481. }
  107482. }
  107483. declare module BABYLON {
  107484. /**
  107485. * Defines the potential axis of a Joystick
  107486. */
  107487. export enum JoystickAxis {
  107488. /** X axis */
  107489. X = 0,
  107490. /** Y axis */
  107491. Y = 1,
  107492. /** Z axis */
  107493. Z = 2
  107494. }
  107495. /**
  107496. * Class used to define virtual joystick (used in touch mode)
  107497. */
  107498. export class VirtualJoystick {
  107499. /**
  107500. * Gets or sets a boolean indicating that left and right values must be inverted
  107501. */
  107502. reverseLeftRight: boolean;
  107503. /**
  107504. * Gets or sets a boolean indicating that up and down values must be inverted
  107505. */
  107506. reverseUpDown: boolean;
  107507. /**
  107508. * Gets the offset value for the position (ie. the change of the position value)
  107509. */
  107510. deltaPosition: Vector3;
  107511. /**
  107512. * Gets a boolean indicating if the virtual joystick was pressed
  107513. */
  107514. pressed: boolean;
  107515. /**
  107516. * Canvas the virtual joystick will render onto, default z-index of this is 5
  107517. */
  107518. static Canvas: Nullable<HTMLCanvasElement>;
  107519. private static _globalJoystickIndex;
  107520. private static vjCanvasContext;
  107521. private static vjCanvasWidth;
  107522. private static vjCanvasHeight;
  107523. private static halfWidth;
  107524. private _action;
  107525. private _axisTargetedByLeftAndRight;
  107526. private _axisTargetedByUpAndDown;
  107527. private _joystickSensibility;
  107528. private _inversedSensibility;
  107529. private _joystickPointerID;
  107530. private _joystickColor;
  107531. private _joystickPointerPos;
  107532. private _joystickPreviousPointerPos;
  107533. private _joystickPointerStartPos;
  107534. private _deltaJoystickVector;
  107535. private _leftJoystick;
  107536. private _touches;
  107537. private _onPointerDownHandlerRef;
  107538. private _onPointerMoveHandlerRef;
  107539. private _onPointerUpHandlerRef;
  107540. private _onResize;
  107541. /**
  107542. * Creates a new virtual joystick
  107543. * @param leftJoystick defines that the joystick is for left hand (false by default)
  107544. */
  107545. constructor(leftJoystick?: boolean);
  107546. /**
  107547. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  107548. * @param newJoystickSensibility defines the new sensibility
  107549. */
  107550. setJoystickSensibility(newJoystickSensibility: number): void;
  107551. private _onPointerDown;
  107552. private _onPointerMove;
  107553. private _onPointerUp;
  107554. /**
  107555. * Change the color of the virtual joystick
  107556. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  107557. */
  107558. setJoystickColor(newColor: string): void;
  107559. /**
  107560. * Defines a callback to call when the joystick is touched
  107561. * @param action defines the callback
  107562. */
  107563. setActionOnTouch(action: () => any): void;
  107564. /**
  107565. * Defines which axis you'd like to control for left & right
  107566. * @param axis defines the axis to use
  107567. */
  107568. setAxisForLeftRight(axis: JoystickAxis): void;
  107569. /**
  107570. * Defines which axis you'd like to control for up & down
  107571. * @param axis defines the axis to use
  107572. */
  107573. setAxisForUpDown(axis: JoystickAxis): void;
  107574. private _drawVirtualJoystick;
  107575. /**
  107576. * Release internal HTML canvas
  107577. */
  107578. releaseCanvas(): void;
  107579. }
  107580. }
  107581. declare module BABYLON {
  107582. interface FreeCameraInputsManager {
  107583. /**
  107584. * Add virtual joystick input support to the input manager.
  107585. * @returns the current input manager
  107586. */
  107587. addVirtualJoystick(): FreeCameraInputsManager;
  107588. }
  107589. /**
  107590. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  107591. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  107592. */
  107593. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  107594. /**
  107595. * Defines the camera the input is attached to.
  107596. */
  107597. camera: FreeCamera;
  107598. private _leftjoystick;
  107599. private _rightjoystick;
  107600. /**
  107601. * Gets the left stick of the virtual joystick.
  107602. * @returns The virtual Joystick
  107603. */
  107604. getLeftJoystick(): VirtualJoystick;
  107605. /**
  107606. * Gets the right stick of the virtual joystick.
  107607. * @returns The virtual Joystick
  107608. */
  107609. getRightJoystick(): VirtualJoystick;
  107610. /**
  107611. * Update the current camera state depending on the inputs that have been used this frame.
  107612. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  107613. */
  107614. checkInputs(): void;
  107615. /**
  107616. * Attach the input controls to a specific dom element to get the input from.
  107617. * @param element Defines the element the controls should be listened from
  107618. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  107619. */
  107620. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  107621. /**
  107622. * Detach the current controls from the specified dom element.
  107623. * @param element Defines the element to stop listening the inputs from
  107624. */
  107625. detachControl(element: Nullable<HTMLElement>): void;
  107626. /**
  107627. * Gets the class name of the current intput.
  107628. * @returns the class name
  107629. */
  107630. getClassName(): string;
  107631. /**
  107632. * Get the friendly name associated with the input class.
  107633. * @returns the input friendly name
  107634. */
  107635. getSimpleName(): string;
  107636. }
  107637. }
  107638. declare module BABYLON {
  107639. /**
  107640. * This represents a FPS type of camera controlled by touch.
  107641. * This is like a universal camera minus the Gamepad controls.
  107642. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  107643. */
  107644. export class TouchCamera extends FreeCamera {
  107645. /**
  107646. * Defines the touch sensibility for rotation.
  107647. * The higher the faster.
  107648. */
  107649. touchAngularSensibility: number;
  107650. /**
  107651. * Defines the touch sensibility for move.
  107652. * The higher the faster.
  107653. */
  107654. touchMoveSensibility: number;
  107655. /**
  107656. * Instantiates a new touch camera.
  107657. * This represents a FPS type of camera controlled by touch.
  107658. * This is like a universal camera minus the Gamepad controls.
  107659. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  107660. * @param name Define the name of the camera in the scene
  107661. * @param position Define the start position of the camera in the scene
  107662. * @param scene Define the scene the camera belongs to
  107663. */
  107664. constructor(name: string, position: Vector3, scene: Scene);
  107665. /**
  107666. * Gets the current object class name.
  107667. * @return the class name
  107668. */
  107669. getClassName(): string;
  107670. /** @hidden */
  107671. _setupInputs(): void;
  107672. }
  107673. }
  107674. declare module BABYLON {
  107675. /**
  107676. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  107677. * being tilted forward or back and left or right.
  107678. */
  107679. export class DeviceOrientationCamera extends FreeCamera {
  107680. private _initialQuaternion;
  107681. private _quaternionCache;
  107682. private _tmpDragQuaternion;
  107683. private _disablePointerInputWhenUsingDeviceOrientation;
  107684. /**
  107685. * Creates a new device orientation camera
  107686. * @param name The name of the camera
  107687. * @param position The start position camera
  107688. * @param scene The scene the camera belongs to
  107689. */
  107690. constructor(name: string, position: Vector3, scene: Scene);
  107691. /**
  107692. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  107693. */
  107694. disablePointerInputWhenUsingDeviceOrientation: boolean;
  107695. private _dragFactor;
  107696. /**
  107697. * Enabled turning on the y axis when the orientation sensor is active
  107698. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  107699. */
  107700. enableHorizontalDragging(dragFactor?: number): void;
  107701. /**
  107702. * Gets the current instance class name ("DeviceOrientationCamera").
  107703. * This helps avoiding instanceof at run time.
  107704. * @returns the class name
  107705. */
  107706. getClassName(): string;
  107707. /**
  107708. * @hidden
  107709. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  107710. */
  107711. _checkInputs(): void;
  107712. /**
  107713. * Reset the camera to its default orientation on the specified axis only.
  107714. * @param axis The axis to reset
  107715. */
  107716. resetToCurrentRotation(axis?: Axis): void;
  107717. }
  107718. }
  107719. declare module BABYLON {
  107720. /**
  107721. * Defines supported buttons for XBox360 compatible gamepads
  107722. */
  107723. export enum Xbox360Button {
  107724. /** A */
  107725. A = 0,
  107726. /** B */
  107727. B = 1,
  107728. /** X */
  107729. X = 2,
  107730. /** Y */
  107731. Y = 3,
  107732. /** Start */
  107733. Start = 4,
  107734. /** Back */
  107735. Back = 5,
  107736. /** Left button */
  107737. LB = 6,
  107738. /** Right button */
  107739. RB = 7,
  107740. /** Left stick */
  107741. LeftStick = 8,
  107742. /** Right stick */
  107743. RightStick = 9
  107744. }
  107745. /** Defines values for XBox360 DPad */
  107746. export enum Xbox360Dpad {
  107747. /** Up */
  107748. Up = 0,
  107749. /** Down */
  107750. Down = 1,
  107751. /** Left */
  107752. Left = 2,
  107753. /** Right */
  107754. Right = 3
  107755. }
  107756. /**
  107757. * Defines a XBox360 gamepad
  107758. */
  107759. export class Xbox360Pad extends Gamepad {
  107760. private _leftTrigger;
  107761. private _rightTrigger;
  107762. private _onlefttriggerchanged;
  107763. private _onrighttriggerchanged;
  107764. private _onbuttondown;
  107765. private _onbuttonup;
  107766. private _ondpaddown;
  107767. private _ondpadup;
  107768. /** Observable raised when a button is pressed */
  107769. onButtonDownObservable: Observable<Xbox360Button>;
  107770. /** Observable raised when a button is released */
  107771. onButtonUpObservable: Observable<Xbox360Button>;
  107772. /** Observable raised when a pad is pressed */
  107773. onPadDownObservable: Observable<Xbox360Dpad>;
  107774. /** Observable raised when a pad is released */
  107775. onPadUpObservable: Observable<Xbox360Dpad>;
  107776. private _buttonA;
  107777. private _buttonB;
  107778. private _buttonX;
  107779. private _buttonY;
  107780. private _buttonBack;
  107781. private _buttonStart;
  107782. private _buttonLB;
  107783. private _buttonRB;
  107784. private _buttonLeftStick;
  107785. private _buttonRightStick;
  107786. private _dPadUp;
  107787. private _dPadDown;
  107788. private _dPadLeft;
  107789. private _dPadRight;
  107790. private _isXboxOnePad;
  107791. /**
  107792. * Creates a new XBox360 gamepad object
  107793. * @param id defines the id of this gamepad
  107794. * @param index defines its index
  107795. * @param gamepad defines the internal HTML gamepad object
  107796. * @param xboxOne defines if it is a XBox One gamepad
  107797. */
  107798. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  107799. /**
  107800. * Defines the callback to call when left trigger is pressed
  107801. * @param callback defines the callback to use
  107802. */
  107803. onlefttriggerchanged(callback: (value: number) => void): void;
  107804. /**
  107805. * Defines the callback to call when right trigger is pressed
  107806. * @param callback defines the callback to use
  107807. */
  107808. onrighttriggerchanged(callback: (value: number) => void): void;
  107809. /**
  107810. * Gets the left trigger value
  107811. */
  107812. /**
  107813. * Sets the left trigger value
  107814. */
  107815. leftTrigger: number;
  107816. /**
  107817. * Gets the right trigger value
  107818. */
  107819. /**
  107820. * Sets the right trigger value
  107821. */
  107822. rightTrigger: number;
  107823. /**
  107824. * Defines the callback to call when a button is pressed
  107825. * @param callback defines the callback to use
  107826. */
  107827. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  107828. /**
  107829. * Defines the callback to call when a button is released
  107830. * @param callback defines the callback to use
  107831. */
  107832. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  107833. /**
  107834. * Defines the callback to call when a pad is pressed
  107835. * @param callback defines the callback to use
  107836. */
  107837. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  107838. /**
  107839. * Defines the callback to call when a pad is released
  107840. * @param callback defines the callback to use
  107841. */
  107842. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  107843. private _setButtonValue;
  107844. private _setDPadValue;
  107845. /**
  107846. * Gets the value of the `A` button
  107847. */
  107848. /**
  107849. * Sets the value of the `A` button
  107850. */
  107851. buttonA: number;
  107852. /**
  107853. * Gets the value of the `B` button
  107854. */
  107855. /**
  107856. * Sets the value of the `B` button
  107857. */
  107858. buttonB: number;
  107859. /**
  107860. * Gets the value of the `X` button
  107861. */
  107862. /**
  107863. * Sets the value of the `X` button
  107864. */
  107865. buttonX: number;
  107866. /**
  107867. * Gets the value of the `Y` button
  107868. */
  107869. /**
  107870. * Sets the value of the `Y` button
  107871. */
  107872. buttonY: number;
  107873. /**
  107874. * Gets the value of the `Start` button
  107875. */
  107876. /**
  107877. * Sets the value of the `Start` button
  107878. */
  107879. buttonStart: number;
  107880. /**
  107881. * Gets the value of the `Back` button
  107882. */
  107883. /**
  107884. * Sets the value of the `Back` button
  107885. */
  107886. buttonBack: number;
  107887. /**
  107888. * Gets the value of the `Left` button
  107889. */
  107890. /**
  107891. * Sets the value of the `Left` button
  107892. */
  107893. buttonLB: number;
  107894. /**
  107895. * Gets the value of the `Right` button
  107896. */
  107897. /**
  107898. * Sets the value of the `Right` button
  107899. */
  107900. buttonRB: number;
  107901. /**
  107902. * Gets the value of the Left joystick
  107903. */
  107904. /**
  107905. * Sets the value of the Left joystick
  107906. */
  107907. buttonLeftStick: number;
  107908. /**
  107909. * Gets the value of the Right joystick
  107910. */
  107911. /**
  107912. * Sets the value of the Right joystick
  107913. */
  107914. buttonRightStick: number;
  107915. /**
  107916. * Gets the value of D-pad up
  107917. */
  107918. /**
  107919. * Sets the value of D-pad up
  107920. */
  107921. dPadUp: number;
  107922. /**
  107923. * Gets the value of D-pad down
  107924. */
  107925. /**
  107926. * Sets the value of D-pad down
  107927. */
  107928. dPadDown: number;
  107929. /**
  107930. * Gets the value of D-pad left
  107931. */
  107932. /**
  107933. * Sets the value of D-pad left
  107934. */
  107935. dPadLeft: number;
  107936. /**
  107937. * Gets the value of D-pad right
  107938. */
  107939. /**
  107940. * Sets the value of D-pad right
  107941. */
  107942. dPadRight: number;
  107943. /**
  107944. * Force the gamepad to synchronize with device values
  107945. */
  107946. update(): void;
  107947. /**
  107948. * Disposes the gamepad
  107949. */
  107950. dispose(): void;
  107951. }
  107952. }
  107953. declare module BABYLON {
  107954. /**
  107955. * Defines supported buttons for DualShock compatible gamepads
  107956. */
  107957. export enum DualShockButton {
  107958. /** Cross */
  107959. Cross = 0,
  107960. /** Circle */
  107961. Circle = 1,
  107962. /** Square */
  107963. Square = 2,
  107964. /** Triangle */
  107965. Triangle = 3,
  107966. /** Options */
  107967. Options = 4,
  107968. /** Share */
  107969. Share = 5,
  107970. /** L1 */
  107971. L1 = 6,
  107972. /** R1 */
  107973. R1 = 7,
  107974. /** Left stick */
  107975. LeftStick = 8,
  107976. /** Right stick */
  107977. RightStick = 9
  107978. }
  107979. /** Defines values for DualShock DPad */
  107980. export enum DualShockDpad {
  107981. /** Up */
  107982. Up = 0,
  107983. /** Down */
  107984. Down = 1,
  107985. /** Left */
  107986. Left = 2,
  107987. /** Right */
  107988. Right = 3
  107989. }
  107990. /**
  107991. * Defines a DualShock gamepad
  107992. */
  107993. export class DualShockPad extends Gamepad {
  107994. private _leftTrigger;
  107995. private _rightTrigger;
  107996. private _onlefttriggerchanged;
  107997. private _onrighttriggerchanged;
  107998. private _onbuttondown;
  107999. private _onbuttonup;
  108000. private _ondpaddown;
  108001. private _ondpadup;
  108002. /** Observable raised when a button is pressed */
  108003. onButtonDownObservable: Observable<DualShockButton>;
  108004. /** Observable raised when a button is released */
  108005. onButtonUpObservable: Observable<DualShockButton>;
  108006. /** Observable raised when a pad is pressed */
  108007. onPadDownObservable: Observable<DualShockDpad>;
  108008. /** Observable raised when a pad is released */
  108009. onPadUpObservable: Observable<DualShockDpad>;
  108010. private _buttonCross;
  108011. private _buttonCircle;
  108012. private _buttonSquare;
  108013. private _buttonTriangle;
  108014. private _buttonShare;
  108015. private _buttonOptions;
  108016. private _buttonL1;
  108017. private _buttonR1;
  108018. private _buttonLeftStick;
  108019. private _buttonRightStick;
  108020. private _dPadUp;
  108021. private _dPadDown;
  108022. private _dPadLeft;
  108023. private _dPadRight;
  108024. /**
  108025. * Creates a new DualShock gamepad object
  108026. * @param id defines the id of this gamepad
  108027. * @param index defines its index
  108028. * @param gamepad defines the internal HTML gamepad object
  108029. */
  108030. constructor(id: string, index: number, gamepad: any);
  108031. /**
  108032. * Defines the callback to call when left trigger is pressed
  108033. * @param callback defines the callback to use
  108034. */
  108035. onlefttriggerchanged(callback: (value: number) => void): void;
  108036. /**
  108037. * Defines the callback to call when right trigger is pressed
  108038. * @param callback defines the callback to use
  108039. */
  108040. onrighttriggerchanged(callback: (value: number) => void): void;
  108041. /**
  108042. * Gets the left trigger value
  108043. */
  108044. /**
  108045. * Sets the left trigger value
  108046. */
  108047. leftTrigger: number;
  108048. /**
  108049. * Gets the right trigger value
  108050. */
  108051. /**
  108052. * Sets the right trigger value
  108053. */
  108054. rightTrigger: number;
  108055. /**
  108056. * Defines the callback to call when a button is pressed
  108057. * @param callback defines the callback to use
  108058. */
  108059. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  108060. /**
  108061. * Defines the callback to call when a button is released
  108062. * @param callback defines the callback to use
  108063. */
  108064. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  108065. /**
  108066. * Defines the callback to call when a pad is pressed
  108067. * @param callback defines the callback to use
  108068. */
  108069. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  108070. /**
  108071. * Defines the callback to call when a pad is released
  108072. * @param callback defines the callback to use
  108073. */
  108074. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  108075. private _setButtonValue;
  108076. private _setDPadValue;
  108077. /**
  108078. * Gets the value of the `Cross` button
  108079. */
  108080. /**
  108081. * Sets the value of the `Cross` button
  108082. */
  108083. buttonCross: number;
  108084. /**
  108085. * Gets the value of the `Circle` button
  108086. */
  108087. /**
  108088. * Sets the value of the `Circle` button
  108089. */
  108090. buttonCircle: number;
  108091. /**
  108092. * Gets the value of the `Square` button
  108093. */
  108094. /**
  108095. * Sets the value of the `Square` button
  108096. */
  108097. buttonSquare: number;
  108098. /**
  108099. * Gets the value of the `Triangle` button
  108100. */
  108101. /**
  108102. * Sets the value of the `Triangle` button
  108103. */
  108104. buttonTriangle: number;
  108105. /**
  108106. * Gets the value of the `Options` button
  108107. */
  108108. /**
  108109. * Sets the value of the `Options` button
  108110. */
  108111. buttonOptions: number;
  108112. /**
  108113. * Gets the value of the `Share` button
  108114. */
  108115. /**
  108116. * Sets the value of the `Share` button
  108117. */
  108118. buttonShare: number;
  108119. /**
  108120. * Gets the value of the `L1` button
  108121. */
  108122. /**
  108123. * Sets the value of the `L1` button
  108124. */
  108125. buttonL1: number;
  108126. /**
  108127. * Gets the value of the `R1` button
  108128. */
  108129. /**
  108130. * Sets the value of the `R1` button
  108131. */
  108132. buttonR1: number;
  108133. /**
  108134. * Gets the value of the Left joystick
  108135. */
  108136. /**
  108137. * Sets the value of the Left joystick
  108138. */
  108139. buttonLeftStick: number;
  108140. /**
  108141. * Gets the value of the Right joystick
  108142. */
  108143. /**
  108144. * Sets the value of the Right joystick
  108145. */
  108146. buttonRightStick: number;
  108147. /**
  108148. * Gets the value of D-pad up
  108149. */
  108150. /**
  108151. * Sets the value of D-pad up
  108152. */
  108153. dPadUp: number;
  108154. /**
  108155. * Gets the value of D-pad down
  108156. */
  108157. /**
  108158. * Sets the value of D-pad down
  108159. */
  108160. dPadDown: number;
  108161. /**
  108162. * Gets the value of D-pad left
  108163. */
  108164. /**
  108165. * Sets the value of D-pad left
  108166. */
  108167. dPadLeft: number;
  108168. /**
  108169. * Gets the value of D-pad right
  108170. */
  108171. /**
  108172. * Sets the value of D-pad right
  108173. */
  108174. dPadRight: number;
  108175. /**
  108176. * Force the gamepad to synchronize with device values
  108177. */
  108178. update(): void;
  108179. /**
  108180. * Disposes the gamepad
  108181. */
  108182. dispose(): void;
  108183. }
  108184. }
  108185. declare module BABYLON {
  108186. /**
  108187. * Manager for handling gamepads
  108188. */
  108189. export class GamepadManager {
  108190. private _scene?;
  108191. private _babylonGamepads;
  108192. private _oneGamepadConnected;
  108193. /** @hidden */
  108194. _isMonitoring: boolean;
  108195. private _gamepadEventSupported;
  108196. private _gamepadSupport;
  108197. /**
  108198. * observable to be triggered when the gamepad controller has been connected
  108199. */
  108200. onGamepadConnectedObservable: Observable<Gamepad>;
  108201. /**
  108202. * observable to be triggered when the gamepad controller has been disconnected
  108203. */
  108204. onGamepadDisconnectedObservable: Observable<Gamepad>;
  108205. private _onGamepadConnectedEvent;
  108206. private _onGamepadDisconnectedEvent;
  108207. /**
  108208. * Initializes the gamepad manager
  108209. * @param _scene BabylonJS scene
  108210. */
  108211. constructor(_scene?: Scene | undefined);
  108212. /**
  108213. * The gamepads in the game pad manager
  108214. */
  108215. readonly gamepads: Gamepad[];
  108216. /**
  108217. * Get the gamepad controllers based on type
  108218. * @param type The type of gamepad controller
  108219. * @returns Nullable gamepad
  108220. */
  108221. getGamepadByType(type?: number): Nullable<Gamepad>;
  108222. /**
  108223. * Disposes the gamepad manager
  108224. */
  108225. dispose(): void;
  108226. private _addNewGamepad;
  108227. private _startMonitoringGamepads;
  108228. private _stopMonitoringGamepads;
  108229. /** @hidden */
  108230. _checkGamepadsStatus(): void;
  108231. private _updateGamepadObjects;
  108232. }
  108233. }
  108234. declare module BABYLON {
  108235. interface Scene {
  108236. /** @hidden */
  108237. _gamepadManager: Nullable<GamepadManager>;
  108238. /**
  108239. * Gets the gamepad manager associated with the scene
  108240. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  108241. */
  108242. gamepadManager: GamepadManager;
  108243. }
  108244. /**
  108245. * Interface representing a free camera inputs manager
  108246. */
  108247. interface FreeCameraInputsManager {
  108248. /**
  108249. * Adds gamepad input support to the FreeCameraInputsManager.
  108250. * @returns the FreeCameraInputsManager
  108251. */
  108252. addGamepad(): FreeCameraInputsManager;
  108253. }
  108254. /**
  108255. * Interface representing an arc rotate camera inputs manager
  108256. */
  108257. interface ArcRotateCameraInputsManager {
  108258. /**
  108259. * Adds gamepad input support to the ArcRotateCamera InputManager.
  108260. * @returns the camera inputs manager
  108261. */
  108262. addGamepad(): ArcRotateCameraInputsManager;
  108263. }
  108264. /**
  108265. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  108266. */
  108267. export class GamepadSystemSceneComponent implements ISceneComponent {
  108268. /**
  108269. * The component name helpfull to identify the component in the list of scene components.
  108270. */
  108271. readonly name: string;
  108272. /**
  108273. * The scene the component belongs to.
  108274. */
  108275. scene: Scene;
  108276. /**
  108277. * Creates a new instance of the component for the given scene
  108278. * @param scene Defines the scene to register the component in
  108279. */
  108280. constructor(scene: Scene);
  108281. /**
  108282. * Registers the component in a given scene
  108283. */
  108284. register(): void;
  108285. /**
  108286. * Rebuilds the elements related to this component in case of
  108287. * context lost for instance.
  108288. */
  108289. rebuild(): void;
  108290. /**
  108291. * Disposes the component and the associated ressources
  108292. */
  108293. dispose(): void;
  108294. private _beforeCameraUpdate;
  108295. }
  108296. }
  108297. declare module BABYLON {
  108298. /**
  108299. * 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,
  108300. * which still works and will still be found in many Playgrounds.
  108301. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  108302. */
  108303. export class UniversalCamera extends TouchCamera {
  108304. /**
  108305. * Defines the gamepad rotation sensiblity.
  108306. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  108307. */
  108308. gamepadAngularSensibility: number;
  108309. /**
  108310. * Defines the gamepad move sensiblity.
  108311. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  108312. */
  108313. gamepadMoveSensibility: number;
  108314. /**
  108315. * 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,
  108316. * which still works and will still be found in many Playgrounds.
  108317. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  108318. * @param name Define the name of the camera in the scene
  108319. * @param position Define the start position of the camera in the scene
  108320. * @param scene Define the scene the camera belongs to
  108321. */
  108322. constructor(name: string, position: Vector3, scene: Scene);
  108323. /**
  108324. * Gets the current object class name.
  108325. * @return the class name
  108326. */
  108327. getClassName(): string;
  108328. }
  108329. }
  108330. declare module BABYLON {
  108331. /**
  108332. * This represents a FPS type of camera. This is only here for back compat purpose.
  108333. * Please use the UniversalCamera instead as both are identical.
  108334. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  108335. */
  108336. export class GamepadCamera extends UniversalCamera {
  108337. /**
  108338. * Instantiates a new Gamepad Camera
  108339. * This represents a FPS type of camera. This is only here for back compat purpose.
  108340. * Please use the UniversalCamera instead as both are identical.
  108341. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  108342. * @param name Define the name of the camera in the scene
  108343. * @param position Define the start position of the camera in the scene
  108344. * @param scene Define the scene the camera belongs to
  108345. */
  108346. constructor(name: string, position: Vector3, scene: Scene);
  108347. /**
  108348. * Gets the current object class name.
  108349. * @return the class name
  108350. */
  108351. getClassName(): string;
  108352. }
  108353. }
  108354. declare module BABYLON {
  108355. /** @hidden */
  108356. export var passPixelShader: {
  108357. name: string;
  108358. shader: string;
  108359. };
  108360. }
  108361. declare module BABYLON {
  108362. /** @hidden */
  108363. export var passCubePixelShader: {
  108364. name: string;
  108365. shader: string;
  108366. };
  108367. }
  108368. declare module BABYLON {
  108369. /**
  108370. * PassPostProcess which produces an output the same as it's input
  108371. */
  108372. export class PassPostProcess extends PostProcess {
  108373. /**
  108374. * Creates the PassPostProcess
  108375. * @param name The name of the effect.
  108376. * @param options The required width/height ratio to downsize to before computing the render pass.
  108377. * @param camera The camera to apply the render pass to.
  108378. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  108379. * @param engine The engine which the post process will be applied. (default: current engine)
  108380. * @param reusable If the post process can be reused on the same frame. (default: false)
  108381. * @param textureType The type of texture to be used when performing the post processing.
  108382. * @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)
  108383. */
  108384. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  108385. }
  108386. /**
  108387. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  108388. */
  108389. export class PassCubePostProcess extends PostProcess {
  108390. private _face;
  108391. /**
  108392. * Gets or sets the cube face to display.
  108393. * * 0 is +X
  108394. * * 1 is -X
  108395. * * 2 is +Y
  108396. * * 3 is -Y
  108397. * * 4 is +Z
  108398. * * 5 is -Z
  108399. */
  108400. face: number;
  108401. /**
  108402. * Creates the PassCubePostProcess
  108403. * @param name The name of the effect.
  108404. * @param options The required width/height ratio to downsize to before computing the render pass.
  108405. * @param camera The camera to apply the render pass to.
  108406. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  108407. * @param engine The engine which the post process will be applied. (default: current engine)
  108408. * @param reusable If the post process can be reused on the same frame. (default: false)
  108409. * @param textureType The type of texture to be used when performing the post processing.
  108410. * @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)
  108411. */
  108412. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  108413. }
  108414. }
  108415. declare module BABYLON {
  108416. /** @hidden */
  108417. export var anaglyphPixelShader: {
  108418. name: string;
  108419. shader: string;
  108420. };
  108421. }
  108422. declare module BABYLON {
  108423. /**
  108424. * Postprocess used to generate anaglyphic rendering
  108425. */
  108426. export class AnaglyphPostProcess extends PostProcess {
  108427. private _passedProcess;
  108428. /**
  108429. * Creates a new AnaglyphPostProcess
  108430. * @param name defines postprocess name
  108431. * @param options defines creation options or target ratio scale
  108432. * @param rigCameras defines cameras using this postprocess
  108433. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  108434. * @param engine defines hosting engine
  108435. * @param reusable defines if the postprocess will be reused multiple times per frame
  108436. */
  108437. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  108438. }
  108439. }
  108440. declare module BABYLON {
  108441. /**
  108442. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  108443. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  108444. */
  108445. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  108446. /**
  108447. * Creates a new AnaglyphArcRotateCamera
  108448. * @param name defines camera name
  108449. * @param alpha defines alpha angle (in radians)
  108450. * @param beta defines beta angle (in radians)
  108451. * @param radius defines radius
  108452. * @param target defines camera target
  108453. * @param interaxialDistance defines distance between each color axis
  108454. * @param scene defines the hosting scene
  108455. */
  108456. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  108457. /**
  108458. * Gets camera class name
  108459. * @returns AnaglyphArcRotateCamera
  108460. */
  108461. getClassName(): string;
  108462. }
  108463. }
  108464. declare module BABYLON {
  108465. /**
  108466. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  108467. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  108468. */
  108469. export class AnaglyphFreeCamera extends FreeCamera {
  108470. /**
  108471. * Creates a new AnaglyphFreeCamera
  108472. * @param name defines camera name
  108473. * @param position defines initial position
  108474. * @param interaxialDistance defines distance between each color axis
  108475. * @param scene defines the hosting scene
  108476. */
  108477. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  108478. /**
  108479. * Gets camera class name
  108480. * @returns AnaglyphFreeCamera
  108481. */
  108482. getClassName(): string;
  108483. }
  108484. }
  108485. declare module BABYLON {
  108486. /**
  108487. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  108488. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  108489. */
  108490. export class AnaglyphGamepadCamera extends GamepadCamera {
  108491. /**
  108492. * Creates a new AnaglyphGamepadCamera
  108493. * @param name defines camera name
  108494. * @param position defines initial position
  108495. * @param interaxialDistance defines distance between each color axis
  108496. * @param scene defines the hosting scene
  108497. */
  108498. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  108499. /**
  108500. * Gets camera class name
  108501. * @returns AnaglyphGamepadCamera
  108502. */
  108503. getClassName(): string;
  108504. }
  108505. }
  108506. declare module BABYLON {
  108507. /**
  108508. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  108509. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  108510. */
  108511. export class AnaglyphUniversalCamera extends UniversalCamera {
  108512. /**
  108513. * Creates a new AnaglyphUniversalCamera
  108514. * @param name defines camera name
  108515. * @param position defines initial position
  108516. * @param interaxialDistance defines distance between each color axis
  108517. * @param scene defines the hosting scene
  108518. */
  108519. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  108520. /**
  108521. * Gets camera class name
  108522. * @returns AnaglyphUniversalCamera
  108523. */
  108524. getClassName(): string;
  108525. }
  108526. }
  108527. declare module BABYLON {
  108528. /** @hidden */
  108529. export var stereoscopicInterlacePixelShader: {
  108530. name: string;
  108531. shader: string;
  108532. };
  108533. }
  108534. declare module BABYLON {
  108535. /**
  108536. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  108537. */
  108538. export class StereoscopicInterlacePostProcess extends PostProcess {
  108539. private _stepSize;
  108540. private _passedProcess;
  108541. /**
  108542. * Initializes a StereoscopicInterlacePostProcess
  108543. * @param name The name of the effect.
  108544. * @param rigCameras The rig cameras to be appled to the post process
  108545. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  108546. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  108547. * @param engine The engine which the post process will be applied. (default: current engine)
  108548. * @param reusable If the post process can be reused on the same frame. (default: false)
  108549. */
  108550. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  108551. }
  108552. }
  108553. declare module BABYLON {
  108554. /**
  108555. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  108556. * @see http://doc.babylonjs.com/features/cameras
  108557. */
  108558. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  108559. /**
  108560. * Creates a new StereoscopicArcRotateCamera
  108561. * @param name defines camera name
  108562. * @param alpha defines alpha angle (in radians)
  108563. * @param beta defines beta angle (in radians)
  108564. * @param radius defines radius
  108565. * @param target defines camera target
  108566. * @param interaxialDistance defines distance between each color axis
  108567. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  108568. * @param scene defines the hosting scene
  108569. */
  108570. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  108571. /**
  108572. * Gets camera class name
  108573. * @returns StereoscopicArcRotateCamera
  108574. */
  108575. getClassName(): string;
  108576. }
  108577. }
  108578. declare module BABYLON {
  108579. /**
  108580. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  108581. * @see http://doc.babylonjs.com/features/cameras
  108582. */
  108583. export class StereoscopicFreeCamera extends FreeCamera {
  108584. /**
  108585. * Creates a new StereoscopicFreeCamera
  108586. * @param name defines camera name
  108587. * @param position defines initial position
  108588. * @param interaxialDistance defines distance between each color axis
  108589. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  108590. * @param scene defines the hosting scene
  108591. */
  108592. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  108593. /**
  108594. * Gets camera class name
  108595. * @returns StereoscopicFreeCamera
  108596. */
  108597. getClassName(): string;
  108598. }
  108599. }
  108600. declare module BABYLON {
  108601. /**
  108602. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  108603. * @see http://doc.babylonjs.com/features/cameras
  108604. */
  108605. export class StereoscopicGamepadCamera extends GamepadCamera {
  108606. /**
  108607. * Creates a new StereoscopicGamepadCamera
  108608. * @param name defines camera name
  108609. * @param position defines initial position
  108610. * @param interaxialDistance defines distance between each color axis
  108611. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  108612. * @param scene defines the hosting scene
  108613. */
  108614. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  108615. /**
  108616. * Gets camera class name
  108617. * @returns StereoscopicGamepadCamera
  108618. */
  108619. getClassName(): string;
  108620. }
  108621. }
  108622. declare module BABYLON {
  108623. /**
  108624. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  108625. * @see http://doc.babylonjs.com/features/cameras
  108626. */
  108627. export class StereoscopicUniversalCamera extends UniversalCamera {
  108628. /**
  108629. * Creates a new StereoscopicUniversalCamera
  108630. * @param name defines camera name
  108631. * @param position defines initial position
  108632. * @param interaxialDistance defines distance between each color axis
  108633. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  108634. * @param scene defines the hosting scene
  108635. */
  108636. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  108637. /**
  108638. * Gets camera class name
  108639. * @returns StereoscopicUniversalCamera
  108640. */
  108641. getClassName(): string;
  108642. }
  108643. }
  108644. declare module BABYLON {
  108645. /**
  108646. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  108647. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  108648. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  108649. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  108650. */
  108651. export class VirtualJoysticksCamera extends FreeCamera {
  108652. /**
  108653. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  108654. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  108655. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  108656. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  108657. * @param name Define the name of the camera in the scene
  108658. * @param position Define the start position of the camera in the scene
  108659. * @param scene Define the scene the camera belongs to
  108660. */
  108661. constructor(name: string, position: Vector3, scene: Scene);
  108662. /**
  108663. * Gets the current object class name.
  108664. * @return the class name
  108665. */
  108666. getClassName(): string;
  108667. }
  108668. }
  108669. declare module BABYLON {
  108670. /**
  108671. * This represents all the required metrics to create a VR camera.
  108672. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  108673. */
  108674. export class VRCameraMetrics {
  108675. /**
  108676. * Define the horizontal resolution off the screen.
  108677. */
  108678. hResolution: number;
  108679. /**
  108680. * Define the vertical resolution off the screen.
  108681. */
  108682. vResolution: number;
  108683. /**
  108684. * Define the horizontal screen size.
  108685. */
  108686. hScreenSize: number;
  108687. /**
  108688. * Define the vertical screen size.
  108689. */
  108690. vScreenSize: number;
  108691. /**
  108692. * Define the vertical screen center position.
  108693. */
  108694. vScreenCenter: number;
  108695. /**
  108696. * Define the distance of the eyes to the screen.
  108697. */
  108698. eyeToScreenDistance: number;
  108699. /**
  108700. * Define the distance between both lenses
  108701. */
  108702. lensSeparationDistance: number;
  108703. /**
  108704. * Define the distance between both viewer's eyes.
  108705. */
  108706. interpupillaryDistance: number;
  108707. /**
  108708. * Define the distortion factor of the VR postprocess.
  108709. * Please, touch with care.
  108710. */
  108711. distortionK: number[];
  108712. /**
  108713. * Define the chromatic aberration correction factors for the VR post process.
  108714. */
  108715. chromaAbCorrection: number[];
  108716. /**
  108717. * Define the scale factor of the post process.
  108718. * The smaller the better but the slower.
  108719. */
  108720. postProcessScaleFactor: number;
  108721. /**
  108722. * Define an offset for the lens center.
  108723. */
  108724. lensCenterOffset: number;
  108725. /**
  108726. * Define if the current vr camera should compensate the distortion of the lense or not.
  108727. */
  108728. compensateDistortion: boolean;
  108729. /**
  108730. * Defines if multiview should be enabled when rendering (Default: false)
  108731. */
  108732. multiviewEnabled: boolean;
  108733. /**
  108734. * Gets the rendering aspect ratio based on the provided resolutions.
  108735. */
  108736. readonly aspectRatio: number;
  108737. /**
  108738. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  108739. */
  108740. readonly aspectRatioFov: number;
  108741. /**
  108742. * @hidden
  108743. */
  108744. readonly leftHMatrix: Matrix;
  108745. /**
  108746. * @hidden
  108747. */
  108748. readonly rightHMatrix: Matrix;
  108749. /**
  108750. * @hidden
  108751. */
  108752. readonly leftPreViewMatrix: Matrix;
  108753. /**
  108754. * @hidden
  108755. */
  108756. readonly rightPreViewMatrix: Matrix;
  108757. /**
  108758. * Get the default VRMetrics based on the most generic setup.
  108759. * @returns the default vr metrics
  108760. */
  108761. static GetDefault(): VRCameraMetrics;
  108762. }
  108763. }
  108764. declare module BABYLON {
  108765. /** @hidden */
  108766. export var vrDistortionCorrectionPixelShader: {
  108767. name: string;
  108768. shader: string;
  108769. };
  108770. }
  108771. declare module BABYLON {
  108772. /**
  108773. * VRDistortionCorrectionPostProcess used for mobile VR
  108774. */
  108775. export class VRDistortionCorrectionPostProcess extends PostProcess {
  108776. private _isRightEye;
  108777. private _distortionFactors;
  108778. private _postProcessScaleFactor;
  108779. private _lensCenterOffset;
  108780. private _scaleIn;
  108781. private _scaleFactor;
  108782. private _lensCenter;
  108783. /**
  108784. * Initializes the VRDistortionCorrectionPostProcess
  108785. * @param name The name of the effect.
  108786. * @param camera The camera to apply the render pass to.
  108787. * @param isRightEye If this is for the right eye distortion
  108788. * @param vrMetrics All the required metrics for the VR camera
  108789. */
  108790. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  108791. }
  108792. }
  108793. declare module BABYLON {
  108794. /**
  108795. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  108796. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  108797. */
  108798. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  108799. /**
  108800. * Creates a new VRDeviceOrientationArcRotateCamera
  108801. * @param name defines camera name
  108802. * @param alpha defines the camera rotation along the logitudinal axis
  108803. * @param beta defines the camera rotation along the latitudinal axis
  108804. * @param radius defines the camera distance from its target
  108805. * @param target defines the camera target
  108806. * @param scene defines the scene the camera belongs to
  108807. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  108808. * @param vrCameraMetrics defines the vr metrics associated to the camera
  108809. */
  108810. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  108811. /**
  108812. * Gets camera class name
  108813. * @returns VRDeviceOrientationArcRotateCamera
  108814. */
  108815. getClassName(): string;
  108816. }
  108817. }
  108818. declare module BABYLON {
  108819. /**
  108820. * Camera used to simulate VR rendering (based on FreeCamera)
  108821. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  108822. */
  108823. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  108824. /**
  108825. * Creates a new VRDeviceOrientationFreeCamera
  108826. * @param name defines camera name
  108827. * @param position defines the start position of the camera
  108828. * @param scene defines the scene the camera belongs to
  108829. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  108830. * @param vrCameraMetrics defines the vr metrics associated to the camera
  108831. */
  108832. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  108833. /**
  108834. * Gets camera class name
  108835. * @returns VRDeviceOrientationFreeCamera
  108836. */
  108837. getClassName(): string;
  108838. }
  108839. }
  108840. declare module BABYLON {
  108841. /**
  108842. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  108843. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  108844. */
  108845. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  108846. /**
  108847. * Creates a new VRDeviceOrientationGamepadCamera
  108848. * @param name defines camera name
  108849. * @param position defines the start position of the camera
  108850. * @param scene defines the scene the camera belongs to
  108851. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  108852. * @param vrCameraMetrics defines the vr metrics associated to the camera
  108853. */
  108854. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  108855. /**
  108856. * Gets camera class name
  108857. * @returns VRDeviceOrientationGamepadCamera
  108858. */
  108859. getClassName(): string;
  108860. }
  108861. }
  108862. declare module BABYLON {
  108863. /**
  108864. * Base class of materials working in push mode in babylon JS
  108865. * @hidden
  108866. */
  108867. export class PushMaterial extends Material {
  108868. protected _activeEffect: Effect;
  108869. protected _normalMatrix: Matrix;
  108870. /**
  108871. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  108872. * This means that the material can keep using a previous shader while a new one is being compiled.
  108873. * This is mostly used when shader parallel compilation is supported (true by default)
  108874. */
  108875. allowShaderHotSwapping: boolean;
  108876. constructor(name: string, scene: Scene);
  108877. getEffect(): Effect;
  108878. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  108879. /**
  108880. * Binds the given world matrix to the active effect
  108881. *
  108882. * @param world the matrix to bind
  108883. */
  108884. bindOnlyWorldMatrix(world: Matrix): void;
  108885. /**
  108886. * Binds the given normal matrix to the active effect
  108887. *
  108888. * @param normalMatrix the matrix to bind
  108889. */
  108890. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  108891. bind(world: Matrix, mesh?: Mesh): void;
  108892. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  108893. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  108894. }
  108895. }
  108896. declare module BABYLON {
  108897. /**
  108898. * This groups all the flags used to control the materials channel.
  108899. */
  108900. export class MaterialFlags {
  108901. private static _DiffuseTextureEnabled;
  108902. /**
  108903. * Are diffuse textures enabled in the application.
  108904. */
  108905. static DiffuseTextureEnabled: boolean;
  108906. private static _AmbientTextureEnabled;
  108907. /**
  108908. * Are ambient textures enabled in the application.
  108909. */
  108910. static AmbientTextureEnabled: boolean;
  108911. private static _OpacityTextureEnabled;
  108912. /**
  108913. * Are opacity textures enabled in the application.
  108914. */
  108915. static OpacityTextureEnabled: boolean;
  108916. private static _ReflectionTextureEnabled;
  108917. /**
  108918. * Are reflection textures enabled in the application.
  108919. */
  108920. static ReflectionTextureEnabled: boolean;
  108921. private static _EmissiveTextureEnabled;
  108922. /**
  108923. * Are emissive textures enabled in the application.
  108924. */
  108925. static EmissiveTextureEnabled: boolean;
  108926. private static _SpecularTextureEnabled;
  108927. /**
  108928. * Are specular textures enabled in the application.
  108929. */
  108930. static SpecularTextureEnabled: boolean;
  108931. private static _BumpTextureEnabled;
  108932. /**
  108933. * Are bump textures enabled in the application.
  108934. */
  108935. static BumpTextureEnabled: boolean;
  108936. private static _LightmapTextureEnabled;
  108937. /**
  108938. * Are lightmap textures enabled in the application.
  108939. */
  108940. static LightmapTextureEnabled: boolean;
  108941. private static _RefractionTextureEnabled;
  108942. /**
  108943. * Are refraction textures enabled in the application.
  108944. */
  108945. static RefractionTextureEnabled: boolean;
  108946. private static _ColorGradingTextureEnabled;
  108947. /**
  108948. * Are color grading textures enabled in the application.
  108949. */
  108950. static ColorGradingTextureEnabled: boolean;
  108951. private static _FresnelEnabled;
  108952. /**
  108953. * Are fresnels enabled in the application.
  108954. */
  108955. static FresnelEnabled: boolean;
  108956. private static _ClearCoatTextureEnabled;
  108957. /**
  108958. * Are clear coat textures enabled in the application.
  108959. */
  108960. static ClearCoatTextureEnabled: boolean;
  108961. private static _ClearCoatBumpTextureEnabled;
  108962. /**
  108963. * Are clear coat bump textures enabled in the application.
  108964. */
  108965. static ClearCoatBumpTextureEnabled: boolean;
  108966. private static _ClearCoatTintTextureEnabled;
  108967. /**
  108968. * Are clear coat tint textures enabled in the application.
  108969. */
  108970. static ClearCoatTintTextureEnabled: boolean;
  108971. private static _SheenTextureEnabled;
  108972. /**
  108973. * Are sheen textures enabled in the application.
  108974. */
  108975. static SheenTextureEnabled: boolean;
  108976. private static _AnisotropicTextureEnabled;
  108977. /**
  108978. * Are anisotropic textures enabled in the application.
  108979. */
  108980. static AnisotropicTextureEnabled: boolean;
  108981. private static _ThicknessTextureEnabled;
  108982. /**
  108983. * Are thickness textures enabled in the application.
  108984. */
  108985. static ThicknessTextureEnabled: boolean;
  108986. }
  108987. }
  108988. declare module BABYLON {
  108989. /** @hidden */
  108990. export var defaultFragmentDeclaration: {
  108991. name: string;
  108992. shader: string;
  108993. };
  108994. }
  108995. declare module BABYLON {
  108996. /** @hidden */
  108997. export var defaultUboDeclaration: {
  108998. name: string;
  108999. shader: string;
  109000. };
  109001. }
  109002. declare module BABYLON {
  109003. /** @hidden */
  109004. export var lightFragmentDeclaration: {
  109005. name: string;
  109006. shader: string;
  109007. };
  109008. }
  109009. declare module BABYLON {
  109010. /** @hidden */
  109011. export var lightUboDeclaration: {
  109012. name: string;
  109013. shader: string;
  109014. };
  109015. }
  109016. declare module BABYLON {
  109017. /** @hidden */
  109018. export var lightsFragmentFunctions: {
  109019. name: string;
  109020. shader: string;
  109021. };
  109022. }
  109023. declare module BABYLON {
  109024. /** @hidden */
  109025. export var shadowsFragmentFunctions: {
  109026. name: string;
  109027. shader: string;
  109028. };
  109029. }
  109030. declare module BABYLON {
  109031. /** @hidden */
  109032. export var fresnelFunction: {
  109033. name: string;
  109034. shader: string;
  109035. };
  109036. }
  109037. declare module BABYLON {
  109038. /** @hidden */
  109039. export var reflectionFunction: {
  109040. name: string;
  109041. shader: string;
  109042. };
  109043. }
  109044. declare module BABYLON {
  109045. /** @hidden */
  109046. export var bumpFragmentFunctions: {
  109047. name: string;
  109048. shader: string;
  109049. };
  109050. }
  109051. declare module BABYLON {
  109052. /** @hidden */
  109053. export var logDepthDeclaration: {
  109054. name: string;
  109055. shader: string;
  109056. };
  109057. }
  109058. declare module BABYLON {
  109059. /** @hidden */
  109060. export var bumpFragment: {
  109061. name: string;
  109062. shader: string;
  109063. };
  109064. }
  109065. declare module BABYLON {
  109066. /** @hidden */
  109067. export var depthPrePass: {
  109068. name: string;
  109069. shader: string;
  109070. };
  109071. }
  109072. declare module BABYLON {
  109073. /** @hidden */
  109074. export var lightFragment: {
  109075. name: string;
  109076. shader: string;
  109077. };
  109078. }
  109079. declare module BABYLON {
  109080. /** @hidden */
  109081. export var logDepthFragment: {
  109082. name: string;
  109083. shader: string;
  109084. };
  109085. }
  109086. declare module BABYLON {
  109087. /** @hidden */
  109088. export var defaultPixelShader: {
  109089. name: string;
  109090. shader: string;
  109091. };
  109092. }
  109093. declare module BABYLON {
  109094. /** @hidden */
  109095. export var defaultVertexDeclaration: {
  109096. name: string;
  109097. shader: string;
  109098. };
  109099. }
  109100. declare module BABYLON {
  109101. /** @hidden */
  109102. export var bumpVertexDeclaration: {
  109103. name: string;
  109104. shader: string;
  109105. };
  109106. }
  109107. declare module BABYLON {
  109108. /** @hidden */
  109109. export var bumpVertex: {
  109110. name: string;
  109111. shader: string;
  109112. };
  109113. }
  109114. declare module BABYLON {
  109115. /** @hidden */
  109116. export var fogVertex: {
  109117. name: string;
  109118. shader: string;
  109119. };
  109120. }
  109121. declare module BABYLON {
  109122. /** @hidden */
  109123. export var shadowsVertex: {
  109124. name: string;
  109125. shader: string;
  109126. };
  109127. }
  109128. declare module BABYLON {
  109129. /** @hidden */
  109130. export var pointCloudVertex: {
  109131. name: string;
  109132. shader: string;
  109133. };
  109134. }
  109135. declare module BABYLON {
  109136. /** @hidden */
  109137. export var logDepthVertex: {
  109138. name: string;
  109139. shader: string;
  109140. };
  109141. }
  109142. declare module BABYLON {
  109143. /** @hidden */
  109144. export var defaultVertexShader: {
  109145. name: string;
  109146. shader: string;
  109147. };
  109148. }
  109149. declare module BABYLON {
  109150. /** @hidden */
  109151. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  109152. MAINUV1: boolean;
  109153. MAINUV2: boolean;
  109154. DIFFUSE: boolean;
  109155. DIFFUSEDIRECTUV: number;
  109156. AMBIENT: boolean;
  109157. AMBIENTDIRECTUV: number;
  109158. OPACITY: boolean;
  109159. OPACITYDIRECTUV: number;
  109160. OPACITYRGB: boolean;
  109161. REFLECTION: boolean;
  109162. EMISSIVE: boolean;
  109163. EMISSIVEDIRECTUV: number;
  109164. SPECULAR: boolean;
  109165. SPECULARDIRECTUV: number;
  109166. BUMP: boolean;
  109167. BUMPDIRECTUV: number;
  109168. PARALLAX: boolean;
  109169. PARALLAXOCCLUSION: boolean;
  109170. SPECULAROVERALPHA: boolean;
  109171. CLIPPLANE: boolean;
  109172. CLIPPLANE2: boolean;
  109173. CLIPPLANE3: boolean;
  109174. CLIPPLANE4: boolean;
  109175. ALPHATEST: boolean;
  109176. DEPTHPREPASS: boolean;
  109177. ALPHAFROMDIFFUSE: boolean;
  109178. POINTSIZE: boolean;
  109179. FOG: boolean;
  109180. SPECULARTERM: boolean;
  109181. DIFFUSEFRESNEL: boolean;
  109182. OPACITYFRESNEL: boolean;
  109183. REFLECTIONFRESNEL: boolean;
  109184. REFRACTIONFRESNEL: boolean;
  109185. EMISSIVEFRESNEL: boolean;
  109186. FRESNEL: boolean;
  109187. NORMAL: boolean;
  109188. UV1: boolean;
  109189. UV2: boolean;
  109190. VERTEXCOLOR: boolean;
  109191. VERTEXALPHA: boolean;
  109192. NUM_BONE_INFLUENCERS: number;
  109193. BonesPerMesh: number;
  109194. BONETEXTURE: boolean;
  109195. INSTANCES: boolean;
  109196. GLOSSINESS: boolean;
  109197. ROUGHNESS: boolean;
  109198. EMISSIVEASILLUMINATION: boolean;
  109199. LINKEMISSIVEWITHDIFFUSE: boolean;
  109200. REFLECTIONFRESNELFROMSPECULAR: boolean;
  109201. LIGHTMAP: boolean;
  109202. LIGHTMAPDIRECTUV: number;
  109203. OBJECTSPACE_NORMALMAP: boolean;
  109204. USELIGHTMAPASSHADOWMAP: boolean;
  109205. REFLECTIONMAP_3D: boolean;
  109206. REFLECTIONMAP_SPHERICAL: boolean;
  109207. REFLECTIONMAP_PLANAR: boolean;
  109208. REFLECTIONMAP_CUBIC: boolean;
  109209. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  109210. REFLECTIONMAP_PROJECTION: boolean;
  109211. REFLECTIONMAP_SKYBOX: boolean;
  109212. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  109213. REFLECTIONMAP_EXPLICIT: boolean;
  109214. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  109215. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  109216. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  109217. INVERTCUBICMAP: boolean;
  109218. LOGARITHMICDEPTH: boolean;
  109219. REFRACTION: boolean;
  109220. REFRACTIONMAP_3D: boolean;
  109221. REFLECTIONOVERALPHA: boolean;
  109222. TWOSIDEDLIGHTING: boolean;
  109223. SHADOWFLOAT: boolean;
  109224. MORPHTARGETS: boolean;
  109225. MORPHTARGETS_NORMAL: boolean;
  109226. MORPHTARGETS_TANGENT: boolean;
  109227. MORPHTARGETS_UV: boolean;
  109228. NUM_MORPH_INFLUENCERS: number;
  109229. NONUNIFORMSCALING: boolean;
  109230. PREMULTIPLYALPHA: boolean;
  109231. IMAGEPROCESSING: boolean;
  109232. VIGNETTE: boolean;
  109233. VIGNETTEBLENDMODEMULTIPLY: boolean;
  109234. VIGNETTEBLENDMODEOPAQUE: boolean;
  109235. TONEMAPPING: boolean;
  109236. TONEMAPPING_ACES: boolean;
  109237. CONTRAST: boolean;
  109238. COLORCURVES: boolean;
  109239. COLORGRADING: boolean;
  109240. COLORGRADING3D: boolean;
  109241. SAMPLER3DGREENDEPTH: boolean;
  109242. SAMPLER3DBGRMAP: boolean;
  109243. IMAGEPROCESSINGPOSTPROCESS: boolean;
  109244. MULTIVIEW: boolean;
  109245. /**
  109246. * If the reflection texture on this material is in linear color space
  109247. * @hidden
  109248. */
  109249. IS_REFLECTION_LINEAR: boolean;
  109250. /**
  109251. * If the refraction texture on this material is in linear color space
  109252. * @hidden
  109253. */
  109254. IS_REFRACTION_LINEAR: boolean;
  109255. EXPOSURE: boolean;
  109256. constructor();
  109257. setReflectionMode(modeToEnable: string): void;
  109258. }
  109259. /**
  109260. * This is the default material used in Babylon. It is the best trade off between quality
  109261. * and performances.
  109262. * @see http://doc.babylonjs.com/babylon101/materials
  109263. */
  109264. export class StandardMaterial extends PushMaterial {
  109265. private _diffuseTexture;
  109266. /**
  109267. * The basic texture of the material as viewed under a light.
  109268. */
  109269. diffuseTexture: Nullable<BaseTexture>;
  109270. private _ambientTexture;
  109271. /**
  109272. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  109273. */
  109274. ambientTexture: Nullable<BaseTexture>;
  109275. private _opacityTexture;
  109276. /**
  109277. * Define the transparency of the material from a texture.
  109278. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  109279. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  109280. */
  109281. opacityTexture: Nullable<BaseTexture>;
  109282. private _reflectionTexture;
  109283. /**
  109284. * Define the texture used to display the reflection.
  109285. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  109286. */
  109287. reflectionTexture: Nullable<BaseTexture>;
  109288. private _emissiveTexture;
  109289. /**
  109290. * Define texture of the material as if self lit.
  109291. * This will be mixed in the final result even in the absence of light.
  109292. */
  109293. emissiveTexture: Nullable<BaseTexture>;
  109294. private _specularTexture;
  109295. /**
  109296. * Define how the color and intensity of the highlight given by the light in the material.
  109297. */
  109298. specularTexture: Nullable<BaseTexture>;
  109299. private _bumpTexture;
  109300. /**
  109301. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  109302. * 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.
  109303. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  109304. */
  109305. bumpTexture: Nullable<BaseTexture>;
  109306. private _lightmapTexture;
  109307. /**
  109308. * Complex lighting can be computationally expensive to compute at runtime.
  109309. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  109310. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  109311. */
  109312. lightmapTexture: Nullable<BaseTexture>;
  109313. private _refractionTexture;
  109314. /**
  109315. * Define the texture used to display the refraction.
  109316. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  109317. */
  109318. refractionTexture: Nullable<BaseTexture>;
  109319. /**
  109320. * The color of the material lit by the environmental background lighting.
  109321. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  109322. */
  109323. ambientColor: Color3;
  109324. /**
  109325. * The basic color of the material as viewed under a light.
  109326. */
  109327. diffuseColor: Color3;
  109328. /**
  109329. * Define how the color and intensity of the highlight given by the light in the material.
  109330. */
  109331. specularColor: Color3;
  109332. /**
  109333. * Define the color of the material as if self lit.
  109334. * This will be mixed in the final result even in the absence of light.
  109335. */
  109336. emissiveColor: Color3;
  109337. /**
  109338. * Defines how sharp are the highlights in the material.
  109339. * The bigger the value the sharper giving a more glossy feeling to the result.
  109340. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  109341. */
  109342. specularPower: number;
  109343. private _useAlphaFromDiffuseTexture;
  109344. /**
  109345. * Does the transparency come from the diffuse texture alpha channel.
  109346. */
  109347. useAlphaFromDiffuseTexture: boolean;
  109348. private _useEmissiveAsIllumination;
  109349. /**
  109350. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  109351. */
  109352. useEmissiveAsIllumination: boolean;
  109353. private _linkEmissiveWithDiffuse;
  109354. /**
  109355. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  109356. * the emissive level when the final color is close to one.
  109357. */
  109358. linkEmissiveWithDiffuse: boolean;
  109359. private _useSpecularOverAlpha;
  109360. /**
  109361. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  109362. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  109363. */
  109364. useSpecularOverAlpha: boolean;
  109365. private _useReflectionOverAlpha;
  109366. /**
  109367. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  109368. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  109369. */
  109370. useReflectionOverAlpha: boolean;
  109371. private _disableLighting;
  109372. /**
  109373. * Does lights from the scene impacts this material.
  109374. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  109375. */
  109376. disableLighting: boolean;
  109377. private _useObjectSpaceNormalMap;
  109378. /**
  109379. * Allows using an object space normal map (instead of tangent space).
  109380. */
  109381. useObjectSpaceNormalMap: boolean;
  109382. private _useParallax;
  109383. /**
  109384. * Is parallax enabled or not.
  109385. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  109386. */
  109387. useParallax: boolean;
  109388. private _useParallaxOcclusion;
  109389. /**
  109390. * Is parallax occlusion enabled or not.
  109391. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  109392. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  109393. */
  109394. useParallaxOcclusion: boolean;
  109395. /**
  109396. * 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.
  109397. */
  109398. parallaxScaleBias: number;
  109399. private _roughness;
  109400. /**
  109401. * Helps to define how blurry the reflections should appears in the material.
  109402. */
  109403. roughness: number;
  109404. /**
  109405. * In case of refraction, define the value of the index of refraction.
  109406. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  109407. */
  109408. indexOfRefraction: number;
  109409. /**
  109410. * Invert the refraction texture alongside the y axis.
  109411. * It can be useful with procedural textures or probe for instance.
  109412. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  109413. */
  109414. invertRefractionY: boolean;
  109415. /**
  109416. * Defines the alpha limits in alpha test mode.
  109417. */
  109418. alphaCutOff: number;
  109419. private _useLightmapAsShadowmap;
  109420. /**
  109421. * In case of light mapping, define whether the map contains light or shadow informations.
  109422. */
  109423. useLightmapAsShadowmap: boolean;
  109424. private _diffuseFresnelParameters;
  109425. /**
  109426. * Define the diffuse fresnel parameters of the material.
  109427. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  109428. */
  109429. diffuseFresnelParameters: FresnelParameters;
  109430. private _opacityFresnelParameters;
  109431. /**
  109432. * Define the opacity fresnel parameters of the material.
  109433. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  109434. */
  109435. opacityFresnelParameters: FresnelParameters;
  109436. private _reflectionFresnelParameters;
  109437. /**
  109438. * Define the reflection fresnel parameters of the material.
  109439. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  109440. */
  109441. reflectionFresnelParameters: FresnelParameters;
  109442. private _refractionFresnelParameters;
  109443. /**
  109444. * Define the refraction fresnel parameters of the material.
  109445. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  109446. */
  109447. refractionFresnelParameters: FresnelParameters;
  109448. private _emissiveFresnelParameters;
  109449. /**
  109450. * Define the emissive fresnel parameters of the material.
  109451. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  109452. */
  109453. emissiveFresnelParameters: FresnelParameters;
  109454. private _useReflectionFresnelFromSpecular;
  109455. /**
  109456. * If true automatically deducts the fresnels values from the material specularity.
  109457. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  109458. */
  109459. useReflectionFresnelFromSpecular: boolean;
  109460. private _useGlossinessFromSpecularMapAlpha;
  109461. /**
  109462. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  109463. */
  109464. useGlossinessFromSpecularMapAlpha: boolean;
  109465. private _maxSimultaneousLights;
  109466. /**
  109467. * Defines the maximum number of lights that can be used in the material
  109468. */
  109469. maxSimultaneousLights: number;
  109470. private _invertNormalMapX;
  109471. /**
  109472. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  109473. */
  109474. invertNormalMapX: boolean;
  109475. private _invertNormalMapY;
  109476. /**
  109477. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  109478. */
  109479. invertNormalMapY: boolean;
  109480. private _twoSidedLighting;
  109481. /**
  109482. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  109483. */
  109484. twoSidedLighting: boolean;
  109485. /**
  109486. * Default configuration related to image processing available in the standard Material.
  109487. */
  109488. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  109489. /**
  109490. * Gets the image processing configuration used either in this material.
  109491. */
  109492. /**
  109493. * Sets the Default image processing configuration used either in the this material.
  109494. *
  109495. * If sets to null, the scene one is in use.
  109496. */
  109497. imageProcessingConfiguration: ImageProcessingConfiguration;
  109498. /**
  109499. * Keep track of the image processing observer to allow dispose and replace.
  109500. */
  109501. private _imageProcessingObserver;
  109502. /**
  109503. * Attaches a new image processing configuration to the Standard Material.
  109504. * @param configuration
  109505. */
  109506. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  109507. /**
  109508. * Gets wether the color curves effect is enabled.
  109509. */
  109510. /**
  109511. * Sets wether the color curves effect is enabled.
  109512. */
  109513. cameraColorCurvesEnabled: boolean;
  109514. /**
  109515. * Gets wether the color grading effect is enabled.
  109516. */
  109517. /**
  109518. * Gets wether the color grading effect is enabled.
  109519. */
  109520. cameraColorGradingEnabled: boolean;
  109521. /**
  109522. * Gets wether tonemapping is enabled or not.
  109523. */
  109524. /**
  109525. * Sets wether tonemapping is enabled or not
  109526. */
  109527. cameraToneMappingEnabled: boolean;
  109528. /**
  109529. * The camera exposure used on this material.
  109530. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  109531. * This corresponds to a photographic exposure.
  109532. */
  109533. /**
  109534. * The camera exposure used on this material.
  109535. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  109536. * This corresponds to a photographic exposure.
  109537. */
  109538. cameraExposure: number;
  109539. /**
  109540. * Gets The camera contrast used on this material.
  109541. */
  109542. /**
  109543. * Sets The camera contrast used on this material.
  109544. */
  109545. cameraContrast: number;
  109546. /**
  109547. * Gets the Color Grading 2D Lookup Texture.
  109548. */
  109549. /**
  109550. * Sets the Color Grading 2D Lookup Texture.
  109551. */
  109552. cameraColorGradingTexture: Nullable<BaseTexture>;
  109553. /**
  109554. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  109555. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  109556. * 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;
  109557. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  109558. */
  109559. /**
  109560. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  109561. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  109562. * 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;
  109563. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  109564. */
  109565. cameraColorCurves: Nullable<ColorCurves>;
  109566. /**
  109567. * Custom callback helping to override the default shader used in the material.
  109568. */
  109569. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  109570. protected _renderTargets: SmartArray<RenderTargetTexture>;
  109571. protected _worldViewProjectionMatrix: Matrix;
  109572. protected _globalAmbientColor: Color3;
  109573. protected _useLogarithmicDepth: boolean;
  109574. protected _rebuildInParallel: boolean;
  109575. /**
  109576. * Instantiates a new standard material.
  109577. * This is the default material used in Babylon. It is the best trade off between quality
  109578. * and performances.
  109579. * @see http://doc.babylonjs.com/babylon101/materials
  109580. * @param name Define the name of the material in the scene
  109581. * @param scene Define the scene the material belong to
  109582. */
  109583. constructor(name: string, scene: Scene);
  109584. /**
  109585. * Gets a boolean indicating that current material needs to register RTT
  109586. */
  109587. readonly hasRenderTargetTextures: boolean;
  109588. /**
  109589. * Gets the current class name of the material e.g. "StandardMaterial"
  109590. * Mainly use in serialization.
  109591. * @returns the class name
  109592. */
  109593. getClassName(): string;
  109594. /**
  109595. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  109596. * You can try switching to logarithmic depth.
  109597. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  109598. */
  109599. useLogarithmicDepth: boolean;
  109600. /**
  109601. * Specifies if the material will require alpha blending
  109602. * @returns a boolean specifying if alpha blending is needed
  109603. */
  109604. needAlphaBlending(): boolean;
  109605. /**
  109606. * Specifies if this material should be rendered in alpha test mode
  109607. * @returns a boolean specifying if an alpha test is needed.
  109608. */
  109609. needAlphaTesting(): boolean;
  109610. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  109611. /**
  109612. * Get the texture used for alpha test purpose.
  109613. * @returns the diffuse texture in case of the standard material.
  109614. */
  109615. getAlphaTestTexture(): Nullable<BaseTexture>;
  109616. /**
  109617. * Get if the submesh is ready to be used and all its information available.
  109618. * Child classes can use it to update shaders
  109619. * @param mesh defines the mesh to check
  109620. * @param subMesh defines which submesh to check
  109621. * @param useInstances specifies that instances should be used
  109622. * @returns a boolean indicating that the submesh is ready or not
  109623. */
  109624. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  109625. /**
  109626. * Builds the material UBO layouts.
  109627. * Used internally during the effect preparation.
  109628. */
  109629. buildUniformLayout(): void;
  109630. /**
  109631. * Unbinds the material from the mesh
  109632. */
  109633. unbind(): void;
  109634. /**
  109635. * Binds the submesh to this material by preparing the effect and shader to draw
  109636. * @param world defines the world transformation matrix
  109637. * @param mesh defines the mesh containing the submesh
  109638. * @param subMesh defines the submesh to bind the material to
  109639. */
  109640. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  109641. /**
  109642. * Get the list of animatables in the material.
  109643. * @returns the list of animatables object used in the material
  109644. */
  109645. getAnimatables(): IAnimatable[];
  109646. /**
  109647. * Gets the active textures from the material
  109648. * @returns an array of textures
  109649. */
  109650. getActiveTextures(): BaseTexture[];
  109651. /**
  109652. * Specifies if the material uses a texture
  109653. * @param texture defines the texture to check against the material
  109654. * @returns a boolean specifying if the material uses the texture
  109655. */
  109656. hasTexture(texture: BaseTexture): boolean;
  109657. /**
  109658. * Disposes the material
  109659. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  109660. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  109661. */
  109662. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  109663. /**
  109664. * Makes a duplicate of the material, and gives it a new name
  109665. * @param name defines the new name for the duplicated material
  109666. * @returns the cloned material
  109667. */
  109668. clone(name: string): StandardMaterial;
  109669. /**
  109670. * Serializes this material in a JSON representation
  109671. * @returns the serialized material object
  109672. */
  109673. serialize(): any;
  109674. /**
  109675. * Creates a standard material from parsed material data
  109676. * @param source defines the JSON representation of the material
  109677. * @param scene defines the hosting scene
  109678. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  109679. * @returns a new standard material
  109680. */
  109681. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  109682. /**
  109683. * Are diffuse textures enabled in the application.
  109684. */
  109685. static DiffuseTextureEnabled: boolean;
  109686. /**
  109687. * Are ambient textures enabled in the application.
  109688. */
  109689. static AmbientTextureEnabled: boolean;
  109690. /**
  109691. * Are opacity textures enabled in the application.
  109692. */
  109693. static OpacityTextureEnabled: boolean;
  109694. /**
  109695. * Are reflection textures enabled in the application.
  109696. */
  109697. static ReflectionTextureEnabled: boolean;
  109698. /**
  109699. * Are emissive textures enabled in the application.
  109700. */
  109701. static EmissiveTextureEnabled: boolean;
  109702. /**
  109703. * Are specular textures enabled in the application.
  109704. */
  109705. static SpecularTextureEnabled: boolean;
  109706. /**
  109707. * Are bump textures enabled in the application.
  109708. */
  109709. static BumpTextureEnabled: boolean;
  109710. /**
  109711. * Are lightmap textures enabled in the application.
  109712. */
  109713. static LightmapTextureEnabled: boolean;
  109714. /**
  109715. * Are refraction textures enabled in the application.
  109716. */
  109717. static RefractionTextureEnabled: boolean;
  109718. /**
  109719. * Are color grading textures enabled in the application.
  109720. */
  109721. static ColorGradingTextureEnabled: boolean;
  109722. /**
  109723. * Are fresnels enabled in the application.
  109724. */
  109725. static FresnelEnabled: boolean;
  109726. }
  109727. }
  109728. declare module BABYLON {
  109729. /** @hidden */
  109730. export var imageProcessingPixelShader: {
  109731. name: string;
  109732. shader: string;
  109733. };
  109734. }
  109735. declare module BABYLON {
  109736. /**
  109737. * ImageProcessingPostProcess
  109738. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  109739. */
  109740. export class ImageProcessingPostProcess extends PostProcess {
  109741. /**
  109742. * Default configuration related to image processing available in the PBR Material.
  109743. */
  109744. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  109745. /**
  109746. * Gets the image processing configuration used either in this material.
  109747. */
  109748. /**
  109749. * Sets the Default image processing configuration used either in the this material.
  109750. *
  109751. * If sets to null, the scene one is in use.
  109752. */
  109753. imageProcessingConfiguration: ImageProcessingConfiguration;
  109754. /**
  109755. * Keep track of the image processing observer to allow dispose and replace.
  109756. */
  109757. private _imageProcessingObserver;
  109758. /**
  109759. * Attaches a new image processing configuration to the PBR Material.
  109760. * @param configuration
  109761. */
  109762. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  109763. /**
  109764. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  109765. */
  109766. /**
  109767. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  109768. */
  109769. colorCurves: Nullable<ColorCurves>;
  109770. /**
  109771. * Gets wether the color curves effect is enabled.
  109772. */
  109773. /**
  109774. * Sets wether the color curves effect is enabled.
  109775. */
  109776. colorCurvesEnabled: boolean;
  109777. /**
  109778. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  109779. */
  109780. /**
  109781. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  109782. */
  109783. colorGradingTexture: Nullable<BaseTexture>;
  109784. /**
  109785. * Gets wether the color grading effect is enabled.
  109786. */
  109787. /**
  109788. * Gets wether the color grading effect is enabled.
  109789. */
  109790. colorGradingEnabled: boolean;
  109791. /**
  109792. * Gets exposure used in the effect.
  109793. */
  109794. /**
  109795. * Sets exposure used in the effect.
  109796. */
  109797. exposure: number;
  109798. /**
  109799. * Gets wether tonemapping is enabled or not.
  109800. */
  109801. /**
  109802. * Sets wether tonemapping is enabled or not
  109803. */
  109804. toneMappingEnabled: boolean;
  109805. /**
  109806. * Gets the type of tone mapping effect.
  109807. */
  109808. /**
  109809. * Sets the type of tone mapping effect.
  109810. */
  109811. toneMappingType: number;
  109812. /**
  109813. * Gets contrast used in the effect.
  109814. */
  109815. /**
  109816. * Sets contrast used in the effect.
  109817. */
  109818. contrast: number;
  109819. /**
  109820. * Gets Vignette stretch size.
  109821. */
  109822. /**
  109823. * Sets Vignette stretch size.
  109824. */
  109825. vignetteStretch: number;
  109826. /**
  109827. * Gets Vignette centre X Offset.
  109828. */
  109829. /**
  109830. * Sets Vignette centre X Offset.
  109831. */
  109832. vignetteCentreX: number;
  109833. /**
  109834. * Gets Vignette centre Y Offset.
  109835. */
  109836. /**
  109837. * Sets Vignette centre Y Offset.
  109838. */
  109839. vignetteCentreY: number;
  109840. /**
  109841. * Gets Vignette weight or intensity of the vignette effect.
  109842. */
  109843. /**
  109844. * Sets Vignette weight or intensity of the vignette effect.
  109845. */
  109846. vignetteWeight: number;
  109847. /**
  109848. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  109849. * if vignetteEnabled is set to true.
  109850. */
  109851. /**
  109852. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  109853. * if vignetteEnabled is set to true.
  109854. */
  109855. vignetteColor: Color4;
  109856. /**
  109857. * Gets Camera field of view used by the Vignette effect.
  109858. */
  109859. /**
  109860. * Sets Camera field of view used by the Vignette effect.
  109861. */
  109862. vignetteCameraFov: number;
  109863. /**
  109864. * Gets the vignette blend mode allowing different kind of effect.
  109865. */
  109866. /**
  109867. * Sets the vignette blend mode allowing different kind of effect.
  109868. */
  109869. vignetteBlendMode: number;
  109870. /**
  109871. * Gets wether the vignette effect is enabled.
  109872. */
  109873. /**
  109874. * Sets wether the vignette effect is enabled.
  109875. */
  109876. vignetteEnabled: boolean;
  109877. private _fromLinearSpace;
  109878. /**
  109879. * Gets wether the input of the processing is in Gamma or Linear Space.
  109880. */
  109881. /**
  109882. * Sets wether the input of the processing is in Gamma or Linear Space.
  109883. */
  109884. fromLinearSpace: boolean;
  109885. /**
  109886. * Defines cache preventing GC.
  109887. */
  109888. private _defines;
  109889. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  109890. /**
  109891. * "ImageProcessingPostProcess"
  109892. * @returns "ImageProcessingPostProcess"
  109893. */
  109894. getClassName(): string;
  109895. protected _updateParameters(): void;
  109896. dispose(camera?: Camera): void;
  109897. }
  109898. }
  109899. declare module BABYLON {
  109900. /**
  109901. * Class containing static functions to help procedurally build meshes
  109902. */
  109903. export class GroundBuilder {
  109904. /**
  109905. * Creates a ground mesh
  109906. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  109907. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  109908. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109909. * @param name defines the name of the mesh
  109910. * @param options defines the options used to create the mesh
  109911. * @param scene defines the hosting scene
  109912. * @returns the ground mesh
  109913. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  109914. */
  109915. static CreateGround(name: string, options: {
  109916. width?: number;
  109917. height?: number;
  109918. subdivisions?: number;
  109919. subdivisionsX?: number;
  109920. subdivisionsY?: number;
  109921. updatable?: boolean;
  109922. }, scene: any): Mesh;
  109923. /**
  109924. * Creates a tiled ground mesh
  109925. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  109926. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  109927. * * 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
  109928. * * 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
  109929. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  109930. * @param name defines the name of the mesh
  109931. * @param options defines the options used to create the mesh
  109932. * @param scene defines the hosting scene
  109933. * @returns the tiled ground mesh
  109934. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  109935. */
  109936. static CreateTiledGround(name: string, options: {
  109937. xmin: number;
  109938. zmin: number;
  109939. xmax: number;
  109940. zmax: number;
  109941. subdivisions?: {
  109942. w: number;
  109943. h: number;
  109944. };
  109945. precision?: {
  109946. w: number;
  109947. h: number;
  109948. };
  109949. updatable?: boolean;
  109950. }, scene?: Nullable<Scene>): Mesh;
  109951. /**
  109952. * Creates a ground mesh from a height map
  109953. * * The parameter `url` sets the URL of the height map image resource.
  109954. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  109955. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  109956. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  109957. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  109958. * * 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.
  109959. * * 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).
  109960. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  109961. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  109962. * @param name defines the name of the mesh
  109963. * @param url defines the url to the height map
  109964. * @param options defines the options used to create the mesh
  109965. * @param scene defines the hosting scene
  109966. * @returns the ground mesh
  109967. * @see https://doc.babylonjs.com/babylon101/height_map
  109968. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  109969. */
  109970. static CreateGroundFromHeightMap(name: string, url: string, options: {
  109971. width?: number;
  109972. height?: number;
  109973. subdivisions?: number;
  109974. minHeight?: number;
  109975. maxHeight?: number;
  109976. colorFilter?: Color3;
  109977. alphaFilter?: number;
  109978. updatable?: boolean;
  109979. onReady?: (mesh: GroundMesh) => void;
  109980. }, scene?: Nullable<Scene>): GroundMesh;
  109981. }
  109982. }
  109983. declare module BABYLON {
  109984. /**
  109985. * Class containing static functions to help procedurally build meshes
  109986. */
  109987. export class TorusBuilder {
  109988. /**
  109989. * Creates a torus mesh
  109990. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  109991. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  109992. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  109993. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109994. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109995. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  109996. * @param name defines the name of the mesh
  109997. * @param options defines the options used to create the mesh
  109998. * @param scene defines the hosting scene
  109999. * @returns the torus mesh
  110000. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  110001. */
  110002. static CreateTorus(name: string, options: {
  110003. diameter?: number;
  110004. thickness?: number;
  110005. tessellation?: number;
  110006. updatable?: boolean;
  110007. sideOrientation?: number;
  110008. frontUVs?: Vector4;
  110009. backUVs?: Vector4;
  110010. }, scene: any): Mesh;
  110011. }
  110012. }
  110013. declare module BABYLON {
  110014. /**
  110015. * Class containing static functions to help procedurally build meshes
  110016. */
  110017. export class CylinderBuilder {
  110018. /**
  110019. * Creates a cylinder or a cone mesh
  110020. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  110021. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  110022. * * 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.
  110023. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  110024. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  110025. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  110026. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  110027. * * 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).
  110028. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  110029. * * 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).
  110030. * * 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
  110031. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  110032. * * 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
  110033. * * 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.
  110034. * * If `enclose` is false, a ring surface is one element.
  110035. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  110036. * * 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
  110037. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110038. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110039. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  110040. * @param name defines the name of the mesh
  110041. * @param options defines the options used to create the mesh
  110042. * @param scene defines the hosting scene
  110043. * @returns the cylinder mesh
  110044. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  110045. */
  110046. static CreateCylinder(name: string, options: {
  110047. height?: number;
  110048. diameterTop?: number;
  110049. diameterBottom?: number;
  110050. diameter?: number;
  110051. tessellation?: number;
  110052. subdivisions?: number;
  110053. arc?: number;
  110054. faceColors?: Color4[];
  110055. faceUV?: Vector4[];
  110056. updatable?: boolean;
  110057. hasRings?: boolean;
  110058. enclose?: boolean;
  110059. cap?: number;
  110060. sideOrientation?: number;
  110061. frontUVs?: Vector4;
  110062. backUVs?: Vector4;
  110063. }, scene: any): Mesh;
  110064. }
  110065. }
  110066. declare module BABYLON {
  110067. /**
  110068. * Options to modify the vr teleportation behavior.
  110069. */
  110070. export interface VRTeleportationOptions {
  110071. /**
  110072. * The name of the mesh which should be used as the teleportation floor. (default: null)
  110073. */
  110074. floorMeshName?: string;
  110075. /**
  110076. * A list of meshes to be used as the teleportation floor. (default: empty)
  110077. */
  110078. floorMeshes?: Mesh[];
  110079. /**
  110080. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  110081. */
  110082. teleportationMode?: number;
  110083. /**
  110084. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  110085. */
  110086. teleportationTime?: number;
  110087. /**
  110088. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  110089. */
  110090. teleportationSpeed?: number;
  110091. }
  110092. /**
  110093. * Options to modify the vr experience helper's behavior.
  110094. */
  110095. export interface VRExperienceHelperOptions extends WebVROptions {
  110096. /**
  110097. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  110098. */
  110099. createDeviceOrientationCamera?: boolean;
  110100. /**
  110101. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  110102. */
  110103. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  110104. /**
  110105. * Uses the main button on the controller to toggle the laser casted. (default: true)
  110106. */
  110107. laserToggle?: boolean;
  110108. /**
  110109. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  110110. */
  110111. floorMeshes?: Mesh[];
  110112. /**
  110113. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  110114. */
  110115. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  110116. }
  110117. /**
  110118. * Event containing information after VR has been entered
  110119. */
  110120. export class OnAfterEnteringVRObservableEvent {
  110121. /**
  110122. * If entering vr was successful
  110123. */
  110124. success: boolean;
  110125. }
  110126. /**
  110127. * Helps to quickly add VR support to an existing scene.
  110128. * See http://doc.babylonjs.com/how_to/webvr_helper
  110129. */
  110130. export class VRExperienceHelper {
  110131. /** Options to modify the vr experience helper's behavior. */
  110132. webVROptions: VRExperienceHelperOptions;
  110133. private _scene;
  110134. private _position;
  110135. private _btnVR;
  110136. private _btnVRDisplayed;
  110137. private _webVRsupported;
  110138. private _webVRready;
  110139. private _webVRrequesting;
  110140. private _webVRpresenting;
  110141. private _hasEnteredVR;
  110142. private _fullscreenVRpresenting;
  110143. private _inputElement;
  110144. private _webVRCamera;
  110145. private _vrDeviceOrientationCamera;
  110146. private _deviceOrientationCamera;
  110147. private _existingCamera;
  110148. private _onKeyDown;
  110149. private _onVrDisplayPresentChange;
  110150. private _onVRDisplayChanged;
  110151. private _onVRRequestPresentStart;
  110152. private _onVRRequestPresentComplete;
  110153. /**
  110154. * 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)
  110155. */
  110156. enableGazeEvenWhenNoPointerLock: boolean;
  110157. /**
  110158. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  110159. */
  110160. exitVROnDoubleTap: boolean;
  110161. /**
  110162. * Observable raised right before entering VR.
  110163. */
  110164. onEnteringVRObservable: Observable<VRExperienceHelper>;
  110165. /**
  110166. * Observable raised when entering VR has completed.
  110167. */
  110168. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  110169. /**
  110170. * Observable raised when exiting VR.
  110171. */
  110172. onExitingVRObservable: Observable<VRExperienceHelper>;
  110173. /**
  110174. * Observable raised when controller mesh is loaded.
  110175. */
  110176. onControllerMeshLoadedObservable: Observable<WebVRController>;
  110177. /** Return this.onEnteringVRObservable
  110178. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  110179. */
  110180. readonly onEnteringVR: Observable<VRExperienceHelper>;
  110181. /** Return this.onExitingVRObservable
  110182. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  110183. */
  110184. readonly onExitingVR: Observable<VRExperienceHelper>;
  110185. /** Return this.onControllerMeshLoadedObservable
  110186. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  110187. */
  110188. readonly onControllerMeshLoaded: Observable<WebVRController>;
  110189. private _rayLength;
  110190. private _useCustomVRButton;
  110191. private _teleportationRequested;
  110192. private _teleportActive;
  110193. private _floorMeshName;
  110194. private _floorMeshesCollection;
  110195. private _teleportationMode;
  110196. private _teleportationTime;
  110197. private _teleportationSpeed;
  110198. private _rotationAllowed;
  110199. private _teleportBackwardsVector;
  110200. private _teleportationTarget;
  110201. private _isDefaultTeleportationTarget;
  110202. private _postProcessMove;
  110203. private _teleportationFillColor;
  110204. private _teleportationBorderColor;
  110205. private _rotationAngle;
  110206. private _haloCenter;
  110207. private _cameraGazer;
  110208. private _padSensibilityUp;
  110209. private _padSensibilityDown;
  110210. private _leftController;
  110211. private _rightController;
  110212. /**
  110213. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  110214. */
  110215. onNewMeshSelected: Observable<AbstractMesh>;
  110216. /**
  110217. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  110218. * This observable will provide the mesh and the controller used to select the mesh
  110219. */
  110220. onMeshSelectedWithController: Observable<{
  110221. mesh: AbstractMesh;
  110222. controller: WebVRController;
  110223. }>;
  110224. /**
  110225. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  110226. */
  110227. onNewMeshPicked: Observable<PickingInfo>;
  110228. private _circleEase;
  110229. /**
  110230. * Observable raised before camera teleportation
  110231. */
  110232. onBeforeCameraTeleport: Observable<Vector3>;
  110233. /**
  110234. * Observable raised after camera teleportation
  110235. */
  110236. onAfterCameraTeleport: Observable<Vector3>;
  110237. /**
  110238. * Observable raised when current selected mesh gets unselected
  110239. */
  110240. onSelectedMeshUnselected: Observable<AbstractMesh>;
  110241. private _raySelectionPredicate;
  110242. /**
  110243. * To be optionaly changed by user to define custom ray selection
  110244. */
  110245. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  110246. /**
  110247. * To be optionaly changed by user to define custom selection logic (after ray selection)
  110248. */
  110249. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  110250. /**
  110251. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  110252. */
  110253. teleportationEnabled: boolean;
  110254. private _defaultHeight;
  110255. private _teleportationInitialized;
  110256. private _interactionsEnabled;
  110257. private _interactionsRequested;
  110258. private _displayGaze;
  110259. private _displayLaserPointer;
  110260. /**
  110261. * The mesh used to display where the user is going to teleport.
  110262. */
  110263. /**
  110264. * Sets the mesh to be used to display where the user is going to teleport.
  110265. */
  110266. teleportationTarget: Mesh;
  110267. /**
  110268. * 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
  110269. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  110270. * See http://doc.babylonjs.com/resources/baking_transformations
  110271. */
  110272. gazeTrackerMesh: Mesh;
  110273. /**
  110274. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  110275. */
  110276. updateGazeTrackerScale: boolean;
  110277. /**
  110278. * If the gaze trackers color should be updated when selecting meshes
  110279. */
  110280. updateGazeTrackerColor: boolean;
  110281. /**
  110282. * If the controller laser color should be updated when selecting meshes
  110283. */
  110284. updateControllerLaserColor: boolean;
  110285. /**
  110286. * The gaze tracking mesh corresponding to the left controller
  110287. */
  110288. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  110289. /**
  110290. * The gaze tracking mesh corresponding to the right controller
  110291. */
  110292. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  110293. /**
  110294. * If the ray of the gaze should be displayed.
  110295. */
  110296. /**
  110297. * Sets if the ray of the gaze should be displayed.
  110298. */
  110299. displayGaze: boolean;
  110300. /**
  110301. * If the ray of the LaserPointer should be displayed.
  110302. */
  110303. /**
  110304. * Sets if the ray of the LaserPointer should be displayed.
  110305. */
  110306. displayLaserPointer: boolean;
  110307. /**
  110308. * The deviceOrientationCamera used as the camera when not in VR.
  110309. */
  110310. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  110311. /**
  110312. * Based on the current WebVR support, returns the current VR camera used.
  110313. */
  110314. readonly currentVRCamera: Nullable<Camera>;
  110315. /**
  110316. * The webVRCamera which is used when in VR.
  110317. */
  110318. readonly webVRCamera: WebVRFreeCamera;
  110319. /**
  110320. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  110321. */
  110322. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  110323. /**
  110324. * The html button that is used to trigger entering into VR.
  110325. */
  110326. readonly vrButton: Nullable<HTMLButtonElement>;
  110327. private readonly _teleportationRequestInitiated;
  110328. /**
  110329. * Defines wether or not Pointer lock should be requested when switching to
  110330. * full screen.
  110331. */
  110332. requestPointerLockOnFullScreen: boolean;
  110333. /**
  110334. * Instantiates a VRExperienceHelper.
  110335. * Helps to quickly add VR support to an existing scene.
  110336. * @param scene The scene the VRExperienceHelper belongs to.
  110337. * @param webVROptions Options to modify the vr experience helper's behavior.
  110338. */
  110339. constructor(scene: Scene,
  110340. /** Options to modify the vr experience helper's behavior. */
  110341. webVROptions?: VRExperienceHelperOptions);
  110342. private _onDefaultMeshLoaded;
  110343. private _onResize;
  110344. private _onFullscreenChange;
  110345. /**
  110346. * Gets a value indicating if we are currently in VR mode.
  110347. */
  110348. readonly isInVRMode: boolean;
  110349. private onVrDisplayPresentChange;
  110350. private onVRDisplayChanged;
  110351. private moveButtonToBottomRight;
  110352. private displayVRButton;
  110353. private updateButtonVisibility;
  110354. private _cachedAngularSensibility;
  110355. /**
  110356. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  110357. * Otherwise, will use the fullscreen API.
  110358. */
  110359. enterVR(): void;
  110360. /**
  110361. * Attempt to exit VR, or fullscreen.
  110362. */
  110363. exitVR(): void;
  110364. /**
  110365. * The position of the vr experience helper.
  110366. */
  110367. /**
  110368. * Sets the position of the vr experience helper.
  110369. */
  110370. position: Vector3;
  110371. /**
  110372. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  110373. */
  110374. enableInteractions(): void;
  110375. private readonly _noControllerIsActive;
  110376. private beforeRender;
  110377. private _isTeleportationFloor;
  110378. /**
  110379. * Adds a floor mesh to be used for teleportation.
  110380. * @param floorMesh the mesh to be used for teleportation.
  110381. */
  110382. addFloorMesh(floorMesh: Mesh): void;
  110383. /**
  110384. * Removes a floor mesh from being used for teleportation.
  110385. * @param floorMesh the mesh to be removed.
  110386. */
  110387. removeFloorMesh(floorMesh: Mesh): void;
  110388. /**
  110389. * Enables interactions and teleportation using the VR controllers and gaze.
  110390. * @param vrTeleportationOptions options to modify teleportation behavior.
  110391. */
  110392. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  110393. private _onNewGamepadConnected;
  110394. private _tryEnableInteractionOnController;
  110395. private _onNewGamepadDisconnected;
  110396. private _enableInteractionOnController;
  110397. private _checkTeleportWithRay;
  110398. private _checkRotate;
  110399. private _checkTeleportBackwards;
  110400. private _enableTeleportationOnController;
  110401. private _createTeleportationCircles;
  110402. private _displayTeleportationTarget;
  110403. private _hideTeleportationTarget;
  110404. private _rotateCamera;
  110405. private _moveTeleportationSelectorTo;
  110406. private _workingVector;
  110407. private _workingQuaternion;
  110408. private _workingMatrix;
  110409. /**
  110410. * Time Constant Teleportation Mode
  110411. */
  110412. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  110413. /**
  110414. * Speed Constant Teleportation Mode
  110415. */
  110416. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  110417. /**
  110418. * Teleports the users feet to the desired location
  110419. * @param location The location where the user's feet should be placed
  110420. */
  110421. teleportCamera(location: Vector3): void;
  110422. private _convertNormalToDirectionOfRay;
  110423. private _castRayAndSelectObject;
  110424. private _notifySelectedMeshUnselected;
  110425. /**
  110426. * Sets the color of the laser ray from the vr controllers.
  110427. * @param color new color for the ray.
  110428. */
  110429. changeLaserColor(color: Color3): void;
  110430. /**
  110431. * Sets the color of the ray from the vr headsets gaze.
  110432. * @param color new color for the ray.
  110433. */
  110434. changeGazeColor(color: Color3): void;
  110435. /**
  110436. * Exits VR and disposes of the vr experience helper
  110437. */
  110438. dispose(): void;
  110439. /**
  110440. * Gets the name of the VRExperienceHelper class
  110441. * @returns "VRExperienceHelper"
  110442. */
  110443. getClassName(): string;
  110444. }
  110445. }
  110446. declare module BABYLON {
  110447. /**
  110448. * States of the webXR experience
  110449. */
  110450. export enum WebXRState {
  110451. /**
  110452. * Transitioning to being in XR mode
  110453. */
  110454. ENTERING_XR = 0,
  110455. /**
  110456. * Transitioning to non XR mode
  110457. */
  110458. EXITING_XR = 1,
  110459. /**
  110460. * In XR mode and presenting
  110461. */
  110462. IN_XR = 2,
  110463. /**
  110464. * Not entered XR mode
  110465. */
  110466. NOT_IN_XR = 3
  110467. }
  110468. /**
  110469. * Abstraction of the XR render target
  110470. */
  110471. export interface WebXRRenderTarget extends IDisposable {
  110472. /**
  110473. * xrpresent context of the canvas which can be used to display/mirror xr content
  110474. */
  110475. canvasContext: WebGLRenderingContext;
  110476. /**
  110477. * xr layer for the canvas
  110478. */
  110479. xrLayer: Nullable<XRWebGLLayer>;
  110480. /**
  110481. * Initializes the xr layer for the session
  110482. * @param xrSession xr session
  110483. * @returns a promise that will resolve once the XR Layer has been created
  110484. */
  110485. initializeXRLayerAsync(xrSession: XRSession): Promise<void>;
  110486. }
  110487. }
  110488. declare module BABYLON {
  110489. /**
  110490. * COnfiguration object for WebXR output canvas
  110491. */
  110492. export class WebXRManagedOutputCanvasOptions {
  110493. /**
  110494. * Options for this XR Layer output
  110495. */
  110496. canvasOptions: XRWebGLLayerOptions;
  110497. /**
  110498. * CSS styling for a newly created canvas (if not provided)
  110499. */
  110500. newCanvasCssStyle?: string;
  110501. /**
  110502. * Get the default values of the configuration object
  110503. * @returns default values of this configuration object
  110504. */
  110505. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  110506. }
  110507. /**
  110508. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  110509. */
  110510. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  110511. private configuration;
  110512. private _engine;
  110513. private _canvas;
  110514. /**
  110515. * xrpresent context of the canvas which can be used to display/mirror xr content
  110516. */
  110517. canvasContext: WebGLRenderingContext;
  110518. /**
  110519. * xr layer for the canvas
  110520. */
  110521. xrLayer: Nullable<XRWebGLLayer>;
  110522. /**
  110523. * Initializes the xr layer for the session
  110524. * @param xrSession xr session
  110525. * @returns a promise that will resolve once the XR Layer has been created
  110526. */
  110527. initializeXRLayerAsync(xrSession: any): any;
  110528. /**
  110529. * Initializes the canvas to be added/removed upon entering/exiting xr
  110530. * @param engine the Babylon engine
  110531. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  110532. * @param onStateChangedObservable the mechanism by which the canvas will be added/removed based on XR state
  110533. * @param configuration optional configuration for this canvas output. defaults will be used if not provided
  110534. */
  110535. constructor(engine: ThinEngine, canvas?: HTMLCanvasElement, onStateChangedObservable?: Observable<WebXRState>, configuration?: WebXRManagedOutputCanvasOptions);
  110536. /**
  110537. * Disposes of the object
  110538. */
  110539. dispose(): void;
  110540. private _setManagedOutputCanvas;
  110541. private _addCanvas;
  110542. private _removeCanvas;
  110543. }
  110544. }
  110545. declare module BABYLON {
  110546. /**
  110547. * Manages an XRSession to work with Babylon's engine
  110548. * @see https://doc.babylonjs.com/how_to/webxr
  110549. */
  110550. export class WebXRSessionManager implements IDisposable {
  110551. private scene;
  110552. /**
  110553. * Fires every time a new xrFrame arrives which can be used to update the camera
  110554. */
  110555. onXRFrameObservable: Observable<any>;
  110556. /**
  110557. * Fires when the xr session is ended either by the device or manually done
  110558. */
  110559. onXRSessionEnded: Observable<any>;
  110560. /**
  110561. * Underlying xr session
  110562. */
  110563. session: XRSession;
  110564. /**
  110565. * Type of reference space used when creating the session
  110566. */
  110567. referenceSpace: XRReferenceSpace;
  110568. /**
  110569. * Current XR frame
  110570. */
  110571. currentFrame: Nullable<XRFrame>;
  110572. private _xrNavigator;
  110573. private baseLayer;
  110574. private _rttProvider;
  110575. private _sessionEnded;
  110576. /**
  110577. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  110578. * @param scene The scene which the session should be created for
  110579. */
  110580. constructor(scene: Scene);
  110581. /**
  110582. * Initializes the manager
  110583. * After initialization enterXR can be called to start an XR session
  110584. * @returns Promise which resolves after it is initialized
  110585. */
  110586. initializeAsync(): Promise<void>;
  110587. /**
  110588. * Initializes an xr session
  110589. * @param xrSessionMode mode to initialize
  110590. * @param optionalFeatures defines optional values to pass to the session builder
  110591. * @returns a promise which will resolve once the session has been initialized
  110592. */
  110593. initializeSessionAsync(xrSessionMode: XRSessionMode, optionalFeatures?: any): Promise<XRSession>;
  110594. /**
  110595. * Sets the reference space on the xr session
  110596. * @param referenceSpace space to set
  110597. * @returns a promise that will resolve once the reference space has been set
  110598. */
  110599. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  110600. /**
  110601. * Updates the render state of the session
  110602. * @param state state to set
  110603. * @returns a promise that resolves once the render state has been updated
  110604. */
  110605. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  110606. /**
  110607. * Starts rendering to the xr layer
  110608. * @returns a promise that will resolve once rendering has started
  110609. */
  110610. startRenderingToXRAsync(): Promise<void>;
  110611. /**
  110612. * Gets the correct render target texture to be rendered this frame for this eye
  110613. * @param eye the eye for which to get the render target
  110614. * @returns the render target for the specified eye
  110615. */
  110616. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  110617. /**
  110618. * Stops the xrSession and restores the renderloop
  110619. * @returns Promise which resolves after it exits XR
  110620. */
  110621. exitXRAsync(): Promise<void>;
  110622. /**
  110623. * Checks if a session would be supported for the creation options specified
  110624. * @param sessionMode session mode to check if supported eg. immersive-vr
  110625. * @returns true if supported
  110626. */
  110627. supportsSessionAsync(sessionMode: XRSessionMode): any;
  110628. /**
  110629. * Creates a WebXRRenderTarget object for the XR session
  110630. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  110631. * @param options optional options to provide when creating a new render target
  110632. * @returns a WebXR render target to which the session can render
  110633. */
  110634. getWebXRRenderTarget(onStateChangedObservable?: Observable<WebXRState>, options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  110635. /**
  110636. * @hidden
  110637. * Converts the render layer of xrSession to a render target
  110638. * @param session session to create render target for
  110639. * @param scene scene the new render target should be created for
  110640. */
  110641. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  110642. /**
  110643. * Disposes of the session manager
  110644. */
  110645. dispose(): void;
  110646. }
  110647. }
  110648. declare module BABYLON {
  110649. /**
  110650. * WebXR Camera which holds the views for the xrSession
  110651. * @see https://doc.babylonjs.com/how_to/webxr
  110652. */
  110653. export class WebXRCamera extends FreeCamera {
  110654. /**
  110655. * Is the camera in debug mode. Used when using an emulator
  110656. */
  110657. debugMode: boolean;
  110658. /**
  110659. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  110660. * @param name the name of the camera
  110661. * @param scene the scene to add the camera to
  110662. */
  110663. constructor(name: string, scene: Scene);
  110664. private _updateNumberOfRigCameras;
  110665. /** @hidden */
  110666. _updateForDualEyeDebugging(): void;
  110667. /**
  110668. * Updates the cameras position from the current pose information of the XR session
  110669. * @param xrSessionManager the session containing pose information
  110670. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  110671. */
  110672. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  110673. }
  110674. }
  110675. declare module BABYLON {
  110676. /**
  110677. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  110678. * @see https://doc.babylonjs.com/how_to/webxr
  110679. */
  110680. export class WebXRExperienceHelper implements IDisposable {
  110681. private scene;
  110682. /**
  110683. * 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
  110684. */
  110685. container: AbstractMesh;
  110686. /**
  110687. * Camera used to render xr content
  110688. */
  110689. camera: WebXRCamera;
  110690. /**
  110691. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  110692. */
  110693. state: WebXRState;
  110694. private _setState;
  110695. private static _TmpVector;
  110696. /**
  110697. * Fires when the state of the experience helper has changed
  110698. */
  110699. onStateChangedObservable: Observable<WebXRState>;
  110700. /** Session manager used to keep track of xr session */
  110701. sessionManager: WebXRSessionManager;
  110702. private _nonVRCamera;
  110703. private _originalSceneAutoClear;
  110704. private _supported;
  110705. /**
  110706. * Creates the experience helper
  110707. * @param scene the scene to attach the experience helper to
  110708. * @returns a promise for the experience helper
  110709. */
  110710. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  110711. /**
  110712. * Creates a WebXRExperienceHelper
  110713. * @param scene The scene the helper should be created in
  110714. */
  110715. private constructor();
  110716. /**
  110717. * Exits XR mode and returns the scene to its original state
  110718. * @returns promise that resolves after xr mode has exited
  110719. */
  110720. exitXRAsync(): Promise<void>;
  110721. /**
  110722. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  110723. * @param sessionMode options for the XR session
  110724. * @param referenceSpaceType frame of reference of the XR session
  110725. * @param renderTarget the output canvas that will be used to enter XR mode
  110726. * @returns promise that resolves after xr mode has entered
  110727. */
  110728. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget: WebXRRenderTarget): Promise<WebXRSessionManager>;
  110729. /**
  110730. * Updates the global position of the camera by moving the camera's container
  110731. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  110732. * @param position The desired global position of the camera
  110733. */
  110734. setPositionOfCameraUsingContainer(position: Vector3): void;
  110735. /**
  110736. * Rotates the xr camera by rotating the camera's container around the camera's position
  110737. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  110738. * @param rotation the desired quaternion rotation to apply to the camera
  110739. */
  110740. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  110741. /**
  110742. * Disposes of the experience helper
  110743. */
  110744. dispose(): void;
  110745. }
  110746. }
  110747. declare module BABYLON {
  110748. /**
  110749. * Button which can be used to enter a different mode of XR
  110750. */
  110751. export class WebXREnterExitUIButton {
  110752. /** button element */
  110753. element: HTMLElement;
  110754. /** XR initialization options for the button */
  110755. sessionMode: XRSessionMode;
  110756. /** Reference space type */
  110757. referenceSpaceType: XRReferenceSpaceType;
  110758. /**
  110759. * Creates a WebXREnterExitUIButton
  110760. * @param element button element
  110761. * @param sessionMode XR initialization session mode
  110762. * @param referenceSpaceType the type of reference space to be used
  110763. */
  110764. constructor(
  110765. /** button element */
  110766. element: HTMLElement,
  110767. /** XR initialization options for the button */
  110768. sessionMode: XRSessionMode,
  110769. /** Reference space type */
  110770. referenceSpaceType: XRReferenceSpaceType);
  110771. /**
  110772. * Overwritable function which can be used to update the button's visuals when the state changes
  110773. * @param activeButton the current active button in the UI
  110774. */
  110775. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  110776. }
  110777. /**
  110778. * Options to create the webXR UI
  110779. */
  110780. export class WebXREnterExitUIOptions {
  110781. /**
  110782. * Context to enter xr with
  110783. */
  110784. renderTarget?: Nullable<WebXRRenderTarget>;
  110785. /**
  110786. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  110787. */
  110788. customButtons?: Array<WebXREnterExitUIButton>;
  110789. /**
  110790. * A session mode to use when creating the default button.
  110791. * Default is immersive-vr
  110792. */
  110793. sessionMode?: XRSessionMode;
  110794. /**
  110795. * A reference space type to use when creating the default button.
  110796. * Default is local-floor
  110797. */
  110798. referenceSpaceType?: XRReferenceSpaceType;
  110799. }
  110800. /**
  110801. * UI to allow the user to enter/exit XR mode
  110802. */
  110803. export class WebXREnterExitUI implements IDisposable {
  110804. private scene;
  110805. private _overlay;
  110806. private _buttons;
  110807. private _activeButton;
  110808. /**
  110809. * Fired every time the active button is changed.
  110810. *
  110811. * When xr is entered via a button that launches xr that button will be the callback parameter
  110812. *
  110813. * When exiting xr the callback parameter will be null)
  110814. */
  110815. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  110816. /**
  110817. * Creates UI to allow the user to enter/exit XR mode
  110818. * @param scene the scene to add the ui to
  110819. * @param helper the xr experience helper to enter/exit xr with
  110820. * @param options options to configure the UI
  110821. * @returns the created ui
  110822. */
  110823. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  110824. private constructor();
  110825. private _updateButtons;
  110826. /**
  110827. * Disposes of the object
  110828. */
  110829. dispose(): void;
  110830. }
  110831. }
  110832. declare module BABYLON {
  110833. /**
  110834. * Represents an XR input
  110835. */
  110836. export class WebXRController {
  110837. private scene;
  110838. /** The underlying input source for the controller */
  110839. inputSource: XRInputSource;
  110840. private parentContainer;
  110841. /**
  110842. * 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
  110843. */
  110844. grip?: AbstractMesh;
  110845. /**
  110846. * Pointer which can be used to select objects or attach a visible laser to
  110847. */
  110848. pointer: AbstractMesh;
  110849. private _gamepadMode;
  110850. /**
  110851. * If available, this is the gamepad object related to this controller.
  110852. * Using this object it is possible to get click events and trackpad changes of the
  110853. * webxr controller that is currently being used.
  110854. */
  110855. gamepadController?: WebVRController;
  110856. /**
  110857. * Event that fires when the controller is removed/disposed
  110858. */
  110859. onDisposeObservable: Observable<{}>;
  110860. private _tmpMatrix;
  110861. private _tmpQuaternion;
  110862. private _tmpVector;
  110863. /**
  110864. * Creates the controller
  110865. * @see https://doc.babylonjs.com/how_to/webxr
  110866. * @param scene the scene which the controller should be associated to
  110867. * @param inputSource the underlying input source for the controller
  110868. * @param parentContainer parent that the controller meshes should be children of
  110869. */
  110870. constructor(scene: Scene,
  110871. /** The underlying input source for the controller */
  110872. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  110873. /**
  110874. * Updates the controller pose based on the given XRFrame
  110875. * @param xrFrame xr frame to update the pose with
  110876. * @param referenceSpace reference space to use
  110877. */
  110878. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  110879. /**
  110880. * Gets a world space ray coming from the controller
  110881. * @param result the resulting ray
  110882. */
  110883. getWorldPointerRayToRef(result: Ray): void;
  110884. /**
  110885. * Get the scene associated with this controller
  110886. * @returns the scene object
  110887. */
  110888. getScene(): Scene;
  110889. /**
  110890. * Disposes of the object
  110891. */
  110892. dispose(): void;
  110893. }
  110894. }
  110895. declare module BABYLON {
  110896. /**
  110897. * XR input used to track XR inputs such as controllers/rays
  110898. */
  110899. export class WebXRInput implements IDisposable {
  110900. /**
  110901. * Base experience the input listens to
  110902. */
  110903. baseExperience: WebXRExperienceHelper;
  110904. /**
  110905. * XR controllers being tracked
  110906. */
  110907. controllers: Array<WebXRController>;
  110908. private _frameObserver;
  110909. private _stateObserver;
  110910. /**
  110911. * Event when a controller has been connected/added
  110912. */
  110913. onControllerAddedObservable: Observable<WebXRController>;
  110914. /**
  110915. * Event when a controller has been removed/disconnected
  110916. */
  110917. onControllerRemovedObservable: Observable<WebXRController>;
  110918. /**
  110919. * Initializes the WebXRInput
  110920. * @param baseExperience experience helper which the input should be created for
  110921. */
  110922. constructor(
  110923. /**
  110924. * Base experience the input listens to
  110925. */
  110926. baseExperience: WebXRExperienceHelper);
  110927. private _onInputSourcesChange;
  110928. private _addAndRemoveControllers;
  110929. /**
  110930. * Disposes of the object
  110931. */
  110932. dispose(): void;
  110933. }
  110934. }
  110935. declare module BABYLON {
  110936. /**
  110937. * Enables teleportation
  110938. */
  110939. export class WebXRControllerTeleportation {
  110940. private _teleportationFillColor;
  110941. private _teleportationBorderColor;
  110942. private _tmpRay;
  110943. private _tmpVector;
  110944. /**
  110945. * Creates a WebXRControllerTeleportation
  110946. * @param input input manager to add teleportation to
  110947. * @param floorMeshes floormeshes which can be teleported to
  110948. */
  110949. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  110950. }
  110951. }
  110952. declare module BABYLON {
  110953. /**
  110954. * Handles pointer input automatically for the pointer of XR controllers
  110955. */
  110956. export class WebXRControllerPointerSelection {
  110957. private static _idCounter;
  110958. private _tmpRay;
  110959. /**
  110960. * Creates a WebXRControllerPointerSelection
  110961. * @param input input manager to setup pointer selection
  110962. */
  110963. constructor(input: WebXRInput);
  110964. private _convertNormalToDirectionOfRay;
  110965. private _updatePointerDistance;
  110966. }
  110967. }
  110968. declare module BABYLON {
  110969. /**
  110970. * Class used to represent data loading progression
  110971. */
  110972. export class SceneLoaderProgressEvent {
  110973. /** defines if data length to load can be evaluated */
  110974. readonly lengthComputable: boolean;
  110975. /** defines the loaded data length */
  110976. readonly loaded: number;
  110977. /** defines the data length to load */
  110978. readonly total: number;
  110979. /**
  110980. * Create a new progress event
  110981. * @param lengthComputable defines if data length to load can be evaluated
  110982. * @param loaded defines the loaded data length
  110983. * @param total defines the data length to load
  110984. */
  110985. constructor(
  110986. /** defines if data length to load can be evaluated */
  110987. lengthComputable: boolean,
  110988. /** defines the loaded data length */
  110989. loaded: number,
  110990. /** defines the data length to load */
  110991. total: number);
  110992. /**
  110993. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  110994. * @param event defines the source event
  110995. * @returns a new SceneLoaderProgressEvent
  110996. */
  110997. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  110998. }
  110999. /**
  111000. * Interface used by SceneLoader plugins to define supported file extensions
  111001. */
  111002. export interface ISceneLoaderPluginExtensions {
  111003. /**
  111004. * Defines the list of supported extensions
  111005. */
  111006. [extension: string]: {
  111007. isBinary: boolean;
  111008. };
  111009. }
  111010. /**
  111011. * Interface used by SceneLoader plugin factory
  111012. */
  111013. export interface ISceneLoaderPluginFactory {
  111014. /**
  111015. * Defines the name of the factory
  111016. */
  111017. name: string;
  111018. /**
  111019. * Function called to create a new plugin
  111020. * @return the new plugin
  111021. */
  111022. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  111023. /**
  111024. * The callback that returns true if the data can be directly loaded.
  111025. * @param data string containing the file data
  111026. * @returns if the data can be loaded directly
  111027. */
  111028. canDirectLoad?(data: string): boolean;
  111029. }
  111030. /**
  111031. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  111032. */
  111033. export interface ISceneLoaderPluginBase {
  111034. /**
  111035. * The friendly name of this plugin.
  111036. */
  111037. name: string;
  111038. /**
  111039. * The file extensions supported by this plugin.
  111040. */
  111041. extensions: string | ISceneLoaderPluginExtensions;
  111042. /**
  111043. * The callback called when loading from a url.
  111044. * @param scene scene loading this url
  111045. * @param url url to load
  111046. * @param onSuccess callback called when the file successfully loads
  111047. * @param onProgress callback called while file is loading (if the server supports this mode)
  111048. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  111049. * @param onError callback called when the file fails to load
  111050. * @returns a file request object
  111051. */
  111052. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  111053. /**
  111054. * The callback called when loading from a file object.
  111055. * @param scene scene loading this file
  111056. * @param file defines the file to load
  111057. * @param onSuccess defines the callback to call when data is loaded
  111058. * @param onProgress defines the callback to call during loading process
  111059. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  111060. * @param onError defines the callback to call when an error occurs
  111061. * @returns a file request object
  111062. */
  111063. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  111064. /**
  111065. * The callback that returns true if the data can be directly loaded.
  111066. * @param data string containing the file data
  111067. * @returns if the data can be loaded directly
  111068. */
  111069. canDirectLoad?(data: string): boolean;
  111070. /**
  111071. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  111072. * @param scene scene loading this data
  111073. * @param data string containing the data
  111074. * @returns data to pass to the plugin
  111075. */
  111076. directLoad?(scene: Scene, data: string): any;
  111077. /**
  111078. * The callback that allows custom handling of the root url based on the response url.
  111079. * @param rootUrl the original root url
  111080. * @param responseURL the response url if available
  111081. * @returns the new root url
  111082. */
  111083. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  111084. }
  111085. /**
  111086. * Interface used to define a SceneLoader plugin
  111087. */
  111088. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  111089. /**
  111090. * Import meshes into a scene.
  111091. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  111092. * @param scene The scene to import into
  111093. * @param data The data to import
  111094. * @param rootUrl The root url for scene and resources
  111095. * @param meshes The meshes array to import into
  111096. * @param particleSystems The particle systems array to import into
  111097. * @param skeletons The skeletons array to import into
  111098. * @param onError The callback when import fails
  111099. * @returns True if successful or false otherwise
  111100. */
  111101. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  111102. /**
  111103. * Load into a scene.
  111104. * @param scene The scene to load into
  111105. * @param data The data to import
  111106. * @param rootUrl The root url for scene and resources
  111107. * @param onError The callback when import fails
  111108. * @returns True if successful or false otherwise
  111109. */
  111110. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  111111. /**
  111112. * Load into an asset container.
  111113. * @param scene The scene to load into
  111114. * @param data The data to import
  111115. * @param rootUrl The root url for scene and resources
  111116. * @param onError The callback when import fails
  111117. * @returns The loaded asset container
  111118. */
  111119. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  111120. }
  111121. /**
  111122. * Interface used to define an async SceneLoader plugin
  111123. */
  111124. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  111125. /**
  111126. * Import meshes into a scene.
  111127. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  111128. * @param scene The scene to import into
  111129. * @param data The data to import
  111130. * @param rootUrl The root url for scene and resources
  111131. * @param onProgress The callback when the load progresses
  111132. * @param fileName Defines the name of the file to load
  111133. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  111134. */
  111135. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  111136. meshes: AbstractMesh[];
  111137. particleSystems: IParticleSystem[];
  111138. skeletons: Skeleton[];
  111139. animationGroups: AnimationGroup[];
  111140. }>;
  111141. /**
  111142. * Load into a scene.
  111143. * @param scene The scene to load into
  111144. * @param data The data to import
  111145. * @param rootUrl The root url for scene and resources
  111146. * @param onProgress The callback when the load progresses
  111147. * @param fileName Defines the name of the file to load
  111148. * @returns Nothing
  111149. */
  111150. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  111151. /**
  111152. * Load into an asset container.
  111153. * @param scene The scene to load into
  111154. * @param data The data to import
  111155. * @param rootUrl The root url for scene and resources
  111156. * @param onProgress The callback when the load progresses
  111157. * @param fileName Defines the name of the file to load
  111158. * @returns The loaded asset container
  111159. */
  111160. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  111161. }
  111162. /**
  111163. * Class used to load scene from various file formats using registered plugins
  111164. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  111165. */
  111166. export class SceneLoader {
  111167. /**
  111168. * No logging while loading
  111169. */
  111170. static readonly NO_LOGGING: number;
  111171. /**
  111172. * Minimal logging while loading
  111173. */
  111174. static readonly MINIMAL_LOGGING: number;
  111175. /**
  111176. * Summary logging while loading
  111177. */
  111178. static readonly SUMMARY_LOGGING: number;
  111179. /**
  111180. * Detailled logging while loading
  111181. */
  111182. static readonly DETAILED_LOGGING: number;
  111183. /**
  111184. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  111185. */
  111186. static ForceFullSceneLoadingForIncremental: boolean;
  111187. /**
  111188. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  111189. */
  111190. static ShowLoadingScreen: boolean;
  111191. /**
  111192. * Defines the current logging level (while loading the scene)
  111193. * @ignorenaming
  111194. */
  111195. static loggingLevel: number;
  111196. /**
  111197. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  111198. */
  111199. static CleanBoneMatrixWeights: boolean;
  111200. /**
  111201. * Event raised when a plugin is used to load a scene
  111202. */
  111203. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  111204. private static _registeredPlugins;
  111205. private static _getDefaultPlugin;
  111206. private static _getPluginForExtension;
  111207. private static _getPluginForDirectLoad;
  111208. private static _getPluginForFilename;
  111209. private static _getDirectLoad;
  111210. private static _loadData;
  111211. private static _getFileInfo;
  111212. /**
  111213. * Gets a plugin that can load the given extension
  111214. * @param extension defines the extension to load
  111215. * @returns a plugin or null if none works
  111216. */
  111217. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  111218. /**
  111219. * Gets a boolean indicating that the given extension can be loaded
  111220. * @param extension defines the extension to load
  111221. * @returns true if the extension is supported
  111222. */
  111223. static IsPluginForExtensionAvailable(extension: string): boolean;
  111224. /**
  111225. * Adds a new plugin to the list of registered plugins
  111226. * @param plugin defines the plugin to add
  111227. */
  111228. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  111229. /**
  111230. * Import meshes into a scene
  111231. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  111232. * @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)
  111233. * @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)
  111234. * @param scene the instance of BABYLON.Scene to append to
  111235. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  111236. * @param onProgress a callback with a progress event for each file being loaded
  111237. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  111238. * @param pluginExtension the extension used to determine the plugin
  111239. * @returns The loaded plugin
  111240. */
  111241. 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>;
  111242. /**
  111243. * Import meshes into a scene
  111244. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  111245. * @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)
  111246. * @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)
  111247. * @param scene the instance of BABYLON.Scene to append to
  111248. * @param onProgress a callback with a progress event for each file being loaded
  111249. * @param pluginExtension the extension used to determine the plugin
  111250. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  111251. */
  111252. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  111253. meshes: AbstractMesh[];
  111254. particleSystems: IParticleSystem[];
  111255. skeletons: Skeleton[];
  111256. animationGroups: AnimationGroup[];
  111257. }>;
  111258. /**
  111259. * Load a scene
  111260. * @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)
  111261. * @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)
  111262. * @param engine is the instance of BABYLON.Engine to use to create the scene
  111263. * @param onSuccess a callback with the scene when import succeeds
  111264. * @param onProgress a callback with a progress event for each file being loaded
  111265. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  111266. * @param pluginExtension the extension used to determine the plugin
  111267. * @returns The loaded plugin
  111268. */
  111269. 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>;
  111270. /**
  111271. * Load a scene
  111272. * @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)
  111273. * @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)
  111274. * @param engine is the instance of BABYLON.Engine to use to create the scene
  111275. * @param onProgress a callback with a progress event for each file being loaded
  111276. * @param pluginExtension the extension used to determine the plugin
  111277. * @returns The loaded scene
  111278. */
  111279. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  111280. /**
  111281. * Append a scene
  111282. * @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)
  111283. * @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)
  111284. * @param scene is the instance of BABYLON.Scene to append to
  111285. * @param onSuccess a callback with the scene when import succeeds
  111286. * @param onProgress a callback with a progress event for each file being loaded
  111287. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  111288. * @param pluginExtension the extension used to determine the plugin
  111289. * @returns The loaded plugin
  111290. */
  111291. 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>;
  111292. /**
  111293. * Append a scene
  111294. * @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)
  111295. * @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)
  111296. * @param scene is the instance of BABYLON.Scene to append to
  111297. * @param onProgress a callback with a progress event for each file being loaded
  111298. * @param pluginExtension the extension used to determine the plugin
  111299. * @returns The given scene
  111300. */
  111301. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  111302. /**
  111303. * Load a scene into an asset container
  111304. * @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)
  111305. * @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)
  111306. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  111307. * @param onSuccess a callback with the scene when import succeeds
  111308. * @param onProgress a callback with a progress event for each file being loaded
  111309. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  111310. * @param pluginExtension the extension used to determine the plugin
  111311. * @returns The loaded plugin
  111312. */
  111313. 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>;
  111314. /**
  111315. * Load a scene into an asset container
  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 (default: empty string)
  111318. * @param scene is the instance of Scene to append to
  111319. * @param onProgress a callback with a progress event for each file being loaded
  111320. * @param pluginExtension the extension used to determine the plugin
  111321. * @returns The loaded asset container
  111322. */
  111323. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  111324. }
  111325. }
  111326. declare module BABYLON {
  111327. /**
  111328. * Generic Controller
  111329. */
  111330. export class GenericController extends WebVRController {
  111331. /**
  111332. * Base Url for the controller model.
  111333. */
  111334. static readonly MODEL_BASE_URL: string;
  111335. /**
  111336. * File name for the controller model.
  111337. */
  111338. static readonly MODEL_FILENAME: string;
  111339. /**
  111340. * Creates a new GenericController from a gamepad
  111341. * @param vrGamepad the gamepad that the controller should be created from
  111342. */
  111343. constructor(vrGamepad: any);
  111344. /**
  111345. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  111346. * @param scene scene in which to add meshes
  111347. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  111348. */
  111349. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  111350. /**
  111351. * Called once for each button that changed state since the last frame
  111352. * @param buttonIdx Which button index changed
  111353. * @param state New state of the button
  111354. * @param changes Which properties on the state changed since last frame
  111355. */
  111356. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  111357. }
  111358. }
  111359. declare module BABYLON {
  111360. /**
  111361. * Defines the WindowsMotionController object that the state of the windows motion controller
  111362. */
  111363. export class WindowsMotionController extends WebVRController {
  111364. /**
  111365. * The base url used to load the left and right controller models
  111366. */
  111367. static MODEL_BASE_URL: string;
  111368. /**
  111369. * The name of the left controller model file
  111370. */
  111371. static MODEL_LEFT_FILENAME: string;
  111372. /**
  111373. * The name of the right controller model file
  111374. */
  111375. static MODEL_RIGHT_FILENAME: string;
  111376. /**
  111377. * The controller name prefix for this controller type
  111378. */
  111379. static readonly GAMEPAD_ID_PREFIX: string;
  111380. /**
  111381. * The controller id pattern for this controller type
  111382. */
  111383. private static readonly GAMEPAD_ID_PATTERN;
  111384. private _loadedMeshInfo;
  111385. private readonly _mapping;
  111386. /**
  111387. * Fired when the trackpad on this controller is clicked
  111388. */
  111389. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  111390. /**
  111391. * Fired when the trackpad on this controller is modified
  111392. */
  111393. onTrackpadValuesChangedObservable: Observable<StickValues>;
  111394. /**
  111395. * The current x and y values of this controller's trackpad
  111396. */
  111397. trackpad: StickValues;
  111398. /**
  111399. * Creates a new WindowsMotionController from a gamepad
  111400. * @param vrGamepad the gamepad that the controller should be created from
  111401. */
  111402. constructor(vrGamepad: any);
  111403. /**
  111404. * Fired when the trigger on this controller is modified
  111405. */
  111406. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  111407. /**
  111408. * Fired when the menu button on this controller is modified
  111409. */
  111410. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  111411. /**
  111412. * Fired when the grip button on this controller is modified
  111413. */
  111414. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  111415. /**
  111416. * Fired when the thumbstick button on this controller is modified
  111417. */
  111418. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  111419. /**
  111420. * Fired when the touchpad button on this controller is modified
  111421. */
  111422. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  111423. /**
  111424. * Fired when the touchpad values on this controller are modified
  111425. */
  111426. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  111427. private _updateTrackpad;
  111428. /**
  111429. * Called once per frame by the engine.
  111430. */
  111431. update(): void;
  111432. /**
  111433. * Called once for each button that changed state since the last frame
  111434. * @param buttonIdx Which button index changed
  111435. * @param state New state of the button
  111436. * @param changes Which properties on the state changed since last frame
  111437. */
  111438. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  111439. /**
  111440. * Moves the buttons on the controller mesh based on their current state
  111441. * @param buttonName the name of the button to move
  111442. * @param buttonValue the value of the button which determines the buttons new position
  111443. */
  111444. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  111445. /**
  111446. * Moves the axis on the controller mesh based on its current state
  111447. * @param axis the index of the axis
  111448. * @param axisValue the value of the axis which determines the meshes new position
  111449. * @hidden
  111450. */
  111451. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  111452. /**
  111453. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  111454. * @param scene scene in which to add meshes
  111455. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  111456. */
  111457. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  111458. /**
  111459. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  111460. * can be transformed by button presses and axes values, based on this._mapping.
  111461. *
  111462. * @param scene scene in which the meshes exist
  111463. * @param meshes list of meshes that make up the controller model to process
  111464. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  111465. */
  111466. private processModel;
  111467. private createMeshInfo;
  111468. /**
  111469. * Gets the ray of the controller in the direction the controller is pointing
  111470. * @param length the length the resulting ray should be
  111471. * @returns a ray in the direction the controller is pointing
  111472. */
  111473. getForwardRay(length?: number): Ray;
  111474. /**
  111475. * Disposes of the controller
  111476. */
  111477. dispose(): void;
  111478. }
  111479. }
  111480. declare module BABYLON {
  111481. /**
  111482. * Oculus Touch Controller
  111483. */
  111484. export class OculusTouchController extends WebVRController {
  111485. /**
  111486. * Base Url for the controller model.
  111487. */
  111488. static MODEL_BASE_URL: string;
  111489. /**
  111490. * File name for the left controller model.
  111491. */
  111492. static MODEL_LEFT_FILENAME: string;
  111493. /**
  111494. * File name for the right controller model.
  111495. */
  111496. static MODEL_RIGHT_FILENAME: string;
  111497. /**
  111498. * Base Url for the Quest controller model.
  111499. */
  111500. static QUEST_MODEL_BASE_URL: string;
  111501. /**
  111502. * @hidden
  111503. * If the controllers are running on a device that needs the updated Quest controller models
  111504. */
  111505. static _IsQuest: boolean;
  111506. /**
  111507. * Fired when the secondary trigger on this controller is modified
  111508. */
  111509. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  111510. /**
  111511. * Fired when the thumb rest on this controller is modified
  111512. */
  111513. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  111514. /**
  111515. * Creates a new OculusTouchController from a gamepad
  111516. * @param vrGamepad the gamepad that the controller should be created from
  111517. */
  111518. constructor(vrGamepad: any);
  111519. /**
  111520. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  111521. * @param scene scene in which to add meshes
  111522. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  111523. */
  111524. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  111525. /**
  111526. * Fired when the A button on this controller is modified
  111527. */
  111528. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  111529. /**
  111530. * Fired when the B button on this controller is modified
  111531. */
  111532. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  111533. /**
  111534. * Fired when the X button on this controller is modified
  111535. */
  111536. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  111537. /**
  111538. * Fired when the Y button on this controller is modified
  111539. */
  111540. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  111541. /**
  111542. * Called once for each button that changed state since the last frame
  111543. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  111544. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  111545. * 2) secondary trigger (same)
  111546. * 3) A (right) X (left), touch, pressed = value
  111547. * 4) B / Y
  111548. * 5) thumb rest
  111549. * @param buttonIdx Which button index changed
  111550. * @param state New state of the button
  111551. * @param changes Which properties on the state changed since last frame
  111552. */
  111553. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  111554. }
  111555. }
  111556. declare module BABYLON {
  111557. /**
  111558. * Vive Controller
  111559. */
  111560. export class ViveController extends WebVRController {
  111561. /**
  111562. * Base Url for the controller model.
  111563. */
  111564. static MODEL_BASE_URL: string;
  111565. /**
  111566. * File name for the controller model.
  111567. */
  111568. static MODEL_FILENAME: string;
  111569. /**
  111570. * Creates a new ViveController from a gamepad
  111571. * @param vrGamepad the gamepad that the controller should be created from
  111572. */
  111573. constructor(vrGamepad: any);
  111574. /**
  111575. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  111576. * @param scene scene in which to add meshes
  111577. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  111578. */
  111579. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  111580. /**
  111581. * Fired when the left button on this controller is modified
  111582. */
  111583. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  111584. /**
  111585. * Fired when the right button on this controller is modified
  111586. */
  111587. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  111588. /**
  111589. * Fired when the menu button on this controller is modified
  111590. */
  111591. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  111592. /**
  111593. * Called once for each button that changed state since the last frame
  111594. * Vive mapping:
  111595. * 0: touchpad
  111596. * 1: trigger
  111597. * 2: left AND right buttons
  111598. * 3: menu button
  111599. * @param buttonIdx Which button index changed
  111600. * @param state New state of the button
  111601. * @param changes Which properties on the state changed since last frame
  111602. */
  111603. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  111604. }
  111605. }
  111606. declare module BABYLON {
  111607. /**
  111608. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  111609. */
  111610. export class WebXRControllerModelLoader {
  111611. /**
  111612. * an observable that triggers when a new model (the mesh itself) was initialized.
  111613. * To know when the mesh was loaded use the controller's own modelLoaded() method
  111614. */
  111615. onControllerModelLoaded: Observable<WebXRController>;
  111616. /**
  111617. * Creates the WebXRControllerModelLoader
  111618. * @param input xr input that creates the controllers
  111619. */
  111620. constructor(input: WebXRInput);
  111621. }
  111622. }
  111623. declare module BABYLON {
  111624. /**
  111625. * Options for the default xr helper
  111626. */
  111627. export class WebXRDefaultExperienceOptions {
  111628. /**
  111629. * Floor meshes that should be used for teleporting
  111630. */
  111631. floorMeshes: Array<AbstractMesh>;
  111632. /**
  111633. * Enable or disable default UI to enter XR
  111634. */
  111635. disableDefaultUI: boolean;
  111636. /**
  111637. * optional configuration for the output canvas
  111638. */
  111639. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  111640. }
  111641. /**
  111642. * Default experience which provides a similar setup to the previous webVRExperience
  111643. */
  111644. export class WebXRDefaultExperience {
  111645. /**
  111646. * Base experience
  111647. */
  111648. baseExperience: WebXRExperienceHelper;
  111649. /**
  111650. * Input experience extension
  111651. */
  111652. input: WebXRInput;
  111653. /**
  111654. * Loads the controller models
  111655. */
  111656. controllerModelLoader: WebXRControllerModelLoader;
  111657. /**
  111658. * Enables laser pointer and selection
  111659. */
  111660. pointerSelection: WebXRControllerPointerSelection;
  111661. /**
  111662. * Enables teleportation
  111663. */
  111664. teleportation: WebXRControllerTeleportation;
  111665. /**
  111666. * Enables ui for enetering/exiting xr
  111667. */
  111668. enterExitUI: WebXREnterExitUI;
  111669. /**
  111670. * Default target xr should render to
  111671. */
  111672. renderTarget: WebXRRenderTarget;
  111673. /**
  111674. * Creates the default xr experience
  111675. * @param scene scene
  111676. * @param options options for basic configuration
  111677. * @returns resulting WebXRDefaultExperience
  111678. */
  111679. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  111680. private constructor();
  111681. /**
  111682. * DIsposes of the experience helper
  111683. */
  111684. dispose(): void;
  111685. }
  111686. }
  111687. declare module BABYLON {
  111688. /**
  111689. * Contains an array of blocks representing the octree
  111690. */
  111691. export interface IOctreeContainer<T> {
  111692. /**
  111693. * Blocks within the octree
  111694. */
  111695. blocks: Array<OctreeBlock<T>>;
  111696. }
  111697. /**
  111698. * Class used to store a cell in an octree
  111699. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  111700. */
  111701. export class OctreeBlock<T> {
  111702. /**
  111703. * Gets the content of the current block
  111704. */
  111705. entries: T[];
  111706. /**
  111707. * Gets the list of block children
  111708. */
  111709. blocks: Array<OctreeBlock<T>>;
  111710. private _depth;
  111711. private _maxDepth;
  111712. private _capacity;
  111713. private _minPoint;
  111714. private _maxPoint;
  111715. private _boundingVectors;
  111716. private _creationFunc;
  111717. /**
  111718. * Creates a new block
  111719. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  111720. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  111721. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  111722. * @param depth defines the current depth of this block in the octree
  111723. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  111724. * @param creationFunc defines a callback to call when an element is added to the block
  111725. */
  111726. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  111727. /**
  111728. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  111729. */
  111730. readonly capacity: number;
  111731. /**
  111732. * Gets the minimum vector (in world space) of the block's bounding box
  111733. */
  111734. readonly minPoint: Vector3;
  111735. /**
  111736. * Gets the maximum vector (in world space) of the block's bounding box
  111737. */
  111738. readonly maxPoint: Vector3;
  111739. /**
  111740. * Add a new element to this block
  111741. * @param entry defines the element to add
  111742. */
  111743. addEntry(entry: T): void;
  111744. /**
  111745. * Remove an element from this block
  111746. * @param entry defines the element to remove
  111747. */
  111748. removeEntry(entry: T): void;
  111749. /**
  111750. * Add an array of elements to this block
  111751. * @param entries defines the array of elements to add
  111752. */
  111753. addEntries(entries: T[]): void;
  111754. /**
  111755. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  111756. * @param frustumPlanes defines the frustum planes to test
  111757. * @param selection defines the array to store current content if selection is positive
  111758. * @param allowDuplicate defines if the selection array can contains duplicated entries
  111759. */
  111760. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  111761. /**
  111762. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  111763. * @param sphereCenter defines the bounding sphere center
  111764. * @param sphereRadius defines the bounding sphere radius
  111765. * @param selection defines the array to store current content if selection is positive
  111766. * @param allowDuplicate defines if the selection array can contains duplicated entries
  111767. */
  111768. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  111769. /**
  111770. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  111771. * @param ray defines the ray to test with
  111772. * @param selection defines the array to store current content if selection is positive
  111773. */
  111774. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  111775. /**
  111776. * Subdivide the content into child blocks (this block will then be empty)
  111777. */
  111778. createInnerBlocks(): void;
  111779. /**
  111780. * @hidden
  111781. */
  111782. 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;
  111783. }
  111784. }
  111785. declare module BABYLON {
  111786. /**
  111787. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  111788. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  111789. */
  111790. export class Octree<T> {
  111791. /** 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.) */
  111792. maxDepth: number;
  111793. /**
  111794. * Blocks within the octree containing objects
  111795. */
  111796. blocks: Array<OctreeBlock<T>>;
  111797. /**
  111798. * Content stored in the octree
  111799. */
  111800. dynamicContent: T[];
  111801. private _maxBlockCapacity;
  111802. private _selectionContent;
  111803. private _creationFunc;
  111804. /**
  111805. * Creates a octree
  111806. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  111807. * @param creationFunc function to be used to instatiate the octree
  111808. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  111809. * @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.)
  111810. */
  111811. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  111812. /** 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.) */
  111813. maxDepth?: number);
  111814. /**
  111815. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  111816. * @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);
  111817. * @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);
  111818. * @param entries meshes to be added to the octree blocks
  111819. */
  111820. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  111821. /**
  111822. * Adds a mesh to the octree
  111823. * @param entry Mesh to add to the octree
  111824. */
  111825. addMesh(entry: T): void;
  111826. /**
  111827. * Remove an element from the octree
  111828. * @param entry defines the element to remove
  111829. */
  111830. removeMesh(entry: T): void;
  111831. /**
  111832. * Selects an array of meshes within the frustum
  111833. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  111834. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  111835. * @returns array of meshes within the frustum
  111836. */
  111837. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  111838. /**
  111839. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  111840. * @param sphereCenter defines the bounding sphere center
  111841. * @param sphereRadius defines the bounding sphere radius
  111842. * @param allowDuplicate defines if the selection array can contains duplicated entries
  111843. * @returns an array of objects that intersect the sphere
  111844. */
  111845. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  111846. /**
  111847. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  111848. * @param ray defines the ray to test with
  111849. * @returns array of intersected objects
  111850. */
  111851. intersectsRay(ray: Ray): SmartArray<T>;
  111852. /**
  111853. * Adds a mesh into the octree block if it intersects the block
  111854. */
  111855. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  111856. /**
  111857. * Adds a submesh into the octree block if it intersects the block
  111858. */
  111859. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  111860. }
  111861. }
  111862. declare module BABYLON {
  111863. interface Scene {
  111864. /**
  111865. * @hidden
  111866. * Backing Filed
  111867. */
  111868. _selectionOctree: Octree<AbstractMesh>;
  111869. /**
  111870. * Gets the octree used to boost mesh selection (picking)
  111871. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  111872. */
  111873. selectionOctree: Octree<AbstractMesh>;
  111874. /**
  111875. * Creates or updates the octree used to boost selection (picking)
  111876. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  111877. * @param maxCapacity defines the maximum capacity per leaf
  111878. * @param maxDepth defines the maximum depth of the octree
  111879. * @returns an octree of AbstractMesh
  111880. */
  111881. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  111882. }
  111883. interface AbstractMesh {
  111884. /**
  111885. * @hidden
  111886. * Backing Field
  111887. */
  111888. _submeshesOctree: Octree<SubMesh>;
  111889. /**
  111890. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  111891. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  111892. * @param maxCapacity defines the maximum size of each block (64 by default)
  111893. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  111894. * @returns the new octree
  111895. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  111896. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  111897. */
  111898. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  111899. }
  111900. /**
  111901. * Defines the octree scene component responsible to manage any octrees
  111902. * in a given scene.
  111903. */
  111904. export class OctreeSceneComponent {
  111905. /**
  111906. * The component name help to identify the component in the list of scene components.
  111907. */
  111908. readonly name: string;
  111909. /**
  111910. * The scene the component belongs to.
  111911. */
  111912. scene: Scene;
  111913. /**
  111914. * Indicates if the meshes have been checked to make sure they are isEnabled()
  111915. */
  111916. readonly checksIsEnabled: boolean;
  111917. /**
  111918. * Creates a new instance of the component for the given scene
  111919. * @param scene Defines the scene to register the component in
  111920. */
  111921. constructor(scene: Scene);
  111922. /**
  111923. * Registers the component in a given scene
  111924. */
  111925. register(): void;
  111926. /**
  111927. * Return the list of active meshes
  111928. * @returns the list of active meshes
  111929. */
  111930. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  111931. /**
  111932. * Return the list of active sub meshes
  111933. * @param mesh The mesh to get the candidates sub meshes from
  111934. * @returns the list of active sub meshes
  111935. */
  111936. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  111937. private _tempRay;
  111938. /**
  111939. * Return the list of sub meshes intersecting with a given local ray
  111940. * @param mesh defines the mesh to find the submesh for
  111941. * @param localRay defines the ray in local space
  111942. * @returns the list of intersecting sub meshes
  111943. */
  111944. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  111945. /**
  111946. * Return the list of sub meshes colliding with a collider
  111947. * @param mesh defines the mesh to find the submesh for
  111948. * @param collider defines the collider to evaluate the collision against
  111949. * @returns the list of colliding sub meshes
  111950. */
  111951. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  111952. /**
  111953. * Rebuilds the elements related to this component in case of
  111954. * context lost for instance.
  111955. */
  111956. rebuild(): void;
  111957. /**
  111958. * Disposes the component and the associated ressources.
  111959. */
  111960. dispose(): void;
  111961. }
  111962. }
  111963. declare module BABYLON {
  111964. /**
  111965. * Renders a layer on top of an existing scene
  111966. */
  111967. export class UtilityLayerRenderer implements IDisposable {
  111968. /** the original scene that will be rendered on top of */
  111969. originalScene: Scene;
  111970. private _pointerCaptures;
  111971. private _lastPointerEvents;
  111972. private static _DefaultUtilityLayer;
  111973. private static _DefaultKeepDepthUtilityLayer;
  111974. private _sharedGizmoLight;
  111975. private _renderCamera;
  111976. /**
  111977. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  111978. * @returns the camera that is used when rendering the utility layer
  111979. */
  111980. getRenderCamera(): Nullable<Camera>;
  111981. /**
  111982. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  111983. * @param cam the camera that should be used when rendering the utility layer
  111984. */
  111985. setRenderCamera(cam: Nullable<Camera>): void;
  111986. /**
  111987. * @hidden
  111988. * Light which used by gizmos to get light shading
  111989. */
  111990. _getSharedGizmoLight(): HemisphericLight;
  111991. /**
  111992. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  111993. */
  111994. pickUtilitySceneFirst: boolean;
  111995. /**
  111996. * 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)
  111997. */
  111998. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  111999. /**
  112000. * 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)
  112001. */
  112002. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  112003. /**
  112004. * The scene that is rendered on top of the original scene
  112005. */
  112006. utilityLayerScene: Scene;
  112007. /**
  112008. * If the utility layer should automatically be rendered on top of existing scene
  112009. */
  112010. shouldRender: boolean;
  112011. /**
  112012. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  112013. */
  112014. onlyCheckPointerDownEvents: boolean;
  112015. /**
  112016. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  112017. */
  112018. processAllEvents: boolean;
  112019. /**
  112020. * Observable raised when the pointer move from the utility layer scene to the main scene
  112021. */
  112022. onPointerOutObservable: Observable<number>;
  112023. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  112024. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  112025. private _afterRenderObserver;
  112026. private _sceneDisposeObserver;
  112027. private _originalPointerObserver;
  112028. /**
  112029. * Instantiates a UtilityLayerRenderer
  112030. * @param originalScene the original scene that will be rendered on top of
  112031. * @param handleEvents boolean indicating if the utility layer should handle events
  112032. */
  112033. constructor(
  112034. /** the original scene that will be rendered on top of */
  112035. originalScene: Scene, handleEvents?: boolean);
  112036. private _notifyObservers;
  112037. /**
  112038. * Renders the utility layers scene on top of the original scene
  112039. */
  112040. render(): void;
  112041. /**
  112042. * Disposes of the renderer
  112043. */
  112044. dispose(): void;
  112045. private _updateCamera;
  112046. }
  112047. }
  112048. declare module BABYLON {
  112049. /**
  112050. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  112051. */
  112052. export class Gizmo implements IDisposable {
  112053. /** The utility layer the gizmo will be added to */
  112054. gizmoLayer: UtilityLayerRenderer;
  112055. /**
  112056. * The root mesh of the gizmo
  112057. */
  112058. _rootMesh: Mesh;
  112059. private _attachedMesh;
  112060. /**
  112061. * Ratio for the scale of the gizmo (Default: 1)
  112062. */
  112063. scaleRatio: number;
  112064. /**
  112065. * If a custom mesh has been set (Default: false)
  112066. */
  112067. protected _customMeshSet: boolean;
  112068. /**
  112069. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  112070. * * When set, interactions will be enabled
  112071. */
  112072. attachedMesh: Nullable<AbstractMesh>;
  112073. /**
  112074. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  112075. * @param mesh The mesh to replace the default mesh of the gizmo
  112076. */
  112077. setCustomMesh(mesh: Mesh): void;
  112078. /**
  112079. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  112080. */
  112081. updateGizmoRotationToMatchAttachedMesh: boolean;
  112082. /**
  112083. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  112084. */
  112085. updateGizmoPositionToMatchAttachedMesh: boolean;
  112086. /**
  112087. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  112088. */
  112089. updateScale: boolean;
  112090. protected _interactionsEnabled: boolean;
  112091. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  112092. private _beforeRenderObserver;
  112093. private _tempVector;
  112094. /**
  112095. * Creates a gizmo
  112096. * @param gizmoLayer The utility layer the gizmo will be added to
  112097. */
  112098. constructor(
  112099. /** The utility layer the gizmo will be added to */
  112100. gizmoLayer?: UtilityLayerRenderer);
  112101. /**
  112102. * Updates the gizmo to match the attached mesh's position/rotation
  112103. */
  112104. protected _update(): void;
  112105. /**
  112106. * Disposes of the gizmo
  112107. */
  112108. dispose(): void;
  112109. }
  112110. }
  112111. declare module BABYLON {
  112112. /**
  112113. * Single plane drag gizmo
  112114. */
  112115. export class PlaneDragGizmo extends Gizmo {
  112116. /**
  112117. * Drag behavior responsible for the gizmos dragging interactions
  112118. */
  112119. dragBehavior: PointerDragBehavior;
  112120. private _pointerObserver;
  112121. /**
  112122. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  112123. */
  112124. snapDistance: number;
  112125. /**
  112126. * Event that fires each time the gizmo snaps to a new location.
  112127. * * snapDistance is the the change in distance
  112128. */
  112129. onSnapObservable: Observable<{
  112130. snapDistance: number;
  112131. }>;
  112132. private _plane;
  112133. private _coloredMaterial;
  112134. private _hoverMaterial;
  112135. private _isEnabled;
  112136. private _parent;
  112137. /** @hidden */
  112138. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  112139. /** @hidden */
  112140. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  112141. /**
  112142. * Creates a PlaneDragGizmo
  112143. * @param gizmoLayer The utility layer the gizmo will be added to
  112144. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  112145. * @param color The color of the gizmo
  112146. */
  112147. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  112148. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  112149. /**
  112150. * If the gizmo is enabled
  112151. */
  112152. isEnabled: boolean;
  112153. /**
  112154. * Disposes of the gizmo
  112155. */
  112156. dispose(): void;
  112157. }
  112158. }
  112159. declare module BABYLON {
  112160. /**
  112161. * Gizmo that enables dragging a mesh along 3 axis
  112162. */
  112163. export class PositionGizmo extends Gizmo {
  112164. /**
  112165. * Internal gizmo used for interactions on the x axis
  112166. */
  112167. xGizmo: AxisDragGizmo;
  112168. /**
  112169. * Internal gizmo used for interactions on the y axis
  112170. */
  112171. yGizmo: AxisDragGizmo;
  112172. /**
  112173. * Internal gizmo used for interactions on the z axis
  112174. */
  112175. zGizmo: AxisDragGizmo;
  112176. /**
  112177. * Internal gizmo used for interactions on the yz plane
  112178. */
  112179. xPlaneGizmo: PlaneDragGizmo;
  112180. /**
  112181. * Internal gizmo used for interactions on the xz plane
  112182. */
  112183. yPlaneGizmo: PlaneDragGizmo;
  112184. /**
  112185. * Internal gizmo used for interactions on the xy plane
  112186. */
  112187. zPlaneGizmo: PlaneDragGizmo;
  112188. /**
  112189. * private variables
  112190. */
  112191. private _meshAttached;
  112192. private _updateGizmoRotationToMatchAttachedMesh;
  112193. private _snapDistance;
  112194. private _scaleRatio;
  112195. /** Fires an event when any of it's sub gizmos are dragged */
  112196. onDragStartObservable: Observable<unknown>;
  112197. /** Fires an event when any of it's sub gizmos are released from dragging */
  112198. onDragEndObservable: Observable<unknown>;
  112199. /**
  112200. * If set to true, planar drag is enabled
  112201. */
  112202. private _planarGizmoEnabled;
  112203. attachedMesh: Nullable<AbstractMesh>;
  112204. /**
  112205. * Creates a PositionGizmo
  112206. * @param gizmoLayer The utility layer the gizmo will be added to
  112207. */
  112208. constructor(gizmoLayer?: UtilityLayerRenderer);
  112209. /**
  112210. * If the planar drag gizmo is enabled
  112211. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  112212. */
  112213. planarGizmoEnabled: boolean;
  112214. updateGizmoRotationToMatchAttachedMesh: boolean;
  112215. /**
  112216. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  112217. */
  112218. snapDistance: number;
  112219. /**
  112220. * Ratio for the scale of the gizmo (Default: 1)
  112221. */
  112222. scaleRatio: number;
  112223. /**
  112224. * Disposes of the gizmo
  112225. */
  112226. dispose(): void;
  112227. /**
  112228. * CustomMeshes are not supported by this gizmo
  112229. * @param mesh The mesh to replace the default mesh of the gizmo
  112230. */
  112231. setCustomMesh(mesh: Mesh): void;
  112232. }
  112233. }
  112234. declare module BABYLON {
  112235. /**
  112236. * Single axis drag gizmo
  112237. */
  112238. export class AxisDragGizmo extends Gizmo {
  112239. /**
  112240. * Drag behavior responsible for the gizmos dragging interactions
  112241. */
  112242. dragBehavior: PointerDragBehavior;
  112243. private _pointerObserver;
  112244. /**
  112245. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  112246. */
  112247. snapDistance: number;
  112248. /**
  112249. * Event that fires each time the gizmo snaps to a new location.
  112250. * * snapDistance is the the change in distance
  112251. */
  112252. onSnapObservable: Observable<{
  112253. snapDistance: number;
  112254. }>;
  112255. private _isEnabled;
  112256. private _parent;
  112257. private _arrow;
  112258. private _coloredMaterial;
  112259. private _hoverMaterial;
  112260. /** @hidden */
  112261. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  112262. /** @hidden */
  112263. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  112264. /**
  112265. * Creates an AxisDragGizmo
  112266. * @param gizmoLayer The utility layer the gizmo will be added to
  112267. * @param dragAxis The axis which the gizmo will be able to drag on
  112268. * @param color The color of the gizmo
  112269. */
  112270. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  112271. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  112272. /**
  112273. * If the gizmo is enabled
  112274. */
  112275. isEnabled: boolean;
  112276. /**
  112277. * Disposes of the gizmo
  112278. */
  112279. dispose(): void;
  112280. }
  112281. }
  112282. declare module BABYLON.Debug {
  112283. /**
  112284. * The Axes viewer will show 3 axes in a specific point in space
  112285. */
  112286. export class AxesViewer {
  112287. private _xAxis;
  112288. private _yAxis;
  112289. private _zAxis;
  112290. private _scaleLinesFactor;
  112291. private _instanced;
  112292. /**
  112293. * Gets the hosting scene
  112294. */
  112295. scene: Scene;
  112296. /**
  112297. * Gets or sets a number used to scale line length
  112298. */
  112299. scaleLines: number;
  112300. /** Gets the node hierarchy used to render x-axis */
  112301. readonly xAxis: TransformNode;
  112302. /** Gets the node hierarchy used to render y-axis */
  112303. readonly yAxis: TransformNode;
  112304. /** Gets the node hierarchy used to render z-axis */
  112305. readonly zAxis: TransformNode;
  112306. /**
  112307. * Creates a new AxesViewer
  112308. * @param scene defines the hosting scene
  112309. * @param scaleLines defines a number used to scale line length (1 by default)
  112310. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  112311. * @param xAxis defines the node hierarchy used to render the x-axis
  112312. * @param yAxis defines the node hierarchy used to render the y-axis
  112313. * @param zAxis defines the node hierarchy used to render the z-axis
  112314. */
  112315. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  112316. /**
  112317. * Force the viewer to update
  112318. * @param position defines the position of the viewer
  112319. * @param xaxis defines the x axis of the viewer
  112320. * @param yaxis defines the y axis of the viewer
  112321. * @param zaxis defines the z axis of the viewer
  112322. */
  112323. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  112324. /**
  112325. * Creates an instance of this axes viewer.
  112326. * @returns a new axes viewer with instanced meshes
  112327. */
  112328. createInstance(): AxesViewer;
  112329. /** Releases resources */
  112330. dispose(): void;
  112331. private static _SetRenderingGroupId;
  112332. }
  112333. }
  112334. declare module BABYLON.Debug {
  112335. /**
  112336. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  112337. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  112338. */
  112339. export class BoneAxesViewer extends AxesViewer {
  112340. /**
  112341. * Gets or sets the target mesh where to display the axes viewer
  112342. */
  112343. mesh: Nullable<Mesh>;
  112344. /**
  112345. * Gets or sets the target bone where to display the axes viewer
  112346. */
  112347. bone: Nullable<Bone>;
  112348. /** Gets current position */
  112349. pos: Vector3;
  112350. /** Gets direction of X axis */
  112351. xaxis: Vector3;
  112352. /** Gets direction of Y axis */
  112353. yaxis: Vector3;
  112354. /** Gets direction of Z axis */
  112355. zaxis: Vector3;
  112356. /**
  112357. * Creates a new BoneAxesViewer
  112358. * @param scene defines the hosting scene
  112359. * @param bone defines the target bone
  112360. * @param mesh defines the target mesh
  112361. * @param scaleLines defines a scaling factor for line length (1 by default)
  112362. */
  112363. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  112364. /**
  112365. * Force the viewer to update
  112366. */
  112367. update(): void;
  112368. /** Releases resources */
  112369. dispose(): void;
  112370. }
  112371. }
  112372. declare module BABYLON {
  112373. /**
  112374. * Interface used to define scene explorer extensibility option
  112375. */
  112376. export interface IExplorerExtensibilityOption {
  112377. /**
  112378. * Define the option label
  112379. */
  112380. label: string;
  112381. /**
  112382. * Defines the action to execute on click
  112383. */
  112384. action: (entity: any) => void;
  112385. }
  112386. /**
  112387. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  112388. */
  112389. export interface IExplorerExtensibilityGroup {
  112390. /**
  112391. * Defines a predicate to test if a given type mut be extended
  112392. */
  112393. predicate: (entity: any) => boolean;
  112394. /**
  112395. * Gets the list of options added to a type
  112396. */
  112397. entries: IExplorerExtensibilityOption[];
  112398. }
  112399. /**
  112400. * Interface used to define the options to use to create the Inspector
  112401. */
  112402. export interface IInspectorOptions {
  112403. /**
  112404. * Display in overlay mode (default: false)
  112405. */
  112406. overlay?: boolean;
  112407. /**
  112408. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  112409. */
  112410. globalRoot?: HTMLElement;
  112411. /**
  112412. * Display the Scene explorer
  112413. */
  112414. showExplorer?: boolean;
  112415. /**
  112416. * Display the property inspector
  112417. */
  112418. showInspector?: boolean;
  112419. /**
  112420. * Display in embed mode (both panes on the right)
  112421. */
  112422. embedMode?: boolean;
  112423. /**
  112424. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  112425. */
  112426. handleResize?: boolean;
  112427. /**
  112428. * Allow the panes to popup (default: true)
  112429. */
  112430. enablePopup?: boolean;
  112431. /**
  112432. * Allow the panes to be closed by users (default: true)
  112433. */
  112434. enableClose?: boolean;
  112435. /**
  112436. * Optional list of extensibility entries
  112437. */
  112438. explorerExtensibility?: IExplorerExtensibilityGroup[];
  112439. /**
  112440. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  112441. */
  112442. inspectorURL?: string;
  112443. }
  112444. interface Scene {
  112445. /**
  112446. * @hidden
  112447. * Backing field
  112448. */
  112449. _debugLayer: DebugLayer;
  112450. /**
  112451. * Gets the debug layer (aka Inspector) associated with the scene
  112452. * @see http://doc.babylonjs.com/features/playground_debuglayer
  112453. */
  112454. debugLayer: DebugLayer;
  112455. }
  112456. /**
  112457. * The debug layer (aka Inspector) is the go to tool in order to better understand
  112458. * what is happening in your scene
  112459. * @see http://doc.babylonjs.com/features/playground_debuglayer
  112460. */
  112461. export class DebugLayer {
  112462. /**
  112463. * Define the url to get the inspector script from.
  112464. * By default it uses the babylonjs CDN.
  112465. * @ignoreNaming
  112466. */
  112467. static InspectorURL: string;
  112468. private _scene;
  112469. private BJSINSPECTOR;
  112470. private _onPropertyChangedObservable?;
  112471. /**
  112472. * Observable triggered when a property is changed through the inspector.
  112473. */
  112474. readonly onPropertyChangedObservable: any;
  112475. /**
  112476. * Instantiates a new debug layer.
  112477. * The debug layer (aka Inspector) is the go to tool in order to better understand
  112478. * what is happening in your scene
  112479. * @see http://doc.babylonjs.com/features/playground_debuglayer
  112480. * @param scene Defines the scene to inspect
  112481. */
  112482. constructor(scene: Scene);
  112483. /** Creates the inspector window. */
  112484. private _createInspector;
  112485. /**
  112486. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  112487. * @param entity defines the entity to select
  112488. * @param lineContainerTitle defines the specific block to highlight
  112489. */
  112490. select(entity: any, lineContainerTitle?: string): void;
  112491. /** Get the inspector from bundle or global */
  112492. private _getGlobalInspector;
  112493. /**
  112494. * Get if the inspector is visible or not.
  112495. * @returns true if visible otherwise, false
  112496. */
  112497. isVisible(): boolean;
  112498. /**
  112499. * Hide the inspector and close its window.
  112500. */
  112501. hide(): void;
  112502. /**
  112503. * Launch the debugLayer.
  112504. * @param config Define the configuration of the inspector
  112505. * @return a promise fulfilled when the debug layer is visible
  112506. */
  112507. show(config?: IInspectorOptions): Promise<DebugLayer>;
  112508. }
  112509. }
  112510. declare module BABYLON {
  112511. /**
  112512. * Class containing static functions to help procedurally build meshes
  112513. */
  112514. export class BoxBuilder {
  112515. /**
  112516. * Creates a box mesh
  112517. * * The parameter `size` sets the size (float) of each box side (default 1)
  112518. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  112519. * * 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)
  112520. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  112521. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  112522. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  112523. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  112524. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  112525. * @param name defines the name of the mesh
  112526. * @param options defines the options used to create the mesh
  112527. * @param scene defines the hosting scene
  112528. * @returns the box mesh
  112529. */
  112530. static CreateBox(name: string, options: {
  112531. size?: number;
  112532. width?: number;
  112533. height?: number;
  112534. depth?: number;
  112535. faceUV?: Vector4[];
  112536. faceColors?: Color4[];
  112537. sideOrientation?: number;
  112538. frontUVs?: Vector4;
  112539. backUVs?: Vector4;
  112540. wrap?: boolean;
  112541. topBaseAt?: number;
  112542. bottomBaseAt?: number;
  112543. updatable?: boolean;
  112544. }, scene?: Nullable<Scene>): Mesh;
  112545. }
  112546. }
  112547. declare module BABYLON {
  112548. /**
  112549. * Class containing static functions to help procedurally build meshes
  112550. */
  112551. export class SphereBuilder {
  112552. /**
  112553. * Creates a sphere mesh
  112554. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  112555. * * 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`)
  112556. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  112557. * * 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
  112558. * * 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)
  112559. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  112560. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  112561. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  112562. * @param name defines the name of the mesh
  112563. * @param options defines the options used to create the mesh
  112564. * @param scene defines the hosting scene
  112565. * @returns the sphere mesh
  112566. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  112567. */
  112568. static CreateSphere(name: string, options: {
  112569. segments?: number;
  112570. diameter?: number;
  112571. diameterX?: number;
  112572. diameterY?: number;
  112573. diameterZ?: number;
  112574. arc?: number;
  112575. slice?: number;
  112576. sideOrientation?: number;
  112577. frontUVs?: Vector4;
  112578. backUVs?: Vector4;
  112579. updatable?: boolean;
  112580. }, scene?: Nullable<Scene>): Mesh;
  112581. }
  112582. }
  112583. declare module BABYLON.Debug {
  112584. /**
  112585. * Used to show the physics impostor around the specific mesh
  112586. */
  112587. export class PhysicsViewer {
  112588. /** @hidden */
  112589. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  112590. /** @hidden */
  112591. protected _meshes: Array<Nullable<AbstractMesh>>;
  112592. /** @hidden */
  112593. protected _scene: Nullable<Scene>;
  112594. /** @hidden */
  112595. protected _numMeshes: number;
  112596. /** @hidden */
  112597. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  112598. private _renderFunction;
  112599. private _utilityLayer;
  112600. private _debugBoxMesh;
  112601. private _debugSphereMesh;
  112602. private _debugCylinderMesh;
  112603. private _debugMaterial;
  112604. private _debugMeshMeshes;
  112605. /**
  112606. * Creates a new PhysicsViewer
  112607. * @param scene defines the hosting scene
  112608. */
  112609. constructor(scene: Scene);
  112610. /** @hidden */
  112611. protected _updateDebugMeshes(): void;
  112612. /**
  112613. * Renders a specified physic impostor
  112614. * @param impostor defines the impostor to render
  112615. * @param targetMesh defines the mesh represented by the impostor
  112616. * @returns the new debug mesh used to render the impostor
  112617. */
  112618. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  112619. /**
  112620. * Hides a specified physic impostor
  112621. * @param impostor defines the impostor to hide
  112622. */
  112623. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  112624. private _getDebugMaterial;
  112625. private _getDebugBoxMesh;
  112626. private _getDebugSphereMesh;
  112627. private _getDebugCylinderMesh;
  112628. private _getDebugMeshMesh;
  112629. private _getDebugMesh;
  112630. /** Releases all resources */
  112631. dispose(): void;
  112632. }
  112633. }
  112634. declare module BABYLON {
  112635. /**
  112636. * Class containing static functions to help procedurally build meshes
  112637. */
  112638. export class LinesBuilder {
  112639. /**
  112640. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  112641. * * 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
  112642. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  112643. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  112644. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  112645. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  112646. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  112647. * * 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
  112648. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  112649. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  112650. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  112651. * @param name defines the name of the new line system
  112652. * @param options defines the options used to create the line system
  112653. * @param scene defines the hosting scene
  112654. * @returns a new line system mesh
  112655. */
  112656. static CreateLineSystem(name: string, options: {
  112657. lines: Vector3[][];
  112658. updatable?: boolean;
  112659. instance?: Nullable<LinesMesh>;
  112660. colors?: Nullable<Color4[][]>;
  112661. useVertexAlpha?: boolean;
  112662. }, scene: Nullable<Scene>): LinesMesh;
  112663. /**
  112664. * Creates a line mesh
  112665. * 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
  112666. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  112667. * * The parameter `points` is an array successive Vector3
  112668. * * 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
  112669. * * The optional parameter `colors` is an array of successive Color4, one per line point
  112670. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  112671. * * When updating an instance, remember that only point positions can change, not the number of points
  112672. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  112673. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  112674. * @param name defines the name of the new line system
  112675. * @param options defines the options used to create the line system
  112676. * @param scene defines the hosting scene
  112677. * @returns a new line mesh
  112678. */
  112679. static CreateLines(name: string, options: {
  112680. points: Vector3[];
  112681. updatable?: boolean;
  112682. instance?: Nullable<LinesMesh>;
  112683. colors?: Color4[];
  112684. useVertexAlpha?: boolean;
  112685. }, scene?: Nullable<Scene>): LinesMesh;
  112686. /**
  112687. * Creates a dashed line mesh
  112688. * * 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
  112689. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  112690. * * The parameter `points` is an array successive Vector3
  112691. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  112692. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  112693. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  112694. * * 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
  112695. * * When updating an instance, remember that only point positions can change, not the number of points
  112696. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  112697. * @param name defines the name of the mesh
  112698. * @param options defines the options used to create the mesh
  112699. * @param scene defines the hosting scene
  112700. * @returns the dashed line mesh
  112701. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  112702. */
  112703. static CreateDashedLines(name: string, options: {
  112704. points: Vector3[];
  112705. dashSize?: number;
  112706. gapSize?: number;
  112707. dashNb?: number;
  112708. updatable?: boolean;
  112709. instance?: LinesMesh;
  112710. }, scene?: Nullable<Scene>): LinesMesh;
  112711. }
  112712. }
  112713. declare module BABYLON {
  112714. /**
  112715. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  112716. * in order to better appreciate the issue one might have.
  112717. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  112718. */
  112719. export class RayHelper {
  112720. /**
  112721. * Defines the ray we are currently tryin to visualize.
  112722. */
  112723. ray: Nullable<Ray>;
  112724. private _renderPoints;
  112725. private _renderLine;
  112726. private _renderFunction;
  112727. private _scene;
  112728. private _updateToMeshFunction;
  112729. private _attachedToMesh;
  112730. private _meshSpaceDirection;
  112731. private _meshSpaceOrigin;
  112732. /**
  112733. * Helper function to create a colored helper in a scene in one line.
  112734. * @param ray Defines the ray we are currently tryin to visualize
  112735. * @param scene Defines the scene the ray is used in
  112736. * @param color Defines the color we want to see the ray in
  112737. * @returns The newly created ray helper.
  112738. */
  112739. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  112740. /**
  112741. * Instantiate a new ray helper.
  112742. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  112743. * in order to better appreciate the issue one might have.
  112744. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  112745. * @param ray Defines the ray we are currently tryin to visualize
  112746. */
  112747. constructor(ray: Ray);
  112748. /**
  112749. * Shows the ray we are willing to debug.
  112750. * @param scene Defines the scene the ray needs to be rendered in
  112751. * @param color Defines the color the ray needs to be rendered in
  112752. */
  112753. show(scene: Scene, color?: Color3): void;
  112754. /**
  112755. * Hides the ray we are debugging.
  112756. */
  112757. hide(): void;
  112758. private _render;
  112759. /**
  112760. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  112761. * @param mesh Defines the mesh we want the helper attached to
  112762. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  112763. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  112764. * @param length Defines the length of the ray
  112765. */
  112766. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  112767. /**
  112768. * Detach the ray helper from the mesh it has previously been attached to.
  112769. */
  112770. detachFromMesh(): void;
  112771. private _updateToMesh;
  112772. /**
  112773. * Dispose the helper and release its associated resources.
  112774. */
  112775. dispose(): void;
  112776. }
  112777. }
  112778. declare module BABYLON.Debug {
  112779. /**
  112780. * Class used to render a debug view of a given skeleton
  112781. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  112782. */
  112783. export class SkeletonViewer {
  112784. /** defines the skeleton to render */
  112785. skeleton: Skeleton;
  112786. /** defines the mesh attached to the skeleton */
  112787. mesh: AbstractMesh;
  112788. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  112789. autoUpdateBonesMatrices: boolean;
  112790. /** defines the rendering group id to use with the viewer */
  112791. renderingGroupId: number;
  112792. /** Gets or sets the color used to render the skeleton */
  112793. color: Color3;
  112794. private _scene;
  112795. private _debugLines;
  112796. private _debugMesh;
  112797. private _isEnabled;
  112798. private _renderFunction;
  112799. private _utilityLayer;
  112800. /**
  112801. * Returns the mesh used to render the bones
  112802. */
  112803. readonly debugMesh: Nullable<LinesMesh>;
  112804. /**
  112805. * Creates a new SkeletonViewer
  112806. * @param skeleton defines the skeleton to render
  112807. * @param mesh defines the mesh attached to the skeleton
  112808. * @param scene defines the hosting scene
  112809. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  112810. * @param renderingGroupId defines the rendering group id to use with the viewer
  112811. */
  112812. constructor(
  112813. /** defines the skeleton to render */
  112814. skeleton: Skeleton,
  112815. /** defines the mesh attached to the skeleton */
  112816. mesh: AbstractMesh, scene: Scene,
  112817. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  112818. autoUpdateBonesMatrices?: boolean,
  112819. /** defines the rendering group id to use with the viewer */
  112820. renderingGroupId?: number);
  112821. /** Gets or sets a boolean indicating if the viewer is enabled */
  112822. isEnabled: boolean;
  112823. private _getBonePosition;
  112824. private _getLinesForBonesWithLength;
  112825. private _getLinesForBonesNoLength;
  112826. /** Update the viewer to sync with current skeleton state */
  112827. update(): void;
  112828. /** Release associated resources */
  112829. dispose(): void;
  112830. }
  112831. }
  112832. declare module BABYLON {
  112833. /**
  112834. * Options to create the null engine
  112835. */
  112836. export class NullEngineOptions {
  112837. /**
  112838. * Render width (Default: 512)
  112839. */
  112840. renderWidth: number;
  112841. /**
  112842. * Render height (Default: 256)
  112843. */
  112844. renderHeight: number;
  112845. /**
  112846. * Texture size (Default: 512)
  112847. */
  112848. textureSize: number;
  112849. /**
  112850. * If delta time between frames should be constant
  112851. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  112852. */
  112853. deterministicLockstep: boolean;
  112854. /**
  112855. * Maximum about of steps between frames (Default: 4)
  112856. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  112857. */
  112858. lockstepMaxSteps: number;
  112859. }
  112860. /**
  112861. * The null engine class provides support for headless version of babylon.js.
  112862. * This can be used in server side scenario or for testing purposes
  112863. */
  112864. export class NullEngine extends Engine {
  112865. private _options;
  112866. /**
  112867. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  112868. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  112869. * @returns true if engine is in deterministic lock step mode
  112870. */
  112871. isDeterministicLockStep(): boolean;
  112872. /**
  112873. * Gets the max steps when engine is running in deterministic lock step
  112874. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  112875. * @returns the max steps
  112876. */
  112877. getLockstepMaxSteps(): number;
  112878. /**
  112879. * Gets the current hardware scaling level.
  112880. * By default the hardware scaling level is computed from the window device ratio.
  112881. * 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.
  112882. * @returns a number indicating the current hardware scaling level
  112883. */
  112884. getHardwareScalingLevel(): number;
  112885. constructor(options?: NullEngineOptions);
  112886. /**
  112887. * Creates a vertex buffer
  112888. * @param vertices the data for the vertex buffer
  112889. * @returns the new WebGL static buffer
  112890. */
  112891. createVertexBuffer(vertices: FloatArray): DataBuffer;
  112892. /**
  112893. * Creates a new index buffer
  112894. * @param indices defines the content of the index buffer
  112895. * @param updatable defines if the index buffer must be updatable
  112896. * @returns a new webGL buffer
  112897. */
  112898. createIndexBuffer(indices: IndicesArray): DataBuffer;
  112899. /**
  112900. * Clear the current render buffer or the current render target (if any is set up)
  112901. * @param color defines the color to use
  112902. * @param backBuffer defines if the back buffer must be cleared
  112903. * @param depth defines if the depth buffer must be cleared
  112904. * @param stencil defines if the stencil buffer must be cleared
  112905. */
  112906. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  112907. /**
  112908. * Gets the current render width
  112909. * @param useScreen defines if screen size must be used (or the current render target if any)
  112910. * @returns a number defining the current render width
  112911. */
  112912. getRenderWidth(useScreen?: boolean): number;
  112913. /**
  112914. * Gets the current render height
  112915. * @param useScreen defines if screen size must be used (or the current render target if any)
  112916. * @returns a number defining the current render height
  112917. */
  112918. getRenderHeight(useScreen?: boolean): number;
  112919. /**
  112920. * Set the WebGL's viewport
  112921. * @param viewport defines the viewport element to be used
  112922. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  112923. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  112924. */
  112925. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  112926. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  112927. /**
  112928. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  112929. * @param pipelineContext defines the pipeline context to use
  112930. * @param uniformsNames defines the list of uniform names
  112931. * @returns an array of webGL uniform locations
  112932. */
  112933. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  112934. /**
  112935. * Gets the lsit of active attributes for a given webGL program
  112936. * @param pipelineContext defines the pipeline context to use
  112937. * @param attributesNames defines the list of attribute names to get
  112938. * @returns an array of indices indicating the offset of each attribute
  112939. */
  112940. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  112941. /**
  112942. * Binds an effect to the webGL context
  112943. * @param effect defines the effect to bind
  112944. */
  112945. bindSamplers(effect: Effect): void;
  112946. /**
  112947. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  112948. * @param effect defines the effect to activate
  112949. */
  112950. enableEffect(effect: Effect): void;
  112951. /**
  112952. * Set various states to the webGL context
  112953. * @param culling defines backface culling state
  112954. * @param zOffset defines the value to apply to zOffset (0 by default)
  112955. * @param force defines if states must be applied even if cache is up to date
  112956. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  112957. */
  112958. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  112959. /**
  112960. * Set the value of an uniform to an array of int32
  112961. * @param uniform defines the webGL uniform location where to store the value
  112962. * @param array defines the array of int32 to store
  112963. */
  112964. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  112965. /**
  112966. * Set the value of an uniform to an array of int32 (stored as vec2)
  112967. * @param uniform defines the webGL uniform location where to store the value
  112968. * @param array defines the array of int32 to store
  112969. */
  112970. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  112971. /**
  112972. * Set the value of an uniform to an array of int32 (stored as vec3)
  112973. * @param uniform defines the webGL uniform location where to store the value
  112974. * @param array defines the array of int32 to store
  112975. */
  112976. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  112977. /**
  112978. * Set the value of an uniform to an array of int32 (stored as vec4)
  112979. * @param uniform defines the webGL uniform location where to store the value
  112980. * @param array defines the array of int32 to store
  112981. */
  112982. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  112983. /**
  112984. * Set the value of an uniform to an array of float32
  112985. * @param uniform defines the webGL uniform location where to store the value
  112986. * @param array defines the array of float32 to store
  112987. */
  112988. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  112989. /**
  112990. * Set the value of an uniform to an array of float32 (stored as vec2)
  112991. * @param uniform defines the webGL uniform location where to store the value
  112992. * @param array defines the array of float32 to store
  112993. */
  112994. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  112995. /**
  112996. * Set the value of an uniform to an array of float32 (stored as vec3)
  112997. * @param uniform defines the webGL uniform location where to store the value
  112998. * @param array defines the array of float32 to store
  112999. */
  113000. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  113001. /**
  113002. * Set the value of an uniform to an array of float32 (stored as vec4)
  113003. * @param uniform defines the webGL uniform location where to store the value
  113004. * @param array defines the array of float32 to store
  113005. */
  113006. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  113007. /**
  113008. * Set the value of an uniform to an array of number
  113009. * @param uniform defines the webGL uniform location where to store the value
  113010. * @param array defines the array of number to store
  113011. */
  113012. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  113013. /**
  113014. * Set the value of an uniform to an array of number (stored as vec2)
  113015. * @param uniform defines the webGL uniform location where to store the value
  113016. * @param array defines the array of number to store
  113017. */
  113018. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  113019. /**
  113020. * Set the value of an uniform to an array of number (stored as vec3)
  113021. * @param uniform defines the webGL uniform location where to store the value
  113022. * @param array defines the array of number to store
  113023. */
  113024. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  113025. /**
  113026. * Set the value of an uniform to an array of number (stored as vec4)
  113027. * @param uniform defines the webGL uniform location where to store the value
  113028. * @param array defines the array of number to store
  113029. */
  113030. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  113031. /**
  113032. * Set the value of an uniform to an array of float32 (stored as matrices)
  113033. * @param uniform defines the webGL uniform location where to store the value
  113034. * @param matrices defines the array of float32 to store
  113035. */
  113036. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  113037. /**
  113038. * Set the value of an uniform to a matrix (3x3)
  113039. * @param uniform defines the webGL uniform location where to store the value
  113040. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  113041. */
  113042. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  113043. /**
  113044. * Set the value of an uniform to a matrix (2x2)
  113045. * @param uniform defines the webGL uniform location where to store the value
  113046. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  113047. */
  113048. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  113049. /**
  113050. * Set the value of an uniform to a number (float)
  113051. * @param uniform defines the webGL uniform location where to store the value
  113052. * @param value defines the float number to store
  113053. */
  113054. setFloat(uniform: WebGLUniformLocation, value: number): void;
  113055. /**
  113056. * Set the value of an uniform to a vec2
  113057. * @param uniform defines the webGL uniform location where to store the value
  113058. * @param x defines the 1st component of the value
  113059. * @param y defines the 2nd component of the value
  113060. */
  113061. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  113062. /**
  113063. * Set the value of an uniform to a vec3
  113064. * @param uniform defines the webGL uniform location where to store the value
  113065. * @param x defines the 1st component of the value
  113066. * @param y defines the 2nd component of the value
  113067. * @param z defines the 3rd component of the value
  113068. */
  113069. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  113070. /**
  113071. * Set the value of an uniform to a boolean
  113072. * @param uniform defines the webGL uniform location where to store the value
  113073. * @param bool defines the boolean to store
  113074. */
  113075. setBool(uniform: WebGLUniformLocation, bool: number): void;
  113076. /**
  113077. * Set the value of an uniform to a vec4
  113078. * @param uniform defines the webGL uniform location where to store the value
  113079. * @param x defines the 1st component of the value
  113080. * @param y defines the 2nd component of the value
  113081. * @param z defines the 3rd component of the value
  113082. * @param w defines the 4th component of the value
  113083. */
  113084. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  113085. /**
  113086. * Sets the current alpha mode
  113087. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  113088. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  113089. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  113090. */
  113091. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  113092. /**
  113093. * Bind webGl buffers directly to the webGL context
  113094. * @param vertexBuffers defines the vertex buffer to bind
  113095. * @param indexBuffer defines the index buffer to bind
  113096. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  113097. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  113098. * @param effect defines the effect associated with the vertex buffer
  113099. */
  113100. bindBuffers(vertexBuffers: {
  113101. [key: string]: VertexBuffer;
  113102. }, indexBuffer: DataBuffer, effect: Effect): void;
  113103. /**
  113104. * Force the entire cache to be cleared
  113105. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  113106. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  113107. */
  113108. wipeCaches(bruteForce?: boolean): void;
  113109. /**
  113110. * Send a draw order
  113111. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  113112. * @param indexStart defines the starting index
  113113. * @param indexCount defines the number of index to draw
  113114. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  113115. */
  113116. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  113117. /**
  113118. * Draw a list of indexed primitives
  113119. * @param fillMode defines the primitive to use
  113120. * @param indexStart defines the starting index
  113121. * @param indexCount defines the number of index to draw
  113122. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  113123. */
  113124. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  113125. /**
  113126. * Draw a list of unindexed primitives
  113127. * @param fillMode defines the primitive to use
  113128. * @param verticesStart defines the index of first vertex to draw
  113129. * @param verticesCount defines the count of vertices to draw
  113130. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  113131. */
  113132. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  113133. /** @hidden */
  113134. _createTexture(): WebGLTexture;
  113135. /** @hidden */
  113136. _releaseTexture(texture: InternalTexture): void;
  113137. /**
  113138. * Usually called from Texture.ts.
  113139. * Passed information to create a WebGLTexture
  113140. * @param urlArg defines a value which contains one of the following:
  113141. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  113142. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  113143. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  113144. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  113145. * @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)
  113146. * @param scene needed for loading to the correct scene
  113147. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  113148. * @param onLoad optional callback to be called upon successful completion
  113149. * @param onError optional callback to be called upon failure
  113150. * @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
  113151. * @param fallBack an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  113152. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  113153. * @param forcedExtension defines the extension to use to pick the right loader
  113154. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  113155. * @returns a InternalTexture for assignment back into BABYLON.Texture
  113156. */
  113157. 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;
  113158. /**
  113159. * Creates a new render target texture
  113160. * @param size defines the size of the texture
  113161. * @param options defines the options used to create the texture
  113162. * @returns a new render target texture stored in an InternalTexture
  113163. */
  113164. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  113165. /**
  113166. * Update the sampling mode of a given texture
  113167. * @param samplingMode defines the required sampling mode
  113168. * @param texture defines the texture to update
  113169. */
  113170. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  113171. /**
  113172. * Binds the frame buffer to the specified texture.
  113173. * @param texture The texture to render to or null for the default canvas
  113174. * @param faceIndex The face of the texture to render to in case of cube texture
  113175. * @param requiredWidth The width of the target to render to
  113176. * @param requiredHeight The height of the target to render to
  113177. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  113178. * @param depthStencilTexture The depth stencil texture to use to render
  113179. * @param lodLevel defines le lod level to bind to the frame buffer
  113180. */
  113181. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  113182. /**
  113183. * Unbind the current render target texture from the webGL context
  113184. * @param texture defines the render target texture to unbind
  113185. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  113186. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  113187. */
  113188. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  113189. /**
  113190. * Creates a dynamic vertex buffer
  113191. * @param vertices the data for the dynamic vertex buffer
  113192. * @returns the new WebGL dynamic buffer
  113193. */
  113194. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  113195. /**
  113196. * Update the content of a dynamic texture
  113197. * @param texture defines the texture to update
  113198. * @param canvas defines the canvas containing the source
  113199. * @param invertY defines if data must be stored with Y axis inverted
  113200. * @param premulAlpha defines if alpha is stored as premultiplied
  113201. * @param format defines the format of the data
  113202. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  113203. */
  113204. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  113205. /**
  113206. * Gets a boolean indicating if all created effects are ready
  113207. * @returns true if all effects are ready
  113208. */
  113209. areAllEffectsReady(): boolean;
  113210. /**
  113211. * @hidden
  113212. * Get the current error code of the webGL context
  113213. * @returns the error code
  113214. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  113215. */
  113216. getError(): number;
  113217. /** @hidden */
  113218. _getUnpackAlignement(): number;
  113219. /** @hidden */
  113220. _unpackFlipY(value: boolean): void;
  113221. /**
  113222. * Update a dynamic index buffer
  113223. * @param indexBuffer defines the target index buffer
  113224. * @param indices defines the data to update
  113225. * @param offset defines the offset in the target index buffer where update should start
  113226. */
  113227. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  113228. /**
  113229. * Updates a dynamic vertex buffer.
  113230. * @param vertexBuffer the vertex buffer to update
  113231. * @param vertices the data used to update the vertex buffer
  113232. * @param byteOffset the byte offset of the data (optional)
  113233. * @param byteLength the byte length of the data (optional)
  113234. */
  113235. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  113236. /** @hidden */
  113237. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  113238. /** @hidden */
  113239. _bindTexture(channel: number, texture: InternalTexture): void;
  113240. protected _deleteBuffer(buffer: WebGLBuffer): void;
  113241. /**
  113242. * 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
  113243. */
  113244. releaseEffects(): void;
  113245. displayLoadingUI(): void;
  113246. hideLoadingUI(): void;
  113247. /** @hidden */
  113248. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  113249. /** @hidden */
  113250. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  113251. /** @hidden */
  113252. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  113253. /** @hidden */
  113254. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  113255. }
  113256. }
  113257. declare module BABYLON {
  113258. /** @hidden */
  113259. export class _OcclusionDataStorage {
  113260. /** @hidden */
  113261. occlusionInternalRetryCounter: number;
  113262. /** @hidden */
  113263. isOcclusionQueryInProgress: boolean;
  113264. /** @hidden */
  113265. isOccluded: boolean;
  113266. /** @hidden */
  113267. occlusionRetryCount: number;
  113268. /** @hidden */
  113269. occlusionType: number;
  113270. /** @hidden */
  113271. occlusionQueryAlgorithmType: number;
  113272. }
  113273. interface Engine {
  113274. /**
  113275. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  113276. * @return the new query
  113277. */
  113278. createQuery(): WebGLQuery;
  113279. /**
  113280. * Delete and release a webGL query
  113281. * @param query defines the query to delete
  113282. * @return the current engine
  113283. */
  113284. deleteQuery(query: WebGLQuery): Engine;
  113285. /**
  113286. * Check if a given query has resolved and got its value
  113287. * @param query defines the query to check
  113288. * @returns true if the query got its value
  113289. */
  113290. isQueryResultAvailable(query: WebGLQuery): boolean;
  113291. /**
  113292. * Gets the value of a given query
  113293. * @param query defines the query to check
  113294. * @returns the value of the query
  113295. */
  113296. getQueryResult(query: WebGLQuery): number;
  113297. /**
  113298. * Initiates an occlusion query
  113299. * @param algorithmType defines the algorithm to use
  113300. * @param query defines the query to use
  113301. * @returns the current engine
  113302. * @see http://doc.babylonjs.com/features/occlusionquery
  113303. */
  113304. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  113305. /**
  113306. * Ends an occlusion query
  113307. * @see http://doc.babylonjs.com/features/occlusionquery
  113308. * @param algorithmType defines the algorithm to use
  113309. * @returns the current engine
  113310. */
  113311. endOcclusionQuery(algorithmType: number): Engine;
  113312. /**
  113313. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  113314. * Please note that only one query can be issued at a time
  113315. * @returns a time token used to track the time span
  113316. */
  113317. startTimeQuery(): Nullable<_TimeToken>;
  113318. /**
  113319. * Ends a time query
  113320. * @param token defines the token used to measure the time span
  113321. * @returns the time spent (in ns)
  113322. */
  113323. endTimeQuery(token: _TimeToken): int;
  113324. /** @hidden */
  113325. _currentNonTimestampToken: Nullable<_TimeToken>;
  113326. /** @hidden */
  113327. _createTimeQuery(): WebGLQuery;
  113328. /** @hidden */
  113329. _deleteTimeQuery(query: WebGLQuery): void;
  113330. /** @hidden */
  113331. _getGlAlgorithmType(algorithmType: number): number;
  113332. /** @hidden */
  113333. _getTimeQueryResult(query: WebGLQuery): any;
  113334. /** @hidden */
  113335. _getTimeQueryAvailability(query: WebGLQuery): any;
  113336. }
  113337. interface AbstractMesh {
  113338. /**
  113339. * Backing filed
  113340. * @hidden
  113341. */
  113342. __occlusionDataStorage: _OcclusionDataStorage;
  113343. /**
  113344. * Access property
  113345. * @hidden
  113346. */
  113347. _occlusionDataStorage: _OcclusionDataStorage;
  113348. /**
  113349. * 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.
  113350. * The default value is -1 which means don't break the query and wait till the result
  113351. * @see http://doc.babylonjs.com/features/occlusionquery
  113352. */
  113353. occlusionRetryCount: number;
  113354. /**
  113355. * 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:
  113356. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  113357. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  113358. * * 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.
  113359. * @see http://doc.babylonjs.com/features/occlusionquery
  113360. */
  113361. occlusionType: number;
  113362. /**
  113363. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  113364. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  113365. * * 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.
  113366. * @see http://doc.babylonjs.com/features/occlusionquery
  113367. */
  113368. occlusionQueryAlgorithmType: number;
  113369. /**
  113370. * 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
  113371. * @see http://doc.babylonjs.com/features/occlusionquery
  113372. */
  113373. isOccluded: boolean;
  113374. /**
  113375. * Flag to check the progress status of the query
  113376. * @see http://doc.babylonjs.com/features/occlusionquery
  113377. */
  113378. isOcclusionQueryInProgress: boolean;
  113379. }
  113380. }
  113381. declare module BABYLON {
  113382. /** @hidden */
  113383. export var _forceTransformFeedbackToBundle: boolean;
  113384. interface Engine {
  113385. /**
  113386. * Creates a webGL transform feedback object
  113387. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  113388. * @returns the webGL transform feedback object
  113389. */
  113390. createTransformFeedback(): WebGLTransformFeedback;
  113391. /**
  113392. * Delete a webGL transform feedback object
  113393. * @param value defines the webGL transform feedback object to delete
  113394. */
  113395. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  113396. /**
  113397. * Bind a webGL transform feedback object to the webgl context
  113398. * @param value defines the webGL transform feedback object to bind
  113399. */
  113400. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  113401. /**
  113402. * Begins a transform feedback operation
  113403. * @param usePoints defines if points or triangles must be used
  113404. */
  113405. beginTransformFeedback(usePoints: boolean): void;
  113406. /**
  113407. * Ends a transform feedback operation
  113408. */
  113409. endTransformFeedback(): void;
  113410. /**
  113411. * Specify the varyings to use with transform feedback
  113412. * @param program defines the associated webGL program
  113413. * @param value defines the list of strings representing the varying names
  113414. */
  113415. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  113416. /**
  113417. * Bind a webGL buffer for a transform feedback operation
  113418. * @param value defines the webGL buffer to bind
  113419. */
  113420. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  113421. }
  113422. }
  113423. declare module BABYLON {
  113424. /**
  113425. * Creation options of the multi render target texture.
  113426. */
  113427. export interface IMultiRenderTargetOptions {
  113428. /**
  113429. * Define if the texture needs to create mip maps after render.
  113430. */
  113431. generateMipMaps?: boolean;
  113432. /**
  113433. * Define the types of all the draw buffers we want to create
  113434. */
  113435. types?: number[];
  113436. /**
  113437. * Define the sampling modes of all the draw buffers we want to create
  113438. */
  113439. samplingModes?: number[];
  113440. /**
  113441. * Define if a depth buffer is required
  113442. */
  113443. generateDepthBuffer?: boolean;
  113444. /**
  113445. * Define if a stencil buffer is required
  113446. */
  113447. generateStencilBuffer?: boolean;
  113448. /**
  113449. * Define if a depth texture is required instead of a depth buffer
  113450. */
  113451. generateDepthTexture?: boolean;
  113452. /**
  113453. * Define the number of desired draw buffers
  113454. */
  113455. textureCount?: number;
  113456. /**
  113457. * Define if aspect ratio should be adapted to the texture or stay the scene one
  113458. */
  113459. doNotChangeAspectRatio?: boolean;
  113460. /**
  113461. * Define the default type of the buffers we are creating
  113462. */
  113463. defaultType?: number;
  113464. }
  113465. /**
  113466. * A multi render target, like a render target provides the ability to render to a texture.
  113467. * Unlike the render target, it can render to several draw buffers in one draw.
  113468. * This is specially interesting in deferred rendering or for any effects requiring more than
  113469. * just one color from a single pass.
  113470. */
  113471. export class MultiRenderTarget extends RenderTargetTexture {
  113472. private _internalTextures;
  113473. private _textures;
  113474. private _multiRenderTargetOptions;
  113475. /**
  113476. * Get if draw buffers are currently supported by the used hardware and browser.
  113477. */
  113478. readonly isSupported: boolean;
  113479. /**
  113480. * Get the list of textures generated by the multi render target.
  113481. */
  113482. readonly textures: Texture[];
  113483. /**
  113484. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  113485. */
  113486. readonly depthTexture: Texture;
  113487. /**
  113488. * Set the wrapping mode on U of all the textures we are rendering to.
  113489. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  113490. */
  113491. wrapU: number;
  113492. /**
  113493. * Set the wrapping mode on V of all the textures we are rendering to.
  113494. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  113495. */
  113496. wrapV: number;
  113497. /**
  113498. * Instantiate a new multi render target texture.
  113499. * A multi render target, like a render target provides the ability to render to a texture.
  113500. * Unlike the render target, it can render to several draw buffers in one draw.
  113501. * This is specially interesting in deferred rendering or for any effects requiring more than
  113502. * just one color from a single pass.
  113503. * @param name Define the name of the texture
  113504. * @param size Define the size of the buffers to render to
  113505. * @param count Define the number of target we are rendering into
  113506. * @param scene Define the scene the texture belongs to
  113507. * @param options Define the options used to create the multi render target
  113508. */
  113509. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  113510. /** @hidden */
  113511. _rebuild(): void;
  113512. private _createInternalTextures;
  113513. private _createTextures;
  113514. /**
  113515. * Define the number of samples used if MSAA is enabled.
  113516. */
  113517. samples: number;
  113518. /**
  113519. * Resize all the textures in the multi render target.
  113520. * Be carrefull as it will recreate all the data in the new texture.
  113521. * @param size Define the new size
  113522. */
  113523. resize(size: any): void;
  113524. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  113525. /**
  113526. * Dispose the render targets and their associated resources
  113527. */
  113528. dispose(): void;
  113529. /**
  113530. * Release all the underlying texture used as draw buffers.
  113531. */
  113532. releaseInternalTextures(): void;
  113533. }
  113534. }
  113535. declare module BABYLON {
  113536. interface ThinEngine {
  113537. /**
  113538. * Unbind a list of render target textures from the webGL context
  113539. * This is used only when drawBuffer extension or webGL2 are active
  113540. * @param textures defines the render target textures to unbind
  113541. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  113542. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  113543. */
  113544. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  113545. /**
  113546. * Create a multi render target texture
  113547. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  113548. * @param size defines the size of the texture
  113549. * @param options defines the creation options
  113550. * @returns the cube texture as an InternalTexture
  113551. */
  113552. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  113553. /**
  113554. * Update the sample count for a given multiple render target texture
  113555. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  113556. * @param textures defines the textures to update
  113557. * @param samples defines the sample count to set
  113558. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  113559. */
  113560. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  113561. }
  113562. }
  113563. declare module BABYLON {
  113564. /**
  113565. * Class used to define an additional view for the engine
  113566. * @see https://doc.babylonjs.com/how_to/multi_canvases
  113567. */
  113568. export class EngineView {
  113569. /** Defines the canvas where to render the view */
  113570. target: HTMLCanvasElement;
  113571. /** Defines an optional camera used to render the view (will use active camera else) */
  113572. camera?: Camera;
  113573. }
  113574. interface Engine {
  113575. /**
  113576. * Gets or sets the HTML element to use for attaching events
  113577. */
  113578. inputElement: Nullable<HTMLElement>;
  113579. /**
  113580. * Gets the current engine view
  113581. * @see https://doc.babylonjs.com/how_to/multi_canvases
  113582. */
  113583. activeView: Nullable<EngineView>;
  113584. /** Gets or sets the list of views */
  113585. views: EngineView[];
  113586. /**
  113587. * Register a new child canvas
  113588. * @param canvas defines the canvas to register
  113589. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  113590. * @returns the associated view
  113591. */
  113592. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  113593. /**
  113594. * Remove a registered child canvas
  113595. * @param canvas defines the canvas to remove
  113596. * @returns the current engine
  113597. */
  113598. unRegisterView(canvas: HTMLCanvasElement): Engine;
  113599. }
  113600. }
  113601. declare module BABYLON {
  113602. /**
  113603. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  113604. */
  113605. export interface CubeMapInfo {
  113606. /**
  113607. * The pixel array for the front face.
  113608. * This is stored in format, left to right, up to down format.
  113609. */
  113610. front: Nullable<ArrayBufferView>;
  113611. /**
  113612. * The pixel array for the back face.
  113613. * This is stored in format, left to right, up to down format.
  113614. */
  113615. back: Nullable<ArrayBufferView>;
  113616. /**
  113617. * The pixel array for the left face.
  113618. * This is stored in format, left to right, up to down format.
  113619. */
  113620. left: Nullable<ArrayBufferView>;
  113621. /**
  113622. * The pixel array for the right face.
  113623. * This is stored in format, left to right, up to down format.
  113624. */
  113625. right: Nullable<ArrayBufferView>;
  113626. /**
  113627. * The pixel array for the up face.
  113628. * This is stored in format, left to right, up to down format.
  113629. */
  113630. up: Nullable<ArrayBufferView>;
  113631. /**
  113632. * The pixel array for the down face.
  113633. * This is stored in format, left to right, up to down format.
  113634. */
  113635. down: Nullable<ArrayBufferView>;
  113636. /**
  113637. * The size of the cubemap stored.
  113638. *
  113639. * Each faces will be size * size pixels.
  113640. */
  113641. size: number;
  113642. /**
  113643. * The format of the texture.
  113644. *
  113645. * RGBA, RGB.
  113646. */
  113647. format: number;
  113648. /**
  113649. * The type of the texture data.
  113650. *
  113651. * UNSIGNED_INT, FLOAT.
  113652. */
  113653. type: number;
  113654. /**
  113655. * Specifies whether the texture is in gamma space.
  113656. */
  113657. gammaSpace: boolean;
  113658. }
  113659. /**
  113660. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  113661. */
  113662. export class PanoramaToCubeMapTools {
  113663. private static FACE_FRONT;
  113664. private static FACE_BACK;
  113665. private static FACE_RIGHT;
  113666. private static FACE_LEFT;
  113667. private static FACE_DOWN;
  113668. private static FACE_UP;
  113669. /**
  113670. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  113671. *
  113672. * @param float32Array The source data.
  113673. * @param inputWidth The width of the input panorama.
  113674. * @param inputHeight The height of the input panorama.
  113675. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  113676. * @return The cubemap data
  113677. */
  113678. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  113679. private static CreateCubemapTexture;
  113680. private static CalcProjectionSpherical;
  113681. }
  113682. }
  113683. declare module BABYLON {
  113684. /**
  113685. * Helper class dealing with the extraction of spherical polynomial dataArray
  113686. * from a cube map.
  113687. */
  113688. export class CubeMapToSphericalPolynomialTools {
  113689. private static FileFaces;
  113690. /**
  113691. * Converts a texture to the according Spherical Polynomial data.
  113692. * This extracts the first 3 orders only as they are the only one used in the lighting.
  113693. *
  113694. * @param texture The texture to extract the information from.
  113695. * @return The Spherical Polynomial data.
  113696. */
  113697. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  113698. /**
  113699. * Converts a cubemap to the according Spherical Polynomial data.
  113700. * This extracts the first 3 orders only as they are the only one used in the lighting.
  113701. *
  113702. * @param cubeInfo The Cube map to extract the information from.
  113703. * @return The Spherical Polynomial data.
  113704. */
  113705. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  113706. }
  113707. }
  113708. declare module BABYLON {
  113709. interface BaseTexture {
  113710. /**
  113711. * Get the polynomial representation of the texture data.
  113712. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  113713. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  113714. */
  113715. sphericalPolynomial: Nullable<SphericalPolynomial>;
  113716. }
  113717. }
  113718. declare module BABYLON {
  113719. /** @hidden */
  113720. export var rgbdEncodePixelShader: {
  113721. name: string;
  113722. shader: string;
  113723. };
  113724. }
  113725. declare module BABYLON {
  113726. /** @hidden */
  113727. export var rgbdDecodePixelShader: {
  113728. name: string;
  113729. shader: string;
  113730. };
  113731. }
  113732. declare module BABYLON {
  113733. /**
  113734. * Raw texture data and descriptor sufficient for WebGL texture upload
  113735. */
  113736. export interface EnvironmentTextureInfo {
  113737. /**
  113738. * Version of the environment map
  113739. */
  113740. version: number;
  113741. /**
  113742. * Width of image
  113743. */
  113744. width: number;
  113745. /**
  113746. * Irradiance information stored in the file.
  113747. */
  113748. irradiance: any;
  113749. /**
  113750. * Specular information stored in the file.
  113751. */
  113752. specular: any;
  113753. }
  113754. /**
  113755. * Defines One Image in the file. It requires only the position in the file
  113756. * as well as the length.
  113757. */
  113758. interface BufferImageData {
  113759. /**
  113760. * Length of the image data.
  113761. */
  113762. length: number;
  113763. /**
  113764. * Position of the data from the null terminator delimiting the end of the JSON.
  113765. */
  113766. position: number;
  113767. }
  113768. /**
  113769. * Defines the specular data enclosed in the file.
  113770. * This corresponds to the version 1 of the data.
  113771. */
  113772. export interface EnvironmentTextureSpecularInfoV1 {
  113773. /**
  113774. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  113775. */
  113776. specularDataPosition?: number;
  113777. /**
  113778. * This contains all the images data needed to reconstruct the cubemap.
  113779. */
  113780. mipmaps: Array<BufferImageData>;
  113781. /**
  113782. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  113783. */
  113784. lodGenerationScale: number;
  113785. }
  113786. /**
  113787. * Sets of helpers addressing the serialization and deserialization of environment texture
  113788. * stored in a BabylonJS env file.
  113789. * Those files are usually stored as .env files.
  113790. */
  113791. export class EnvironmentTextureTools {
  113792. /**
  113793. * Magic number identifying the env file.
  113794. */
  113795. private static _MagicBytes;
  113796. /**
  113797. * Gets the environment info from an env file.
  113798. * @param data The array buffer containing the .env bytes.
  113799. * @returns the environment file info (the json header) if successfully parsed.
  113800. */
  113801. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  113802. /**
  113803. * Creates an environment texture from a loaded cube texture.
  113804. * @param texture defines the cube texture to convert in env file
  113805. * @return a promise containing the environment data if succesfull.
  113806. */
  113807. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  113808. /**
  113809. * Creates a JSON representation of the spherical data.
  113810. * @param texture defines the texture containing the polynomials
  113811. * @return the JSON representation of the spherical info
  113812. */
  113813. private static _CreateEnvTextureIrradiance;
  113814. /**
  113815. * Creates the ArrayBufferViews used for initializing environment texture image data.
  113816. * @param arrayBuffer the underlying ArrayBuffer to which the views refer
  113817. * @param info parameters that determine what views will be created for accessing the underlying buffer
  113818. * @return the views described by info providing access to the underlying buffer
  113819. */
  113820. static CreateImageDataArrayBufferViews(arrayBuffer: any, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  113821. /**
  113822. * Uploads the texture info contained in the env file to the GPU.
  113823. * @param texture defines the internal texture to upload to
  113824. * @param arrayBuffer defines the buffer cotaining the data to load
  113825. * @param info defines the texture info retrieved through the GetEnvInfo method
  113826. * @returns a promise
  113827. */
  113828. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  113829. private static _OnImageReadyAsync;
  113830. /**
  113831. * Uploads the levels of image data to the GPU.
  113832. * @param texture defines the internal texture to upload to
  113833. * @param imageData defines the array buffer views of image data [mipmap][face]
  113834. * @returns a promise
  113835. */
  113836. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  113837. /**
  113838. * Uploads spherical polynomials information to the texture.
  113839. * @param texture defines the texture we are trying to upload the information to
  113840. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  113841. */
  113842. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  113843. /** @hidden */
  113844. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  113845. }
  113846. }
  113847. declare module BABYLON {
  113848. /**
  113849. * Contains position and normal vectors for a vertex
  113850. */
  113851. export class PositionNormalVertex {
  113852. /** the position of the vertex (defaut: 0,0,0) */
  113853. position: Vector3;
  113854. /** the normal of the vertex (defaut: 0,1,0) */
  113855. normal: Vector3;
  113856. /**
  113857. * Creates a PositionNormalVertex
  113858. * @param position the position of the vertex (defaut: 0,0,0)
  113859. * @param normal the normal of the vertex (defaut: 0,1,0)
  113860. */
  113861. constructor(
  113862. /** the position of the vertex (defaut: 0,0,0) */
  113863. position?: Vector3,
  113864. /** the normal of the vertex (defaut: 0,1,0) */
  113865. normal?: Vector3);
  113866. /**
  113867. * Clones the PositionNormalVertex
  113868. * @returns the cloned PositionNormalVertex
  113869. */
  113870. clone(): PositionNormalVertex;
  113871. }
  113872. /**
  113873. * Contains position, normal and uv vectors for a vertex
  113874. */
  113875. export class PositionNormalTextureVertex {
  113876. /** the position of the vertex (defaut: 0,0,0) */
  113877. position: Vector3;
  113878. /** the normal of the vertex (defaut: 0,1,0) */
  113879. normal: Vector3;
  113880. /** the uv of the vertex (default: 0,0) */
  113881. uv: Vector2;
  113882. /**
  113883. * Creates a PositionNormalTextureVertex
  113884. * @param position the position of the vertex (defaut: 0,0,0)
  113885. * @param normal the normal of the vertex (defaut: 0,1,0)
  113886. * @param uv the uv of the vertex (default: 0,0)
  113887. */
  113888. constructor(
  113889. /** the position of the vertex (defaut: 0,0,0) */
  113890. position?: Vector3,
  113891. /** the normal of the vertex (defaut: 0,1,0) */
  113892. normal?: Vector3,
  113893. /** the uv of the vertex (default: 0,0) */
  113894. uv?: Vector2);
  113895. /**
  113896. * Clones the PositionNormalTextureVertex
  113897. * @returns the cloned PositionNormalTextureVertex
  113898. */
  113899. clone(): PositionNormalTextureVertex;
  113900. }
  113901. }
  113902. declare module BABYLON {
  113903. /** @hidden */
  113904. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  113905. private _genericAttributeLocation;
  113906. private _varyingLocationCount;
  113907. private _varyingLocationMap;
  113908. private _replacements;
  113909. private _textureCount;
  113910. private _uniforms;
  113911. lineProcessor(line: string): string;
  113912. attributeProcessor(attribute: string): string;
  113913. varyingProcessor(varying: string, isFragment: boolean): string;
  113914. uniformProcessor(uniform: string): string;
  113915. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  113916. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  113917. }
  113918. }
  113919. declare module BABYLON {
  113920. /**
  113921. * Container for accessors for natively-stored mesh data buffers.
  113922. */
  113923. class NativeDataBuffer extends DataBuffer {
  113924. /**
  113925. * Accessor value used to identify/retrieve a natively-stored index buffer.
  113926. */
  113927. nativeIndexBuffer?: any;
  113928. /**
  113929. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  113930. */
  113931. nativeVertexBuffer?: any;
  113932. }
  113933. /** @hidden */
  113934. class NativeTexture extends InternalTexture {
  113935. getInternalTexture(): InternalTexture;
  113936. getViewCount(): number;
  113937. }
  113938. /** @hidden */
  113939. export class NativeEngine extends Engine {
  113940. private readonly _native;
  113941. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  113942. private readonly INVALID_HANDLE;
  113943. getHardwareScalingLevel(): number;
  113944. constructor();
  113945. /**
  113946. * Can be used to override the current requestAnimationFrame requester.
  113947. * @hidden
  113948. */
  113949. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  113950. /**
  113951. * Override default engine behavior.
  113952. * @param color
  113953. * @param backBuffer
  113954. * @param depth
  113955. * @param stencil
  113956. */
  113957. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  113958. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  113959. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  113960. createVertexBuffer(data: DataArray): NativeDataBuffer;
  113961. recordVertexArrayObject(vertexBuffers: {
  113962. [key: string]: VertexBuffer;
  113963. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  113964. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  113965. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  113966. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  113967. /**
  113968. * Draw a list of indexed primitives
  113969. * @param fillMode defines the primitive to use
  113970. * @param indexStart defines the starting index
  113971. * @param indexCount defines the number of index to draw
  113972. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  113973. */
  113974. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  113975. /**
  113976. * Draw a list of unindexed primitives
  113977. * @param fillMode defines the primitive to use
  113978. * @param verticesStart defines the index of first vertex to draw
  113979. * @param verticesCount defines the count of vertices to draw
  113980. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  113981. */
  113982. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  113983. createPipelineContext(): IPipelineContext;
  113984. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  113985. /** @hidden */
  113986. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  113987. /** @hidden */
  113988. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  113989. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  113990. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  113991. protected _setProgram(program: WebGLProgram): void;
  113992. _releaseEffect(effect: Effect): void;
  113993. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  113994. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  113995. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  113996. bindSamplers(effect: Effect): void;
  113997. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  113998. getRenderWidth(useScreen?: boolean): number;
  113999. getRenderHeight(useScreen?: boolean): number;
  114000. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  114001. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  114002. /**
  114003. * Set the z offset to apply to current rendering
  114004. * @param value defines the offset to apply
  114005. */
  114006. setZOffset(value: number): void;
  114007. /**
  114008. * Gets the current value of the zOffset
  114009. * @returns the current zOffset state
  114010. */
  114011. getZOffset(): number;
  114012. /**
  114013. * Enable or disable depth buffering
  114014. * @param enable defines the state to set
  114015. */
  114016. setDepthBuffer(enable: boolean): void;
  114017. /**
  114018. * Gets a boolean indicating if depth writing is enabled
  114019. * @returns the current depth writing state
  114020. */
  114021. getDepthWrite(): boolean;
  114022. /**
  114023. * Enable or disable depth writing
  114024. * @param enable defines the state to set
  114025. */
  114026. setDepthWrite(enable: boolean): void;
  114027. /**
  114028. * Enable or disable color writing
  114029. * @param enable defines the state to set
  114030. */
  114031. setColorWrite(enable: boolean): void;
  114032. /**
  114033. * Gets a boolean indicating if color writing is enabled
  114034. * @returns the current color writing state
  114035. */
  114036. getColorWrite(): boolean;
  114037. /**
  114038. * Sets alpha constants used by some alpha blending modes
  114039. * @param r defines the red component
  114040. * @param g defines the green component
  114041. * @param b defines the blue component
  114042. * @param a defines the alpha component
  114043. */
  114044. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  114045. /**
  114046. * Sets the current alpha mode
  114047. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  114048. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  114049. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  114050. */
  114051. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  114052. /**
  114053. * Gets the current alpha mode
  114054. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  114055. * @returns the current alpha mode
  114056. */
  114057. getAlphaMode(): number;
  114058. setInt(uniform: WebGLUniformLocation, int: number): void;
  114059. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  114060. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  114061. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  114062. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  114063. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  114064. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  114065. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  114066. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  114067. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  114068. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  114069. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  114070. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  114071. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  114072. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  114073. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  114074. setFloat(uniform: WebGLUniformLocation, value: number): void;
  114075. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  114076. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  114077. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  114078. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  114079. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  114080. wipeCaches(bruteForce?: boolean): void;
  114081. _createTexture(): WebGLTexture;
  114082. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  114083. /**
  114084. * Usually called from BABYLON.Texture.ts.
  114085. * Passed information to create a WebGLTexture
  114086. * @param urlArg defines a value which contains one of the following:
  114087. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  114088. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  114089. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  114090. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  114091. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  114092. * @param scene needed for loading to the correct scene
  114093. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  114094. * @param onLoad optional callback to be called upon successful completion
  114095. * @param onError optional callback to be called upon failure
  114096. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  114097. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  114098. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  114099. * @param forcedExtension defines the extension to use to pick the right loader
  114100. * @returns a InternalTexture for assignment back into BABYLON.Texture
  114101. */
  114102. 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;
  114103. /**
  114104. * Creates a cube texture
  114105. * @param rootUrl defines the url where the files to load is located
  114106. * @param scene defines the current scene
  114107. * @param files defines the list of files to load (1 per face)
  114108. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  114109. * @param onLoad defines an optional callback raised when the texture is loaded
  114110. * @param onError defines an optional callback raised if there is an issue to load the texture
  114111. * @param format defines the format of the data
  114112. * @param forcedExtension defines the extension to use to pick the right loader
  114113. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  114114. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  114115. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  114116. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  114117. * @returns the cube texture as an InternalTexture
  114118. */
  114119. 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;
  114120. private _getSamplingFilter;
  114121. private static _GetNativeTextureFormat;
  114122. createRenderTargetTexture(size: number | {
  114123. width: number;
  114124. height: number;
  114125. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  114126. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  114127. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  114128. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  114129. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  114130. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  114131. /**
  114132. * Updates a dynamic vertex buffer.
  114133. * @param vertexBuffer the vertex buffer to update
  114134. * @param data the data used to update the vertex buffer
  114135. * @param byteOffset the byte offset of the data (optional)
  114136. * @param byteLength the byte length of the data (optional)
  114137. */
  114138. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  114139. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  114140. private _updateAnisotropicLevel;
  114141. private _getAddressMode;
  114142. /** @hidden */
  114143. _bindTexture(channel: number, texture: InternalTexture): void;
  114144. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  114145. releaseEffects(): void;
  114146. /** @hidden */
  114147. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  114148. /** @hidden */
  114149. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  114150. /** @hidden */
  114151. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  114152. /** @hidden */
  114153. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  114154. }
  114155. }
  114156. declare module BABYLON {
  114157. /**
  114158. * Gather the list of clipboard event types as constants.
  114159. */
  114160. export class ClipboardEventTypes {
  114161. /**
  114162. * The clipboard event is fired when a copy command is active (pressed).
  114163. */
  114164. static readonly COPY: number;
  114165. /**
  114166. * The clipboard event is fired when a cut command is active (pressed).
  114167. */
  114168. static readonly CUT: number;
  114169. /**
  114170. * The clipboard event is fired when a paste command is active (pressed).
  114171. */
  114172. static readonly PASTE: number;
  114173. }
  114174. /**
  114175. * This class is used to store clipboard related info for the onClipboardObservable event.
  114176. */
  114177. export class ClipboardInfo {
  114178. /**
  114179. * Defines the type of event (BABYLON.ClipboardEventTypes)
  114180. */
  114181. type: number;
  114182. /**
  114183. * Defines the related dom event
  114184. */
  114185. event: ClipboardEvent;
  114186. /**
  114187. *Creates an instance of ClipboardInfo.
  114188. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  114189. * @param event Defines the related dom event
  114190. */
  114191. constructor(
  114192. /**
  114193. * Defines the type of event (BABYLON.ClipboardEventTypes)
  114194. */
  114195. type: number,
  114196. /**
  114197. * Defines the related dom event
  114198. */
  114199. event: ClipboardEvent);
  114200. /**
  114201. * Get the clipboard event's type from the keycode.
  114202. * @param keyCode Defines the keyCode for the current keyboard event.
  114203. * @return {number}
  114204. */
  114205. static GetTypeFromCharacter(keyCode: number): number;
  114206. }
  114207. }
  114208. declare module BABYLON {
  114209. /**
  114210. * Google Daydream controller
  114211. */
  114212. export class DaydreamController extends WebVRController {
  114213. /**
  114214. * Base Url for the controller model.
  114215. */
  114216. static MODEL_BASE_URL: string;
  114217. /**
  114218. * File name for the controller model.
  114219. */
  114220. static MODEL_FILENAME: string;
  114221. /**
  114222. * Gamepad Id prefix used to identify Daydream Controller.
  114223. */
  114224. static readonly GAMEPAD_ID_PREFIX: string;
  114225. /**
  114226. * Creates a new DaydreamController from a gamepad
  114227. * @param vrGamepad the gamepad that the controller should be created from
  114228. */
  114229. constructor(vrGamepad: any);
  114230. /**
  114231. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  114232. * @param scene scene in which to add meshes
  114233. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  114234. */
  114235. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  114236. /**
  114237. * Called once for each button that changed state since the last frame
  114238. * @param buttonIdx Which button index changed
  114239. * @param state New state of the button
  114240. * @param changes Which properties on the state changed since last frame
  114241. */
  114242. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  114243. }
  114244. }
  114245. declare module BABYLON {
  114246. /**
  114247. * Gear VR Controller
  114248. */
  114249. export class GearVRController extends WebVRController {
  114250. /**
  114251. * Base Url for the controller model.
  114252. */
  114253. static MODEL_BASE_URL: string;
  114254. /**
  114255. * File name for the controller model.
  114256. */
  114257. static MODEL_FILENAME: string;
  114258. /**
  114259. * Gamepad Id prefix used to identify this controller.
  114260. */
  114261. static readonly GAMEPAD_ID_PREFIX: string;
  114262. private readonly _buttonIndexToObservableNameMap;
  114263. /**
  114264. * Creates a new GearVRController from a gamepad
  114265. * @param vrGamepad the gamepad that the controller should be created from
  114266. */
  114267. constructor(vrGamepad: any);
  114268. /**
  114269. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  114270. * @param scene scene in which to add meshes
  114271. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  114272. */
  114273. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  114274. /**
  114275. * Called once for each button that changed state since the last frame
  114276. * @param buttonIdx Which button index changed
  114277. * @param state New state of the button
  114278. * @param changes Which properties on the state changed since last frame
  114279. */
  114280. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  114281. }
  114282. }
  114283. declare module BABYLON {
  114284. /**
  114285. * Class containing static functions to help procedurally build meshes
  114286. */
  114287. export class PolyhedronBuilder {
  114288. /**
  114289. * Creates a polyhedron mesh
  114290. * * 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
  114291. * * The parameter `size` (positive float, default 1) sets the polygon size
  114292. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  114293. * * 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`
  114294. * * 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
  114295. * * 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)`)
  114296. * * 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
  114297. * * 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
  114298. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  114299. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  114300. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  114301. * @param name defines the name of the mesh
  114302. * @param options defines the options used to create the mesh
  114303. * @param scene defines the hosting scene
  114304. * @returns the polyhedron mesh
  114305. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  114306. */
  114307. static CreatePolyhedron(name: string, options: {
  114308. type?: number;
  114309. size?: number;
  114310. sizeX?: number;
  114311. sizeY?: number;
  114312. sizeZ?: number;
  114313. custom?: any;
  114314. faceUV?: Vector4[];
  114315. faceColors?: Color4[];
  114316. flat?: boolean;
  114317. updatable?: boolean;
  114318. sideOrientation?: number;
  114319. frontUVs?: Vector4;
  114320. backUVs?: Vector4;
  114321. }, scene?: Nullable<Scene>): Mesh;
  114322. }
  114323. }
  114324. declare module BABYLON {
  114325. /**
  114326. * Gizmo that enables scaling a mesh along 3 axis
  114327. */
  114328. export class ScaleGizmo extends Gizmo {
  114329. /**
  114330. * Internal gizmo used for interactions on the x axis
  114331. */
  114332. xGizmo: AxisScaleGizmo;
  114333. /**
  114334. * Internal gizmo used for interactions on the y axis
  114335. */
  114336. yGizmo: AxisScaleGizmo;
  114337. /**
  114338. * Internal gizmo used for interactions on the z axis
  114339. */
  114340. zGizmo: AxisScaleGizmo;
  114341. /**
  114342. * Internal gizmo used to scale all axis equally
  114343. */
  114344. uniformScaleGizmo: AxisScaleGizmo;
  114345. private _meshAttached;
  114346. private _updateGizmoRotationToMatchAttachedMesh;
  114347. private _snapDistance;
  114348. private _scaleRatio;
  114349. private _uniformScalingMesh;
  114350. private _octahedron;
  114351. private _sensitivity;
  114352. /** Fires an event when any of it's sub gizmos are dragged */
  114353. onDragStartObservable: Observable<unknown>;
  114354. /** Fires an event when any of it's sub gizmos are released from dragging */
  114355. onDragEndObservable: Observable<unknown>;
  114356. attachedMesh: Nullable<AbstractMesh>;
  114357. /**
  114358. * Creates a ScaleGizmo
  114359. * @param gizmoLayer The utility layer the gizmo will be added to
  114360. */
  114361. constructor(gizmoLayer?: UtilityLayerRenderer);
  114362. updateGizmoRotationToMatchAttachedMesh: boolean;
  114363. /**
  114364. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  114365. */
  114366. snapDistance: number;
  114367. /**
  114368. * Ratio for the scale of the gizmo (Default: 1)
  114369. */
  114370. scaleRatio: number;
  114371. /**
  114372. * Sensitivity factor for dragging (Default: 1)
  114373. */
  114374. sensitivity: number;
  114375. /**
  114376. * Disposes of the gizmo
  114377. */
  114378. dispose(): void;
  114379. }
  114380. }
  114381. declare module BABYLON {
  114382. /**
  114383. * Single axis scale gizmo
  114384. */
  114385. export class AxisScaleGizmo extends Gizmo {
  114386. /**
  114387. * Drag behavior responsible for the gizmos dragging interactions
  114388. */
  114389. dragBehavior: PointerDragBehavior;
  114390. private _pointerObserver;
  114391. /**
  114392. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  114393. */
  114394. snapDistance: number;
  114395. /**
  114396. * Event that fires each time the gizmo snaps to a new location.
  114397. * * snapDistance is the the change in distance
  114398. */
  114399. onSnapObservable: Observable<{
  114400. snapDistance: number;
  114401. }>;
  114402. /**
  114403. * If the scaling operation should be done on all axis (default: false)
  114404. */
  114405. uniformScaling: boolean;
  114406. /**
  114407. * Custom sensitivity value for the drag strength
  114408. */
  114409. sensitivity: number;
  114410. private _isEnabled;
  114411. private _parent;
  114412. private _arrow;
  114413. private _coloredMaterial;
  114414. private _hoverMaterial;
  114415. /**
  114416. * Creates an AxisScaleGizmo
  114417. * @param gizmoLayer The utility layer the gizmo will be added to
  114418. * @param dragAxis The axis which the gizmo will be able to scale on
  114419. * @param color The color of the gizmo
  114420. */
  114421. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  114422. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  114423. /**
  114424. * If the gizmo is enabled
  114425. */
  114426. isEnabled: boolean;
  114427. /**
  114428. * Disposes of the gizmo
  114429. */
  114430. dispose(): void;
  114431. /**
  114432. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  114433. * @param mesh The mesh to replace the default mesh of the gizmo
  114434. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  114435. */
  114436. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  114437. }
  114438. }
  114439. declare module BABYLON {
  114440. /**
  114441. * Bounding box gizmo
  114442. */
  114443. export class BoundingBoxGizmo extends Gizmo {
  114444. private _lineBoundingBox;
  114445. private _rotateSpheresParent;
  114446. private _scaleBoxesParent;
  114447. private _boundingDimensions;
  114448. private _renderObserver;
  114449. private _pointerObserver;
  114450. private _scaleDragSpeed;
  114451. private _tmpQuaternion;
  114452. private _tmpVector;
  114453. private _tmpRotationMatrix;
  114454. /**
  114455. * 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)
  114456. */
  114457. ignoreChildren: boolean;
  114458. /**
  114459. * 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)
  114460. */
  114461. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  114462. /**
  114463. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  114464. */
  114465. rotationSphereSize: number;
  114466. /**
  114467. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  114468. */
  114469. scaleBoxSize: number;
  114470. /**
  114471. * 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)
  114472. */
  114473. fixedDragMeshScreenSize: boolean;
  114474. /**
  114475. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  114476. */
  114477. fixedDragMeshScreenSizeDistanceFactor: number;
  114478. /**
  114479. * Fired when a rotation sphere or scale box is dragged
  114480. */
  114481. onDragStartObservable: Observable<{}>;
  114482. /**
  114483. * Fired when a scale box is dragged
  114484. */
  114485. onScaleBoxDragObservable: Observable<{}>;
  114486. /**
  114487. * Fired when a scale box drag is ended
  114488. */
  114489. onScaleBoxDragEndObservable: Observable<{}>;
  114490. /**
  114491. * Fired when a rotation sphere is dragged
  114492. */
  114493. onRotationSphereDragObservable: Observable<{}>;
  114494. /**
  114495. * Fired when a rotation sphere drag is ended
  114496. */
  114497. onRotationSphereDragEndObservable: Observable<{}>;
  114498. /**
  114499. * 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)
  114500. */
  114501. scalePivot: Nullable<Vector3>;
  114502. /**
  114503. * Mesh used as a pivot to rotate the attached mesh
  114504. */
  114505. private _anchorMesh;
  114506. private _existingMeshScale;
  114507. private _dragMesh;
  114508. private pointerDragBehavior;
  114509. private coloredMaterial;
  114510. private hoverColoredMaterial;
  114511. /**
  114512. * Sets the color of the bounding box gizmo
  114513. * @param color the color to set
  114514. */
  114515. setColor(color: Color3): void;
  114516. /**
  114517. * Creates an BoundingBoxGizmo
  114518. * @param gizmoLayer The utility layer the gizmo will be added to
  114519. * @param color The color of the gizmo
  114520. */
  114521. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  114522. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  114523. private _selectNode;
  114524. /**
  114525. * Updates the bounding box information for the Gizmo
  114526. */
  114527. updateBoundingBox(): void;
  114528. private _updateRotationSpheres;
  114529. private _updateScaleBoxes;
  114530. /**
  114531. * Enables rotation on the specified axis and disables rotation on the others
  114532. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  114533. */
  114534. setEnabledRotationAxis(axis: string): void;
  114535. /**
  114536. * Enables/disables scaling
  114537. * @param enable if scaling should be enabled
  114538. */
  114539. setEnabledScaling(enable: boolean): void;
  114540. private _updateDummy;
  114541. /**
  114542. * Enables a pointer drag behavior on the bounding box of the gizmo
  114543. */
  114544. enableDragBehavior(): void;
  114545. /**
  114546. * Disposes of the gizmo
  114547. */
  114548. dispose(): void;
  114549. /**
  114550. * 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)
  114551. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  114552. * @returns the bounding box mesh with the passed in mesh as a child
  114553. */
  114554. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  114555. /**
  114556. * CustomMeshes are not supported by this gizmo
  114557. * @param mesh The mesh to replace the default mesh of the gizmo
  114558. */
  114559. setCustomMesh(mesh: Mesh): void;
  114560. }
  114561. }
  114562. declare module BABYLON {
  114563. /**
  114564. * Single plane rotation gizmo
  114565. */
  114566. export class PlaneRotationGizmo extends Gizmo {
  114567. /**
  114568. * Drag behavior responsible for the gizmos dragging interactions
  114569. */
  114570. dragBehavior: PointerDragBehavior;
  114571. private _pointerObserver;
  114572. /**
  114573. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  114574. */
  114575. snapDistance: number;
  114576. /**
  114577. * Event that fires each time the gizmo snaps to a new location.
  114578. * * snapDistance is the the change in distance
  114579. */
  114580. onSnapObservable: Observable<{
  114581. snapDistance: number;
  114582. }>;
  114583. private _isEnabled;
  114584. private _parent;
  114585. /**
  114586. * Creates a PlaneRotationGizmo
  114587. * @param gizmoLayer The utility layer the gizmo will be added to
  114588. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  114589. * @param color The color of the gizmo
  114590. * @param tessellation Amount of tessellation to be used when creating rotation circles
  114591. * @param useEulerRotation Use and update Euler angle instead of quaternion
  114592. */
  114593. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  114594. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  114595. /**
  114596. * If the gizmo is enabled
  114597. */
  114598. isEnabled: boolean;
  114599. /**
  114600. * Disposes of the gizmo
  114601. */
  114602. dispose(): void;
  114603. }
  114604. }
  114605. declare module BABYLON {
  114606. /**
  114607. * Gizmo that enables rotating a mesh along 3 axis
  114608. */
  114609. export class RotationGizmo extends Gizmo {
  114610. /**
  114611. * Internal gizmo used for interactions on the x axis
  114612. */
  114613. xGizmo: PlaneRotationGizmo;
  114614. /**
  114615. * Internal gizmo used for interactions on the y axis
  114616. */
  114617. yGizmo: PlaneRotationGizmo;
  114618. /**
  114619. * Internal gizmo used for interactions on the z axis
  114620. */
  114621. zGizmo: PlaneRotationGizmo;
  114622. /** Fires an event when any of it's sub gizmos are dragged */
  114623. onDragStartObservable: Observable<unknown>;
  114624. /** Fires an event when any of it's sub gizmos are released from dragging */
  114625. onDragEndObservable: Observable<unknown>;
  114626. private _meshAttached;
  114627. attachedMesh: Nullable<AbstractMesh>;
  114628. /**
  114629. * Creates a RotationGizmo
  114630. * @param gizmoLayer The utility layer the gizmo will be added to
  114631. * @param tessellation Amount of tessellation to be used when creating rotation circles
  114632. * @param useEulerRotation Use and update Euler angle instead of quaternion
  114633. */
  114634. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  114635. updateGizmoRotationToMatchAttachedMesh: boolean;
  114636. /**
  114637. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  114638. */
  114639. snapDistance: number;
  114640. /**
  114641. * Ratio for the scale of the gizmo (Default: 1)
  114642. */
  114643. scaleRatio: number;
  114644. /**
  114645. * Disposes of the gizmo
  114646. */
  114647. dispose(): void;
  114648. /**
  114649. * CustomMeshes are not supported by this gizmo
  114650. * @param mesh The mesh to replace the default mesh of the gizmo
  114651. */
  114652. setCustomMesh(mesh: Mesh): void;
  114653. }
  114654. }
  114655. declare module BABYLON {
  114656. /**
  114657. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  114658. */
  114659. export class GizmoManager implements IDisposable {
  114660. private scene;
  114661. /**
  114662. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  114663. */
  114664. gizmos: {
  114665. positionGizmo: Nullable<PositionGizmo>;
  114666. rotationGizmo: Nullable<RotationGizmo>;
  114667. scaleGizmo: Nullable<ScaleGizmo>;
  114668. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  114669. };
  114670. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  114671. clearGizmoOnEmptyPointerEvent: boolean;
  114672. /** Fires an event when the manager is attached to a mesh */
  114673. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  114674. private _gizmosEnabled;
  114675. private _pointerObserver;
  114676. private _attachedMesh;
  114677. private _boundingBoxColor;
  114678. private _defaultUtilityLayer;
  114679. private _defaultKeepDepthUtilityLayer;
  114680. /**
  114681. * When bounding box gizmo is enabled, this can be used to track drag/end events
  114682. */
  114683. boundingBoxDragBehavior: SixDofDragBehavior;
  114684. /**
  114685. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  114686. */
  114687. attachableMeshes: Nullable<Array<AbstractMesh>>;
  114688. /**
  114689. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  114690. */
  114691. usePointerToAttachGizmos: boolean;
  114692. /**
  114693. * Utility layer that the bounding box gizmo belongs to
  114694. */
  114695. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  114696. /**
  114697. * Utility layer that all gizmos besides bounding box belong to
  114698. */
  114699. readonly utilityLayer: UtilityLayerRenderer;
  114700. /**
  114701. * Instatiates a gizmo manager
  114702. * @param scene the scene to overlay the gizmos on top of
  114703. */
  114704. constructor(scene: Scene);
  114705. /**
  114706. * Attaches a set of gizmos to the specified mesh
  114707. * @param mesh The mesh the gizmo's should be attached to
  114708. */
  114709. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  114710. /**
  114711. * If the position gizmo is enabled
  114712. */
  114713. positionGizmoEnabled: boolean;
  114714. /**
  114715. * If the rotation gizmo is enabled
  114716. */
  114717. rotationGizmoEnabled: boolean;
  114718. /**
  114719. * If the scale gizmo is enabled
  114720. */
  114721. scaleGizmoEnabled: boolean;
  114722. /**
  114723. * If the boundingBox gizmo is enabled
  114724. */
  114725. boundingBoxGizmoEnabled: boolean;
  114726. /**
  114727. * Disposes of the gizmo manager
  114728. */
  114729. dispose(): void;
  114730. }
  114731. }
  114732. declare module BABYLON {
  114733. /**
  114734. * A directional light is defined by a direction (what a surprise!).
  114735. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  114736. * 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.
  114737. * Documentation: https://doc.babylonjs.com/babylon101/lights
  114738. */
  114739. export class DirectionalLight extends ShadowLight {
  114740. private _shadowFrustumSize;
  114741. /**
  114742. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  114743. */
  114744. /**
  114745. * Specifies a fix frustum size for the shadow generation.
  114746. */
  114747. shadowFrustumSize: number;
  114748. private _shadowOrthoScale;
  114749. /**
  114750. * Gets the shadow projection scale against the optimal computed one.
  114751. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  114752. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  114753. */
  114754. /**
  114755. * Sets the shadow projection scale against the optimal computed one.
  114756. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  114757. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  114758. */
  114759. shadowOrthoScale: number;
  114760. /**
  114761. * Automatically compute the projection matrix to best fit (including all the casters)
  114762. * on each frame.
  114763. */
  114764. autoUpdateExtends: boolean;
  114765. private _orthoLeft;
  114766. private _orthoRight;
  114767. private _orthoTop;
  114768. private _orthoBottom;
  114769. /**
  114770. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  114771. * The directional light is emitted from everywhere in the given direction.
  114772. * It can cast shadows.
  114773. * Documentation : https://doc.babylonjs.com/babylon101/lights
  114774. * @param name The friendly name of the light
  114775. * @param direction The direction of the light
  114776. * @param scene The scene the light belongs to
  114777. */
  114778. constructor(name: string, direction: Vector3, scene: Scene);
  114779. /**
  114780. * Returns the string "DirectionalLight".
  114781. * @return The class name
  114782. */
  114783. getClassName(): string;
  114784. /**
  114785. * Returns the integer 1.
  114786. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  114787. */
  114788. getTypeID(): number;
  114789. /**
  114790. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  114791. * Returns the DirectionalLight Shadow projection matrix.
  114792. */
  114793. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  114794. /**
  114795. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  114796. * Returns the DirectionalLight Shadow projection matrix.
  114797. */
  114798. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  114799. /**
  114800. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  114801. * Returns the DirectionalLight Shadow projection matrix.
  114802. */
  114803. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  114804. protected _buildUniformLayout(): void;
  114805. /**
  114806. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  114807. * @param effect The effect to update
  114808. * @param lightIndex The index of the light in the effect to update
  114809. * @returns The directional light
  114810. */
  114811. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  114812. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  114813. /**
  114814. * Gets the minZ used for shadow according to both the scene and the light.
  114815. *
  114816. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  114817. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  114818. * @param activeCamera The camera we are returning the min for
  114819. * @returns the depth min z
  114820. */
  114821. getDepthMinZ(activeCamera: Camera): number;
  114822. /**
  114823. * Gets the maxZ used for shadow according to both the scene and the light.
  114824. *
  114825. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  114826. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  114827. * @param activeCamera The camera we are returning the max for
  114828. * @returns the depth max z
  114829. */
  114830. getDepthMaxZ(activeCamera: Camera): number;
  114831. /**
  114832. * Prepares the list of defines specific to the light type.
  114833. * @param defines the list of defines
  114834. * @param lightIndex defines the index of the light for the effect
  114835. */
  114836. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  114837. }
  114838. }
  114839. declare module BABYLON {
  114840. /**
  114841. * Class containing static functions to help procedurally build meshes
  114842. */
  114843. export class HemisphereBuilder {
  114844. /**
  114845. * Creates a hemisphere mesh
  114846. * @param name defines the name of the mesh
  114847. * @param options defines the options used to create the mesh
  114848. * @param scene defines the hosting scene
  114849. * @returns the hemisphere mesh
  114850. */
  114851. static CreateHemisphere(name: string, options: {
  114852. segments?: number;
  114853. diameter?: number;
  114854. sideOrientation?: number;
  114855. }, scene: any): Mesh;
  114856. }
  114857. }
  114858. declare module BABYLON {
  114859. /**
  114860. * A spot light is defined by a position, a direction, an angle, and an exponent.
  114861. * These values define a cone of light starting from the position, emitting toward the direction.
  114862. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  114863. * and the exponent defines the speed of the decay of the light with distance (reach).
  114864. * Documentation: https://doc.babylonjs.com/babylon101/lights
  114865. */
  114866. export class SpotLight extends ShadowLight {
  114867. private _angle;
  114868. private _innerAngle;
  114869. private _cosHalfAngle;
  114870. private _lightAngleScale;
  114871. private _lightAngleOffset;
  114872. /**
  114873. * Gets the cone angle of the spot light in Radians.
  114874. */
  114875. /**
  114876. * Sets the cone angle of the spot light in Radians.
  114877. */
  114878. angle: number;
  114879. /**
  114880. * Only used in gltf falloff mode, this defines the angle where
  114881. * the directional falloff will start before cutting at angle which could be seen
  114882. * as outer angle.
  114883. */
  114884. /**
  114885. * Only used in gltf falloff mode, this defines the angle where
  114886. * the directional falloff will start before cutting at angle which could be seen
  114887. * as outer angle.
  114888. */
  114889. innerAngle: number;
  114890. private _shadowAngleScale;
  114891. /**
  114892. * Allows scaling the angle of the light for shadow generation only.
  114893. */
  114894. /**
  114895. * Allows scaling the angle of the light for shadow generation only.
  114896. */
  114897. shadowAngleScale: number;
  114898. /**
  114899. * The light decay speed with the distance from the emission spot.
  114900. */
  114901. exponent: number;
  114902. private _projectionTextureMatrix;
  114903. /**
  114904. * Allows reading the projecton texture
  114905. */
  114906. readonly projectionTextureMatrix: Matrix;
  114907. protected _projectionTextureLightNear: number;
  114908. /**
  114909. * Gets the near clip of the Spotlight for texture projection.
  114910. */
  114911. /**
  114912. * Sets the near clip of the Spotlight for texture projection.
  114913. */
  114914. projectionTextureLightNear: number;
  114915. protected _projectionTextureLightFar: number;
  114916. /**
  114917. * Gets the far clip of the Spotlight for texture projection.
  114918. */
  114919. /**
  114920. * Sets the far clip of the Spotlight for texture projection.
  114921. */
  114922. projectionTextureLightFar: number;
  114923. protected _projectionTextureUpDirection: Vector3;
  114924. /**
  114925. * Gets the Up vector of the Spotlight for texture projection.
  114926. */
  114927. /**
  114928. * Sets the Up vector of the Spotlight for texture projection.
  114929. */
  114930. projectionTextureUpDirection: Vector3;
  114931. private _projectionTexture;
  114932. /**
  114933. * Gets the projection texture of the light.
  114934. */
  114935. /**
  114936. * Sets the projection texture of the light.
  114937. */
  114938. projectionTexture: Nullable<BaseTexture>;
  114939. private _projectionTextureViewLightDirty;
  114940. private _projectionTextureProjectionLightDirty;
  114941. private _projectionTextureDirty;
  114942. private _projectionTextureViewTargetVector;
  114943. private _projectionTextureViewLightMatrix;
  114944. private _projectionTextureProjectionLightMatrix;
  114945. private _projectionTextureScalingMatrix;
  114946. /**
  114947. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  114948. * It can cast shadows.
  114949. * Documentation : https://doc.babylonjs.com/babylon101/lights
  114950. * @param name The light friendly name
  114951. * @param position The position of the spot light in the scene
  114952. * @param direction The direction of the light in the scene
  114953. * @param angle The cone angle of the light in Radians
  114954. * @param exponent The light decay speed with the distance from the emission spot
  114955. * @param scene The scene the lights belongs to
  114956. */
  114957. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  114958. /**
  114959. * Returns the string "SpotLight".
  114960. * @returns the class name
  114961. */
  114962. getClassName(): string;
  114963. /**
  114964. * Returns the integer 2.
  114965. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  114966. */
  114967. getTypeID(): number;
  114968. /**
  114969. * Overrides the direction setter to recompute the projection texture view light Matrix.
  114970. */
  114971. protected _setDirection(value: Vector3): void;
  114972. /**
  114973. * Overrides the position setter to recompute the projection texture view light Matrix.
  114974. */
  114975. protected _setPosition(value: Vector3): void;
  114976. /**
  114977. * 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.
  114978. * Returns the SpotLight.
  114979. */
  114980. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  114981. protected _computeProjectionTextureViewLightMatrix(): void;
  114982. protected _computeProjectionTextureProjectionLightMatrix(): void;
  114983. /**
  114984. * Main function for light texture projection matrix computing.
  114985. */
  114986. protected _computeProjectionTextureMatrix(): void;
  114987. protected _buildUniformLayout(): void;
  114988. private _computeAngleValues;
  114989. /**
  114990. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  114991. * @param effect The effect to update
  114992. * @param lightIndex The index of the light in the effect to update
  114993. * @returns The spot light
  114994. */
  114995. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  114996. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  114997. /**
  114998. * Disposes the light and the associated resources.
  114999. */
  115000. dispose(): void;
  115001. /**
  115002. * Prepares the list of defines specific to the light type.
  115003. * @param defines the list of defines
  115004. * @param lightIndex defines the index of the light for the effect
  115005. */
  115006. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  115007. }
  115008. }
  115009. declare module BABYLON {
  115010. /**
  115011. * Gizmo that enables viewing a light
  115012. */
  115013. export class LightGizmo extends Gizmo {
  115014. private _lightMesh;
  115015. private _material;
  115016. private _cachedPosition;
  115017. private _cachedForward;
  115018. private _attachedMeshParent;
  115019. /**
  115020. * Creates a LightGizmo
  115021. * @param gizmoLayer The utility layer the gizmo will be added to
  115022. */
  115023. constructor(gizmoLayer?: UtilityLayerRenderer);
  115024. private _light;
  115025. /**
  115026. * The light that the gizmo is attached to
  115027. */
  115028. light: Nullable<Light>;
  115029. /**
  115030. * Gets the material used to render the light gizmo
  115031. */
  115032. readonly material: StandardMaterial;
  115033. /**
  115034. * @hidden
  115035. * Updates the gizmo to match the attached mesh's position/rotation
  115036. */
  115037. protected _update(): void;
  115038. private static _Scale;
  115039. /**
  115040. * Creates the lines for a light mesh
  115041. */
  115042. private static _CreateLightLines;
  115043. /**
  115044. * Disposes of the light gizmo
  115045. */
  115046. dispose(): void;
  115047. private static _CreateHemisphericLightMesh;
  115048. private static _CreatePointLightMesh;
  115049. private static _CreateSpotLightMesh;
  115050. private static _CreateDirectionalLightMesh;
  115051. }
  115052. }
  115053. declare module BABYLON {
  115054. /** @hidden */
  115055. export var backgroundFragmentDeclaration: {
  115056. name: string;
  115057. shader: string;
  115058. };
  115059. }
  115060. declare module BABYLON {
  115061. /** @hidden */
  115062. export var backgroundUboDeclaration: {
  115063. name: string;
  115064. shader: string;
  115065. };
  115066. }
  115067. declare module BABYLON {
  115068. /** @hidden */
  115069. export var backgroundPixelShader: {
  115070. name: string;
  115071. shader: string;
  115072. };
  115073. }
  115074. declare module BABYLON {
  115075. /** @hidden */
  115076. export var backgroundVertexDeclaration: {
  115077. name: string;
  115078. shader: string;
  115079. };
  115080. }
  115081. declare module BABYLON {
  115082. /** @hidden */
  115083. export var backgroundVertexShader: {
  115084. name: string;
  115085. shader: string;
  115086. };
  115087. }
  115088. declare module BABYLON {
  115089. /**
  115090. * Background material used to create an efficient environement around your scene.
  115091. */
  115092. export class BackgroundMaterial extends PushMaterial {
  115093. /**
  115094. * Standard reflectance value at parallel view angle.
  115095. */
  115096. static StandardReflectance0: number;
  115097. /**
  115098. * Standard reflectance value at grazing angle.
  115099. */
  115100. static StandardReflectance90: number;
  115101. protected _primaryColor: Color3;
  115102. /**
  115103. * Key light Color (multiply against the environement texture)
  115104. */
  115105. primaryColor: Color3;
  115106. protected __perceptualColor: Nullable<Color3>;
  115107. /**
  115108. * Experimental Internal Use Only.
  115109. *
  115110. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  115111. * This acts as a helper to set the primary color to a more "human friendly" value.
  115112. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  115113. * output color as close as possible from the chosen value.
  115114. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  115115. * part of lighting setup.)
  115116. */
  115117. _perceptualColor: Nullable<Color3>;
  115118. protected _primaryColorShadowLevel: float;
  115119. /**
  115120. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  115121. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  115122. */
  115123. primaryColorShadowLevel: float;
  115124. protected _primaryColorHighlightLevel: float;
  115125. /**
  115126. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  115127. * The primary color is used at the level chosen to define what the white area would look.
  115128. */
  115129. primaryColorHighlightLevel: float;
  115130. protected _reflectionTexture: Nullable<BaseTexture>;
  115131. /**
  115132. * Reflection Texture used in the material.
  115133. * Should be author in a specific way for the best result (refer to the documentation).
  115134. */
  115135. reflectionTexture: Nullable<BaseTexture>;
  115136. protected _reflectionBlur: float;
  115137. /**
  115138. * Reflection Texture level of blur.
  115139. *
  115140. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  115141. * texture twice.
  115142. */
  115143. reflectionBlur: float;
  115144. protected _diffuseTexture: Nullable<BaseTexture>;
  115145. /**
  115146. * Diffuse Texture used in the material.
  115147. * Should be author in a specific way for the best result (refer to the documentation).
  115148. */
  115149. diffuseTexture: Nullable<BaseTexture>;
  115150. protected _shadowLights: Nullable<IShadowLight[]>;
  115151. /**
  115152. * Specify the list of lights casting shadow on the material.
  115153. * All scene shadow lights will be included if null.
  115154. */
  115155. shadowLights: Nullable<IShadowLight[]>;
  115156. protected _shadowLevel: float;
  115157. /**
  115158. * Helps adjusting the shadow to a softer level if required.
  115159. * 0 means black shadows and 1 means no shadows.
  115160. */
  115161. shadowLevel: float;
  115162. protected _sceneCenter: Vector3;
  115163. /**
  115164. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  115165. * It is usually zero but might be interesting to modify according to your setup.
  115166. */
  115167. sceneCenter: Vector3;
  115168. protected _opacityFresnel: boolean;
  115169. /**
  115170. * This helps specifying that the material is falling off to the sky box at grazing angle.
  115171. * This helps ensuring a nice transition when the camera goes under the ground.
  115172. */
  115173. opacityFresnel: boolean;
  115174. protected _reflectionFresnel: boolean;
  115175. /**
  115176. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  115177. * This helps adding a mirror texture on the ground.
  115178. */
  115179. reflectionFresnel: boolean;
  115180. protected _reflectionFalloffDistance: number;
  115181. /**
  115182. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  115183. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  115184. */
  115185. reflectionFalloffDistance: number;
  115186. protected _reflectionAmount: number;
  115187. /**
  115188. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  115189. */
  115190. reflectionAmount: number;
  115191. protected _reflectionReflectance0: number;
  115192. /**
  115193. * This specifies the weight of the reflection at grazing angle.
  115194. */
  115195. reflectionReflectance0: number;
  115196. protected _reflectionReflectance90: number;
  115197. /**
  115198. * This specifies the weight of the reflection at a perpendicular point of view.
  115199. */
  115200. reflectionReflectance90: number;
  115201. /**
  115202. * Sets the reflection reflectance fresnel values according to the default standard
  115203. * empirically know to work well :-)
  115204. */
  115205. reflectionStandardFresnelWeight: number;
  115206. protected _useRGBColor: boolean;
  115207. /**
  115208. * Helps to directly use the maps channels instead of their level.
  115209. */
  115210. useRGBColor: boolean;
  115211. protected _enableNoise: boolean;
  115212. /**
  115213. * This helps reducing the banding effect that could occur on the background.
  115214. */
  115215. enableNoise: boolean;
  115216. /**
  115217. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  115218. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  115219. * Recommended to be keep at 1.0 except for special cases.
  115220. */
  115221. fovMultiplier: number;
  115222. private _fovMultiplier;
  115223. /**
  115224. * Enable the FOV adjustment feature controlled by fovMultiplier.
  115225. */
  115226. useEquirectangularFOV: boolean;
  115227. private _maxSimultaneousLights;
  115228. /**
  115229. * Number of Simultaneous lights allowed on the material.
  115230. */
  115231. maxSimultaneousLights: int;
  115232. /**
  115233. * Default configuration related to image processing available in the Background Material.
  115234. */
  115235. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  115236. /**
  115237. * Keep track of the image processing observer to allow dispose and replace.
  115238. */
  115239. private _imageProcessingObserver;
  115240. /**
  115241. * Attaches a new image processing configuration to the PBR Material.
  115242. * @param configuration (if null the scene configuration will be use)
  115243. */
  115244. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  115245. /**
  115246. * Gets the image processing configuration used either in this material.
  115247. */
  115248. /**
  115249. * Sets the Default image processing configuration used either in the this material.
  115250. *
  115251. * If sets to null, the scene one is in use.
  115252. */
  115253. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  115254. /**
  115255. * Gets wether the color curves effect is enabled.
  115256. */
  115257. /**
  115258. * Sets wether the color curves effect is enabled.
  115259. */
  115260. cameraColorCurvesEnabled: boolean;
  115261. /**
  115262. * Gets wether the color grading effect is enabled.
  115263. */
  115264. /**
  115265. * Gets wether the color grading effect is enabled.
  115266. */
  115267. cameraColorGradingEnabled: boolean;
  115268. /**
  115269. * Gets wether tonemapping is enabled or not.
  115270. */
  115271. /**
  115272. * Sets wether tonemapping is enabled or not
  115273. */
  115274. cameraToneMappingEnabled: boolean;
  115275. /**
  115276. * The camera exposure used on this material.
  115277. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  115278. * This corresponds to a photographic exposure.
  115279. */
  115280. /**
  115281. * The camera exposure used on this material.
  115282. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  115283. * This corresponds to a photographic exposure.
  115284. */
  115285. cameraExposure: float;
  115286. /**
  115287. * Gets The camera contrast used on this material.
  115288. */
  115289. /**
  115290. * Sets The camera contrast used on this material.
  115291. */
  115292. cameraContrast: float;
  115293. /**
  115294. * Gets the Color Grading 2D Lookup Texture.
  115295. */
  115296. /**
  115297. * Sets the Color Grading 2D Lookup Texture.
  115298. */
  115299. cameraColorGradingTexture: Nullable<BaseTexture>;
  115300. /**
  115301. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  115302. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  115303. * 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;
  115304. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  115305. */
  115306. /**
  115307. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  115308. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  115309. * 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;
  115310. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  115311. */
  115312. cameraColorCurves: Nullable<ColorCurves>;
  115313. /**
  115314. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  115315. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  115316. */
  115317. switchToBGR: boolean;
  115318. private _renderTargets;
  115319. private _reflectionControls;
  115320. private _white;
  115321. private _primaryShadowColor;
  115322. private _primaryHighlightColor;
  115323. /**
  115324. * Instantiates a Background Material in the given scene
  115325. * @param name The friendly name of the material
  115326. * @param scene The scene to add the material to
  115327. */
  115328. constructor(name: string, scene: Scene);
  115329. /**
  115330. * Gets a boolean indicating that current material needs to register RTT
  115331. */
  115332. readonly hasRenderTargetTextures: boolean;
  115333. /**
  115334. * The entire material has been created in order to prevent overdraw.
  115335. * @returns false
  115336. */
  115337. needAlphaTesting(): boolean;
  115338. /**
  115339. * The entire material has been created in order to prevent overdraw.
  115340. * @returns true if blending is enable
  115341. */
  115342. needAlphaBlending(): boolean;
  115343. /**
  115344. * Checks wether the material is ready to be rendered for a given mesh.
  115345. * @param mesh The mesh to render
  115346. * @param subMesh The submesh to check against
  115347. * @param useInstances Specify wether or not the material is used with instances
  115348. * @returns true if all the dependencies are ready (Textures, Effects...)
  115349. */
  115350. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  115351. /**
  115352. * Compute the primary color according to the chosen perceptual color.
  115353. */
  115354. private _computePrimaryColorFromPerceptualColor;
  115355. /**
  115356. * Compute the highlights and shadow colors according to their chosen levels.
  115357. */
  115358. private _computePrimaryColors;
  115359. /**
  115360. * Build the uniform buffer used in the material.
  115361. */
  115362. buildUniformLayout(): void;
  115363. /**
  115364. * Unbind the material.
  115365. */
  115366. unbind(): void;
  115367. /**
  115368. * Bind only the world matrix to the material.
  115369. * @param world The world matrix to bind.
  115370. */
  115371. bindOnlyWorldMatrix(world: Matrix): void;
  115372. /**
  115373. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  115374. * @param world The world matrix to bind.
  115375. * @param subMesh The submesh to bind for.
  115376. */
  115377. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  115378. /**
  115379. * Checks to see if a texture is used in the material.
  115380. * @param texture - Base texture to use.
  115381. * @returns - Boolean specifying if a texture is used in the material.
  115382. */
  115383. hasTexture(texture: BaseTexture): boolean;
  115384. /**
  115385. * Dispose the material.
  115386. * @param forceDisposeEffect Force disposal of the associated effect.
  115387. * @param forceDisposeTextures Force disposal of the associated textures.
  115388. */
  115389. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  115390. /**
  115391. * Clones the material.
  115392. * @param name The cloned name.
  115393. * @returns The cloned material.
  115394. */
  115395. clone(name: string): BackgroundMaterial;
  115396. /**
  115397. * Serializes the current material to its JSON representation.
  115398. * @returns The JSON representation.
  115399. */
  115400. serialize(): any;
  115401. /**
  115402. * Gets the class name of the material
  115403. * @returns "BackgroundMaterial"
  115404. */
  115405. getClassName(): string;
  115406. /**
  115407. * Parse a JSON input to create back a background material.
  115408. * @param source The JSON data to parse
  115409. * @param scene The scene to create the parsed material in
  115410. * @param rootUrl The root url of the assets the material depends upon
  115411. * @returns the instantiated BackgroundMaterial.
  115412. */
  115413. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  115414. }
  115415. }
  115416. declare module BABYLON {
  115417. /**
  115418. * Represents the different options available during the creation of
  115419. * a Environment helper.
  115420. *
  115421. * This can control the default ground, skybox and image processing setup of your scene.
  115422. */
  115423. export interface IEnvironmentHelperOptions {
  115424. /**
  115425. * Specifies wether or not to create a ground.
  115426. * True by default.
  115427. */
  115428. createGround: boolean;
  115429. /**
  115430. * Specifies the ground size.
  115431. * 15 by default.
  115432. */
  115433. groundSize: number;
  115434. /**
  115435. * The texture used on the ground for the main color.
  115436. * Comes from the BabylonJS CDN by default.
  115437. *
  115438. * Remarks: Can be either a texture or a url.
  115439. */
  115440. groundTexture: string | BaseTexture;
  115441. /**
  115442. * The color mixed in the ground texture by default.
  115443. * BabylonJS clearColor by default.
  115444. */
  115445. groundColor: Color3;
  115446. /**
  115447. * Specifies the ground opacity.
  115448. * 1 by default.
  115449. */
  115450. groundOpacity: number;
  115451. /**
  115452. * Enables the ground to receive shadows.
  115453. * True by default.
  115454. */
  115455. enableGroundShadow: boolean;
  115456. /**
  115457. * Helps preventing the shadow to be fully black on the ground.
  115458. * 0.5 by default.
  115459. */
  115460. groundShadowLevel: number;
  115461. /**
  115462. * Creates a mirror texture attach to the ground.
  115463. * false by default.
  115464. */
  115465. enableGroundMirror: boolean;
  115466. /**
  115467. * Specifies the ground mirror size ratio.
  115468. * 0.3 by default as the default kernel is 64.
  115469. */
  115470. groundMirrorSizeRatio: number;
  115471. /**
  115472. * Specifies the ground mirror blur kernel size.
  115473. * 64 by default.
  115474. */
  115475. groundMirrorBlurKernel: number;
  115476. /**
  115477. * Specifies the ground mirror visibility amount.
  115478. * 1 by default
  115479. */
  115480. groundMirrorAmount: number;
  115481. /**
  115482. * Specifies the ground mirror reflectance weight.
  115483. * This uses the standard weight of the background material to setup the fresnel effect
  115484. * of the mirror.
  115485. * 1 by default.
  115486. */
  115487. groundMirrorFresnelWeight: number;
  115488. /**
  115489. * Specifies the ground mirror Falloff distance.
  115490. * This can helps reducing the size of the reflection.
  115491. * 0 by Default.
  115492. */
  115493. groundMirrorFallOffDistance: number;
  115494. /**
  115495. * Specifies the ground mirror texture type.
  115496. * Unsigned Int by Default.
  115497. */
  115498. groundMirrorTextureType: number;
  115499. /**
  115500. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  115501. * the shown objects.
  115502. */
  115503. groundYBias: number;
  115504. /**
  115505. * Specifies wether or not to create a skybox.
  115506. * True by default.
  115507. */
  115508. createSkybox: boolean;
  115509. /**
  115510. * Specifies the skybox size.
  115511. * 20 by default.
  115512. */
  115513. skyboxSize: number;
  115514. /**
  115515. * The texture used on the skybox for the main color.
  115516. * Comes from the BabylonJS CDN by default.
  115517. *
  115518. * Remarks: Can be either a texture or a url.
  115519. */
  115520. skyboxTexture: string | BaseTexture;
  115521. /**
  115522. * The color mixed in the skybox texture by default.
  115523. * BabylonJS clearColor by default.
  115524. */
  115525. skyboxColor: Color3;
  115526. /**
  115527. * The background rotation around the Y axis of the scene.
  115528. * This helps aligning the key lights of your scene with the background.
  115529. * 0 by default.
  115530. */
  115531. backgroundYRotation: number;
  115532. /**
  115533. * Compute automatically the size of the elements to best fit with the scene.
  115534. */
  115535. sizeAuto: boolean;
  115536. /**
  115537. * Default position of the rootMesh if autoSize is not true.
  115538. */
  115539. rootPosition: Vector3;
  115540. /**
  115541. * Sets up the image processing in the scene.
  115542. * true by default.
  115543. */
  115544. setupImageProcessing: boolean;
  115545. /**
  115546. * The texture used as your environment texture in the scene.
  115547. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  115548. *
  115549. * Remarks: Can be either a texture or a url.
  115550. */
  115551. environmentTexture: string | BaseTexture;
  115552. /**
  115553. * The value of the exposure to apply to the scene.
  115554. * 0.6 by default if setupImageProcessing is true.
  115555. */
  115556. cameraExposure: number;
  115557. /**
  115558. * The value of the contrast to apply to the scene.
  115559. * 1.6 by default if setupImageProcessing is true.
  115560. */
  115561. cameraContrast: number;
  115562. /**
  115563. * Specifies wether or not tonemapping should be enabled in the scene.
  115564. * true by default if setupImageProcessing is true.
  115565. */
  115566. toneMappingEnabled: boolean;
  115567. }
  115568. /**
  115569. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  115570. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  115571. * It also helps with the default setup of your imageProcessing configuration.
  115572. */
  115573. export class EnvironmentHelper {
  115574. /**
  115575. * Default ground texture URL.
  115576. */
  115577. private static _groundTextureCDNUrl;
  115578. /**
  115579. * Default skybox texture URL.
  115580. */
  115581. private static _skyboxTextureCDNUrl;
  115582. /**
  115583. * Default environment texture URL.
  115584. */
  115585. private static _environmentTextureCDNUrl;
  115586. /**
  115587. * Creates the default options for the helper.
  115588. */
  115589. private static _getDefaultOptions;
  115590. private _rootMesh;
  115591. /**
  115592. * Gets the root mesh created by the helper.
  115593. */
  115594. readonly rootMesh: Mesh;
  115595. private _skybox;
  115596. /**
  115597. * Gets the skybox created by the helper.
  115598. */
  115599. readonly skybox: Nullable<Mesh>;
  115600. private _skyboxTexture;
  115601. /**
  115602. * Gets the skybox texture created by the helper.
  115603. */
  115604. readonly skyboxTexture: Nullable<BaseTexture>;
  115605. private _skyboxMaterial;
  115606. /**
  115607. * Gets the skybox material created by the helper.
  115608. */
  115609. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  115610. private _ground;
  115611. /**
  115612. * Gets the ground mesh created by the helper.
  115613. */
  115614. readonly ground: Nullable<Mesh>;
  115615. private _groundTexture;
  115616. /**
  115617. * Gets the ground texture created by the helper.
  115618. */
  115619. readonly groundTexture: Nullable<BaseTexture>;
  115620. private _groundMirror;
  115621. /**
  115622. * Gets the ground mirror created by the helper.
  115623. */
  115624. readonly groundMirror: Nullable<MirrorTexture>;
  115625. /**
  115626. * Gets the ground mirror render list to helps pushing the meshes
  115627. * you wish in the ground reflection.
  115628. */
  115629. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  115630. private _groundMaterial;
  115631. /**
  115632. * Gets the ground material created by the helper.
  115633. */
  115634. readonly groundMaterial: Nullable<BackgroundMaterial>;
  115635. /**
  115636. * Stores the creation options.
  115637. */
  115638. private readonly _scene;
  115639. private _options;
  115640. /**
  115641. * This observable will be notified with any error during the creation of the environment,
  115642. * mainly texture creation errors.
  115643. */
  115644. onErrorObservable: Observable<{
  115645. message?: string;
  115646. exception?: any;
  115647. }>;
  115648. /**
  115649. * constructor
  115650. * @param options Defines the options we want to customize the helper
  115651. * @param scene The scene to add the material to
  115652. */
  115653. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  115654. /**
  115655. * Updates the background according to the new options
  115656. * @param options
  115657. */
  115658. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  115659. /**
  115660. * Sets the primary color of all the available elements.
  115661. * @param color the main color to affect to the ground and the background
  115662. */
  115663. setMainColor(color: Color3): void;
  115664. /**
  115665. * Setup the image processing according to the specified options.
  115666. */
  115667. private _setupImageProcessing;
  115668. /**
  115669. * Setup the environment texture according to the specified options.
  115670. */
  115671. private _setupEnvironmentTexture;
  115672. /**
  115673. * Setup the background according to the specified options.
  115674. */
  115675. private _setupBackground;
  115676. /**
  115677. * Get the scene sizes according to the setup.
  115678. */
  115679. private _getSceneSize;
  115680. /**
  115681. * Setup the ground according to the specified options.
  115682. */
  115683. private _setupGround;
  115684. /**
  115685. * Setup the ground material according to the specified options.
  115686. */
  115687. private _setupGroundMaterial;
  115688. /**
  115689. * Setup the ground diffuse texture according to the specified options.
  115690. */
  115691. private _setupGroundDiffuseTexture;
  115692. /**
  115693. * Setup the ground mirror texture according to the specified options.
  115694. */
  115695. private _setupGroundMirrorTexture;
  115696. /**
  115697. * Setup the ground to receive the mirror texture.
  115698. */
  115699. private _setupMirrorInGroundMaterial;
  115700. /**
  115701. * Setup the skybox according to the specified options.
  115702. */
  115703. private _setupSkybox;
  115704. /**
  115705. * Setup the skybox material according to the specified options.
  115706. */
  115707. private _setupSkyboxMaterial;
  115708. /**
  115709. * Setup the skybox reflection texture according to the specified options.
  115710. */
  115711. private _setupSkyboxReflectionTexture;
  115712. private _errorHandler;
  115713. /**
  115714. * Dispose all the elements created by the Helper.
  115715. */
  115716. dispose(): void;
  115717. }
  115718. }
  115719. declare module BABYLON {
  115720. /**
  115721. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  115722. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  115723. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  115724. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  115725. */
  115726. export class PhotoDome extends TransformNode {
  115727. /**
  115728. * Define the image as a Monoscopic panoramic 360 image.
  115729. */
  115730. static readonly MODE_MONOSCOPIC: number;
  115731. /**
  115732. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  115733. */
  115734. static readonly MODE_TOPBOTTOM: number;
  115735. /**
  115736. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  115737. */
  115738. static readonly MODE_SIDEBYSIDE: number;
  115739. private _useDirectMapping;
  115740. /**
  115741. * The texture being displayed on the sphere
  115742. */
  115743. protected _photoTexture: Texture;
  115744. /**
  115745. * Gets or sets the texture being displayed on the sphere
  115746. */
  115747. photoTexture: Texture;
  115748. /**
  115749. * Observable raised when an error occured while loading the 360 image
  115750. */
  115751. onLoadErrorObservable: Observable<string>;
  115752. /**
  115753. * The skybox material
  115754. */
  115755. protected _material: BackgroundMaterial;
  115756. /**
  115757. * The surface used for the skybox
  115758. */
  115759. protected _mesh: Mesh;
  115760. /**
  115761. * Gets the mesh used for the skybox.
  115762. */
  115763. readonly mesh: Mesh;
  115764. /**
  115765. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  115766. * Also see the options.resolution property.
  115767. */
  115768. fovMultiplier: number;
  115769. private _imageMode;
  115770. /**
  115771. * Gets or set the current video mode for the video. It can be:
  115772. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  115773. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  115774. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  115775. */
  115776. imageMode: number;
  115777. /**
  115778. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  115779. * @param name Element's name, child elements will append suffixes for their own names.
  115780. * @param urlsOfPhoto defines the url of the photo to display
  115781. * @param options defines an object containing optional or exposed sub element properties
  115782. * @param onError defines a callback called when an error occured while loading the texture
  115783. */
  115784. constructor(name: string, urlOfPhoto: string, options: {
  115785. resolution?: number;
  115786. size?: number;
  115787. useDirectMapping?: boolean;
  115788. faceForward?: boolean;
  115789. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  115790. private _onBeforeCameraRenderObserver;
  115791. private _changeImageMode;
  115792. /**
  115793. * Releases resources associated with this node.
  115794. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  115795. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  115796. */
  115797. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  115798. }
  115799. }
  115800. declare module BABYLON {
  115801. /**
  115802. * Class used to host RGBD texture specific utilities
  115803. */
  115804. export class RGBDTextureTools {
  115805. /**
  115806. * Expand the RGBD Texture from RGBD to Half Float if possible.
  115807. * @param texture the texture to expand.
  115808. */
  115809. static ExpandRGBDTexture(texture: Texture): void;
  115810. }
  115811. }
  115812. declare module BABYLON {
  115813. /**
  115814. * Class used to host texture specific utilities
  115815. */
  115816. export class BRDFTextureTools {
  115817. /**
  115818. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  115819. * @param scene defines the hosting scene
  115820. * @returns the environment BRDF texture
  115821. */
  115822. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  115823. private static _environmentBRDFBase64Texture;
  115824. }
  115825. }
  115826. declare module BABYLON {
  115827. /**
  115828. * @hidden
  115829. */
  115830. export interface IMaterialClearCoatDefines {
  115831. CLEARCOAT: boolean;
  115832. CLEARCOAT_DEFAULTIOR: boolean;
  115833. CLEARCOAT_TEXTURE: boolean;
  115834. CLEARCOAT_TEXTUREDIRECTUV: number;
  115835. CLEARCOAT_BUMP: boolean;
  115836. CLEARCOAT_BUMPDIRECTUV: number;
  115837. CLEARCOAT_TINT: boolean;
  115838. CLEARCOAT_TINT_TEXTURE: boolean;
  115839. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  115840. /** @hidden */
  115841. _areTexturesDirty: boolean;
  115842. }
  115843. /**
  115844. * Define the code related to the clear coat parameters of the pbr material.
  115845. */
  115846. export class PBRClearCoatConfiguration {
  115847. /**
  115848. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  115849. * The default fits with a polyurethane material.
  115850. */
  115851. private static readonly _DefaultIndexOfRefraction;
  115852. private _isEnabled;
  115853. /**
  115854. * Defines if the clear coat is enabled in the material.
  115855. */
  115856. isEnabled: boolean;
  115857. /**
  115858. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  115859. */
  115860. intensity: number;
  115861. /**
  115862. * Defines the clear coat layer roughness.
  115863. */
  115864. roughness: number;
  115865. private _indexOfRefraction;
  115866. /**
  115867. * Defines the index of refraction of the clear coat.
  115868. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  115869. * The default fits with a polyurethane material.
  115870. * Changing the default value is more performance intensive.
  115871. */
  115872. indexOfRefraction: number;
  115873. private _texture;
  115874. /**
  115875. * Stores the clear coat values in a texture.
  115876. */
  115877. texture: Nullable<BaseTexture>;
  115878. private _bumpTexture;
  115879. /**
  115880. * Define the clear coat specific bump texture.
  115881. */
  115882. bumpTexture: Nullable<BaseTexture>;
  115883. private _isTintEnabled;
  115884. /**
  115885. * Defines if the clear coat tint is enabled in the material.
  115886. */
  115887. isTintEnabled: boolean;
  115888. /**
  115889. * Defines the clear coat tint of the material.
  115890. * This is only use if tint is enabled
  115891. */
  115892. tintColor: Color3;
  115893. /**
  115894. * Defines the distance at which the tint color should be found in the
  115895. * clear coat media.
  115896. * This is only use if tint is enabled
  115897. */
  115898. tintColorAtDistance: number;
  115899. /**
  115900. * Defines the clear coat layer thickness.
  115901. * This is only use if tint is enabled
  115902. */
  115903. tintThickness: number;
  115904. private _tintTexture;
  115905. /**
  115906. * Stores the clear tint values in a texture.
  115907. * rgb is tint
  115908. * a is a thickness factor
  115909. */
  115910. tintTexture: Nullable<BaseTexture>;
  115911. /** @hidden */
  115912. private _internalMarkAllSubMeshesAsTexturesDirty;
  115913. /** @hidden */
  115914. _markAllSubMeshesAsTexturesDirty(): void;
  115915. /**
  115916. * Instantiate a new istance of clear coat configuration.
  115917. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  115918. */
  115919. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  115920. /**
  115921. * Gets wehter the submesh is ready to be used or not.
  115922. * @param defines the list of "defines" to update.
  115923. * @param scene defines the scene the material belongs to.
  115924. * @param engine defines the engine the material belongs to.
  115925. * @param disableBumpMap defines wether the material disables bump or not.
  115926. * @returns - boolean indicating that the submesh is ready or not.
  115927. */
  115928. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  115929. /**
  115930. * Checks to see if a texture is used in the material.
  115931. * @param defines the list of "defines" to update.
  115932. * @param scene defines the scene to the material belongs to.
  115933. */
  115934. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  115935. /**
  115936. * Binds the material data.
  115937. * @param uniformBuffer defines the Uniform buffer to fill in.
  115938. * @param scene defines the scene the material belongs to.
  115939. * @param engine defines the engine the material belongs to.
  115940. * @param disableBumpMap defines wether the material disables bump or not.
  115941. * @param isFrozen defines wether the material is frozen or not.
  115942. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  115943. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  115944. */
  115945. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  115946. /**
  115947. * Checks to see if a texture is used in the material.
  115948. * @param texture - Base texture to use.
  115949. * @returns - Boolean specifying if a texture is used in the material.
  115950. */
  115951. hasTexture(texture: BaseTexture): boolean;
  115952. /**
  115953. * Returns an array of the actively used textures.
  115954. * @param activeTextures Array of BaseTextures
  115955. */
  115956. getActiveTextures(activeTextures: BaseTexture[]): void;
  115957. /**
  115958. * Returns the animatable textures.
  115959. * @param animatables Array of animatable textures.
  115960. */
  115961. getAnimatables(animatables: IAnimatable[]): void;
  115962. /**
  115963. * Disposes the resources of the material.
  115964. * @param forceDisposeTextures - Forces the disposal of all textures.
  115965. */
  115966. dispose(forceDisposeTextures?: boolean): void;
  115967. /**
  115968. * Get the current class name of the texture useful for serialization or dynamic coding.
  115969. * @returns "PBRClearCoatConfiguration"
  115970. */
  115971. getClassName(): string;
  115972. /**
  115973. * Add fallbacks to the effect fallbacks list.
  115974. * @param defines defines the Base texture to use.
  115975. * @param fallbacks defines the current fallback list.
  115976. * @param currentRank defines the current fallback rank.
  115977. * @returns the new fallback rank.
  115978. */
  115979. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  115980. /**
  115981. * Add the required uniforms to the current list.
  115982. * @param uniforms defines the current uniform list.
  115983. */
  115984. static AddUniforms(uniforms: string[]): void;
  115985. /**
  115986. * Add the required samplers to the current list.
  115987. * @param samplers defines the current sampler list.
  115988. */
  115989. static AddSamplers(samplers: string[]): void;
  115990. /**
  115991. * Add the required uniforms to the current buffer.
  115992. * @param uniformBuffer defines the current uniform buffer.
  115993. */
  115994. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  115995. /**
  115996. * Makes a duplicate of the current configuration into another one.
  115997. * @param clearCoatConfiguration define the config where to copy the info
  115998. */
  115999. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  116000. /**
  116001. * Serializes this clear coat configuration.
  116002. * @returns - An object with the serialized config.
  116003. */
  116004. serialize(): any;
  116005. /**
  116006. * Parses a anisotropy Configuration from a serialized object.
  116007. * @param source - Serialized object.
  116008. * @param scene Defines the scene we are parsing for
  116009. * @param rootUrl Defines the rootUrl to load from
  116010. */
  116011. parse(source: any, scene: Scene, rootUrl: string): void;
  116012. }
  116013. }
  116014. declare module BABYLON {
  116015. /**
  116016. * @hidden
  116017. */
  116018. export interface IMaterialAnisotropicDefines {
  116019. ANISOTROPIC: boolean;
  116020. ANISOTROPIC_TEXTURE: boolean;
  116021. ANISOTROPIC_TEXTUREDIRECTUV: number;
  116022. MAINUV1: boolean;
  116023. _areTexturesDirty: boolean;
  116024. _needUVs: boolean;
  116025. }
  116026. /**
  116027. * Define the code related to the anisotropic parameters of the pbr material.
  116028. */
  116029. export class PBRAnisotropicConfiguration {
  116030. private _isEnabled;
  116031. /**
  116032. * Defines if the anisotropy is enabled in the material.
  116033. */
  116034. isEnabled: boolean;
  116035. /**
  116036. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  116037. */
  116038. intensity: number;
  116039. /**
  116040. * Defines if the effect is along the tangents, bitangents or in between.
  116041. * By default, the effect is "strectching" the highlights along the tangents.
  116042. */
  116043. direction: Vector2;
  116044. private _texture;
  116045. /**
  116046. * Stores the anisotropy values in a texture.
  116047. * rg is direction (like normal from -1 to 1)
  116048. * b is a intensity
  116049. */
  116050. texture: Nullable<BaseTexture>;
  116051. /** @hidden */
  116052. private _internalMarkAllSubMeshesAsTexturesDirty;
  116053. /** @hidden */
  116054. _markAllSubMeshesAsTexturesDirty(): void;
  116055. /**
  116056. * Instantiate a new istance of anisotropy configuration.
  116057. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  116058. */
  116059. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  116060. /**
  116061. * Specifies that the submesh is ready to be used.
  116062. * @param defines the list of "defines" to update.
  116063. * @param scene defines the scene the material belongs to.
  116064. * @returns - boolean indicating that the submesh is ready or not.
  116065. */
  116066. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  116067. /**
  116068. * Checks to see if a texture is used in the material.
  116069. * @param defines the list of "defines" to update.
  116070. * @param mesh the mesh we are preparing the defines for.
  116071. * @param scene defines the scene the material belongs to.
  116072. */
  116073. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  116074. /**
  116075. * Binds the material data.
  116076. * @param uniformBuffer defines the Uniform buffer to fill in.
  116077. * @param scene defines the scene the material belongs to.
  116078. * @param isFrozen defines wether the material is frozen or not.
  116079. */
  116080. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  116081. /**
  116082. * Checks to see if a texture is used in the material.
  116083. * @param texture - Base texture to use.
  116084. * @returns - Boolean specifying if a texture is used in the material.
  116085. */
  116086. hasTexture(texture: BaseTexture): boolean;
  116087. /**
  116088. * Returns an array of the actively used textures.
  116089. * @param activeTextures Array of BaseTextures
  116090. */
  116091. getActiveTextures(activeTextures: BaseTexture[]): void;
  116092. /**
  116093. * Returns the animatable textures.
  116094. * @param animatables Array of animatable textures.
  116095. */
  116096. getAnimatables(animatables: IAnimatable[]): void;
  116097. /**
  116098. * Disposes the resources of the material.
  116099. * @param forceDisposeTextures - Forces the disposal of all textures.
  116100. */
  116101. dispose(forceDisposeTextures?: boolean): void;
  116102. /**
  116103. * Get the current class name of the texture useful for serialization or dynamic coding.
  116104. * @returns "PBRAnisotropicConfiguration"
  116105. */
  116106. getClassName(): string;
  116107. /**
  116108. * Add fallbacks to the effect fallbacks list.
  116109. * @param defines defines the Base texture to use.
  116110. * @param fallbacks defines the current fallback list.
  116111. * @param currentRank defines the current fallback rank.
  116112. * @returns the new fallback rank.
  116113. */
  116114. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  116115. /**
  116116. * Add the required uniforms to the current list.
  116117. * @param uniforms defines the current uniform list.
  116118. */
  116119. static AddUniforms(uniforms: string[]): void;
  116120. /**
  116121. * Add the required uniforms to the current buffer.
  116122. * @param uniformBuffer defines the current uniform buffer.
  116123. */
  116124. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  116125. /**
  116126. * Add the required samplers to the current list.
  116127. * @param samplers defines the current sampler list.
  116128. */
  116129. static AddSamplers(samplers: string[]): void;
  116130. /**
  116131. * Makes a duplicate of the current configuration into another one.
  116132. * @param anisotropicConfiguration define the config where to copy the info
  116133. */
  116134. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  116135. /**
  116136. * Serializes this anisotropy configuration.
  116137. * @returns - An object with the serialized config.
  116138. */
  116139. serialize(): any;
  116140. /**
  116141. * Parses a anisotropy Configuration from a serialized object.
  116142. * @param source - Serialized object.
  116143. * @param scene Defines the scene we are parsing for
  116144. * @param rootUrl Defines the rootUrl to load from
  116145. */
  116146. parse(source: any, scene: Scene, rootUrl: string): void;
  116147. }
  116148. }
  116149. declare module BABYLON {
  116150. /**
  116151. * @hidden
  116152. */
  116153. export interface IMaterialBRDFDefines {
  116154. BRDF_V_HEIGHT_CORRELATED: boolean;
  116155. MS_BRDF_ENERGY_CONSERVATION: boolean;
  116156. SPHERICAL_HARMONICS: boolean;
  116157. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  116158. /** @hidden */
  116159. _areMiscDirty: boolean;
  116160. }
  116161. /**
  116162. * Define the code related to the BRDF parameters of the pbr material.
  116163. */
  116164. export class PBRBRDFConfiguration {
  116165. /**
  116166. * Default value used for the energy conservation.
  116167. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  116168. */
  116169. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  116170. /**
  116171. * Default value used for the Smith Visibility Height Correlated mode.
  116172. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  116173. */
  116174. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  116175. /**
  116176. * Default value used for the IBL diffuse part.
  116177. * This can help switching back to the polynomials mode globally which is a tiny bit
  116178. * less GPU intensive at the drawback of a lower quality.
  116179. */
  116180. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  116181. /**
  116182. * Default value used for activating energy conservation for the specular workflow.
  116183. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  116184. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  116185. */
  116186. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  116187. private _useEnergyConservation;
  116188. /**
  116189. * Defines if the material uses energy conservation.
  116190. */
  116191. useEnergyConservation: boolean;
  116192. private _useSmithVisibilityHeightCorrelated;
  116193. /**
  116194. * LEGACY Mode set to false
  116195. * Defines if the material uses height smith correlated visibility term.
  116196. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  116197. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  116198. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  116199. * Not relying on height correlated will also disable energy conservation.
  116200. */
  116201. useSmithVisibilityHeightCorrelated: boolean;
  116202. private _useSphericalHarmonics;
  116203. /**
  116204. * LEGACY Mode set to false
  116205. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  116206. * diffuse part of the IBL.
  116207. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  116208. * to the ground truth.
  116209. */
  116210. useSphericalHarmonics: boolean;
  116211. private _useSpecularGlossinessInputEnergyConservation;
  116212. /**
  116213. * Defines if the material uses energy conservation, when the specular workflow is active.
  116214. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  116215. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  116216. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  116217. */
  116218. useSpecularGlossinessInputEnergyConservation: boolean;
  116219. /** @hidden */
  116220. private _internalMarkAllSubMeshesAsMiscDirty;
  116221. /** @hidden */
  116222. _markAllSubMeshesAsMiscDirty(): void;
  116223. /**
  116224. * Instantiate a new istance of clear coat configuration.
  116225. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  116226. */
  116227. constructor(markAllSubMeshesAsMiscDirty: () => void);
  116228. /**
  116229. * Checks to see if a texture is used in the material.
  116230. * @param defines the list of "defines" to update.
  116231. */
  116232. prepareDefines(defines: IMaterialBRDFDefines): void;
  116233. /**
  116234. * Get the current class name of the texture useful for serialization or dynamic coding.
  116235. * @returns "PBRClearCoatConfiguration"
  116236. */
  116237. getClassName(): string;
  116238. /**
  116239. * Makes a duplicate of the current configuration into another one.
  116240. * @param brdfConfiguration define the config where to copy the info
  116241. */
  116242. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  116243. /**
  116244. * Serializes this BRDF configuration.
  116245. * @returns - An object with the serialized config.
  116246. */
  116247. serialize(): any;
  116248. /**
  116249. * Parses a anisotropy Configuration from a serialized object.
  116250. * @param source - Serialized object.
  116251. * @param scene Defines the scene we are parsing for
  116252. * @param rootUrl Defines the rootUrl to load from
  116253. */
  116254. parse(source: any, scene: Scene, rootUrl: string): void;
  116255. }
  116256. }
  116257. declare module BABYLON {
  116258. /**
  116259. * @hidden
  116260. */
  116261. export interface IMaterialSheenDefines {
  116262. SHEEN: boolean;
  116263. SHEEN_TEXTURE: boolean;
  116264. SHEEN_TEXTUREDIRECTUV: number;
  116265. SHEEN_LINKWITHALBEDO: boolean;
  116266. /** @hidden */
  116267. _areTexturesDirty: boolean;
  116268. }
  116269. /**
  116270. * Define the code related to the Sheen parameters of the pbr material.
  116271. */
  116272. export class PBRSheenConfiguration {
  116273. private _isEnabled;
  116274. /**
  116275. * Defines if the material uses sheen.
  116276. */
  116277. isEnabled: boolean;
  116278. private _linkSheenWithAlbedo;
  116279. /**
  116280. * Defines if the sheen is linked to the sheen color.
  116281. */
  116282. linkSheenWithAlbedo: boolean;
  116283. /**
  116284. * Defines the sheen intensity.
  116285. */
  116286. intensity: number;
  116287. /**
  116288. * Defines the sheen color.
  116289. */
  116290. color: Color3;
  116291. private _texture;
  116292. /**
  116293. * Stores the sheen tint values in a texture.
  116294. * rgb is tint
  116295. * a is a intensity
  116296. */
  116297. texture: Nullable<BaseTexture>;
  116298. /** @hidden */
  116299. private _internalMarkAllSubMeshesAsTexturesDirty;
  116300. /** @hidden */
  116301. _markAllSubMeshesAsTexturesDirty(): void;
  116302. /**
  116303. * Instantiate a new istance of clear coat configuration.
  116304. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  116305. */
  116306. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  116307. /**
  116308. * Specifies that the submesh is ready to be used.
  116309. * @param defines the list of "defines" to update.
  116310. * @param scene defines the scene the material belongs to.
  116311. * @returns - boolean indicating that the submesh is ready or not.
  116312. */
  116313. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  116314. /**
  116315. * Checks to see if a texture is used in the material.
  116316. * @param defines the list of "defines" to update.
  116317. * @param scene defines the scene the material belongs to.
  116318. */
  116319. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  116320. /**
  116321. * Binds the material data.
  116322. * @param uniformBuffer defines the Uniform buffer to fill in.
  116323. * @param scene defines the scene the material belongs to.
  116324. * @param isFrozen defines wether the material is frozen or not.
  116325. */
  116326. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  116327. /**
  116328. * Checks to see if a texture is used in the material.
  116329. * @param texture - Base texture to use.
  116330. * @returns - Boolean specifying if a texture is used in the material.
  116331. */
  116332. hasTexture(texture: BaseTexture): boolean;
  116333. /**
  116334. * Returns an array of the actively used textures.
  116335. * @param activeTextures Array of BaseTextures
  116336. */
  116337. getActiveTextures(activeTextures: BaseTexture[]): void;
  116338. /**
  116339. * Returns the animatable textures.
  116340. * @param animatables Array of animatable textures.
  116341. */
  116342. getAnimatables(animatables: IAnimatable[]): void;
  116343. /**
  116344. * Disposes the resources of the material.
  116345. * @param forceDisposeTextures - Forces the disposal of all textures.
  116346. */
  116347. dispose(forceDisposeTextures?: boolean): void;
  116348. /**
  116349. * Get the current class name of the texture useful for serialization or dynamic coding.
  116350. * @returns "PBRSheenConfiguration"
  116351. */
  116352. getClassName(): string;
  116353. /**
  116354. * Add fallbacks to the effect fallbacks list.
  116355. * @param defines defines the Base texture to use.
  116356. * @param fallbacks defines the current fallback list.
  116357. * @param currentRank defines the current fallback rank.
  116358. * @returns the new fallback rank.
  116359. */
  116360. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  116361. /**
  116362. * Add the required uniforms to the current list.
  116363. * @param uniforms defines the current uniform list.
  116364. */
  116365. static AddUniforms(uniforms: string[]): void;
  116366. /**
  116367. * Add the required uniforms to the current buffer.
  116368. * @param uniformBuffer defines the current uniform buffer.
  116369. */
  116370. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  116371. /**
  116372. * Add the required samplers to the current list.
  116373. * @param samplers defines the current sampler list.
  116374. */
  116375. static AddSamplers(samplers: string[]): void;
  116376. /**
  116377. * Makes a duplicate of the current configuration into another one.
  116378. * @param sheenConfiguration define the config where to copy the info
  116379. */
  116380. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  116381. /**
  116382. * Serializes this BRDF configuration.
  116383. * @returns - An object with the serialized config.
  116384. */
  116385. serialize(): any;
  116386. /**
  116387. * Parses a anisotropy Configuration from a serialized object.
  116388. * @param source - Serialized object.
  116389. * @param scene Defines the scene we are parsing for
  116390. * @param rootUrl Defines the rootUrl to load from
  116391. */
  116392. parse(source: any, scene: Scene, rootUrl: string): void;
  116393. }
  116394. }
  116395. declare module BABYLON {
  116396. /**
  116397. * @hidden
  116398. */
  116399. export interface IMaterialSubSurfaceDefines {
  116400. SUBSURFACE: boolean;
  116401. SS_REFRACTION: boolean;
  116402. SS_TRANSLUCENCY: boolean;
  116403. SS_SCATERRING: boolean;
  116404. SS_THICKNESSANDMASK_TEXTURE: boolean;
  116405. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  116406. SS_REFRACTIONMAP_3D: boolean;
  116407. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  116408. SS_LODINREFRACTIONALPHA: boolean;
  116409. SS_GAMMAREFRACTION: boolean;
  116410. SS_RGBDREFRACTION: boolean;
  116411. SS_LINEARSPECULARREFRACTION: boolean;
  116412. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  116413. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  116414. /** @hidden */
  116415. _areTexturesDirty: boolean;
  116416. }
  116417. /**
  116418. * Define the code related to the sub surface parameters of the pbr material.
  116419. */
  116420. export class PBRSubSurfaceConfiguration {
  116421. private _isRefractionEnabled;
  116422. /**
  116423. * Defines if the refraction is enabled in the material.
  116424. */
  116425. isRefractionEnabled: boolean;
  116426. private _isTranslucencyEnabled;
  116427. /**
  116428. * Defines if the translucency is enabled in the material.
  116429. */
  116430. isTranslucencyEnabled: boolean;
  116431. private _isScatteringEnabled;
  116432. /**
  116433. * Defines the refraction intensity of the material.
  116434. * The refraction when enabled replaces the Diffuse part of the material.
  116435. * The intensity helps transitionning between diffuse and refraction.
  116436. */
  116437. refractionIntensity: number;
  116438. /**
  116439. * Defines the translucency intensity of the material.
  116440. * When translucency has been enabled, this defines how much of the "translucency"
  116441. * is addded to the diffuse part of the material.
  116442. */
  116443. translucencyIntensity: number;
  116444. /**
  116445. * Defines the scattering intensity of the material.
  116446. * When scattering has been enabled, this defines how much of the "scattered light"
  116447. * is addded to the diffuse part of the material.
  116448. */
  116449. scatteringIntensity: number;
  116450. private _thicknessTexture;
  116451. /**
  116452. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  116453. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  116454. * 0 would mean minimumThickness
  116455. * 1 would mean maximumThickness
  116456. * The other channels might be use as a mask to vary the different effects intensity.
  116457. */
  116458. thicknessTexture: Nullable<BaseTexture>;
  116459. private _refractionTexture;
  116460. /**
  116461. * Defines the texture to use for refraction.
  116462. */
  116463. refractionTexture: Nullable<BaseTexture>;
  116464. private _indexOfRefraction;
  116465. /**
  116466. * Defines the index of refraction used in the material.
  116467. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  116468. */
  116469. indexOfRefraction: number;
  116470. private _invertRefractionY;
  116471. /**
  116472. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  116473. */
  116474. invertRefractionY: boolean;
  116475. private _linkRefractionWithTransparency;
  116476. /**
  116477. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  116478. * Materials half opaque for instance using refraction could benefit from this control.
  116479. */
  116480. linkRefractionWithTransparency: boolean;
  116481. /**
  116482. * Defines the minimum thickness stored in the thickness map.
  116483. * If no thickness map is defined, this value will be used to simulate thickness.
  116484. */
  116485. minimumThickness: number;
  116486. /**
  116487. * Defines the maximum thickness stored in the thickness map.
  116488. */
  116489. maximumThickness: number;
  116490. /**
  116491. * Defines the volume tint of the material.
  116492. * This is used for both translucency and scattering.
  116493. */
  116494. tintColor: Color3;
  116495. /**
  116496. * Defines the distance at which the tint color should be found in the media.
  116497. * This is used for refraction only.
  116498. */
  116499. tintColorAtDistance: number;
  116500. /**
  116501. * Defines how far each channel transmit through the media.
  116502. * It is defined as a color to simplify it selection.
  116503. */
  116504. diffusionDistance: Color3;
  116505. private _useMaskFromThicknessTexture;
  116506. /**
  116507. * Stores the intensity of the different subsurface effects in the thickness texture.
  116508. * * the green channel is the translucency intensity.
  116509. * * the blue channel is the scattering intensity.
  116510. * * the alpha channel is the refraction intensity.
  116511. */
  116512. useMaskFromThicknessTexture: boolean;
  116513. /** @hidden */
  116514. private _internalMarkAllSubMeshesAsTexturesDirty;
  116515. /** @hidden */
  116516. _markAllSubMeshesAsTexturesDirty(): void;
  116517. /**
  116518. * Instantiate a new istance of sub surface configuration.
  116519. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  116520. */
  116521. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  116522. /**
  116523. * Gets wehter the submesh is ready to be used or not.
  116524. * @param defines the list of "defines" to update.
  116525. * @param scene defines the scene the material belongs to.
  116526. * @returns - boolean indicating that the submesh is ready or not.
  116527. */
  116528. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  116529. /**
  116530. * Checks to see if a texture is used in the material.
  116531. * @param defines the list of "defines" to update.
  116532. * @param scene defines the scene to the material belongs to.
  116533. */
  116534. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  116535. /**
  116536. * Binds the material data.
  116537. * @param uniformBuffer defines the Uniform buffer to fill in.
  116538. * @param scene defines the scene the material belongs to.
  116539. * @param engine defines the engine the material belongs to.
  116540. * @param isFrozen defines wether the material is frozen or not.
  116541. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  116542. */
  116543. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  116544. /**
  116545. * Unbinds the material from the mesh.
  116546. * @param activeEffect defines the effect that should be unbound from.
  116547. * @returns true if unbound, otherwise false
  116548. */
  116549. unbind(activeEffect: Effect): boolean;
  116550. /**
  116551. * Returns the texture used for refraction or null if none is used.
  116552. * @param scene defines the scene the material belongs to.
  116553. * @returns - Refraction texture if present. If no refraction texture and refraction
  116554. * is linked with transparency, returns environment texture. Otherwise, returns null.
  116555. */
  116556. private _getRefractionTexture;
  116557. /**
  116558. * Returns true if alpha blending should be disabled.
  116559. */
  116560. readonly disableAlphaBlending: boolean;
  116561. /**
  116562. * Fills the list of render target textures.
  116563. * @param renderTargets the list of render targets to update
  116564. */
  116565. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  116566. /**
  116567. * Checks to see if a texture is used in the material.
  116568. * @param texture - Base texture to use.
  116569. * @returns - Boolean specifying if a texture is used in the material.
  116570. */
  116571. hasTexture(texture: BaseTexture): boolean;
  116572. /**
  116573. * Gets a boolean indicating that current material needs to register RTT
  116574. * @returns true if this uses a render target otherwise false.
  116575. */
  116576. hasRenderTargetTextures(): boolean;
  116577. /**
  116578. * Returns an array of the actively used textures.
  116579. * @param activeTextures Array of BaseTextures
  116580. */
  116581. getActiveTextures(activeTextures: BaseTexture[]): void;
  116582. /**
  116583. * Returns the animatable textures.
  116584. * @param animatables Array of animatable textures.
  116585. */
  116586. getAnimatables(animatables: IAnimatable[]): void;
  116587. /**
  116588. * Disposes the resources of the material.
  116589. * @param forceDisposeTextures - Forces the disposal of all textures.
  116590. */
  116591. dispose(forceDisposeTextures?: boolean): void;
  116592. /**
  116593. * Get the current class name of the texture useful for serialization or dynamic coding.
  116594. * @returns "PBRSubSurfaceConfiguration"
  116595. */
  116596. getClassName(): string;
  116597. /**
  116598. * Add fallbacks to the effect fallbacks list.
  116599. * @param defines defines the Base texture to use.
  116600. * @param fallbacks defines the current fallback list.
  116601. * @param currentRank defines the current fallback rank.
  116602. * @returns the new fallback rank.
  116603. */
  116604. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  116605. /**
  116606. * Add the required uniforms to the current list.
  116607. * @param uniforms defines the current uniform list.
  116608. */
  116609. static AddUniforms(uniforms: string[]): void;
  116610. /**
  116611. * Add the required samplers to the current list.
  116612. * @param samplers defines the current sampler list.
  116613. */
  116614. static AddSamplers(samplers: string[]): void;
  116615. /**
  116616. * Add the required uniforms to the current buffer.
  116617. * @param uniformBuffer defines the current uniform buffer.
  116618. */
  116619. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  116620. /**
  116621. * Makes a duplicate of the current configuration into another one.
  116622. * @param configuration define the config where to copy the info
  116623. */
  116624. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  116625. /**
  116626. * Serializes this Sub Surface configuration.
  116627. * @returns - An object with the serialized config.
  116628. */
  116629. serialize(): any;
  116630. /**
  116631. * Parses a anisotropy Configuration from a serialized object.
  116632. * @param source - Serialized object.
  116633. * @param scene Defines the scene we are parsing for
  116634. * @param rootUrl Defines the rootUrl to load from
  116635. */
  116636. parse(source: any, scene: Scene, rootUrl: string): void;
  116637. }
  116638. }
  116639. declare module BABYLON {
  116640. /** @hidden */
  116641. export var pbrFragmentDeclaration: {
  116642. name: string;
  116643. shader: string;
  116644. };
  116645. }
  116646. declare module BABYLON {
  116647. /** @hidden */
  116648. export var pbrUboDeclaration: {
  116649. name: string;
  116650. shader: string;
  116651. };
  116652. }
  116653. declare module BABYLON {
  116654. /** @hidden */
  116655. export var pbrFragmentExtraDeclaration: {
  116656. name: string;
  116657. shader: string;
  116658. };
  116659. }
  116660. declare module BABYLON {
  116661. /** @hidden */
  116662. export var pbrFragmentSamplersDeclaration: {
  116663. name: string;
  116664. shader: string;
  116665. };
  116666. }
  116667. declare module BABYLON {
  116668. /** @hidden */
  116669. export var pbrHelperFunctions: {
  116670. name: string;
  116671. shader: string;
  116672. };
  116673. }
  116674. declare module BABYLON {
  116675. /** @hidden */
  116676. export var harmonicsFunctions: {
  116677. name: string;
  116678. shader: string;
  116679. };
  116680. }
  116681. declare module BABYLON {
  116682. /** @hidden */
  116683. export var pbrDirectLightingSetupFunctions: {
  116684. name: string;
  116685. shader: string;
  116686. };
  116687. }
  116688. declare module BABYLON {
  116689. /** @hidden */
  116690. export var pbrDirectLightingFalloffFunctions: {
  116691. name: string;
  116692. shader: string;
  116693. };
  116694. }
  116695. declare module BABYLON {
  116696. /** @hidden */
  116697. export var pbrBRDFFunctions: {
  116698. name: string;
  116699. shader: string;
  116700. };
  116701. }
  116702. declare module BABYLON {
  116703. /** @hidden */
  116704. export var pbrDirectLightingFunctions: {
  116705. name: string;
  116706. shader: string;
  116707. };
  116708. }
  116709. declare module BABYLON {
  116710. /** @hidden */
  116711. export var pbrIBLFunctions: {
  116712. name: string;
  116713. shader: string;
  116714. };
  116715. }
  116716. declare module BABYLON {
  116717. /** @hidden */
  116718. export var pbrDebug: {
  116719. name: string;
  116720. shader: string;
  116721. };
  116722. }
  116723. declare module BABYLON {
  116724. /** @hidden */
  116725. export var pbrPixelShader: {
  116726. name: string;
  116727. shader: string;
  116728. };
  116729. }
  116730. declare module BABYLON {
  116731. /** @hidden */
  116732. export var pbrVertexDeclaration: {
  116733. name: string;
  116734. shader: string;
  116735. };
  116736. }
  116737. declare module BABYLON {
  116738. /** @hidden */
  116739. export var pbrVertexShader: {
  116740. name: string;
  116741. shader: string;
  116742. };
  116743. }
  116744. declare module BABYLON {
  116745. /**
  116746. * Manages the defines for the PBR Material.
  116747. * @hidden
  116748. */
  116749. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  116750. PBR: boolean;
  116751. MAINUV1: boolean;
  116752. MAINUV2: boolean;
  116753. UV1: boolean;
  116754. UV2: boolean;
  116755. ALBEDO: boolean;
  116756. ALBEDODIRECTUV: number;
  116757. VERTEXCOLOR: boolean;
  116758. AMBIENT: boolean;
  116759. AMBIENTDIRECTUV: number;
  116760. AMBIENTINGRAYSCALE: boolean;
  116761. OPACITY: boolean;
  116762. VERTEXALPHA: boolean;
  116763. OPACITYDIRECTUV: number;
  116764. OPACITYRGB: boolean;
  116765. ALPHATEST: boolean;
  116766. DEPTHPREPASS: boolean;
  116767. ALPHABLEND: boolean;
  116768. ALPHAFROMALBEDO: boolean;
  116769. ALPHATESTVALUE: string;
  116770. SPECULAROVERALPHA: boolean;
  116771. RADIANCEOVERALPHA: boolean;
  116772. ALPHAFRESNEL: boolean;
  116773. LINEARALPHAFRESNEL: boolean;
  116774. PREMULTIPLYALPHA: boolean;
  116775. EMISSIVE: boolean;
  116776. EMISSIVEDIRECTUV: number;
  116777. REFLECTIVITY: boolean;
  116778. REFLECTIVITYDIRECTUV: number;
  116779. SPECULARTERM: boolean;
  116780. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  116781. MICROSURFACEAUTOMATIC: boolean;
  116782. LODBASEDMICROSFURACE: boolean;
  116783. MICROSURFACEMAP: boolean;
  116784. MICROSURFACEMAPDIRECTUV: number;
  116785. METALLICWORKFLOW: boolean;
  116786. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  116787. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  116788. METALLNESSSTOREINMETALMAPBLUE: boolean;
  116789. AOSTOREINMETALMAPRED: boolean;
  116790. METALLICF0FACTORFROMMETALLICMAP: boolean;
  116791. ENVIRONMENTBRDF: boolean;
  116792. ENVIRONMENTBRDF_RGBD: boolean;
  116793. NORMAL: boolean;
  116794. TANGENT: boolean;
  116795. BUMP: boolean;
  116796. BUMPDIRECTUV: number;
  116797. OBJECTSPACE_NORMALMAP: boolean;
  116798. PARALLAX: boolean;
  116799. PARALLAXOCCLUSION: boolean;
  116800. NORMALXYSCALE: boolean;
  116801. LIGHTMAP: boolean;
  116802. LIGHTMAPDIRECTUV: number;
  116803. USELIGHTMAPASSHADOWMAP: boolean;
  116804. GAMMALIGHTMAP: boolean;
  116805. RGBDLIGHTMAP: boolean;
  116806. REFLECTION: boolean;
  116807. REFLECTIONMAP_3D: boolean;
  116808. REFLECTIONMAP_SPHERICAL: boolean;
  116809. REFLECTIONMAP_PLANAR: boolean;
  116810. REFLECTIONMAP_CUBIC: boolean;
  116811. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  116812. REFLECTIONMAP_PROJECTION: boolean;
  116813. REFLECTIONMAP_SKYBOX: boolean;
  116814. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  116815. REFLECTIONMAP_EXPLICIT: boolean;
  116816. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  116817. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  116818. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  116819. INVERTCUBICMAP: boolean;
  116820. USESPHERICALFROMREFLECTIONMAP: boolean;
  116821. USEIRRADIANCEMAP: boolean;
  116822. SPHERICAL_HARMONICS: boolean;
  116823. USESPHERICALINVERTEX: boolean;
  116824. REFLECTIONMAP_OPPOSITEZ: boolean;
  116825. LODINREFLECTIONALPHA: boolean;
  116826. GAMMAREFLECTION: boolean;
  116827. RGBDREFLECTION: boolean;
  116828. LINEARSPECULARREFLECTION: boolean;
  116829. RADIANCEOCCLUSION: boolean;
  116830. HORIZONOCCLUSION: boolean;
  116831. INSTANCES: boolean;
  116832. NUM_BONE_INFLUENCERS: number;
  116833. BonesPerMesh: number;
  116834. BONETEXTURE: boolean;
  116835. NONUNIFORMSCALING: boolean;
  116836. MORPHTARGETS: boolean;
  116837. MORPHTARGETS_NORMAL: boolean;
  116838. MORPHTARGETS_TANGENT: boolean;
  116839. MORPHTARGETS_UV: boolean;
  116840. NUM_MORPH_INFLUENCERS: number;
  116841. IMAGEPROCESSING: boolean;
  116842. VIGNETTE: boolean;
  116843. VIGNETTEBLENDMODEMULTIPLY: boolean;
  116844. VIGNETTEBLENDMODEOPAQUE: boolean;
  116845. TONEMAPPING: boolean;
  116846. TONEMAPPING_ACES: boolean;
  116847. CONTRAST: boolean;
  116848. COLORCURVES: boolean;
  116849. COLORGRADING: boolean;
  116850. COLORGRADING3D: boolean;
  116851. SAMPLER3DGREENDEPTH: boolean;
  116852. SAMPLER3DBGRMAP: boolean;
  116853. IMAGEPROCESSINGPOSTPROCESS: boolean;
  116854. EXPOSURE: boolean;
  116855. MULTIVIEW: boolean;
  116856. USEPHYSICALLIGHTFALLOFF: boolean;
  116857. USEGLTFLIGHTFALLOFF: boolean;
  116858. TWOSIDEDLIGHTING: boolean;
  116859. SHADOWFLOAT: boolean;
  116860. CLIPPLANE: boolean;
  116861. CLIPPLANE2: boolean;
  116862. CLIPPLANE3: boolean;
  116863. CLIPPLANE4: boolean;
  116864. POINTSIZE: boolean;
  116865. FOG: boolean;
  116866. LOGARITHMICDEPTH: boolean;
  116867. FORCENORMALFORWARD: boolean;
  116868. SPECULARAA: boolean;
  116869. CLEARCOAT: boolean;
  116870. CLEARCOAT_DEFAULTIOR: boolean;
  116871. CLEARCOAT_TEXTURE: boolean;
  116872. CLEARCOAT_TEXTUREDIRECTUV: number;
  116873. CLEARCOAT_BUMP: boolean;
  116874. CLEARCOAT_BUMPDIRECTUV: number;
  116875. CLEARCOAT_TINT: boolean;
  116876. CLEARCOAT_TINT_TEXTURE: boolean;
  116877. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  116878. ANISOTROPIC: boolean;
  116879. ANISOTROPIC_TEXTURE: boolean;
  116880. ANISOTROPIC_TEXTUREDIRECTUV: number;
  116881. BRDF_V_HEIGHT_CORRELATED: boolean;
  116882. MS_BRDF_ENERGY_CONSERVATION: boolean;
  116883. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  116884. SHEEN: boolean;
  116885. SHEEN_TEXTURE: boolean;
  116886. SHEEN_TEXTUREDIRECTUV: number;
  116887. SHEEN_LINKWITHALBEDO: boolean;
  116888. SUBSURFACE: boolean;
  116889. SS_REFRACTION: boolean;
  116890. SS_TRANSLUCENCY: boolean;
  116891. SS_SCATERRING: boolean;
  116892. SS_THICKNESSANDMASK_TEXTURE: boolean;
  116893. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  116894. SS_REFRACTIONMAP_3D: boolean;
  116895. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  116896. SS_LODINREFRACTIONALPHA: boolean;
  116897. SS_GAMMAREFRACTION: boolean;
  116898. SS_RGBDREFRACTION: boolean;
  116899. SS_LINEARSPECULARREFRACTION: boolean;
  116900. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  116901. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  116902. UNLIT: boolean;
  116903. DEBUGMODE: number;
  116904. /**
  116905. * Initializes the PBR Material defines.
  116906. */
  116907. constructor();
  116908. /**
  116909. * Resets the PBR Material defines.
  116910. */
  116911. reset(): void;
  116912. }
  116913. /**
  116914. * The Physically based material base class of BJS.
  116915. *
  116916. * This offers the main features of a standard PBR material.
  116917. * For more information, please refer to the documentation :
  116918. * https://doc.babylonjs.com/how_to/physically_based_rendering
  116919. */
  116920. export abstract class PBRBaseMaterial extends PushMaterial {
  116921. /**
  116922. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  116923. */
  116924. static readonly PBRMATERIAL_OPAQUE: number;
  116925. /**
  116926. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  116927. */
  116928. static readonly PBRMATERIAL_ALPHATEST: number;
  116929. /**
  116930. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  116931. */
  116932. static readonly PBRMATERIAL_ALPHABLEND: number;
  116933. /**
  116934. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  116935. * They are also discarded below the alpha cutoff threshold to improve performances.
  116936. */
  116937. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  116938. /**
  116939. * Defines the default value of how much AO map is occluding the analytical lights
  116940. * (point spot...).
  116941. */
  116942. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  116943. /**
  116944. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  116945. */
  116946. static readonly LIGHTFALLOFF_PHYSICAL: number;
  116947. /**
  116948. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  116949. * to enhance interoperability with other engines.
  116950. */
  116951. static readonly LIGHTFALLOFF_GLTF: number;
  116952. /**
  116953. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  116954. * to enhance interoperability with other materials.
  116955. */
  116956. static readonly LIGHTFALLOFF_STANDARD: number;
  116957. /**
  116958. * Intensity of the direct lights e.g. the four lights available in your scene.
  116959. * This impacts both the direct diffuse and specular highlights.
  116960. */
  116961. protected _directIntensity: number;
  116962. /**
  116963. * Intensity of the emissive part of the material.
  116964. * This helps controlling the emissive effect without modifying the emissive color.
  116965. */
  116966. protected _emissiveIntensity: number;
  116967. /**
  116968. * Intensity of the environment e.g. how much the environment will light the object
  116969. * either through harmonics for rough material or through the refelction for shiny ones.
  116970. */
  116971. protected _environmentIntensity: number;
  116972. /**
  116973. * This is a special control allowing the reduction of the specular highlights coming from the
  116974. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  116975. */
  116976. protected _specularIntensity: number;
  116977. /**
  116978. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  116979. */
  116980. private _lightingInfos;
  116981. /**
  116982. * Debug Control allowing disabling the bump map on this material.
  116983. */
  116984. protected _disableBumpMap: boolean;
  116985. /**
  116986. * AKA Diffuse Texture in standard nomenclature.
  116987. */
  116988. protected _albedoTexture: Nullable<BaseTexture>;
  116989. /**
  116990. * AKA Occlusion Texture in other nomenclature.
  116991. */
  116992. protected _ambientTexture: Nullable<BaseTexture>;
  116993. /**
  116994. * AKA Occlusion Texture Intensity in other nomenclature.
  116995. */
  116996. protected _ambientTextureStrength: number;
  116997. /**
  116998. * Defines how much the AO map is occluding the analytical lights (point spot...).
  116999. * 1 means it completely occludes it
  117000. * 0 mean it has no impact
  117001. */
  117002. protected _ambientTextureImpactOnAnalyticalLights: number;
  117003. /**
  117004. * Stores the alpha values in a texture.
  117005. */
  117006. protected _opacityTexture: Nullable<BaseTexture>;
  117007. /**
  117008. * Stores the reflection values in a texture.
  117009. */
  117010. protected _reflectionTexture: Nullable<BaseTexture>;
  117011. /**
  117012. * Stores the emissive values in a texture.
  117013. */
  117014. protected _emissiveTexture: Nullable<BaseTexture>;
  117015. /**
  117016. * AKA Specular texture in other nomenclature.
  117017. */
  117018. protected _reflectivityTexture: Nullable<BaseTexture>;
  117019. /**
  117020. * Used to switch from specular/glossiness to metallic/roughness workflow.
  117021. */
  117022. protected _metallicTexture: Nullable<BaseTexture>;
  117023. /**
  117024. * Specifies the metallic scalar of the metallic/roughness workflow.
  117025. * Can also be used to scale the metalness values of the metallic texture.
  117026. */
  117027. protected _metallic: Nullable<number>;
  117028. /**
  117029. * Specifies the roughness scalar of the metallic/roughness workflow.
  117030. * Can also be used to scale the roughness values of the metallic texture.
  117031. */
  117032. protected _roughness: Nullable<number>;
  117033. /**
  117034. * Specifies the an F0 factor to help configuring the material F0.
  117035. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  117036. * to 0.5 the previously hard coded value stays the same.
  117037. * Can also be used to scale the F0 values of the metallic texture.
  117038. */
  117039. protected _metallicF0Factor: number;
  117040. /**
  117041. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  117042. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  117043. * your expectation as it multiplies with the texture data.
  117044. */
  117045. protected _useMetallicF0FactorFromMetallicTexture: boolean;
  117046. /**
  117047. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  117048. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  117049. */
  117050. protected _microSurfaceTexture: Nullable<BaseTexture>;
  117051. /**
  117052. * Stores surface normal data used to displace a mesh in a texture.
  117053. */
  117054. protected _bumpTexture: Nullable<BaseTexture>;
  117055. /**
  117056. * Stores the pre-calculated light information of a mesh in a texture.
  117057. */
  117058. protected _lightmapTexture: Nullable<BaseTexture>;
  117059. /**
  117060. * The color of a material in ambient lighting.
  117061. */
  117062. protected _ambientColor: Color3;
  117063. /**
  117064. * AKA Diffuse Color in other nomenclature.
  117065. */
  117066. protected _albedoColor: Color3;
  117067. /**
  117068. * AKA Specular Color in other nomenclature.
  117069. */
  117070. protected _reflectivityColor: Color3;
  117071. /**
  117072. * The color applied when light is reflected from a material.
  117073. */
  117074. protected _reflectionColor: Color3;
  117075. /**
  117076. * The color applied when light is emitted from a material.
  117077. */
  117078. protected _emissiveColor: Color3;
  117079. /**
  117080. * AKA Glossiness in other nomenclature.
  117081. */
  117082. protected _microSurface: number;
  117083. /**
  117084. * Specifies that the material will use the light map as a show map.
  117085. */
  117086. protected _useLightmapAsShadowmap: boolean;
  117087. /**
  117088. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  117089. * makes the reflect vector face the model (under horizon).
  117090. */
  117091. protected _useHorizonOcclusion: boolean;
  117092. /**
  117093. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  117094. * too much the area relying on ambient texture to define their ambient occlusion.
  117095. */
  117096. protected _useRadianceOcclusion: boolean;
  117097. /**
  117098. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  117099. */
  117100. protected _useAlphaFromAlbedoTexture: boolean;
  117101. /**
  117102. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  117103. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  117104. */
  117105. protected _useSpecularOverAlpha: boolean;
  117106. /**
  117107. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  117108. */
  117109. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  117110. /**
  117111. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  117112. */
  117113. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  117114. /**
  117115. * Specifies if the metallic texture contains the roughness information in its green channel.
  117116. */
  117117. protected _useRoughnessFromMetallicTextureGreen: boolean;
  117118. /**
  117119. * Specifies if the metallic texture contains the metallness information in its blue channel.
  117120. */
  117121. protected _useMetallnessFromMetallicTextureBlue: boolean;
  117122. /**
  117123. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  117124. */
  117125. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  117126. /**
  117127. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  117128. */
  117129. protected _useAmbientInGrayScale: boolean;
  117130. /**
  117131. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  117132. * The material will try to infer what glossiness each pixel should be.
  117133. */
  117134. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  117135. /**
  117136. * Defines the falloff type used in this material.
  117137. * It by default is Physical.
  117138. */
  117139. protected _lightFalloff: number;
  117140. /**
  117141. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  117142. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  117143. */
  117144. protected _useRadianceOverAlpha: boolean;
  117145. /**
  117146. * Allows using an object space normal map (instead of tangent space).
  117147. */
  117148. protected _useObjectSpaceNormalMap: boolean;
  117149. /**
  117150. * Allows using the bump map in parallax mode.
  117151. */
  117152. protected _useParallax: boolean;
  117153. /**
  117154. * Allows using the bump map in parallax occlusion mode.
  117155. */
  117156. protected _useParallaxOcclusion: boolean;
  117157. /**
  117158. * Controls the scale bias of the parallax mode.
  117159. */
  117160. protected _parallaxScaleBias: number;
  117161. /**
  117162. * If sets to true, disables all the lights affecting the material.
  117163. */
  117164. protected _disableLighting: boolean;
  117165. /**
  117166. * Number of Simultaneous lights allowed on the material.
  117167. */
  117168. protected _maxSimultaneousLights: number;
  117169. /**
  117170. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  117171. */
  117172. protected _invertNormalMapX: boolean;
  117173. /**
  117174. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  117175. */
  117176. protected _invertNormalMapY: boolean;
  117177. /**
  117178. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  117179. */
  117180. protected _twoSidedLighting: boolean;
  117181. /**
  117182. * Defines the alpha limits in alpha test mode.
  117183. */
  117184. protected _alphaCutOff: number;
  117185. /**
  117186. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  117187. */
  117188. protected _forceAlphaTest: boolean;
  117189. /**
  117190. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  117191. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  117192. */
  117193. protected _useAlphaFresnel: boolean;
  117194. /**
  117195. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  117196. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  117197. */
  117198. protected _useLinearAlphaFresnel: boolean;
  117199. /**
  117200. * The transparency mode of the material.
  117201. */
  117202. protected _transparencyMode: Nullable<number>;
  117203. /**
  117204. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  117205. * from cos thetav and roughness:
  117206. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  117207. */
  117208. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  117209. /**
  117210. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  117211. */
  117212. protected _forceIrradianceInFragment: boolean;
  117213. /**
  117214. * Force normal to face away from face.
  117215. */
  117216. protected _forceNormalForward: boolean;
  117217. /**
  117218. * Enables specular anti aliasing in the PBR shader.
  117219. * It will both interacts on the Geometry for analytical and IBL lighting.
  117220. * It also prefilter the roughness map based on the bump values.
  117221. */
  117222. protected _enableSpecularAntiAliasing: boolean;
  117223. /**
  117224. * Default configuration related to image processing available in the PBR Material.
  117225. */
  117226. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  117227. /**
  117228. * Keep track of the image processing observer to allow dispose and replace.
  117229. */
  117230. private _imageProcessingObserver;
  117231. /**
  117232. * Attaches a new image processing configuration to the PBR Material.
  117233. * @param configuration
  117234. */
  117235. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  117236. /**
  117237. * Stores the available render targets.
  117238. */
  117239. private _renderTargets;
  117240. /**
  117241. * Sets the global ambient color for the material used in lighting calculations.
  117242. */
  117243. private _globalAmbientColor;
  117244. /**
  117245. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  117246. */
  117247. private _useLogarithmicDepth;
  117248. /**
  117249. * If set to true, no lighting calculations will be applied.
  117250. */
  117251. private _unlit;
  117252. private _debugMode;
  117253. /**
  117254. * @hidden
  117255. * This is reserved for the inspector.
  117256. * Defines the material debug mode.
  117257. * It helps seeing only some components of the material while troubleshooting.
  117258. */
  117259. debugMode: number;
  117260. /**
  117261. * @hidden
  117262. * This is reserved for the inspector.
  117263. * Specify from where on screen the debug mode should start.
  117264. * The value goes from -1 (full screen) to 1 (not visible)
  117265. * It helps with side by side comparison against the final render
  117266. * This defaults to -1
  117267. */
  117268. private debugLimit;
  117269. /**
  117270. * @hidden
  117271. * This is reserved for the inspector.
  117272. * As the default viewing range might not be enough (if the ambient is really small for instance)
  117273. * You can use the factor to better multiply the final value.
  117274. */
  117275. private debugFactor;
  117276. /**
  117277. * Defines the clear coat layer parameters for the material.
  117278. */
  117279. readonly clearCoat: PBRClearCoatConfiguration;
  117280. /**
  117281. * Defines the anisotropic parameters for the material.
  117282. */
  117283. readonly anisotropy: PBRAnisotropicConfiguration;
  117284. /**
  117285. * Defines the BRDF parameters for the material.
  117286. */
  117287. readonly brdf: PBRBRDFConfiguration;
  117288. /**
  117289. * Defines the Sheen parameters for the material.
  117290. */
  117291. readonly sheen: PBRSheenConfiguration;
  117292. /**
  117293. * Defines the SubSurface parameters for the material.
  117294. */
  117295. readonly subSurface: PBRSubSurfaceConfiguration;
  117296. /**
  117297. * Custom callback helping to override the default shader used in the material.
  117298. */
  117299. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  117300. protected _rebuildInParallel: boolean;
  117301. /**
  117302. * Instantiates a new PBRMaterial instance.
  117303. *
  117304. * @param name The material name
  117305. * @param scene The scene the material will be use in.
  117306. */
  117307. constructor(name: string, scene: Scene);
  117308. /**
  117309. * Gets a boolean indicating that current material needs to register RTT
  117310. */
  117311. readonly hasRenderTargetTextures: boolean;
  117312. /**
  117313. * Gets the name of the material class.
  117314. */
  117315. getClassName(): string;
  117316. /**
  117317. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  117318. */
  117319. /**
  117320. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  117321. */
  117322. useLogarithmicDepth: boolean;
  117323. /**
  117324. * Gets the current transparency mode.
  117325. */
  117326. /**
  117327. * Sets the transparency mode of the material.
  117328. *
  117329. * | Value | Type | Description |
  117330. * | ----- | ----------------------------------- | ----------- |
  117331. * | 0 | OPAQUE | |
  117332. * | 1 | ALPHATEST | |
  117333. * | 2 | ALPHABLEND | |
  117334. * | 3 | ALPHATESTANDBLEND | |
  117335. *
  117336. */
  117337. transparencyMode: Nullable<number>;
  117338. /**
  117339. * Returns true if alpha blending should be disabled.
  117340. */
  117341. private readonly _disableAlphaBlending;
  117342. /**
  117343. * Specifies whether or not this material should be rendered in alpha blend mode.
  117344. */
  117345. needAlphaBlending(): boolean;
  117346. /**
  117347. * Specifies if the mesh will require alpha blending.
  117348. * @param mesh - BJS mesh.
  117349. */
  117350. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  117351. /**
  117352. * Specifies whether or not this material should be rendered in alpha test mode.
  117353. */
  117354. needAlphaTesting(): boolean;
  117355. /**
  117356. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  117357. */
  117358. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  117359. /**
  117360. * Gets the texture used for the alpha test.
  117361. */
  117362. getAlphaTestTexture(): Nullable<BaseTexture>;
  117363. /**
  117364. * Specifies that the submesh is ready to be used.
  117365. * @param mesh - BJS mesh.
  117366. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  117367. * @param useInstances - Specifies that instances should be used.
  117368. * @returns - boolean indicating that the submesh is ready or not.
  117369. */
  117370. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  117371. /**
  117372. * Specifies if the material uses metallic roughness workflow.
  117373. * @returns boolean specifiying if the material uses metallic roughness workflow.
  117374. */
  117375. isMetallicWorkflow(): boolean;
  117376. private _prepareEffect;
  117377. private _prepareDefines;
  117378. /**
  117379. * Force shader compilation
  117380. */
  117381. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  117382. /**
  117383. * Initializes the uniform buffer layout for the shader.
  117384. */
  117385. buildUniformLayout(): void;
  117386. /**
  117387. * Unbinds the material from the mesh
  117388. */
  117389. unbind(): void;
  117390. /**
  117391. * Binds the submesh data.
  117392. * @param world - The world matrix.
  117393. * @param mesh - The BJS mesh.
  117394. * @param subMesh - A submesh of the BJS mesh.
  117395. */
  117396. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  117397. /**
  117398. * Returns the animatable textures.
  117399. * @returns - Array of animatable textures.
  117400. */
  117401. getAnimatables(): IAnimatable[];
  117402. /**
  117403. * Returns the texture used for reflections.
  117404. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  117405. */
  117406. private _getReflectionTexture;
  117407. /**
  117408. * Returns an array of the actively used textures.
  117409. * @returns - Array of BaseTextures
  117410. */
  117411. getActiveTextures(): BaseTexture[];
  117412. /**
  117413. * Checks to see if a texture is used in the material.
  117414. * @param texture - Base texture to use.
  117415. * @returns - Boolean specifying if a texture is used in the material.
  117416. */
  117417. hasTexture(texture: BaseTexture): boolean;
  117418. /**
  117419. * Disposes the resources of the material.
  117420. * @param forceDisposeEffect - Forces the disposal of effects.
  117421. * @param forceDisposeTextures - Forces the disposal of all textures.
  117422. */
  117423. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  117424. }
  117425. }
  117426. declare module BABYLON {
  117427. /**
  117428. * The Physically based material of BJS.
  117429. *
  117430. * This offers the main features of a standard PBR material.
  117431. * For more information, please refer to the documentation :
  117432. * https://doc.babylonjs.com/how_to/physically_based_rendering
  117433. */
  117434. export class PBRMaterial extends PBRBaseMaterial {
  117435. /**
  117436. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  117437. */
  117438. static readonly PBRMATERIAL_OPAQUE: number;
  117439. /**
  117440. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  117441. */
  117442. static readonly PBRMATERIAL_ALPHATEST: number;
  117443. /**
  117444. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  117445. */
  117446. static readonly PBRMATERIAL_ALPHABLEND: number;
  117447. /**
  117448. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  117449. * They are also discarded below the alpha cutoff threshold to improve performances.
  117450. */
  117451. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  117452. /**
  117453. * Defines the default value of how much AO map is occluding the analytical lights
  117454. * (point spot...).
  117455. */
  117456. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  117457. /**
  117458. * Intensity of the direct lights e.g. the four lights available in your scene.
  117459. * This impacts both the direct diffuse and specular highlights.
  117460. */
  117461. directIntensity: number;
  117462. /**
  117463. * Intensity of the emissive part of the material.
  117464. * This helps controlling the emissive effect without modifying the emissive color.
  117465. */
  117466. emissiveIntensity: number;
  117467. /**
  117468. * Intensity of the environment e.g. how much the environment will light the object
  117469. * either through harmonics for rough material or through the refelction for shiny ones.
  117470. */
  117471. environmentIntensity: number;
  117472. /**
  117473. * This is a special control allowing the reduction of the specular highlights coming from the
  117474. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  117475. */
  117476. specularIntensity: number;
  117477. /**
  117478. * Debug Control allowing disabling the bump map on this material.
  117479. */
  117480. disableBumpMap: boolean;
  117481. /**
  117482. * AKA Diffuse Texture in standard nomenclature.
  117483. */
  117484. albedoTexture: BaseTexture;
  117485. /**
  117486. * AKA Occlusion Texture in other nomenclature.
  117487. */
  117488. ambientTexture: BaseTexture;
  117489. /**
  117490. * AKA Occlusion Texture Intensity in other nomenclature.
  117491. */
  117492. ambientTextureStrength: number;
  117493. /**
  117494. * Defines how much the AO map is occluding the analytical lights (point spot...).
  117495. * 1 means it completely occludes it
  117496. * 0 mean it has no impact
  117497. */
  117498. ambientTextureImpactOnAnalyticalLights: number;
  117499. /**
  117500. * Stores the alpha values in a texture.
  117501. */
  117502. opacityTexture: BaseTexture;
  117503. /**
  117504. * Stores the reflection values in a texture.
  117505. */
  117506. reflectionTexture: Nullable<BaseTexture>;
  117507. /**
  117508. * Stores the emissive values in a texture.
  117509. */
  117510. emissiveTexture: BaseTexture;
  117511. /**
  117512. * AKA Specular texture in other nomenclature.
  117513. */
  117514. reflectivityTexture: BaseTexture;
  117515. /**
  117516. * Used to switch from specular/glossiness to metallic/roughness workflow.
  117517. */
  117518. metallicTexture: BaseTexture;
  117519. /**
  117520. * Specifies the metallic scalar of the metallic/roughness workflow.
  117521. * Can also be used to scale the metalness values of the metallic texture.
  117522. */
  117523. metallic: Nullable<number>;
  117524. /**
  117525. * Specifies the roughness scalar of the metallic/roughness workflow.
  117526. * Can also be used to scale the roughness values of the metallic texture.
  117527. */
  117528. roughness: Nullable<number>;
  117529. /**
  117530. * Specifies the an F0 factor to help configuring the material F0.
  117531. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  117532. * to 0.5 the previously hard coded value stays the same.
  117533. * Can also be used to scale the F0 values of the metallic texture.
  117534. */
  117535. metallicF0Factor: number;
  117536. /**
  117537. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  117538. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  117539. * your expectation as it multiplies with the texture data.
  117540. */
  117541. useMetallicF0FactorFromMetallicTexture: boolean;
  117542. /**
  117543. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  117544. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  117545. */
  117546. microSurfaceTexture: BaseTexture;
  117547. /**
  117548. * Stores surface normal data used to displace a mesh in a texture.
  117549. */
  117550. bumpTexture: BaseTexture;
  117551. /**
  117552. * Stores the pre-calculated light information of a mesh in a texture.
  117553. */
  117554. lightmapTexture: BaseTexture;
  117555. /**
  117556. * Stores the refracted light information in a texture.
  117557. */
  117558. refractionTexture: Nullable<BaseTexture>;
  117559. /**
  117560. * The color of a material in ambient lighting.
  117561. */
  117562. ambientColor: Color3;
  117563. /**
  117564. * AKA Diffuse Color in other nomenclature.
  117565. */
  117566. albedoColor: Color3;
  117567. /**
  117568. * AKA Specular Color in other nomenclature.
  117569. */
  117570. reflectivityColor: Color3;
  117571. /**
  117572. * The color reflected from the material.
  117573. */
  117574. reflectionColor: Color3;
  117575. /**
  117576. * The color emitted from the material.
  117577. */
  117578. emissiveColor: Color3;
  117579. /**
  117580. * AKA Glossiness in other nomenclature.
  117581. */
  117582. microSurface: number;
  117583. /**
  117584. * source material index of refraction (IOR)' / 'destination material IOR.
  117585. */
  117586. indexOfRefraction: number;
  117587. /**
  117588. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  117589. */
  117590. invertRefractionY: boolean;
  117591. /**
  117592. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  117593. * Materials half opaque for instance using refraction could benefit from this control.
  117594. */
  117595. linkRefractionWithTransparency: boolean;
  117596. /**
  117597. * If true, the light map contains occlusion information instead of lighting info.
  117598. */
  117599. useLightmapAsShadowmap: boolean;
  117600. /**
  117601. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  117602. */
  117603. useAlphaFromAlbedoTexture: boolean;
  117604. /**
  117605. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  117606. */
  117607. forceAlphaTest: boolean;
  117608. /**
  117609. * Defines the alpha limits in alpha test mode.
  117610. */
  117611. alphaCutOff: number;
  117612. /**
  117613. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  117614. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  117615. */
  117616. useSpecularOverAlpha: boolean;
  117617. /**
  117618. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  117619. */
  117620. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  117621. /**
  117622. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  117623. */
  117624. useRoughnessFromMetallicTextureAlpha: boolean;
  117625. /**
  117626. * Specifies if the metallic texture contains the roughness information in its green channel.
  117627. */
  117628. useRoughnessFromMetallicTextureGreen: boolean;
  117629. /**
  117630. * Specifies if the metallic texture contains the metallness information in its blue channel.
  117631. */
  117632. useMetallnessFromMetallicTextureBlue: boolean;
  117633. /**
  117634. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  117635. */
  117636. useAmbientOcclusionFromMetallicTextureRed: boolean;
  117637. /**
  117638. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  117639. */
  117640. useAmbientInGrayScale: boolean;
  117641. /**
  117642. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  117643. * The material will try to infer what glossiness each pixel should be.
  117644. */
  117645. useAutoMicroSurfaceFromReflectivityMap: boolean;
  117646. /**
  117647. * BJS is using an harcoded light falloff based on a manually sets up range.
  117648. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  117649. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  117650. */
  117651. /**
  117652. * BJS is using an harcoded light falloff based on a manually sets up range.
  117653. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  117654. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  117655. */
  117656. usePhysicalLightFalloff: boolean;
  117657. /**
  117658. * In order to support the falloff compatibility with gltf, a special mode has been added
  117659. * to reproduce the gltf light falloff.
  117660. */
  117661. /**
  117662. * In order to support the falloff compatibility with gltf, a special mode has been added
  117663. * to reproduce the gltf light falloff.
  117664. */
  117665. useGLTFLightFalloff: boolean;
  117666. /**
  117667. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  117668. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  117669. */
  117670. useRadianceOverAlpha: boolean;
  117671. /**
  117672. * Allows using an object space normal map (instead of tangent space).
  117673. */
  117674. useObjectSpaceNormalMap: boolean;
  117675. /**
  117676. * Allows using the bump map in parallax mode.
  117677. */
  117678. useParallax: boolean;
  117679. /**
  117680. * Allows using the bump map in parallax occlusion mode.
  117681. */
  117682. useParallaxOcclusion: boolean;
  117683. /**
  117684. * Controls the scale bias of the parallax mode.
  117685. */
  117686. parallaxScaleBias: number;
  117687. /**
  117688. * If sets to true, disables all the lights affecting the material.
  117689. */
  117690. disableLighting: boolean;
  117691. /**
  117692. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  117693. */
  117694. forceIrradianceInFragment: boolean;
  117695. /**
  117696. * Number of Simultaneous lights allowed on the material.
  117697. */
  117698. maxSimultaneousLights: number;
  117699. /**
  117700. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  117701. */
  117702. invertNormalMapX: boolean;
  117703. /**
  117704. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  117705. */
  117706. invertNormalMapY: boolean;
  117707. /**
  117708. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  117709. */
  117710. twoSidedLighting: boolean;
  117711. /**
  117712. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  117713. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  117714. */
  117715. useAlphaFresnel: boolean;
  117716. /**
  117717. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  117718. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  117719. */
  117720. useLinearAlphaFresnel: boolean;
  117721. /**
  117722. * Let user defines the brdf lookup texture used for IBL.
  117723. * A default 8bit version is embedded but you could point at :
  117724. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  117725. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  117726. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  117727. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  117728. */
  117729. environmentBRDFTexture: Nullable<BaseTexture>;
  117730. /**
  117731. * Force normal to face away from face.
  117732. */
  117733. forceNormalForward: boolean;
  117734. /**
  117735. * Enables specular anti aliasing in the PBR shader.
  117736. * It will both interacts on the Geometry for analytical and IBL lighting.
  117737. * It also prefilter the roughness map based on the bump values.
  117738. */
  117739. enableSpecularAntiAliasing: boolean;
  117740. /**
  117741. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  117742. * makes the reflect vector face the model (under horizon).
  117743. */
  117744. useHorizonOcclusion: boolean;
  117745. /**
  117746. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  117747. * too much the area relying on ambient texture to define their ambient occlusion.
  117748. */
  117749. useRadianceOcclusion: boolean;
  117750. /**
  117751. * If set to true, no lighting calculations will be applied.
  117752. */
  117753. unlit: boolean;
  117754. /**
  117755. * Gets the image processing configuration used either in this material.
  117756. */
  117757. /**
  117758. * Sets the Default image processing configuration used either in the this material.
  117759. *
  117760. * If sets to null, the scene one is in use.
  117761. */
  117762. imageProcessingConfiguration: ImageProcessingConfiguration;
  117763. /**
  117764. * Gets wether the color curves effect is enabled.
  117765. */
  117766. /**
  117767. * Sets wether the color curves effect is enabled.
  117768. */
  117769. cameraColorCurvesEnabled: boolean;
  117770. /**
  117771. * Gets wether the color grading effect is enabled.
  117772. */
  117773. /**
  117774. * Gets wether the color grading effect is enabled.
  117775. */
  117776. cameraColorGradingEnabled: boolean;
  117777. /**
  117778. * Gets wether tonemapping is enabled or not.
  117779. */
  117780. /**
  117781. * Sets wether tonemapping is enabled or not
  117782. */
  117783. cameraToneMappingEnabled: boolean;
  117784. /**
  117785. * The camera exposure used on this material.
  117786. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  117787. * This corresponds to a photographic exposure.
  117788. */
  117789. /**
  117790. * The camera exposure used on this material.
  117791. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  117792. * This corresponds to a photographic exposure.
  117793. */
  117794. cameraExposure: number;
  117795. /**
  117796. * Gets The camera contrast used on this material.
  117797. */
  117798. /**
  117799. * Sets The camera contrast used on this material.
  117800. */
  117801. cameraContrast: number;
  117802. /**
  117803. * Gets the Color Grading 2D Lookup Texture.
  117804. */
  117805. /**
  117806. * Sets the Color Grading 2D Lookup Texture.
  117807. */
  117808. cameraColorGradingTexture: Nullable<BaseTexture>;
  117809. /**
  117810. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  117811. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  117812. * 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;
  117813. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  117814. */
  117815. /**
  117816. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  117817. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  117818. * 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;
  117819. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  117820. */
  117821. cameraColorCurves: Nullable<ColorCurves>;
  117822. /**
  117823. * Instantiates a new PBRMaterial instance.
  117824. *
  117825. * @param name The material name
  117826. * @param scene The scene the material will be use in.
  117827. */
  117828. constructor(name: string, scene: Scene);
  117829. /**
  117830. * Returns the name of this material class.
  117831. */
  117832. getClassName(): string;
  117833. /**
  117834. * Makes a duplicate of the current material.
  117835. * @param name - name to use for the new material.
  117836. */
  117837. clone(name: string): PBRMaterial;
  117838. /**
  117839. * Serializes this PBR Material.
  117840. * @returns - An object with the serialized material.
  117841. */
  117842. serialize(): any;
  117843. /**
  117844. * Parses a PBR Material from a serialized object.
  117845. * @param source - Serialized object.
  117846. * @param scene - BJS scene instance.
  117847. * @param rootUrl - url for the scene object
  117848. * @returns - PBRMaterial
  117849. */
  117850. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  117851. }
  117852. }
  117853. declare module BABYLON {
  117854. /**
  117855. * Direct draw surface info
  117856. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  117857. */
  117858. export interface DDSInfo {
  117859. /**
  117860. * Width of the texture
  117861. */
  117862. width: number;
  117863. /**
  117864. * Width of the texture
  117865. */
  117866. height: number;
  117867. /**
  117868. * Number of Mipmaps for the texture
  117869. * @see https://en.wikipedia.org/wiki/Mipmap
  117870. */
  117871. mipmapCount: number;
  117872. /**
  117873. * If the textures format is a known fourCC format
  117874. * @see https://www.fourcc.org/
  117875. */
  117876. isFourCC: boolean;
  117877. /**
  117878. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  117879. */
  117880. isRGB: boolean;
  117881. /**
  117882. * If the texture is a lumincance format
  117883. */
  117884. isLuminance: boolean;
  117885. /**
  117886. * If this is a cube texture
  117887. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  117888. */
  117889. isCube: boolean;
  117890. /**
  117891. * If the texture is a compressed format eg. FOURCC_DXT1
  117892. */
  117893. isCompressed: boolean;
  117894. /**
  117895. * The dxgiFormat of the texture
  117896. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  117897. */
  117898. dxgiFormat: number;
  117899. /**
  117900. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  117901. */
  117902. textureType: number;
  117903. /**
  117904. * Sphericle polynomial created for the dds texture
  117905. */
  117906. sphericalPolynomial?: SphericalPolynomial;
  117907. }
  117908. /**
  117909. * Class used to provide DDS decompression tools
  117910. */
  117911. export class DDSTools {
  117912. /**
  117913. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  117914. */
  117915. static StoreLODInAlphaChannel: boolean;
  117916. /**
  117917. * Gets DDS information from an array buffer
  117918. * @param arrayBuffer defines the array buffer to read data from
  117919. * @returns the DDS information
  117920. */
  117921. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  117922. private static _FloatView;
  117923. private static _Int32View;
  117924. private static _ToHalfFloat;
  117925. private static _FromHalfFloat;
  117926. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  117927. private static _GetHalfFloatRGBAArrayBuffer;
  117928. private static _GetFloatRGBAArrayBuffer;
  117929. private static _GetFloatAsUIntRGBAArrayBuffer;
  117930. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  117931. private static _GetRGBAArrayBuffer;
  117932. private static _ExtractLongWordOrder;
  117933. private static _GetRGBArrayBuffer;
  117934. private static _GetLuminanceArrayBuffer;
  117935. /**
  117936. * Uploads DDS Levels to a Babylon Texture
  117937. * @hidden
  117938. */
  117939. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  117940. }
  117941. interface ThinEngine {
  117942. /**
  117943. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  117944. * @param rootUrl defines the url where the file to load is located
  117945. * @param scene defines the current scene
  117946. * @param lodScale defines scale to apply to the mip map selection
  117947. * @param lodOffset defines offset to apply to the mip map selection
  117948. * @param onLoad defines an optional callback raised when the texture is loaded
  117949. * @param onError defines an optional callback raised if there is an issue to load the texture
  117950. * @param format defines the format of the data
  117951. * @param forcedExtension defines the extension to use to pick the right loader
  117952. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  117953. * @returns the cube texture as an InternalTexture
  117954. */
  117955. 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;
  117956. }
  117957. }
  117958. declare module BABYLON {
  117959. /**
  117960. * Implementation of the DDS Texture Loader.
  117961. * @hidden
  117962. */
  117963. export class _DDSTextureLoader implements IInternalTextureLoader {
  117964. /**
  117965. * Defines wether the loader supports cascade loading the different faces.
  117966. */
  117967. readonly supportCascades: boolean;
  117968. /**
  117969. * This returns if the loader support the current file information.
  117970. * @param extension defines the file extension of the file being loaded
  117971. * @param textureFormatInUse defines the current compressed format in use iun the engine
  117972. * @param fallback defines the fallback internal texture if any
  117973. * @param isBase64 defines whether the texture is encoded as a base64
  117974. * @param isBuffer defines whether the texture data are stored as a buffer
  117975. * @returns true if the loader can load the specified file
  117976. */
  117977. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  117978. /**
  117979. * Transform the url before loading if required.
  117980. * @param rootUrl the url of the texture
  117981. * @param textureFormatInUse defines the current compressed format in use iun the engine
  117982. * @returns the transformed texture
  117983. */
  117984. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  117985. /**
  117986. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  117987. * @param rootUrl the url of the texture
  117988. * @param textureFormatInUse defines the current compressed format in use iun the engine
  117989. * @returns the fallback texture
  117990. */
  117991. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  117992. /**
  117993. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  117994. * @param data contains the texture data
  117995. * @param texture defines the BabylonJS internal texture
  117996. * @param createPolynomials will be true if polynomials have been requested
  117997. * @param onLoad defines the callback to trigger once the texture is ready
  117998. * @param onError defines the callback to trigger in case of error
  117999. */
  118000. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  118001. /**
  118002. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  118003. * @param data contains the texture data
  118004. * @param texture defines the BabylonJS internal texture
  118005. * @param callback defines the method to call once ready to upload
  118006. */
  118007. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  118008. }
  118009. }
  118010. declare module BABYLON {
  118011. /**
  118012. * Implementation of the ENV Texture Loader.
  118013. * @hidden
  118014. */
  118015. export class _ENVTextureLoader implements IInternalTextureLoader {
  118016. /**
  118017. * Defines wether the loader supports cascade loading the different faces.
  118018. */
  118019. readonly supportCascades: boolean;
  118020. /**
  118021. * This returns if the loader support the current file information.
  118022. * @param extension defines the file extension of the file being loaded
  118023. * @param textureFormatInUse defines the current compressed format in use iun the engine
  118024. * @param fallback defines the fallback internal texture if any
  118025. * @param isBase64 defines whether the texture is encoded as a base64
  118026. * @param isBuffer defines whether the texture data are stored as a buffer
  118027. * @returns true if the loader can load the specified file
  118028. */
  118029. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  118030. /**
  118031. * Transform the url before loading if required.
  118032. * @param rootUrl the url of the texture
  118033. * @param textureFormatInUse defines the current compressed format in use iun the engine
  118034. * @returns the transformed texture
  118035. */
  118036. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  118037. /**
  118038. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  118039. * @param rootUrl the url of the texture
  118040. * @param textureFormatInUse defines the current compressed format in use iun the engine
  118041. * @returns the fallback texture
  118042. */
  118043. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  118044. /**
  118045. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  118046. * @param data contains the texture data
  118047. * @param texture defines the BabylonJS internal texture
  118048. * @param createPolynomials will be true if polynomials have been requested
  118049. * @param onLoad defines the callback to trigger once the texture is ready
  118050. * @param onError defines the callback to trigger in case of error
  118051. */
  118052. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  118053. /**
  118054. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  118055. * @param data contains the texture data
  118056. * @param texture defines the BabylonJS internal texture
  118057. * @param callback defines the method to call once ready to upload
  118058. */
  118059. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  118060. }
  118061. }
  118062. declare module BABYLON {
  118063. /**
  118064. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  118065. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  118066. */
  118067. export class KhronosTextureContainer {
  118068. /** contents of the KTX container file */
  118069. arrayBuffer: any;
  118070. private static HEADER_LEN;
  118071. private static COMPRESSED_2D;
  118072. private static COMPRESSED_3D;
  118073. private static TEX_2D;
  118074. private static TEX_3D;
  118075. /**
  118076. * Gets the openGL type
  118077. */
  118078. glType: number;
  118079. /**
  118080. * Gets the openGL type size
  118081. */
  118082. glTypeSize: number;
  118083. /**
  118084. * Gets the openGL format
  118085. */
  118086. glFormat: number;
  118087. /**
  118088. * Gets the openGL internal format
  118089. */
  118090. glInternalFormat: number;
  118091. /**
  118092. * Gets the base internal format
  118093. */
  118094. glBaseInternalFormat: number;
  118095. /**
  118096. * Gets image width in pixel
  118097. */
  118098. pixelWidth: number;
  118099. /**
  118100. * Gets image height in pixel
  118101. */
  118102. pixelHeight: number;
  118103. /**
  118104. * Gets image depth in pixels
  118105. */
  118106. pixelDepth: number;
  118107. /**
  118108. * Gets the number of array elements
  118109. */
  118110. numberOfArrayElements: number;
  118111. /**
  118112. * Gets the number of faces
  118113. */
  118114. numberOfFaces: number;
  118115. /**
  118116. * Gets the number of mipmap levels
  118117. */
  118118. numberOfMipmapLevels: number;
  118119. /**
  118120. * Gets the bytes of key value data
  118121. */
  118122. bytesOfKeyValueData: number;
  118123. /**
  118124. * Gets the load type
  118125. */
  118126. loadType: number;
  118127. /**
  118128. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  118129. */
  118130. isInvalid: boolean;
  118131. /**
  118132. * Creates a new KhronosTextureContainer
  118133. * @param arrayBuffer contents of the KTX container file
  118134. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  118135. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  118136. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  118137. */
  118138. constructor(
  118139. /** contents of the KTX container file */
  118140. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  118141. /**
  118142. * Uploads KTX content to a Babylon Texture.
  118143. * It is assumed that the texture has already been created & is currently bound
  118144. * @hidden
  118145. */
  118146. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  118147. private _upload2DCompressedLevels;
  118148. }
  118149. }
  118150. declare module BABYLON {
  118151. /**
  118152. * Implementation of the KTX Texture Loader.
  118153. * @hidden
  118154. */
  118155. export class _KTXTextureLoader implements IInternalTextureLoader {
  118156. /**
  118157. * Defines wether the loader supports cascade loading the different faces.
  118158. */
  118159. readonly supportCascades: boolean;
  118160. /**
  118161. * This returns if the loader support the current file information.
  118162. * @param extension defines the file extension of the file being loaded
  118163. * @param textureFormatInUse defines the current compressed format in use iun the engine
  118164. * @param fallback defines the fallback internal texture if any
  118165. * @param isBase64 defines whether the texture is encoded as a base64
  118166. * @param isBuffer defines whether the texture data are stored as a buffer
  118167. * @returns true if the loader can load the specified file
  118168. */
  118169. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  118170. /**
  118171. * Transform the url before loading if required.
  118172. * @param rootUrl the url of the texture
  118173. * @param textureFormatInUse defines the current compressed format in use iun the engine
  118174. * @returns the transformed texture
  118175. */
  118176. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  118177. /**
  118178. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  118179. * @param rootUrl the url of the texture
  118180. * @param textureFormatInUse defines the current compressed format in use iun the engine
  118181. * @returns the fallback texture
  118182. */
  118183. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  118184. /**
  118185. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  118186. * @param data contains the texture data
  118187. * @param texture defines the BabylonJS internal texture
  118188. * @param createPolynomials will be true if polynomials have been requested
  118189. * @param onLoad defines the callback to trigger once the texture is ready
  118190. * @param onError defines the callback to trigger in case of error
  118191. */
  118192. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  118193. /**
  118194. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  118195. * @param data contains the texture data
  118196. * @param texture defines the BabylonJS internal texture
  118197. * @param callback defines the method to call once ready to upload
  118198. */
  118199. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  118200. }
  118201. }
  118202. declare module BABYLON {
  118203. /** @hidden */
  118204. export var _forceSceneHelpersToBundle: boolean;
  118205. interface Scene {
  118206. /**
  118207. * Creates a default light for the scene.
  118208. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  118209. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  118210. */
  118211. createDefaultLight(replace?: boolean): void;
  118212. /**
  118213. * Creates a default camera for the scene.
  118214. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  118215. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  118216. * @param replace has default false, when true replaces the active camera in the scene
  118217. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  118218. */
  118219. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  118220. /**
  118221. * Creates a default camera and a default light.
  118222. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  118223. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  118224. * @param replace has the default false, when true replaces the active camera/light in the scene
  118225. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  118226. */
  118227. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  118228. /**
  118229. * Creates a new sky box
  118230. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  118231. * @param environmentTexture defines the texture to use as environment texture
  118232. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  118233. * @param scale defines the overall scale of the skybox
  118234. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  118235. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  118236. * @returns a new mesh holding the sky box
  118237. */
  118238. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  118239. /**
  118240. * Creates a new environment
  118241. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  118242. * @param options defines the options you can use to configure the environment
  118243. * @returns the new EnvironmentHelper
  118244. */
  118245. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  118246. /**
  118247. * Creates a new VREXperienceHelper
  118248. * @see http://doc.babylonjs.com/how_to/webvr_helper
  118249. * @param webVROptions defines the options used to create the new VREXperienceHelper
  118250. * @returns a new VREXperienceHelper
  118251. */
  118252. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  118253. /**
  118254. * Creates a new WebXRDefaultExperience
  118255. * @see http://doc.babylonjs.com/how_to/webxr
  118256. * @param options experience options
  118257. * @returns a promise for a new WebXRDefaultExperience
  118258. */
  118259. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  118260. }
  118261. }
  118262. declare module BABYLON {
  118263. /**
  118264. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  118265. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  118266. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  118267. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  118268. */
  118269. export class VideoDome extends TransformNode {
  118270. /**
  118271. * Define the video source as a Monoscopic panoramic 360 video.
  118272. */
  118273. static readonly MODE_MONOSCOPIC: number;
  118274. /**
  118275. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  118276. */
  118277. static readonly MODE_TOPBOTTOM: number;
  118278. /**
  118279. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  118280. */
  118281. static readonly MODE_SIDEBYSIDE: number;
  118282. private _halfDome;
  118283. private _useDirectMapping;
  118284. /**
  118285. * The video texture being displayed on the sphere
  118286. */
  118287. protected _videoTexture: VideoTexture;
  118288. /**
  118289. * Gets the video texture being displayed on the sphere
  118290. */
  118291. readonly videoTexture: VideoTexture;
  118292. /**
  118293. * The skybox material
  118294. */
  118295. protected _material: BackgroundMaterial;
  118296. /**
  118297. * The surface used for the skybox
  118298. */
  118299. protected _mesh: Mesh;
  118300. /**
  118301. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  118302. */
  118303. private _halfDomeMask;
  118304. /**
  118305. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  118306. * Also see the options.resolution property.
  118307. */
  118308. fovMultiplier: number;
  118309. private _videoMode;
  118310. /**
  118311. * Gets or set the current video mode for the video. It can be:
  118312. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  118313. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  118314. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  118315. */
  118316. videoMode: number;
  118317. /**
  118318. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  118319. *
  118320. */
  118321. /**
  118322. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  118323. */
  118324. halfDome: boolean;
  118325. /**
  118326. * Oberserver used in Stereoscopic VR Mode.
  118327. */
  118328. private _onBeforeCameraRenderObserver;
  118329. /**
  118330. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  118331. * @param name Element's name, child elements will append suffixes for their own names.
  118332. * @param urlsOrVideo defines the url(s) or the video element to use
  118333. * @param options An object containing optional or exposed sub element properties
  118334. */
  118335. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  118336. resolution?: number;
  118337. clickToPlay?: boolean;
  118338. autoPlay?: boolean;
  118339. loop?: boolean;
  118340. size?: number;
  118341. poster?: string;
  118342. faceForward?: boolean;
  118343. useDirectMapping?: boolean;
  118344. halfDomeMode?: boolean;
  118345. }, scene: Scene);
  118346. private _changeVideoMode;
  118347. /**
  118348. * Releases resources associated with this node.
  118349. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  118350. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  118351. */
  118352. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  118353. }
  118354. }
  118355. declare module BABYLON {
  118356. /**
  118357. * This class can be used to get instrumentation data from a Babylon engine
  118358. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  118359. */
  118360. export class EngineInstrumentation implements IDisposable {
  118361. /**
  118362. * Define the instrumented engine.
  118363. */
  118364. engine: Engine;
  118365. private _captureGPUFrameTime;
  118366. private _gpuFrameTimeToken;
  118367. private _gpuFrameTime;
  118368. private _captureShaderCompilationTime;
  118369. private _shaderCompilationTime;
  118370. private _onBeginFrameObserver;
  118371. private _onEndFrameObserver;
  118372. private _onBeforeShaderCompilationObserver;
  118373. private _onAfterShaderCompilationObserver;
  118374. /**
  118375. * Gets the perf counter used for GPU frame time
  118376. */
  118377. readonly gpuFrameTimeCounter: PerfCounter;
  118378. /**
  118379. * Gets the GPU frame time capture status
  118380. */
  118381. /**
  118382. * Enable or disable the GPU frame time capture
  118383. */
  118384. captureGPUFrameTime: boolean;
  118385. /**
  118386. * Gets the perf counter used for shader compilation time
  118387. */
  118388. readonly shaderCompilationTimeCounter: PerfCounter;
  118389. /**
  118390. * Gets the shader compilation time capture status
  118391. */
  118392. /**
  118393. * Enable or disable the shader compilation time capture
  118394. */
  118395. captureShaderCompilationTime: boolean;
  118396. /**
  118397. * Instantiates a new engine instrumentation.
  118398. * This class can be used to get instrumentation data from a Babylon engine
  118399. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  118400. * @param engine Defines the engine to instrument
  118401. */
  118402. constructor(
  118403. /**
  118404. * Define the instrumented engine.
  118405. */
  118406. engine: Engine);
  118407. /**
  118408. * Dispose and release associated resources.
  118409. */
  118410. dispose(): void;
  118411. }
  118412. }
  118413. declare module BABYLON {
  118414. /**
  118415. * This class can be used to get instrumentation data from a Babylon engine
  118416. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  118417. */
  118418. export class SceneInstrumentation implements IDisposable {
  118419. /**
  118420. * Defines the scene to instrument
  118421. */
  118422. scene: Scene;
  118423. private _captureActiveMeshesEvaluationTime;
  118424. private _activeMeshesEvaluationTime;
  118425. private _captureRenderTargetsRenderTime;
  118426. private _renderTargetsRenderTime;
  118427. private _captureFrameTime;
  118428. private _frameTime;
  118429. private _captureRenderTime;
  118430. private _renderTime;
  118431. private _captureInterFrameTime;
  118432. private _interFrameTime;
  118433. private _captureParticlesRenderTime;
  118434. private _particlesRenderTime;
  118435. private _captureSpritesRenderTime;
  118436. private _spritesRenderTime;
  118437. private _capturePhysicsTime;
  118438. private _physicsTime;
  118439. private _captureAnimationsTime;
  118440. private _animationsTime;
  118441. private _captureCameraRenderTime;
  118442. private _cameraRenderTime;
  118443. private _onBeforeActiveMeshesEvaluationObserver;
  118444. private _onAfterActiveMeshesEvaluationObserver;
  118445. private _onBeforeRenderTargetsRenderObserver;
  118446. private _onAfterRenderTargetsRenderObserver;
  118447. private _onAfterRenderObserver;
  118448. private _onBeforeDrawPhaseObserver;
  118449. private _onAfterDrawPhaseObserver;
  118450. private _onBeforeAnimationsObserver;
  118451. private _onBeforeParticlesRenderingObserver;
  118452. private _onAfterParticlesRenderingObserver;
  118453. private _onBeforeSpritesRenderingObserver;
  118454. private _onAfterSpritesRenderingObserver;
  118455. private _onBeforePhysicsObserver;
  118456. private _onAfterPhysicsObserver;
  118457. private _onAfterAnimationsObserver;
  118458. private _onBeforeCameraRenderObserver;
  118459. private _onAfterCameraRenderObserver;
  118460. /**
  118461. * Gets the perf counter used for active meshes evaluation time
  118462. */
  118463. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  118464. /**
  118465. * Gets the active meshes evaluation time capture status
  118466. */
  118467. /**
  118468. * Enable or disable the active meshes evaluation time capture
  118469. */
  118470. captureActiveMeshesEvaluationTime: boolean;
  118471. /**
  118472. * Gets the perf counter used for render targets render time
  118473. */
  118474. readonly renderTargetsRenderTimeCounter: PerfCounter;
  118475. /**
  118476. * Gets the render targets render time capture status
  118477. */
  118478. /**
  118479. * Enable or disable the render targets render time capture
  118480. */
  118481. captureRenderTargetsRenderTime: boolean;
  118482. /**
  118483. * Gets the perf counter used for particles render time
  118484. */
  118485. readonly particlesRenderTimeCounter: PerfCounter;
  118486. /**
  118487. * Gets the particles render time capture status
  118488. */
  118489. /**
  118490. * Enable or disable the particles render time capture
  118491. */
  118492. captureParticlesRenderTime: boolean;
  118493. /**
  118494. * Gets the perf counter used for sprites render time
  118495. */
  118496. readonly spritesRenderTimeCounter: PerfCounter;
  118497. /**
  118498. * Gets the sprites render time capture status
  118499. */
  118500. /**
  118501. * Enable or disable the sprites render time capture
  118502. */
  118503. captureSpritesRenderTime: boolean;
  118504. /**
  118505. * Gets the perf counter used for physics time
  118506. */
  118507. readonly physicsTimeCounter: PerfCounter;
  118508. /**
  118509. * Gets the physics time capture status
  118510. */
  118511. /**
  118512. * Enable or disable the physics time capture
  118513. */
  118514. capturePhysicsTime: boolean;
  118515. /**
  118516. * Gets the perf counter used for animations time
  118517. */
  118518. readonly animationsTimeCounter: PerfCounter;
  118519. /**
  118520. * Gets the animations time capture status
  118521. */
  118522. /**
  118523. * Enable or disable the animations time capture
  118524. */
  118525. captureAnimationsTime: boolean;
  118526. /**
  118527. * Gets the perf counter used for frame time capture
  118528. */
  118529. readonly frameTimeCounter: PerfCounter;
  118530. /**
  118531. * Gets the frame time capture status
  118532. */
  118533. /**
  118534. * Enable or disable the frame time capture
  118535. */
  118536. captureFrameTime: boolean;
  118537. /**
  118538. * Gets the perf counter used for inter-frames time capture
  118539. */
  118540. readonly interFrameTimeCounter: PerfCounter;
  118541. /**
  118542. * Gets the inter-frames time capture status
  118543. */
  118544. /**
  118545. * Enable or disable the inter-frames time capture
  118546. */
  118547. captureInterFrameTime: boolean;
  118548. /**
  118549. * Gets the perf counter used for render time capture
  118550. */
  118551. readonly renderTimeCounter: PerfCounter;
  118552. /**
  118553. * Gets the render time capture status
  118554. */
  118555. /**
  118556. * Enable or disable the render time capture
  118557. */
  118558. captureRenderTime: boolean;
  118559. /**
  118560. * Gets the perf counter used for camera render time capture
  118561. */
  118562. readonly cameraRenderTimeCounter: PerfCounter;
  118563. /**
  118564. * Gets the camera render time capture status
  118565. */
  118566. /**
  118567. * Enable or disable the camera render time capture
  118568. */
  118569. captureCameraRenderTime: boolean;
  118570. /**
  118571. * Gets the perf counter used for draw calls
  118572. */
  118573. readonly drawCallsCounter: PerfCounter;
  118574. /**
  118575. * Instantiates a new scene instrumentation.
  118576. * This class can be used to get instrumentation data from a Babylon engine
  118577. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  118578. * @param scene Defines the scene to instrument
  118579. */
  118580. constructor(
  118581. /**
  118582. * Defines the scene to instrument
  118583. */
  118584. scene: Scene);
  118585. /**
  118586. * Dispose and release associated resources.
  118587. */
  118588. dispose(): void;
  118589. }
  118590. }
  118591. declare module BABYLON {
  118592. /** @hidden */
  118593. export var glowMapGenerationPixelShader: {
  118594. name: string;
  118595. shader: string;
  118596. };
  118597. }
  118598. declare module BABYLON {
  118599. /** @hidden */
  118600. export var glowMapGenerationVertexShader: {
  118601. name: string;
  118602. shader: string;
  118603. };
  118604. }
  118605. declare module BABYLON {
  118606. /**
  118607. * Effect layer options. This helps customizing the behaviour
  118608. * of the effect layer.
  118609. */
  118610. export interface IEffectLayerOptions {
  118611. /**
  118612. * Multiplication factor apply to the canvas size to compute the render target size
  118613. * used to generated the objects (the smaller the faster).
  118614. */
  118615. mainTextureRatio: number;
  118616. /**
  118617. * Enforces a fixed size texture to ensure effect stability across devices.
  118618. */
  118619. mainTextureFixedSize?: number;
  118620. /**
  118621. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  118622. */
  118623. alphaBlendingMode: number;
  118624. /**
  118625. * The camera attached to the layer.
  118626. */
  118627. camera: Nullable<Camera>;
  118628. /**
  118629. * The rendering group to draw the layer in.
  118630. */
  118631. renderingGroupId: number;
  118632. }
  118633. /**
  118634. * The effect layer Helps adding post process effect blended with the main pass.
  118635. *
  118636. * This can be for instance use to generate glow or higlight effects on the scene.
  118637. *
  118638. * The effect layer class can not be used directly and is intented to inherited from to be
  118639. * customized per effects.
  118640. */
  118641. export abstract class EffectLayer {
  118642. private _vertexBuffers;
  118643. private _indexBuffer;
  118644. private _cachedDefines;
  118645. private _effectLayerMapGenerationEffect;
  118646. private _effectLayerOptions;
  118647. private _mergeEffect;
  118648. protected _scene: Scene;
  118649. protected _engine: Engine;
  118650. protected _maxSize: number;
  118651. protected _mainTextureDesiredSize: ISize;
  118652. protected _mainTexture: RenderTargetTexture;
  118653. protected _shouldRender: boolean;
  118654. protected _postProcesses: PostProcess[];
  118655. protected _textures: BaseTexture[];
  118656. protected _emissiveTextureAndColor: {
  118657. texture: Nullable<BaseTexture>;
  118658. color: Color4;
  118659. };
  118660. /**
  118661. * The name of the layer
  118662. */
  118663. name: string;
  118664. /**
  118665. * The clear color of the texture used to generate the glow map.
  118666. */
  118667. neutralColor: Color4;
  118668. /**
  118669. * Specifies wether the highlight layer is enabled or not.
  118670. */
  118671. isEnabled: boolean;
  118672. /**
  118673. * Gets the camera attached to the layer.
  118674. */
  118675. readonly camera: Nullable<Camera>;
  118676. /**
  118677. * Gets the rendering group id the layer should render in.
  118678. */
  118679. renderingGroupId: number;
  118680. /**
  118681. * An event triggered when the effect layer has been disposed.
  118682. */
  118683. onDisposeObservable: Observable<EffectLayer>;
  118684. /**
  118685. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  118686. */
  118687. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  118688. /**
  118689. * An event triggered when the generated texture is being merged in the scene.
  118690. */
  118691. onBeforeComposeObservable: Observable<EffectLayer>;
  118692. /**
  118693. * An event triggered when the mesh is rendered into the effect render target.
  118694. */
  118695. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  118696. /**
  118697. * An event triggered after the mesh has been rendered into the effect render target.
  118698. */
  118699. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  118700. /**
  118701. * An event triggered when the generated texture has been merged in the scene.
  118702. */
  118703. onAfterComposeObservable: Observable<EffectLayer>;
  118704. /**
  118705. * An event triggered when the efffect layer changes its size.
  118706. */
  118707. onSizeChangedObservable: Observable<EffectLayer>;
  118708. /** @hidden */
  118709. static _SceneComponentInitialization: (scene: Scene) => void;
  118710. /**
  118711. * Instantiates a new effect Layer and references it in the scene.
  118712. * @param name The name of the layer
  118713. * @param scene The scene to use the layer in
  118714. */
  118715. constructor(
  118716. /** The Friendly of the effect in the scene */
  118717. name: string, scene: Scene);
  118718. /**
  118719. * Get the effect name of the layer.
  118720. * @return The effect name
  118721. */
  118722. abstract getEffectName(): string;
  118723. /**
  118724. * Checks for the readiness of the element composing the layer.
  118725. * @param subMesh the mesh to check for
  118726. * @param useInstances specify wether or not to use instances to render the mesh
  118727. * @return true if ready otherwise, false
  118728. */
  118729. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  118730. /**
  118731. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  118732. * @returns true if the effect requires stencil during the main canvas render pass.
  118733. */
  118734. abstract needStencil(): boolean;
  118735. /**
  118736. * Create the merge effect. This is the shader use to blit the information back
  118737. * to the main canvas at the end of the scene rendering.
  118738. * @returns The effect containing the shader used to merge the effect on the main canvas
  118739. */
  118740. protected abstract _createMergeEffect(): Effect;
  118741. /**
  118742. * Creates the render target textures and post processes used in the effect layer.
  118743. */
  118744. protected abstract _createTextureAndPostProcesses(): void;
  118745. /**
  118746. * Implementation specific of rendering the generating effect on the main canvas.
  118747. * @param effect The effect used to render through
  118748. */
  118749. protected abstract _internalRender(effect: Effect): void;
  118750. /**
  118751. * Sets the required values for both the emissive texture and and the main color.
  118752. */
  118753. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  118754. /**
  118755. * Free any resources and references associated to a mesh.
  118756. * Internal use
  118757. * @param mesh The mesh to free.
  118758. */
  118759. abstract _disposeMesh(mesh: Mesh): void;
  118760. /**
  118761. * Serializes this layer (Glow or Highlight for example)
  118762. * @returns a serialized layer object
  118763. */
  118764. abstract serialize?(): any;
  118765. /**
  118766. * Initializes the effect layer with the required options.
  118767. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  118768. */
  118769. protected _init(options: Partial<IEffectLayerOptions>): void;
  118770. /**
  118771. * Generates the index buffer of the full screen quad blending to the main canvas.
  118772. */
  118773. private _generateIndexBuffer;
  118774. /**
  118775. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  118776. */
  118777. private _generateVertexBuffer;
  118778. /**
  118779. * Sets the main texture desired size which is the closest power of two
  118780. * of the engine canvas size.
  118781. */
  118782. private _setMainTextureSize;
  118783. /**
  118784. * Creates the main texture for the effect layer.
  118785. */
  118786. protected _createMainTexture(): void;
  118787. /**
  118788. * Adds specific effects defines.
  118789. * @param defines The defines to add specifics to.
  118790. */
  118791. protected _addCustomEffectDefines(defines: string[]): void;
  118792. /**
  118793. * Checks for the readiness of the element composing the layer.
  118794. * @param subMesh the mesh to check for
  118795. * @param useInstances specify wether or not to use instances to render the mesh
  118796. * @param emissiveTexture the associated emissive texture used to generate the glow
  118797. * @return true if ready otherwise, false
  118798. */
  118799. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  118800. /**
  118801. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  118802. */
  118803. render(): void;
  118804. /**
  118805. * Determine if a given mesh will be used in the current effect.
  118806. * @param mesh mesh to test
  118807. * @returns true if the mesh will be used
  118808. */
  118809. hasMesh(mesh: AbstractMesh): boolean;
  118810. /**
  118811. * Returns true if the layer contains information to display, otherwise false.
  118812. * @returns true if the glow layer should be rendered
  118813. */
  118814. shouldRender(): boolean;
  118815. /**
  118816. * Returns true if the mesh should render, otherwise false.
  118817. * @param mesh The mesh to render
  118818. * @returns true if it should render otherwise false
  118819. */
  118820. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  118821. /**
  118822. * Returns true if the mesh can be rendered, otherwise false.
  118823. * @param mesh The mesh to render
  118824. * @param material The material used on the mesh
  118825. * @returns true if it can be rendered otherwise false
  118826. */
  118827. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  118828. /**
  118829. * Returns true if the mesh should render, otherwise false.
  118830. * @param mesh The mesh to render
  118831. * @returns true if it should render otherwise false
  118832. */
  118833. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  118834. /**
  118835. * Renders the submesh passed in parameter to the generation map.
  118836. */
  118837. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  118838. /**
  118839. * Defines wether the current material of the mesh should be use to render the effect.
  118840. * @param mesh defines the current mesh to render
  118841. */
  118842. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  118843. /**
  118844. * Rebuild the required buffers.
  118845. * @hidden Internal use only.
  118846. */
  118847. _rebuild(): void;
  118848. /**
  118849. * Dispose only the render target textures and post process.
  118850. */
  118851. private _disposeTextureAndPostProcesses;
  118852. /**
  118853. * Dispose the highlight layer and free resources.
  118854. */
  118855. dispose(): void;
  118856. /**
  118857. * Gets the class name of the effect layer
  118858. * @returns the string with the class name of the effect layer
  118859. */
  118860. getClassName(): string;
  118861. /**
  118862. * Creates an effect layer from parsed effect layer data
  118863. * @param parsedEffectLayer defines effect layer data
  118864. * @param scene defines the current scene
  118865. * @param rootUrl defines the root URL containing the effect layer information
  118866. * @returns a parsed effect Layer
  118867. */
  118868. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  118869. }
  118870. }
  118871. declare module BABYLON {
  118872. interface AbstractScene {
  118873. /**
  118874. * The list of effect layers (highlights/glow) added to the scene
  118875. * @see http://doc.babylonjs.com/how_to/highlight_layer
  118876. * @see http://doc.babylonjs.com/how_to/glow_layer
  118877. */
  118878. effectLayers: Array<EffectLayer>;
  118879. /**
  118880. * Removes the given effect layer from this scene.
  118881. * @param toRemove defines the effect layer to remove
  118882. * @returns the index of the removed effect layer
  118883. */
  118884. removeEffectLayer(toRemove: EffectLayer): number;
  118885. /**
  118886. * Adds the given effect layer to this scene
  118887. * @param newEffectLayer defines the effect layer to add
  118888. */
  118889. addEffectLayer(newEffectLayer: EffectLayer): void;
  118890. }
  118891. /**
  118892. * Defines the layer scene component responsible to manage any effect layers
  118893. * in a given scene.
  118894. */
  118895. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  118896. /**
  118897. * The component name helpfull to identify the component in the list of scene components.
  118898. */
  118899. readonly name: string;
  118900. /**
  118901. * The scene the component belongs to.
  118902. */
  118903. scene: Scene;
  118904. private _engine;
  118905. private _renderEffects;
  118906. private _needStencil;
  118907. private _previousStencilState;
  118908. /**
  118909. * Creates a new instance of the component for the given scene
  118910. * @param scene Defines the scene to register the component in
  118911. */
  118912. constructor(scene: Scene);
  118913. /**
  118914. * Registers the component in a given scene
  118915. */
  118916. register(): void;
  118917. /**
  118918. * Rebuilds the elements related to this component in case of
  118919. * context lost for instance.
  118920. */
  118921. rebuild(): void;
  118922. /**
  118923. * Serializes the component data to the specified json object
  118924. * @param serializationObject The object to serialize to
  118925. */
  118926. serialize(serializationObject: any): void;
  118927. /**
  118928. * Adds all the elements from the container to the scene
  118929. * @param container the container holding the elements
  118930. */
  118931. addFromContainer(container: AbstractScene): void;
  118932. /**
  118933. * Removes all the elements in the container from the scene
  118934. * @param container contains the elements to remove
  118935. * @param dispose if the removed element should be disposed (default: false)
  118936. */
  118937. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  118938. /**
  118939. * Disposes the component and the associated ressources.
  118940. */
  118941. dispose(): void;
  118942. private _isReadyForMesh;
  118943. private _renderMainTexture;
  118944. private _setStencil;
  118945. private _setStencilBack;
  118946. private _draw;
  118947. private _drawCamera;
  118948. private _drawRenderingGroup;
  118949. }
  118950. }
  118951. declare module BABYLON {
  118952. /** @hidden */
  118953. export var glowMapMergePixelShader: {
  118954. name: string;
  118955. shader: string;
  118956. };
  118957. }
  118958. declare module BABYLON {
  118959. /** @hidden */
  118960. export var glowMapMergeVertexShader: {
  118961. name: string;
  118962. shader: string;
  118963. };
  118964. }
  118965. declare module BABYLON {
  118966. interface AbstractScene {
  118967. /**
  118968. * Return a the first highlight layer of the scene with a given name.
  118969. * @param name The name of the highlight layer to look for.
  118970. * @return The highlight layer if found otherwise null.
  118971. */
  118972. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  118973. }
  118974. /**
  118975. * Glow layer options. This helps customizing the behaviour
  118976. * of the glow layer.
  118977. */
  118978. export interface IGlowLayerOptions {
  118979. /**
  118980. * Multiplication factor apply to the canvas size to compute the render target size
  118981. * used to generated the glowing objects (the smaller the faster).
  118982. */
  118983. mainTextureRatio: number;
  118984. /**
  118985. * Enforces a fixed size texture to ensure resize independant blur.
  118986. */
  118987. mainTextureFixedSize?: number;
  118988. /**
  118989. * How big is the kernel of the blur texture.
  118990. */
  118991. blurKernelSize: number;
  118992. /**
  118993. * The camera attached to the layer.
  118994. */
  118995. camera: Nullable<Camera>;
  118996. /**
  118997. * Enable MSAA by chosing the number of samples.
  118998. */
  118999. mainTextureSamples?: number;
  119000. /**
  119001. * The rendering group to draw the layer in.
  119002. */
  119003. renderingGroupId: number;
  119004. }
  119005. /**
  119006. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  119007. *
  119008. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  119009. *
  119010. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  119011. */
  119012. export class GlowLayer extends EffectLayer {
  119013. /**
  119014. * Effect Name of the layer.
  119015. */
  119016. static readonly EffectName: string;
  119017. /**
  119018. * The default blur kernel size used for the glow.
  119019. */
  119020. static DefaultBlurKernelSize: number;
  119021. /**
  119022. * The default texture size ratio used for the glow.
  119023. */
  119024. static DefaultTextureRatio: number;
  119025. /**
  119026. * Sets the kernel size of the blur.
  119027. */
  119028. /**
  119029. * Gets the kernel size of the blur.
  119030. */
  119031. blurKernelSize: number;
  119032. /**
  119033. * Sets the glow intensity.
  119034. */
  119035. /**
  119036. * Gets the glow intensity.
  119037. */
  119038. intensity: number;
  119039. private _options;
  119040. private _intensity;
  119041. private _horizontalBlurPostprocess1;
  119042. private _verticalBlurPostprocess1;
  119043. private _horizontalBlurPostprocess2;
  119044. private _verticalBlurPostprocess2;
  119045. private _blurTexture1;
  119046. private _blurTexture2;
  119047. private _postProcesses1;
  119048. private _postProcesses2;
  119049. private _includedOnlyMeshes;
  119050. private _excludedMeshes;
  119051. private _meshesUsingTheirOwnMaterials;
  119052. /**
  119053. * Callback used to let the user override the color selection on a per mesh basis
  119054. */
  119055. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  119056. /**
  119057. * Callback used to let the user override the texture selection on a per mesh basis
  119058. */
  119059. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  119060. /**
  119061. * Instantiates a new glow Layer and references it to the scene.
  119062. * @param name The name of the layer
  119063. * @param scene The scene to use the layer in
  119064. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  119065. */
  119066. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  119067. /**
  119068. * Get the effect name of the layer.
  119069. * @return The effect name
  119070. */
  119071. getEffectName(): string;
  119072. /**
  119073. * Create the merge effect. This is the shader use to blit the information back
  119074. * to the main canvas at the end of the scene rendering.
  119075. */
  119076. protected _createMergeEffect(): Effect;
  119077. /**
  119078. * Creates the render target textures and post processes used in the glow layer.
  119079. */
  119080. protected _createTextureAndPostProcesses(): void;
  119081. /**
  119082. * Checks for the readiness of the element composing the layer.
  119083. * @param subMesh the mesh to check for
  119084. * @param useInstances specify wether or not to use instances to render the mesh
  119085. * @param emissiveTexture the associated emissive texture used to generate the glow
  119086. * @return true if ready otherwise, false
  119087. */
  119088. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  119089. /**
  119090. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  119091. */
  119092. needStencil(): boolean;
  119093. /**
  119094. * Returns true if the mesh can be rendered, otherwise false.
  119095. * @param mesh The mesh to render
  119096. * @param material The material used on the mesh
  119097. * @returns true if it can be rendered otherwise false
  119098. */
  119099. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  119100. /**
  119101. * Implementation specific of rendering the generating effect on the main canvas.
  119102. * @param effect The effect used to render through
  119103. */
  119104. protected _internalRender(effect: Effect): void;
  119105. /**
  119106. * Sets the required values for both the emissive texture and and the main color.
  119107. */
  119108. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  119109. /**
  119110. * Returns true if the mesh should render, otherwise false.
  119111. * @param mesh The mesh to render
  119112. * @returns true if it should render otherwise false
  119113. */
  119114. protected _shouldRenderMesh(mesh: Mesh): boolean;
  119115. /**
  119116. * Adds specific effects defines.
  119117. * @param defines The defines to add specifics to.
  119118. */
  119119. protected _addCustomEffectDefines(defines: string[]): void;
  119120. /**
  119121. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  119122. * @param mesh The mesh to exclude from the glow layer
  119123. */
  119124. addExcludedMesh(mesh: Mesh): void;
  119125. /**
  119126. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  119127. * @param mesh The mesh to remove
  119128. */
  119129. removeExcludedMesh(mesh: Mesh): void;
  119130. /**
  119131. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  119132. * @param mesh The mesh to include in the glow layer
  119133. */
  119134. addIncludedOnlyMesh(mesh: Mesh): void;
  119135. /**
  119136. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  119137. * @param mesh The mesh to remove
  119138. */
  119139. removeIncludedOnlyMesh(mesh: Mesh): void;
  119140. /**
  119141. * Determine if a given mesh will be used in the glow layer
  119142. * @param mesh The mesh to test
  119143. * @returns true if the mesh will be highlighted by the current glow layer
  119144. */
  119145. hasMesh(mesh: AbstractMesh): boolean;
  119146. /**
  119147. * Defines wether the current material of the mesh should be use to render the effect.
  119148. * @param mesh defines the current mesh to render
  119149. */
  119150. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  119151. /**
  119152. * Add a mesh to be rendered through its own material and not with emissive only.
  119153. * @param mesh The mesh for which we need to use its material
  119154. */
  119155. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  119156. /**
  119157. * Remove a mesh from being rendered through its own material and not with emissive only.
  119158. * @param mesh The mesh for which we need to not use its material
  119159. */
  119160. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  119161. /**
  119162. * Free any resources and references associated to a mesh.
  119163. * Internal use
  119164. * @param mesh The mesh to free.
  119165. * @hidden
  119166. */
  119167. _disposeMesh(mesh: Mesh): void;
  119168. /**
  119169. * Gets the class name of the effect layer
  119170. * @returns the string with the class name of the effect layer
  119171. */
  119172. getClassName(): string;
  119173. /**
  119174. * Serializes this glow layer
  119175. * @returns a serialized glow layer object
  119176. */
  119177. serialize(): any;
  119178. /**
  119179. * Creates a Glow Layer from parsed glow layer data
  119180. * @param parsedGlowLayer defines glow layer data
  119181. * @param scene defines the current scene
  119182. * @param rootUrl defines the root URL containing the glow layer information
  119183. * @returns a parsed Glow Layer
  119184. */
  119185. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  119186. }
  119187. }
  119188. declare module BABYLON {
  119189. /** @hidden */
  119190. export var glowBlurPostProcessPixelShader: {
  119191. name: string;
  119192. shader: string;
  119193. };
  119194. }
  119195. declare module BABYLON {
  119196. interface AbstractScene {
  119197. /**
  119198. * Return a the first highlight layer of the scene with a given name.
  119199. * @param name The name of the highlight layer to look for.
  119200. * @return The highlight layer if found otherwise null.
  119201. */
  119202. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  119203. }
  119204. /**
  119205. * Highlight layer options. This helps customizing the behaviour
  119206. * of the highlight layer.
  119207. */
  119208. export interface IHighlightLayerOptions {
  119209. /**
  119210. * Multiplication factor apply to the canvas size to compute the render target size
  119211. * used to generated the glowing objects (the smaller the faster).
  119212. */
  119213. mainTextureRatio: number;
  119214. /**
  119215. * Enforces a fixed size texture to ensure resize independant blur.
  119216. */
  119217. mainTextureFixedSize?: number;
  119218. /**
  119219. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  119220. * of the picture to blur (the smaller the faster).
  119221. */
  119222. blurTextureSizeRatio: number;
  119223. /**
  119224. * How big in texel of the blur texture is the vertical blur.
  119225. */
  119226. blurVerticalSize: number;
  119227. /**
  119228. * How big in texel of the blur texture is the horizontal blur.
  119229. */
  119230. blurHorizontalSize: number;
  119231. /**
  119232. * Alpha blending mode used to apply the blur. Default is combine.
  119233. */
  119234. alphaBlendingMode: number;
  119235. /**
  119236. * The camera attached to the layer.
  119237. */
  119238. camera: Nullable<Camera>;
  119239. /**
  119240. * Should we display highlight as a solid stroke?
  119241. */
  119242. isStroke?: boolean;
  119243. /**
  119244. * The rendering group to draw the layer in.
  119245. */
  119246. renderingGroupId: number;
  119247. }
  119248. /**
  119249. * The highlight layer Helps adding a glow effect around a mesh.
  119250. *
  119251. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  119252. * glowy meshes to your scene.
  119253. *
  119254. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  119255. */
  119256. export class HighlightLayer extends EffectLayer {
  119257. name: string;
  119258. /**
  119259. * Effect Name of the highlight layer.
  119260. */
  119261. static readonly EffectName: string;
  119262. /**
  119263. * The neutral color used during the preparation of the glow effect.
  119264. * This is black by default as the blend operation is a blend operation.
  119265. */
  119266. static NeutralColor: Color4;
  119267. /**
  119268. * Stencil value used for glowing meshes.
  119269. */
  119270. static GlowingMeshStencilReference: number;
  119271. /**
  119272. * Stencil value used for the other meshes in the scene.
  119273. */
  119274. static NormalMeshStencilReference: number;
  119275. /**
  119276. * Specifies whether or not the inner glow is ACTIVE in the layer.
  119277. */
  119278. innerGlow: boolean;
  119279. /**
  119280. * Specifies whether or not the outer glow is ACTIVE in the layer.
  119281. */
  119282. outerGlow: boolean;
  119283. /**
  119284. * Specifies the horizontal size of the blur.
  119285. */
  119286. /**
  119287. * Gets the horizontal size of the blur.
  119288. */
  119289. blurHorizontalSize: number;
  119290. /**
  119291. * Specifies the vertical size of the blur.
  119292. */
  119293. /**
  119294. * Gets the vertical size of the blur.
  119295. */
  119296. blurVerticalSize: number;
  119297. /**
  119298. * An event triggered when the highlight layer is being blurred.
  119299. */
  119300. onBeforeBlurObservable: Observable<HighlightLayer>;
  119301. /**
  119302. * An event triggered when the highlight layer has been blurred.
  119303. */
  119304. onAfterBlurObservable: Observable<HighlightLayer>;
  119305. private _instanceGlowingMeshStencilReference;
  119306. private _options;
  119307. private _downSamplePostprocess;
  119308. private _horizontalBlurPostprocess;
  119309. private _verticalBlurPostprocess;
  119310. private _blurTexture;
  119311. private _meshes;
  119312. private _excludedMeshes;
  119313. /**
  119314. * Instantiates a new highlight Layer and references it to the scene..
  119315. * @param name The name of the layer
  119316. * @param scene The scene to use the layer in
  119317. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  119318. */
  119319. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  119320. /**
  119321. * Get the effect name of the layer.
  119322. * @return The effect name
  119323. */
  119324. getEffectName(): string;
  119325. /**
  119326. * Create the merge effect. This is the shader use to blit the information back
  119327. * to the main canvas at the end of the scene rendering.
  119328. */
  119329. protected _createMergeEffect(): Effect;
  119330. /**
  119331. * Creates the render target textures and post processes used in the highlight layer.
  119332. */
  119333. protected _createTextureAndPostProcesses(): void;
  119334. /**
  119335. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  119336. */
  119337. needStencil(): boolean;
  119338. /**
  119339. * Checks for the readiness of the element composing the layer.
  119340. * @param subMesh the mesh to check for
  119341. * @param useInstances specify wether or not to use instances to render the mesh
  119342. * @param emissiveTexture the associated emissive texture used to generate the glow
  119343. * @return true if ready otherwise, false
  119344. */
  119345. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  119346. /**
  119347. * Implementation specific of rendering the generating effect on the main canvas.
  119348. * @param effect The effect used to render through
  119349. */
  119350. protected _internalRender(effect: Effect): void;
  119351. /**
  119352. * Returns true if the layer contains information to display, otherwise false.
  119353. */
  119354. shouldRender(): boolean;
  119355. /**
  119356. * Returns true if the mesh should render, otherwise false.
  119357. * @param mesh The mesh to render
  119358. * @returns true if it should render otherwise false
  119359. */
  119360. protected _shouldRenderMesh(mesh: Mesh): boolean;
  119361. /**
  119362. * Sets the required values for both the emissive texture and and the main color.
  119363. */
  119364. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  119365. /**
  119366. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  119367. * @param mesh The mesh to exclude from the highlight layer
  119368. */
  119369. addExcludedMesh(mesh: Mesh): void;
  119370. /**
  119371. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  119372. * @param mesh The mesh to highlight
  119373. */
  119374. removeExcludedMesh(mesh: Mesh): void;
  119375. /**
  119376. * Determine if a given mesh will be highlighted by the current HighlightLayer
  119377. * @param mesh mesh to test
  119378. * @returns true if the mesh will be highlighted by the current HighlightLayer
  119379. */
  119380. hasMesh(mesh: AbstractMesh): boolean;
  119381. /**
  119382. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  119383. * @param mesh The mesh to highlight
  119384. * @param color The color of the highlight
  119385. * @param glowEmissiveOnly Extract the glow from the emissive texture
  119386. */
  119387. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  119388. /**
  119389. * Remove a mesh from the highlight layer in order to make it stop glowing.
  119390. * @param mesh The mesh to highlight
  119391. */
  119392. removeMesh(mesh: Mesh): void;
  119393. /**
  119394. * Force the stencil to the normal expected value for none glowing parts
  119395. */
  119396. private _defaultStencilReference;
  119397. /**
  119398. * Free any resources and references associated to a mesh.
  119399. * Internal use
  119400. * @param mesh The mesh to free.
  119401. * @hidden
  119402. */
  119403. _disposeMesh(mesh: Mesh): void;
  119404. /**
  119405. * Dispose the highlight layer and free resources.
  119406. */
  119407. dispose(): void;
  119408. /**
  119409. * Gets the class name of the effect layer
  119410. * @returns the string with the class name of the effect layer
  119411. */
  119412. getClassName(): string;
  119413. /**
  119414. * Serializes this Highlight layer
  119415. * @returns a serialized Highlight layer object
  119416. */
  119417. serialize(): any;
  119418. /**
  119419. * Creates a Highlight layer from parsed Highlight layer data
  119420. * @param parsedHightlightLayer defines the Highlight layer data
  119421. * @param scene defines the current scene
  119422. * @param rootUrl defines the root URL containing the Highlight layer information
  119423. * @returns a parsed Highlight layer
  119424. */
  119425. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  119426. }
  119427. }
  119428. declare module BABYLON {
  119429. interface AbstractScene {
  119430. /**
  119431. * The list of layers (background and foreground) of the scene
  119432. */
  119433. layers: Array<Layer>;
  119434. }
  119435. /**
  119436. * Defines the layer scene component responsible to manage any layers
  119437. * in a given scene.
  119438. */
  119439. export class LayerSceneComponent implements ISceneComponent {
  119440. /**
  119441. * The component name helpfull to identify the component in the list of scene components.
  119442. */
  119443. readonly name: string;
  119444. /**
  119445. * The scene the component belongs to.
  119446. */
  119447. scene: Scene;
  119448. private _engine;
  119449. /**
  119450. * Creates a new instance of the component for the given scene
  119451. * @param scene Defines the scene to register the component in
  119452. */
  119453. constructor(scene: Scene);
  119454. /**
  119455. * Registers the component in a given scene
  119456. */
  119457. register(): void;
  119458. /**
  119459. * Rebuilds the elements related to this component in case of
  119460. * context lost for instance.
  119461. */
  119462. rebuild(): void;
  119463. /**
  119464. * Disposes the component and the associated ressources.
  119465. */
  119466. dispose(): void;
  119467. private _draw;
  119468. private _drawCameraPredicate;
  119469. private _drawCameraBackground;
  119470. private _drawCameraForeground;
  119471. private _drawRenderTargetPredicate;
  119472. private _drawRenderTargetBackground;
  119473. private _drawRenderTargetForeground;
  119474. /**
  119475. * Adds all the elements from the container to the scene
  119476. * @param container the container holding the elements
  119477. */
  119478. addFromContainer(container: AbstractScene): void;
  119479. /**
  119480. * Removes all the elements in the container from the scene
  119481. * @param container contains the elements to remove
  119482. * @param dispose if the removed element should be disposed (default: false)
  119483. */
  119484. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  119485. }
  119486. }
  119487. declare module BABYLON {
  119488. /** @hidden */
  119489. export var layerPixelShader: {
  119490. name: string;
  119491. shader: string;
  119492. };
  119493. }
  119494. declare module BABYLON {
  119495. /** @hidden */
  119496. export var layerVertexShader: {
  119497. name: string;
  119498. shader: string;
  119499. };
  119500. }
  119501. declare module BABYLON {
  119502. /**
  119503. * This represents a full screen 2d layer.
  119504. * This can be useful to display a picture in the background of your scene for instance.
  119505. * @see https://www.babylonjs-playground.com/#08A2BS#1
  119506. */
  119507. export class Layer {
  119508. /**
  119509. * Define the name of the layer.
  119510. */
  119511. name: string;
  119512. /**
  119513. * Define the texture the layer should display.
  119514. */
  119515. texture: Nullable<Texture>;
  119516. /**
  119517. * Is the layer in background or foreground.
  119518. */
  119519. isBackground: boolean;
  119520. /**
  119521. * Define the color of the layer (instead of texture).
  119522. */
  119523. color: Color4;
  119524. /**
  119525. * Define the scale of the layer in order to zoom in out of the texture.
  119526. */
  119527. scale: Vector2;
  119528. /**
  119529. * Define an offset for the layer in order to shift the texture.
  119530. */
  119531. offset: Vector2;
  119532. /**
  119533. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  119534. */
  119535. alphaBlendingMode: number;
  119536. /**
  119537. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  119538. * Alpha test will not mix with the background color in case of transparency.
  119539. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  119540. */
  119541. alphaTest: boolean;
  119542. /**
  119543. * Define a mask to restrict the layer to only some of the scene cameras.
  119544. */
  119545. layerMask: number;
  119546. /**
  119547. * Define the list of render target the layer is visible into.
  119548. */
  119549. renderTargetTextures: RenderTargetTexture[];
  119550. /**
  119551. * Define if the layer is only used in renderTarget or if it also
  119552. * renders in the main frame buffer of the canvas.
  119553. */
  119554. renderOnlyInRenderTargetTextures: boolean;
  119555. private _scene;
  119556. private _vertexBuffers;
  119557. private _indexBuffer;
  119558. private _effect;
  119559. private _alphaTestEffect;
  119560. /**
  119561. * An event triggered when the layer is disposed.
  119562. */
  119563. onDisposeObservable: Observable<Layer>;
  119564. private _onDisposeObserver;
  119565. /**
  119566. * Back compatibility with callback before the onDisposeObservable existed.
  119567. * The set callback will be triggered when the layer has been disposed.
  119568. */
  119569. onDispose: () => void;
  119570. /**
  119571. * An event triggered before rendering the scene
  119572. */
  119573. onBeforeRenderObservable: Observable<Layer>;
  119574. private _onBeforeRenderObserver;
  119575. /**
  119576. * Back compatibility with callback before the onBeforeRenderObservable existed.
  119577. * The set callback will be triggered just before rendering the layer.
  119578. */
  119579. onBeforeRender: () => void;
  119580. /**
  119581. * An event triggered after rendering the scene
  119582. */
  119583. onAfterRenderObservable: Observable<Layer>;
  119584. private _onAfterRenderObserver;
  119585. /**
  119586. * Back compatibility with callback before the onAfterRenderObservable existed.
  119587. * The set callback will be triggered just after rendering the layer.
  119588. */
  119589. onAfterRender: () => void;
  119590. /**
  119591. * Instantiates a new layer.
  119592. * This represents a full screen 2d layer.
  119593. * This can be useful to display a picture in the background of your scene for instance.
  119594. * @see https://www.babylonjs-playground.com/#08A2BS#1
  119595. * @param name Define the name of the layer in the scene
  119596. * @param imgUrl Define the url of the texture to display in the layer
  119597. * @param scene Define the scene the layer belongs to
  119598. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  119599. * @param color Defines a color for the layer
  119600. */
  119601. constructor(
  119602. /**
  119603. * Define the name of the layer.
  119604. */
  119605. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  119606. private _createIndexBuffer;
  119607. /** @hidden */
  119608. _rebuild(): void;
  119609. /**
  119610. * Renders the layer in the scene.
  119611. */
  119612. render(): void;
  119613. /**
  119614. * Disposes and releases the associated ressources.
  119615. */
  119616. dispose(): void;
  119617. }
  119618. }
  119619. declare module BABYLON {
  119620. /** @hidden */
  119621. export var lensFlarePixelShader: {
  119622. name: string;
  119623. shader: string;
  119624. };
  119625. }
  119626. declare module BABYLON {
  119627. /** @hidden */
  119628. export var lensFlareVertexShader: {
  119629. name: string;
  119630. shader: string;
  119631. };
  119632. }
  119633. declare module BABYLON {
  119634. /**
  119635. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  119636. * It is usually composed of several `lensFlare`.
  119637. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  119638. */
  119639. export class LensFlareSystem {
  119640. /**
  119641. * Define the name of the lens flare system
  119642. */
  119643. name: string;
  119644. /**
  119645. * List of lens flares used in this system.
  119646. */
  119647. lensFlares: LensFlare[];
  119648. /**
  119649. * Define a limit from the border the lens flare can be visible.
  119650. */
  119651. borderLimit: number;
  119652. /**
  119653. * Define a viewport border we do not want to see the lens flare in.
  119654. */
  119655. viewportBorder: number;
  119656. /**
  119657. * Define a predicate which could limit the list of meshes able to occlude the effect.
  119658. */
  119659. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  119660. /**
  119661. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  119662. */
  119663. layerMask: number;
  119664. /**
  119665. * Define the id of the lens flare system in the scene.
  119666. * (equal to name by default)
  119667. */
  119668. id: string;
  119669. private _scene;
  119670. private _emitter;
  119671. private _vertexBuffers;
  119672. private _indexBuffer;
  119673. private _effect;
  119674. private _positionX;
  119675. private _positionY;
  119676. private _isEnabled;
  119677. /** @hidden */
  119678. static _SceneComponentInitialization: (scene: Scene) => void;
  119679. /**
  119680. * Instantiates a lens flare system.
  119681. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  119682. * It is usually composed of several `lensFlare`.
  119683. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  119684. * @param name Define the name of the lens flare system in the scene
  119685. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  119686. * @param scene Define the scene the lens flare system belongs to
  119687. */
  119688. constructor(
  119689. /**
  119690. * Define the name of the lens flare system
  119691. */
  119692. name: string, emitter: any, scene: Scene);
  119693. /**
  119694. * Define if the lens flare system is enabled.
  119695. */
  119696. isEnabled: boolean;
  119697. /**
  119698. * Get the scene the effects belongs to.
  119699. * @returns the scene holding the lens flare system
  119700. */
  119701. getScene(): Scene;
  119702. /**
  119703. * Get the emitter of the lens flare system.
  119704. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  119705. * @returns the emitter of the lens flare system
  119706. */
  119707. getEmitter(): any;
  119708. /**
  119709. * Set the emitter of the lens flare system.
  119710. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  119711. * @param newEmitter Define the new emitter of the system
  119712. */
  119713. setEmitter(newEmitter: any): void;
  119714. /**
  119715. * Get the lens flare system emitter position.
  119716. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  119717. * @returns the position
  119718. */
  119719. getEmitterPosition(): Vector3;
  119720. /**
  119721. * @hidden
  119722. */
  119723. computeEffectivePosition(globalViewport: Viewport): boolean;
  119724. /** @hidden */
  119725. _isVisible(): boolean;
  119726. /**
  119727. * @hidden
  119728. */
  119729. render(): boolean;
  119730. /**
  119731. * Dispose and release the lens flare with its associated resources.
  119732. */
  119733. dispose(): void;
  119734. /**
  119735. * Parse a lens flare system from a JSON repressentation
  119736. * @param parsedLensFlareSystem Define the JSON to parse
  119737. * @param scene Define the scene the parsed system should be instantiated in
  119738. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  119739. * @returns the parsed system
  119740. */
  119741. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  119742. /**
  119743. * Serialize the current Lens Flare System into a JSON representation.
  119744. * @returns the serialized JSON
  119745. */
  119746. serialize(): any;
  119747. }
  119748. }
  119749. declare module BABYLON {
  119750. /**
  119751. * This represents one of the lens effect in a `lensFlareSystem`.
  119752. * It controls one of the indiviual texture used in the effect.
  119753. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  119754. */
  119755. export class LensFlare {
  119756. /**
  119757. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  119758. */
  119759. size: number;
  119760. /**
  119761. * 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.
  119762. */
  119763. position: number;
  119764. /**
  119765. * Define the lens color.
  119766. */
  119767. color: Color3;
  119768. /**
  119769. * Define the lens texture.
  119770. */
  119771. texture: Nullable<Texture>;
  119772. /**
  119773. * Define the alpha mode to render this particular lens.
  119774. */
  119775. alphaMode: number;
  119776. private _system;
  119777. /**
  119778. * Creates a new Lens Flare.
  119779. * This represents one of the lens effect in a `lensFlareSystem`.
  119780. * It controls one of the indiviual texture used in the effect.
  119781. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  119782. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  119783. * @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.
  119784. * @param color Define the lens color
  119785. * @param imgUrl Define the lens texture url
  119786. * @param system Define the `lensFlareSystem` this flare is part of
  119787. * @returns The newly created Lens Flare
  119788. */
  119789. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  119790. /**
  119791. * Instantiates a new Lens Flare.
  119792. * This represents one of the lens effect in a `lensFlareSystem`.
  119793. * It controls one of the indiviual texture used in the effect.
  119794. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  119795. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  119796. * @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.
  119797. * @param color Define the lens color
  119798. * @param imgUrl Define the lens texture url
  119799. * @param system Define the `lensFlareSystem` this flare is part of
  119800. */
  119801. constructor(
  119802. /**
  119803. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  119804. */
  119805. size: number,
  119806. /**
  119807. * 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.
  119808. */
  119809. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  119810. /**
  119811. * Dispose and release the lens flare with its associated resources.
  119812. */
  119813. dispose(): void;
  119814. }
  119815. }
  119816. declare module BABYLON {
  119817. interface AbstractScene {
  119818. /**
  119819. * The list of lens flare system added to the scene
  119820. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  119821. */
  119822. lensFlareSystems: Array<LensFlareSystem>;
  119823. /**
  119824. * Removes the given lens flare system from this scene.
  119825. * @param toRemove The lens flare system to remove
  119826. * @returns The index of the removed lens flare system
  119827. */
  119828. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  119829. /**
  119830. * Adds the given lens flare system to this scene
  119831. * @param newLensFlareSystem The lens flare system to add
  119832. */
  119833. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  119834. /**
  119835. * Gets a lens flare system using its name
  119836. * @param name defines the name to look for
  119837. * @returns the lens flare system or null if not found
  119838. */
  119839. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  119840. /**
  119841. * Gets a lens flare system using its id
  119842. * @param id defines the id to look for
  119843. * @returns the lens flare system or null if not found
  119844. */
  119845. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  119846. }
  119847. /**
  119848. * Defines the lens flare scene component responsible to manage any lens flares
  119849. * in a given scene.
  119850. */
  119851. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  119852. /**
  119853. * The component name helpfull to identify the component in the list of scene components.
  119854. */
  119855. readonly name: string;
  119856. /**
  119857. * The scene the component belongs to.
  119858. */
  119859. scene: Scene;
  119860. /**
  119861. * Creates a new instance of the component for the given scene
  119862. * @param scene Defines the scene to register the component in
  119863. */
  119864. constructor(scene: Scene);
  119865. /**
  119866. * Registers the component in a given scene
  119867. */
  119868. register(): void;
  119869. /**
  119870. * Rebuilds the elements related to this component in case of
  119871. * context lost for instance.
  119872. */
  119873. rebuild(): void;
  119874. /**
  119875. * Adds all the elements from the container to the scene
  119876. * @param container the container holding the elements
  119877. */
  119878. addFromContainer(container: AbstractScene): void;
  119879. /**
  119880. * Removes all the elements in the container from the scene
  119881. * @param container contains the elements to remove
  119882. * @param dispose if the removed element should be disposed (default: false)
  119883. */
  119884. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  119885. /**
  119886. * Serializes the component data to the specified json object
  119887. * @param serializationObject The object to serialize to
  119888. */
  119889. serialize(serializationObject: any): void;
  119890. /**
  119891. * Disposes the component and the associated ressources.
  119892. */
  119893. dispose(): void;
  119894. private _draw;
  119895. }
  119896. }
  119897. declare module BABYLON {
  119898. /**
  119899. * Defines the shadow generator component responsible to manage any shadow generators
  119900. * in a given scene.
  119901. */
  119902. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  119903. /**
  119904. * The component name helpfull to identify the component in the list of scene components.
  119905. */
  119906. readonly name: string;
  119907. /**
  119908. * The scene the component belongs to.
  119909. */
  119910. scene: Scene;
  119911. /**
  119912. * Creates a new instance of the component for the given scene
  119913. * @param scene Defines the scene to register the component in
  119914. */
  119915. constructor(scene: Scene);
  119916. /**
  119917. * Registers the component in a given scene
  119918. */
  119919. register(): void;
  119920. /**
  119921. * Rebuilds the elements related to this component in case of
  119922. * context lost for instance.
  119923. */
  119924. rebuild(): void;
  119925. /**
  119926. * Serializes the component data to the specified json object
  119927. * @param serializationObject The object to serialize to
  119928. */
  119929. serialize(serializationObject: any): void;
  119930. /**
  119931. * Adds all the elements from the container to the scene
  119932. * @param container the container holding the elements
  119933. */
  119934. addFromContainer(container: AbstractScene): void;
  119935. /**
  119936. * Removes all the elements in the container from the scene
  119937. * @param container contains the elements to remove
  119938. * @param dispose if the removed element should be disposed (default: false)
  119939. */
  119940. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  119941. /**
  119942. * Rebuilds the elements related to this component in case of
  119943. * context lost for instance.
  119944. */
  119945. dispose(): void;
  119946. private _gatherRenderTargets;
  119947. }
  119948. }
  119949. declare module BABYLON {
  119950. /**
  119951. * A point light is a light defined by an unique point in world space.
  119952. * The light is emitted in every direction from this point.
  119953. * A good example of a point light is a standard light bulb.
  119954. * Documentation: https://doc.babylonjs.com/babylon101/lights
  119955. */
  119956. export class PointLight extends ShadowLight {
  119957. private _shadowAngle;
  119958. /**
  119959. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  119960. * This specifies what angle the shadow will use to be created.
  119961. *
  119962. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  119963. */
  119964. /**
  119965. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  119966. * This specifies what angle the shadow will use to be created.
  119967. *
  119968. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  119969. */
  119970. shadowAngle: number;
  119971. /**
  119972. * Gets the direction if it has been set.
  119973. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  119974. */
  119975. /**
  119976. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  119977. */
  119978. direction: Vector3;
  119979. /**
  119980. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  119981. * A PointLight emits the light in every direction.
  119982. * It can cast shadows.
  119983. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  119984. * ```javascript
  119985. * var pointLight = new PointLight("pl", camera.position, scene);
  119986. * ```
  119987. * Documentation : https://doc.babylonjs.com/babylon101/lights
  119988. * @param name The light friendly name
  119989. * @param position The position of the point light in the scene
  119990. * @param scene The scene the lights belongs to
  119991. */
  119992. constructor(name: string, position: Vector3, scene: Scene);
  119993. /**
  119994. * Returns the string "PointLight"
  119995. * @returns the class name
  119996. */
  119997. getClassName(): string;
  119998. /**
  119999. * Returns the integer 0.
  120000. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  120001. */
  120002. getTypeID(): number;
  120003. /**
  120004. * Specifies wether or not the shadowmap should be a cube texture.
  120005. * @returns true if the shadowmap needs to be a cube texture.
  120006. */
  120007. needCube(): boolean;
  120008. /**
  120009. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  120010. * @param faceIndex The index of the face we are computed the direction to generate shadow
  120011. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  120012. */
  120013. getShadowDirection(faceIndex?: number): Vector3;
  120014. /**
  120015. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  120016. * - fov = PI / 2
  120017. * - aspect ratio : 1.0
  120018. * - z-near and far equal to the active camera minZ and maxZ.
  120019. * Returns the PointLight.
  120020. */
  120021. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  120022. protected _buildUniformLayout(): void;
  120023. /**
  120024. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  120025. * @param effect The effect to update
  120026. * @param lightIndex The index of the light in the effect to update
  120027. * @returns The point light
  120028. */
  120029. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  120030. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  120031. /**
  120032. * Prepares the list of defines specific to the light type.
  120033. * @param defines the list of defines
  120034. * @param lightIndex defines the index of the light for the effect
  120035. */
  120036. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  120037. }
  120038. }
  120039. declare module BABYLON {
  120040. /**
  120041. * Header information of HDR texture files.
  120042. */
  120043. export interface HDRInfo {
  120044. /**
  120045. * The height of the texture in pixels.
  120046. */
  120047. height: number;
  120048. /**
  120049. * The width of the texture in pixels.
  120050. */
  120051. width: number;
  120052. /**
  120053. * The index of the beginning of the data in the binary file.
  120054. */
  120055. dataPosition: number;
  120056. }
  120057. /**
  120058. * This groups tools to convert HDR texture to native colors array.
  120059. */
  120060. export class HDRTools {
  120061. private static Ldexp;
  120062. private static Rgbe2float;
  120063. private static readStringLine;
  120064. /**
  120065. * Reads header information from an RGBE texture stored in a native array.
  120066. * More information on this format are available here:
  120067. * https://en.wikipedia.org/wiki/RGBE_image_format
  120068. *
  120069. * @param uint8array The binary file stored in native array.
  120070. * @return The header information.
  120071. */
  120072. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  120073. /**
  120074. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  120075. * This RGBE texture needs to store the information as a panorama.
  120076. *
  120077. * More information on this format are available here:
  120078. * https://en.wikipedia.org/wiki/RGBE_image_format
  120079. *
  120080. * @param buffer The binary file stored in an array buffer.
  120081. * @param size The expected size of the extracted cubemap.
  120082. * @return The Cube Map information.
  120083. */
  120084. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  120085. /**
  120086. * Returns the pixels data extracted from an RGBE texture.
  120087. * This pixels will be stored left to right up to down in the R G B order in one array.
  120088. *
  120089. * More information on this format are available here:
  120090. * https://en.wikipedia.org/wiki/RGBE_image_format
  120091. *
  120092. * @param uint8array The binary file stored in an array buffer.
  120093. * @param hdrInfo The header information of the file.
  120094. * @return The pixels data in RGB right to left up to down order.
  120095. */
  120096. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  120097. private static RGBE_ReadPixels_RLE;
  120098. }
  120099. }
  120100. declare module BABYLON {
  120101. /**
  120102. * This represents a texture coming from an HDR input.
  120103. *
  120104. * The only supported format is currently panorama picture stored in RGBE format.
  120105. * Example of such files can be found on HDRLib: http://hdrlib.com/
  120106. */
  120107. export class HDRCubeTexture extends BaseTexture {
  120108. private static _facesMapping;
  120109. private _generateHarmonics;
  120110. private _noMipmap;
  120111. private _textureMatrix;
  120112. private _size;
  120113. private _onLoad;
  120114. private _onError;
  120115. /**
  120116. * The texture URL.
  120117. */
  120118. url: string;
  120119. /**
  120120. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  120121. */
  120122. coordinatesMode: number;
  120123. protected _isBlocking: boolean;
  120124. /**
  120125. * Sets wether or not the texture is blocking during loading.
  120126. */
  120127. /**
  120128. * Gets wether or not the texture is blocking during loading.
  120129. */
  120130. isBlocking: boolean;
  120131. protected _rotationY: number;
  120132. /**
  120133. * Sets texture matrix rotation angle around Y axis in radians.
  120134. */
  120135. /**
  120136. * Gets texture matrix rotation angle around Y axis radians.
  120137. */
  120138. rotationY: number;
  120139. /**
  120140. * Gets or sets the center of the bounding box associated with the cube texture
  120141. * It must define where the camera used to render the texture was set
  120142. */
  120143. boundingBoxPosition: Vector3;
  120144. private _boundingBoxSize;
  120145. /**
  120146. * Gets or sets the size of the bounding box associated with the cube texture
  120147. * When defined, the cubemap will switch to local mode
  120148. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  120149. * @example https://www.babylonjs-playground.com/#RNASML
  120150. */
  120151. boundingBoxSize: Vector3;
  120152. /**
  120153. * Instantiates an HDRTexture from the following parameters.
  120154. *
  120155. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  120156. * @param scene The scene the texture will be used in
  120157. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  120158. * @param noMipmap Forces to not generate the mipmap if true
  120159. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  120160. * @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)
  120161. * @param reserved Reserved flag for internal use.
  120162. */
  120163. 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>);
  120164. /**
  120165. * Get the current class name of the texture useful for serialization or dynamic coding.
  120166. * @returns "HDRCubeTexture"
  120167. */
  120168. getClassName(): string;
  120169. /**
  120170. * Occurs when the file is raw .hdr file.
  120171. */
  120172. private loadTexture;
  120173. clone(): HDRCubeTexture;
  120174. delayLoad(): void;
  120175. /**
  120176. * Get the texture reflection matrix used to rotate/transform the reflection.
  120177. * @returns the reflection matrix
  120178. */
  120179. getReflectionTextureMatrix(): Matrix;
  120180. /**
  120181. * Set the texture reflection matrix used to rotate/transform the reflection.
  120182. * @param value Define the reflection matrix to set
  120183. */
  120184. setReflectionTextureMatrix(value: Matrix): void;
  120185. /**
  120186. * Parses a JSON representation of an HDR Texture in order to create the texture
  120187. * @param parsedTexture Define the JSON representation
  120188. * @param scene Define the scene the texture should be created in
  120189. * @param rootUrl Define the root url in case we need to load relative dependencies
  120190. * @returns the newly created texture after parsing
  120191. */
  120192. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  120193. serialize(): any;
  120194. }
  120195. }
  120196. declare module BABYLON {
  120197. /**
  120198. * Class used to control physics engine
  120199. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  120200. */
  120201. export class PhysicsEngine implements IPhysicsEngine {
  120202. private _physicsPlugin;
  120203. /**
  120204. * Global value used to control the smallest number supported by the simulation
  120205. */
  120206. static Epsilon: number;
  120207. private _impostors;
  120208. private _joints;
  120209. /**
  120210. * Gets the gravity vector used by the simulation
  120211. */
  120212. gravity: Vector3;
  120213. /**
  120214. * Factory used to create the default physics plugin.
  120215. * @returns The default physics plugin
  120216. */
  120217. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  120218. /**
  120219. * Creates a new Physics Engine
  120220. * @param gravity defines the gravity vector used by the simulation
  120221. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  120222. */
  120223. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  120224. /**
  120225. * Sets the gravity vector used by the simulation
  120226. * @param gravity defines the gravity vector to use
  120227. */
  120228. setGravity(gravity: Vector3): void;
  120229. /**
  120230. * Set the time step of the physics engine.
  120231. * Default is 1/60.
  120232. * To slow it down, enter 1/600 for example.
  120233. * To speed it up, 1/30
  120234. * @param newTimeStep defines the new timestep to apply to this world.
  120235. */
  120236. setTimeStep(newTimeStep?: number): void;
  120237. /**
  120238. * Get the time step of the physics engine.
  120239. * @returns the current time step
  120240. */
  120241. getTimeStep(): number;
  120242. /**
  120243. * Release all resources
  120244. */
  120245. dispose(): void;
  120246. /**
  120247. * Gets the name of the current physics plugin
  120248. * @returns the name of the plugin
  120249. */
  120250. getPhysicsPluginName(): string;
  120251. /**
  120252. * Adding a new impostor for the impostor tracking.
  120253. * This will be done by the impostor itself.
  120254. * @param impostor the impostor to add
  120255. */
  120256. addImpostor(impostor: PhysicsImpostor): void;
  120257. /**
  120258. * Remove an impostor from the engine.
  120259. * This impostor and its mesh will not longer be updated by the physics engine.
  120260. * @param impostor the impostor to remove
  120261. */
  120262. removeImpostor(impostor: PhysicsImpostor): void;
  120263. /**
  120264. * Add a joint to the physics engine
  120265. * @param mainImpostor defines the main impostor to which the joint is added.
  120266. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  120267. * @param joint defines the joint that will connect both impostors.
  120268. */
  120269. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  120270. /**
  120271. * Removes a joint from the simulation
  120272. * @param mainImpostor defines the impostor used with the joint
  120273. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  120274. * @param joint defines the joint to remove
  120275. */
  120276. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  120277. /**
  120278. * Called by the scene. No need to call it.
  120279. * @param delta defines the timespam between frames
  120280. */
  120281. _step(delta: number): void;
  120282. /**
  120283. * Gets the current plugin used to run the simulation
  120284. * @returns current plugin
  120285. */
  120286. getPhysicsPlugin(): IPhysicsEnginePlugin;
  120287. /**
  120288. * Gets the list of physic impostors
  120289. * @returns an array of PhysicsImpostor
  120290. */
  120291. getImpostors(): Array<PhysicsImpostor>;
  120292. /**
  120293. * Gets the impostor for a physics enabled object
  120294. * @param object defines the object impersonated by the impostor
  120295. * @returns the PhysicsImpostor or null if not found
  120296. */
  120297. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  120298. /**
  120299. * Gets the impostor for a physics body object
  120300. * @param body defines physics body used by the impostor
  120301. * @returns the PhysicsImpostor or null if not found
  120302. */
  120303. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  120304. /**
  120305. * Does a raycast in the physics world
  120306. * @param from when should the ray start?
  120307. * @param to when should the ray end?
  120308. * @returns PhysicsRaycastResult
  120309. */
  120310. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  120311. }
  120312. }
  120313. declare module BABYLON {
  120314. /** @hidden */
  120315. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  120316. private _useDeltaForWorldStep;
  120317. world: any;
  120318. name: string;
  120319. private _physicsMaterials;
  120320. private _fixedTimeStep;
  120321. private _cannonRaycastResult;
  120322. private _raycastResult;
  120323. private _physicsBodysToRemoveAfterStep;
  120324. BJSCANNON: any;
  120325. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  120326. setGravity(gravity: Vector3): void;
  120327. setTimeStep(timeStep: number): void;
  120328. getTimeStep(): number;
  120329. executeStep(delta: number): void;
  120330. private _removeMarkedPhysicsBodiesFromWorld;
  120331. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  120332. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  120333. generatePhysicsBody(impostor: PhysicsImpostor): void;
  120334. private _processChildMeshes;
  120335. removePhysicsBody(impostor: PhysicsImpostor): void;
  120336. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  120337. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  120338. private _addMaterial;
  120339. private _checkWithEpsilon;
  120340. private _createShape;
  120341. private _createHeightmap;
  120342. private _minus90X;
  120343. private _plus90X;
  120344. private _tmpPosition;
  120345. private _tmpDeltaPosition;
  120346. private _tmpUnityRotation;
  120347. private _updatePhysicsBodyTransformation;
  120348. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  120349. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  120350. isSupported(): boolean;
  120351. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  120352. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  120353. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  120354. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  120355. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  120356. getBodyMass(impostor: PhysicsImpostor): number;
  120357. getBodyFriction(impostor: PhysicsImpostor): number;
  120358. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  120359. getBodyRestitution(impostor: PhysicsImpostor): number;
  120360. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  120361. sleepBody(impostor: PhysicsImpostor): void;
  120362. wakeUpBody(impostor: PhysicsImpostor): void;
  120363. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  120364. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  120365. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  120366. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  120367. getRadius(impostor: PhysicsImpostor): number;
  120368. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  120369. dispose(): void;
  120370. private _extendNamespace;
  120371. /**
  120372. * Does a raycast in the physics world
  120373. * @param from when should the ray start?
  120374. * @param to when should the ray end?
  120375. * @returns PhysicsRaycastResult
  120376. */
  120377. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  120378. }
  120379. }
  120380. declare module BABYLON {
  120381. /** @hidden */
  120382. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  120383. world: any;
  120384. name: string;
  120385. BJSOIMO: any;
  120386. private _raycastResult;
  120387. constructor(iterations?: number, oimoInjection?: any);
  120388. setGravity(gravity: Vector3): void;
  120389. setTimeStep(timeStep: number): void;
  120390. getTimeStep(): number;
  120391. private _tmpImpostorsArray;
  120392. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  120393. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  120394. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  120395. generatePhysicsBody(impostor: PhysicsImpostor): void;
  120396. private _tmpPositionVector;
  120397. removePhysicsBody(impostor: PhysicsImpostor): void;
  120398. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  120399. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  120400. isSupported(): boolean;
  120401. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  120402. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  120403. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  120404. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  120405. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  120406. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  120407. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  120408. getBodyMass(impostor: PhysicsImpostor): number;
  120409. getBodyFriction(impostor: PhysicsImpostor): number;
  120410. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  120411. getBodyRestitution(impostor: PhysicsImpostor): number;
  120412. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  120413. sleepBody(impostor: PhysicsImpostor): void;
  120414. wakeUpBody(impostor: PhysicsImpostor): void;
  120415. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  120416. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  120417. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  120418. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  120419. getRadius(impostor: PhysicsImpostor): number;
  120420. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  120421. dispose(): void;
  120422. /**
  120423. * Does a raycast in the physics world
  120424. * @param from when should the ray start?
  120425. * @param to when should the ray end?
  120426. * @returns PhysicsRaycastResult
  120427. */
  120428. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  120429. }
  120430. }
  120431. declare module BABYLON {
  120432. /**
  120433. * Class containing static functions to help procedurally build meshes
  120434. */
  120435. export class RibbonBuilder {
  120436. /**
  120437. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  120438. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  120439. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  120440. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  120441. * * 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
  120442. * * 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
  120443. * * 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
  120444. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  120445. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  120446. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  120447. * * 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
  120448. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  120449. * * 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
  120450. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  120451. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  120452. * @param name defines the name of the mesh
  120453. * @param options defines the options used to create the mesh
  120454. * @param scene defines the hosting scene
  120455. * @returns the ribbon mesh
  120456. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  120457. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  120458. */
  120459. static CreateRibbon(name: string, options: {
  120460. pathArray: Vector3[][];
  120461. closeArray?: boolean;
  120462. closePath?: boolean;
  120463. offset?: number;
  120464. updatable?: boolean;
  120465. sideOrientation?: number;
  120466. frontUVs?: Vector4;
  120467. backUVs?: Vector4;
  120468. instance?: Mesh;
  120469. invertUV?: boolean;
  120470. uvs?: Vector2[];
  120471. colors?: Color4[];
  120472. }, scene?: Nullable<Scene>): Mesh;
  120473. }
  120474. }
  120475. declare module BABYLON {
  120476. /**
  120477. * Class containing static functions to help procedurally build meshes
  120478. */
  120479. export class ShapeBuilder {
  120480. /**
  120481. * 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.
  120482. * * 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.
  120483. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  120484. * * 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.
  120485. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  120486. * * 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
  120487. * * 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
  120488. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  120489. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  120490. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  120491. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  120492. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  120493. * @param name defines the name of the mesh
  120494. * @param options defines the options used to create the mesh
  120495. * @param scene defines the hosting scene
  120496. * @returns the extruded shape mesh
  120497. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  120498. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  120499. */
  120500. static ExtrudeShape(name: string, options: {
  120501. shape: Vector3[];
  120502. path: Vector3[];
  120503. scale?: number;
  120504. rotation?: number;
  120505. cap?: number;
  120506. updatable?: boolean;
  120507. sideOrientation?: number;
  120508. frontUVs?: Vector4;
  120509. backUVs?: Vector4;
  120510. instance?: Mesh;
  120511. invertUV?: boolean;
  120512. }, scene?: Nullable<Scene>): Mesh;
  120513. /**
  120514. * Creates an custom extruded shape mesh.
  120515. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  120516. * * 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.
  120517. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  120518. * * 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
  120519. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  120520. * * 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
  120521. * * It must returns a float value that will be the scale value applied to the shape on each path point
  120522. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  120523. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  120524. * * 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
  120525. * * 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
  120526. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  120527. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  120528. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  120529. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  120530. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  120531. * @param name defines the name of the mesh
  120532. * @param options defines the options used to create the mesh
  120533. * @param scene defines the hosting scene
  120534. * @returns the custom extruded shape mesh
  120535. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  120536. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  120537. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  120538. */
  120539. static ExtrudeShapeCustom(name: string, options: {
  120540. shape: Vector3[];
  120541. path: Vector3[];
  120542. scaleFunction?: any;
  120543. rotationFunction?: any;
  120544. ribbonCloseArray?: boolean;
  120545. ribbonClosePath?: boolean;
  120546. cap?: number;
  120547. updatable?: boolean;
  120548. sideOrientation?: number;
  120549. frontUVs?: Vector4;
  120550. backUVs?: Vector4;
  120551. instance?: Mesh;
  120552. invertUV?: boolean;
  120553. }, scene?: Nullable<Scene>): Mesh;
  120554. private static _ExtrudeShapeGeneric;
  120555. }
  120556. }
  120557. declare module BABYLON {
  120558. /**
  120559. * AmmoJS Physics plugin
  120560. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  120561. * @see https://github.com/kripken/ammo.js/
  120562. */
  120563. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  120564. private _useDeltaForWorldStep;
  120565. /**
  120566. * Reference to the Ammo library
  120567. */
  120568. bjsAMMO: any;
  120569. /**
  120570. * Created ammoJS world which physics bodies are added to
  120571. */
  120572. world: any;
  120573. /**
  120574. * Name of the plugin
  120575. */
  120576. name: string;
  120577. private _timeStep;
  120578. private _fixedTimeStep;
  120579. private _maxSteps;
  120580. private _tmpQuaternion;
  120581. private _tmpAmmoTransform;
  120582. private _tmpAmmoQuaternion;
  120583. private _tmpAmmoConcreteContactResultCallback;
  120584. private _collisionConfiguration;
  120585. private _dispatcher;
  120586. private _overlappingPairCache;
  120587. private _solver;
  120588. private _softBodySolver;
  120589. private _tmpAmmoVectorA;
  120590. private _tmpAmmoVectorB;
  120591. private _tmpAmmoVectorC;
  120592. private _tmpAmmoVectorD;
  120593. private _tmpContactCallbackResult;
  120594. private _tmpAmmoVectorRCA;
  120595. private _tmpAmmoVectorRCB;
  120596. private _raycastResult;
  120597. private static readonly DISABLE_COLLISION_FLAG;
  120598. private static readonly KINEMATIC_FLAG;
  120599. private static readonly DISABLE_DEACTIVATION_FLAG;
  120600. /**
  120601. * Initializes the ammoJS plugin
  120602. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  120603. * @param ammoInjection can be used to inject your own ammo reference
  120604. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  120605. */
  120606. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  120607. /**
  120608. * Sets the gravity of the physics world (m/(s^2))
  120609. * @param gravity Gravity to set
  120610. */
  120611. setGravity(gravity: Vector3): void;
  120612. /**
  120613. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  120614. * @param timeStep timestep to use in seconds
  120615. */
  120616. setTimeStep(timeStep: number): void;
  120617. /**
  120618. * 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)
  120619. * @param fixedTimeStep fixedTimeStep to use in seconds
  120620. */
  120621. setFixedTimeStep(fixedTimeStep: number): void;
  120622. /**
  120623. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  120624. * @param maxSteps the maximum number of steps by the physics engine per frame
  120625. */
  120626. setMaxSteps(maxSteps: number): void;
  120627. /**
  120628. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  120629. * @returns the current timestep in seconds
  120630. */
  120631. getTimeStep(): number;
  120632. private _isImpostorInContact;
  120633. private _isImpostorPairInContact;
  120634. private _stepSimulation;
  120635. /**
  120636. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  120637. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  120638. * After the step the babylon meshes are set to the position of the physics imposters
  120639. * @param delta amount of time to step forward
  120640. * @param impostors array of imposters to update before/after the step
  120641. */
  120642. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  120643. /**
  120644. * Update babylon mesh to match physics world object
  120645. * @param impostor imposter to match
  120646. */
  120647. private _afterSoftStep;
  120648. /**
  120649. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  120650. * @param impostor imposter to match
  120651. */
  120652. private _ropeStep;
  120653. /**
  120654. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  120655. * @param impostor imposter to match
  120656. */
  120657. private _softbodyOrClothStep;
  120658. private _tmpVector;
  120659. private _tmpMatrix;
  120660. /**
  120661. * Applies an impulse on the imposter
  120662. * @param impostor imposter to apply impulse to
  120663. * @param force amount of force to be applied to the imposter
  120664. * @param contactPoint the location to apply the impulse on the imposter
  120665. */
  120666. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  120667. /**
  120668. * Applies a force on the imposter
  120669. * @param impostor imposter to apply force
  120670. * @param force amount of force to be applied to the imposter
  120671. * @param contactPoint the location to apply the force on the imposter
  120672. */
  120673. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  120674. /**
  120675. * Creates a physics body using the plugin
  120676. * @param impostor the imposter to create the physics body on
  120677. */
  120678. generatePhysicsBody(impostor: PhysicsImpostor): void;
  120679. /**
  120680. * Removes the physics body from the imposter and disposes of the body's memory
  120681. * @param impostor imposter to remove the physics body from
  120682. */
  120683. removePhysicsBody(impostor: PhysicsImpostor): void;
  120684. /**
  120685. * Generates a joint
  120686. * @param impostorJoint the imposter joint to create the joint with
  120687. */
  120688. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  120689. /**
  120690. * Removes a joint
  120691. * @param impostorJoint the imposter joint to remove the joint from
  120692. */
  120693. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  120694. private _addMeshVerts;
  120695. /**
  120696. * Initialise the soft body vertices to match its object's (mesh) vertices
  120697. * Softbody vertices (nodes) are in world space and to match this
  120698. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  120699. * @param impostor to create the softbody for
  120700. */
  120701. private _softVertexData;
  120702. /**
  120703. * Create an impostor's soft body
  120704. * @param impostor to create the softbody for
  120705. */
  120706. private _createSoftbody;
  120707. /**
  120708. * Create cloth for an impostor
  120709. * @param impostor to create the softbody for
  120710. */
  120711. private _createCloth;
  120712. /**
  120713. * Create rope for an impostor
  120714. * @param impostor to create the softbody for
  120715. */
  120716. private _createRope;
  120717. private _addHullVerts;
  120718. private _createShape;
  120719. /**
  120720. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  120721. * @param impostor imposter containing the physics body and babylon object
  120722. */
  120723. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  120724. /**
  120725. * Sets the babylon object's position/rotation from the physics body's position/rotation
  120726. * @param impostor imposter containing the physics body and babylon object
  120727. * @param newPosition new position
  120728. * @param newRotation new rotation
  120729. */
  120730. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  120731. /**
  120732. * If this plugin is supported
  120733. * @returns true if its supported
  120734. */
  120735. isSupported(): boolean;
  120736. /**
  120737. * Sets the linear velocity of the physics body
  120738. * @param impostor imposter to set the velocity on
  120739. * @param velocity velocity to set
  120740. */
  120741. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  120742. /**
  120743. * Sets the angular velocity of the physics body
  120744. * @param impostor imposter to set the velocity on
  120745. * @param velocity velocity to set
  120746. */
  120747. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  120748. /**
  120749. * gets the linear velocity
  120750. * @param impostor imposter to get linear velocity from
  120751. * @returns linear velocity
  120752. */
  120753. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  120754. /**
  120755. * gets the angular velocity
  120756. * @param impostor imposter to get angular velocity from
  120757. * @returns angular velocity
  120758. */
  120759. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  120760. /**
  120761. * Sets the mass of physics body
  120762. * @param impostor imposter to set the mass on
  120763. * @param mass mass to set
  120764. */
  120765. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  120766. /**
  120767. * Gets the mass of the physics body
  120768. * @param impostor imposter to get the mass from
  120769. * @returns mass
  120770. */
  120771. getBodyMass(impostor: PhysicsImpostor): number;
  120772. /**
  120773. * Gets friction of the impostor
  120774. * @param impostor impostor to get friction from
  120775. * @returns friction value
  120776. */
  120777. getBodyFriction(impostor: PhysicsImpostor): number;
  120778. /**
  120779. * Sets friction of the impostor
  120780. * @param impostor impostor to set friction on
  120781. * @param friction friction value
  120782. */
  120783. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  120784. /**
  120785. * Gets restitution of the impostor
  120786. * @param impostor impostor to get restitution from
  120787. * @returns restitution value
  120788. */
  120789. getBodyRestitution(impostor: PhysicsImpostor): number;
  120790. /**
  120791. * Sets resitution of the impostor
  120792. * @param impostor impostor to set resitution on
  120793. * @param restitution resitution value
  120794. */
  120795. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  120796. /**
  120797. * Gets pressure inside the impostor
  120798. * @param impostor impostor to get pressure from
  120799. * @returns pressure value
  120800. */
  120801. getBodyPressure(impostor: PhysicsImpostor): number;
  120802. /**
  120803. * Sets pressure inside a soft body impostor
  120804. * Cloth and rope must remain 0 pressure
  120805. * @param impostor impostor to set pressure on
  120806. * @param pressure pressure value
  120807. */
  120808. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  120809. /**
  120810. * Gets stiffness of the impostor
  120811. * @param impostor impostor to get stiffness from
  120812. * @returns pressure value
  120813. */
  120814. getBodyStiffness(impostor: PhysicsImpostor): number;
  120815. /**
  120816. * Sets stiffness of the impostor
  120817. * @param impostor impostor to set stiffness on
  120818. * @param stiffness stiffness value from 0 to 1
  120819. */
  120820. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  120821. /**
  120822. * Gets velocityIterations of the impostor
  120823. * @param impostor impostor to get velocity iterations from
  120824. * @returns velocityIterations value
  120825. */
  120826. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  120827. /**
  120828. * Sets velocityIterations of the impostor
  120829. * @param impostor impostor to set velocity iterations on
  120830. * @param velocityIterations velocityIterations value
  120831. */
  120832. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  120833. /**
  120834. * Gets positionIterations of the impostor
  120835. * @param impostor impostor to get position iterations from
  120836. * @returns positionIterations value
  120837. */
  120838. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  120839. /**
  120840. * Sets positionIterations of the impostor
  120841. * @param impostor impostor to set position on
  120842. * @param positionIterations positionIterations value
  120843. */
  120844. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  120845. /**
  120846. * Append an anchor to a cloth object
  120847. * @param impostor is the cloth impostor to add anchor to
  120848. * @param otherImpostor is the rigid impostor to anchor to
  120849. * @param width ratio across width from 0 to 1
  120850. * @param height ratio up height from 0 to 1
  120851. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  120852. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  120853. */
  120854. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  120855. /**
  120856. * Append an hook to a rope object
  120857. * @param impostor is the rope impostor to add hook to
  120858. * @param otherImpostor is the rigid impostor to hook to
  120859. * @param length ratio along the rope from 0 to 1
  120860. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  120861. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  120862. */
  120863. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  120864. /**
  120865. * Sleeps the physics body and stops it from being active
  120866. * @param impostor impostor to sleep
  120867. */
  120868. sleepBody(impostor: PhysicsImpostor): void;
  120869. /**
  120870. * Activates the physics body
  120871. * @param impostor impostor to activate
  120872. */
  120873. wakeUpBody(impostor: PhysicsImpostor): void;
  120874. /**
  120875. * Updates the distance parameters of the joint
  120876. * @param joint joint to update
  120877. * @param maxDistance maximum distance of the joint
  120878. * @param minDistance minimum distance of the joint
  120879. */
  120880. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  120881. /**
  120882. * Sets a motor on the joint
  120883. * @param joint joint to set motor on
  120884. * @param speed speed of the motor
  120885. * @param maxForce maximum force of the motor
  120886. * @param motorIndex index of the motor
  120887. */
  120888. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  120889. /**
  120890. * Sets the motors limit
  120891. * @param joint joint to set limit on
  120892. * @param upperLimit upper limit
  120893. * @param lowerLimit lower limit
  120894. */
  120895. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  120896. /**
  120897. * Syncs the position and rotation of a mesh with the impostor
  120898. * @param mesh mesh to sync
  120899. * @param impostor impostor to update the mesh with
  120900. */
  120901. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  120902. /**
  120903. * Gets the radius of the impostor
  120904. * @param impostor impostor to get radius from
  120905. * @returns the radius
  120906. */
  120907. getRadius(impostor: PhysicsImpostor): number;
  120908. /**
  120909. * Gets the box size of the impostor
  120910. * @param impostor impostor to get box size from
  120911. * @param result the resulting box size
  120912. */
  120913. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  120914. /**
  120915. * Disposes of the impostor
  120916. */
  120917. dispose(): void;
  120918. /**
  120919. * Does a raycast in the physics world
  120920. * @param from when should the ray start?
  120921. * @param to when should the ray end?
  120922. * @returns PhysicsRaycastResult
  120923. */
  120924. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  120925. }
  120926. }
  120927. declare module BABYLON {
  120928. interface AbstractScene {
  120929. /**
  120930. * The list of reflection probes added to the scene
  120931. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  120932. */
  120933. reflectionProbes: Array<ReflectionProbe>;
  120934. /**
  120935. * Removes the given reflection probe from this scene.
  120936. * @param toRemove The reflection probe to remove
  120937. * @returns The index of the removed reflection probe
  120938. */
  120939. removeReflectionProbe(toRemove: ReflectionProbe): number;
  120940. /**
  120941. * Adds the given reflection probe to this scene.
  120942. * @param newReflectionProbe The reflection probe to add
  120943. */
  120944. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  120945. }
  120946. /**
  120947. * Class used to generate realtime reflection / refraction cube textures
  120948. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  120949. */
  120950. export class ReflectionProbe {
  120951. /** defines the name of the probe */
  120952. name: string;
  120953. private _scene;
  120954. private _renderTargetTexture;
  120955. private _projectionMatrix;
  120956. private _viewMatrix;
  120957. private _target;
  120958. private _add;
  120959. private _attachedMesh;
  120960. private _invertYAxis;
  120961. /** Gets or sets probe position (center of the cube map) */
  120962. position: Vector3;
  120963. /**
  120964. * Creates a new reflection probe
  120965. * @param name defines the name of the probe
  120966. * @param size defines the texture resolution (for each face)
  120967. * @param scene defines the hosting scene
  120968. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  120969. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  120970. */
  120971. constructor(
  120972. /** defines the name of the probe */
  120973. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  120974. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  120975. samples: number;
  120976. /** Gets or sets the refresh rate to use (on every frame by default) */
  120977. refreshRate: number;
  120978. /**
  120979. * Gets the hosting scene
  120980. * @returns a Scene
  120981. */
  120982. getScene(): Scene;
  120983. /** Gets the internal CubeTexture used to render to */
  120984. readonly cubeTexture: RenderTargetTexture;
  120985. /** Gets the list of meshes to render */
  120986. readonly renderList: Nullable<AbstractMesh[]>;
  120987. /**
  120988. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  120989. * @param mesh defines the mesh to attach to
  120990. */
  120991. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  120992. /**
  120993. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  120994. * @param renderingGroupId The rendering group id corresponding to its index
  120995. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  120996. */
  120997. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  120998. /**
  120999. * Clean all associated resources
  121000. */
  121001. dispose(): void;
  121002. /**
  121003. * Converts the reflection probe information to a readable string for debug purpose.
  121004. * @param fullDetails Supports for multiple levels of logging within scene loading
  121005. * @returns the human readable reflection probe info
  121006. */
  121007. toString(fullDetails?: boolean): string;
  121008. /**
  121009. * Get the class name of the relfection probe.
  121010. * @returns "ReflectionProbe"
  121011. */
  121012. getClassName(): string;
  121013. /**
  121014. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  121015. * @returns The JSON representation of the texture
  121016. */
  121017. serialize(): any;
  121018. /**
  121019. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  121020. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  121021. * @param scene Define the scene the parsed reflection probe should be instantiated in
  121022. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  121023. * @returns The parsed reflection probe if successful
  121024. */
  121025. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  121026. }
  121027. }
  121028. declare module BABYLON {
  121029. /** @hidden */
  121030. export var _BabylonLoaderRegistered: boolean;
  121031. /**
  121032. * Helps setting up some configuration for the babylon file loader.
  121033. */
  121034. export class BabylonFileLoaderConfiguration {
  121035. /**
  121036. * The loader does not allow injecting custom physix engine into the plugins.
  121037. * Unfortunately in ES6, we need to manually inject them into the plugin.
  121038. * So you could set this variable to your engine import to make it work.
  121039. */
  121040. static LoaderInjectedPhysicsEngine: any;
  121041. }
  121042. }
  121043. declare module BABYLON {
  121044. /**
  121045. * The Physically based simple base material of BJS.
  121046. *
  121047. * This enables better naming and convention enforcements on top of the pbrMaterial.
  121048. * It is used as the base class for both the specGloss and metalRough conventions.
  121049. */
  121050. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  121051. /**
  121052. * Number of Simultaneous lights allowed on the material.
  121053. */
  121054. maxSimultaneousLights: number;
  121055. /**
  121056. * If sets to true, disables all the lights affecting the material.
  121057. */
  121058. disableLighting: boolean;
  121059. /**
  121060. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  121061. */
  121062. environmentTexture: BaseTexture;
  121063. /**
  121064. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  121065. */
  121066. invertNormalMapX: boolean;
  121067. /**
  121068. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  121069. */
  121070. invertNormalMapY: boolean;
  121071. /**
  121072. * Normal map used in the model.
  121073. */
  121074. normalTexture: BaseTexture;
  121075. /**
  121076. * Emissivie color used to self-illuminate the model.
  121077. */
  121078. emissiveColor: Color3;
  121079. /**
  121080. * Emissivie texture used to self-illuminate the model.
  121081. */
  121082. emissiveTexture: BaseTexture;
  121083. /**
  121084. * Occlusion Channel Strenght.
  121085. */
  121086. occlusionStrength: number;
  121087. /**
  121088. * Occlusion Texture of the material (adding extra occlusion effects).
  121089. */
  121090. occlusionTexture: BaseTexture;
  121091. /**
  121092. * Defines the alpha limits in alpha test mode.
  121093. */
  121094. alphaCutOff: number;
  121095. /**
  121096. * Gets the current double sided mode.
  121097. */
  121098. /**
  121099. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  121100. */
  121101. doubleSided: boolean;
  121102. /**
  121103. * Stores the pre-calculated light information of a mesh in a texture.
  121104. */
  121105. lightmapTexture: BaseTexture;
  121106. /**
  121107. * If true, the light map contains occlusion information instead of lighting info.
  121108. */
  121109. useLightmapAsShadowmap: boolean;
  121110. /**
  121111. * Instantiates a new PBRMaterial instance.
  121112. *
  121113. * @param name The material name
  121114. * @param scene The scene the material will be use in.
  121115. */
  121116. constructor(name: string, scene: Scene);
  121117. getClassName(): string;
  121118. }
  121119. }
  121120. declare module BABYLON {
  121121. /**
  121122. * The PBR material of BJS following the metal roughness convention.
  121123. *
  121124. * This fits to the PBR convention in the GLTF definition:
  121125. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  121126. */
  121127. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  121128. /**
  121129. * The base color has two different interpretations depending on the value of metalness.
  121130. * When the material is a metal, the base color is the specific measured reflectance value
  121131. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  121132. * of the material.
  121133. */
  121134. baseColor: Color3;
  121135. /**
  121136. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  121137. * well as opacity information in the alpha channel.
  121138. */
  121139. baseTexture: BaseTexture;
  121140. /**
  121141. * Specifies the metallic scalar value of the material.
  121142. * Can also be used to scale the metalness values of the metallic texture.
  121143. */
  121144. metallic: number;
  121145. /**
  121146. * Specifies the roughness scalar value of the material.
  121147. * Can also be used to scale the roughness values of the metallic texture.
  121148. */
  121149. roughness: number;
  121150. /**
  121151. * Texture containing both the metallic value in the B channel and the
  121152. * roughness value in the G channel to keep better precision.
  121153. */
  121154. metallicRoughnessTexture: BaseTexture;
  121155. /**
  121156. * Instantiates a new PBRMetalRoughnessMaterial instance.
  121157. *
  121158. * @param name The material name
  121159. * @param scene The scene the material will be use in.
  121160. */
  121161. constructor(name: string, scene: Scene);
  121162. /**
  121163. * Return the currrent class name of the material.
  121164. */
  121165. getClassName(): string;
  121166. /**
  121167. * Makes a duplicate of the current material.
  121168. * @param name - name to use for the new material.
  121169. */
  121170. clone(name: string): PBRMetallicRoughnessMaterial;
  121171. /**
  121172. * Serialize the material to a parsable JSON object.
  121173. */
  121174. serialize(): any;
  121175. /**
  121176. * Parses a JSON object correponding to the serialize function.
  121177. */
  121178. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  121179. }
  121180. }
  121181. declare module BABYLON {
  121182. /**
  121183. * The PBR material of BJS following the specular glossiness convention.
  121184. *
  121185. * This fits to the PBR convention in the GLTF definition:
  121186. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  121187. */
  121188. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  121189. /**
  121190. * Specifies the diffuse color of the material.
  121191. */
  121192. diffuseColor: Color3;
  121193. /**
  121194. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  121195. * channel.
  121196. */
  121197. diffuseTexture: BaseTexture;
  121198. /**
  121199. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  121200. */
  121201. specularColor: Color3;
  121202. /**
  121203. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  121204. */
  121205. glossiness: number;
  121206. /**
  121207. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  121208. */
  121209. specularGlossinessTexture: BaseTexture;
  121210. /**
  121211. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  121212. *
  121213. * @param name The material name
  121214. * @param scene The scene the material will be use in.
  121215. */
  121216. constructor(name: string, scene: Scene);
  121217. /**
  121218. * Return the currrent class name of the material.
  121219. */
  121220. getClassName(): string;
  121221. /**
  121222. * Makes a duplicate of the current material.
  121223. * @param name - name to use for the new material.
  121224. */
  121225. clone(name: string): PBRSpecularGlossinessMaterial;
  121226. /**
  121227. * Serialize the material to a parsable JSON object.
  121228. */
  121229. serialize(): any;
  121230. /**
  121231. * Parses a JSON object correponding to the serialize function.
  121232. */
  121233. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  121234. }
  121235. }
  121236. declare module BABYLON {
  121237. /**
  121238. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  121239. * It can help converting any input color in a desired output one. This can then be used to create effects
  121240. * from sepia, black and white to sixties or futuristic rendering...
  121241. *
  121242. * The only supported format is currently 3dl.
  121243. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  121244. */
  121245. export class ColorGradingTexture extends BaseTexture {
  121246. /**
  121247. * The current texture matrix. (will always be identity in color grading texture)
  121248. */
  121249. private _textureMatrix;
  121250. /**
  121251. * The texture URL.
  121252. */
  121253. url: string;
  121254. /**
  121255. * Empty line regex stored for GC.
  121256. */
  121257. private static _noneEmptyLineRegex;
  121258. private _engine;
  121259. /**
  121260. * Instantiates a ColorGradingTexture from the following parameters.
  121261. *
  121262. * @param url The location of the color gradind data (currently only supporting 3dl)
  121263. * @param scene The scene the texture will be used in
  121264. */
  121265. constructor(url: string, scene: Scene);
  121266. /**
  121267. * Returns the texture matrix used in most of the material.
  121268. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  121269. */
  121270. getTextureMatrix(): Matrix;
  121271. /**
  121272. * Occurs when the file being loaded is a .3dl LUT file.
  121273. */
  121274. private load3dlTexture;
  121275. /**
  121276. * Starts the loading process of the texture.
  121277. */
  121278. private loadTexture;
  121279. /**
  121280. * Clones the color gradind texture.
  121281. */
  121282. clone(): ColorGradingTexture;
  121283. /**
  121284. * Called during delayed load for textures.
  121285. */
  121286. delayLoad(): void;
  121287. /**
  121288. * Parses a color grading texture serialized by Babylon.
  121289. * @param parsedTexture The texture information being parsedTexture
  121290. * @param scene The scene to load the texture in
  121291. * @param rootUrl The root url of the data assets to load
  121292. * @return A color gradind texture
  121293. */
  121294. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  121295. /**
  121296. * Serializes the LUT texture to json format.
  121297. */
  121298. serialize(): any;
  121299. }
  121300. }
  121301. declare module BABYLON {
  121302. /**
  121303. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  121304. */
  121305. export class EquiRectangularCubeTexture extends BaseTexture {
  121306. /** The six faces of the cube. */
  121307. private static _FacesMapping;
  121308. private _noMipmap;
  121309. private _onLoad;
  121310. private _onError;
  121311. /** The size of the cubemap. */
  121312. private _size;
  121313. /** The buffer of the image. */
  121314. private _buffer;
  121315. /** The width of the input image. */
  121316. private _width;
  121317. /** The height of the input image. */
  121318. private _height;
  121319. /** The URL to the image. */
  121320. url: string;
  121321. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  121322. coordinatesMode: number;
  121323. /**
  121324. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  121325. * @param url The location of the image
  121326. * @param scene The scene the texture will be used in
  121327. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  121328. * @param noMipmap Forces to not generate the mipmap if true
  121329. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  121330. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  121331. * @param onLoad — defines a callback called when texture is loaded
  121332. * @param onError — defines a callback called if there is an error
  121333. */
  121334. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  121335. /**
  121336. * Load the image data, by putting the image on a canvas and extracting its buffer.
  121337. */
  121338. private loadImage;
  121339. /**
  121340. * Convert the image buffer into a cubemap and create a CubeTexture.
  121341. */
  121342. private loadTexture;
  121343. /**
  121344. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  121345. * @param buffer The ArrayBuffer that should be converted.
  121346. * @returns The buffer as Float32Array.
  121347. */
  121348. private getFloat32ArrayFromArrayBuffer;
  121349. /**
  121350. * Get the current class name of the texture useful for serialization or dynamic coding.
  121351. * @returns "EquiRectangularCubeTexture"
  121352. */
  121353. getClassName(): string;
  121354. /**
  121355. * Create a clone of the current EquiRectangularCubeTexture and return it.
  121356. * @returns A clone of the current EquiRectangularCubeTexture.
  121357. */
  121358. clone(): EquiRectangularCubeTexture;
  121359. }
  121360. }
  121361. declare module BABYLON {
  121362. /**
  121363. * Based on jsTGALoader - Javascript loader for TGA file
  121364. * By Vincent Thibault
  121365. * @see http://blog.robrowser.com/javascript-tga-loader.html
  121366. */
  121367. export class TGATools {
  121368. private static _TYPE_INDEXED;
  121369. private static _TYPE_RGB;
  121370. private static _TYPE_GREY;
  121371. private static _TYPE_RLE_INDEXED;
  121372. private static _TYPE_RLE_RGB;
  121373. private static _TYPE_RLE_GREY;
  121374. private static _ORIGIN_MASK;
  121375. private static _ORIGIN_SHIFT;
  121376. private static _ORIGIN_BL;
  121377. private static _ORIGIN_BR;
  121378. private static _ORIGIN_UL;
  121379. private static _ORIGIN_UR;
  121380. /**
  121381. * Gets the header of a TGA file
  121382. * @param data defines the TGA data
  121383. * @returns the header
  121384. */
  121385. static GetTGAHeader(data: Uint8Array): any;
  121386. /**
  121387. * Uploads TGA content to a Babylon Texture
  121388. * @hidden
  121389. */
  121390. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  121391. /** @hidden */
  121392. 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;
  121393. /** @hidden */
  121394. 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;
  121395. /** @hidden */
  121396. 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;
  121397. /** @hidden */
  121398. 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;
  121399. /** @hidden */
  121400. 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;
  121401. /** @hidden */
  121402. 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;
  121403. }
  121404. }
  121405. declare module BABYLON {
  121406. /**
  121407. * Implementation of the TGA Texture Loader.
  121408. * @hidden
  121409. */
  121410. export class _TGATextureLoader implements IInternalTextureLoader {
  121411. /**
  121412. * Defines wether the loader supports cascade loading the different faces.
  121413. */
  121414. readonly supportCascades: boolean;
  121415. /**
  121416. * This returns if the loader support the current file information.
  121417. * @param extension defines the file extension of the file being loaded
  121418. * @param textureFormatInUse defines the current compressed format in use iun the engine
  121419. * @param fallback defines the fallback internal texture if any
  121420. * @param isBase64 defines whether the texture is encoded as a base64
  121421. * @param isBuffer defines whether the texture data are stored as a buffer
  121422. * @returns true if the loader can load the specified file
  121423. */
  121424. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  121425. /**
  121426. * Transform the url before loading if required.
  121427. * @param rootUrl the url of the texture
  121428. * @param textureFormatInUse defines the current compressed format in use iun the engine
  121429. * @returns the transformed texture
  121430. */
  121431. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  121432. /**
  121433. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  121434. * @param rootUrl the url of the texture
  121435. * @param textureFormatInUse defines the current compressed format in use iun the engine
  121436. * @returns the fallback texture
  121437. */
  121438. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  121439. /**
  121440. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  121441. * @param data contains the texture data
  121442. * @param texture defines the BabylonJS internal texture
  121443. * @param createPolynomials will be true if polynomials have been requested
  121444. * @param onLoad defines the callback to trigger once the texture is ready
  121445. * @param onError defines the callback to trigger in case of error
  121446. */
  121447. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  121448. /**
  121449. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  121450. * @param data contains the texture data
  121451. * @param texture defines the BabylonJS internal texture
  121452. * @param callback defines the method to call once ready to upload
  121453. */
  121454. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  121455. }
  121456. }
  121457. declare module BABYLON {
  121458. /**
  121459. * Info about the .basis files
  121460. */
  121461. class BasisFileInfo {
  121462. /**
  121463. * If the file has alpha
  121464. */
  121465. hasAlpha: boolean;
  121466. /**
  121467. * Info about each image of the basis file
  121468. */
  121469. images: Array<{
  121470. levels: Array<{
  121471. width: number;
  121472. height: number;
  121473. transcodedPixels: ArrayBufferView;
  121474. }>;
  121475. }>;
  121476. }
  121477. /**
  121478. * Result of transcoding a basis file
  121479. */
  121480. class TranscodeResult {
  121481. /**
  121482. * Info about the .basis file
  121483. */
  121484. fileInfo: BasisFileInfo;
  121485. /**
  121486. * Format to use when loading the file
  121487. */
  121488. format: number;
  121489. }
  121490. /**
  121491. * Configuration options for the Basis transcoder
  121492. */
  121493. export class BasisTranscodeConfiguration {
  121494. /**
  121495. * Supported compression formats used to determine the supported output format of the transcoder
  121496. */
  121497. supportedCompressionFormats?: {
  121498. /**
  121499. * etc1 compression format
  121500. */
  121501. etc1?: boolean;
  121502. /**
  121503. * s3tc compression format
  121504. */
  121505. s3tc?: boolean;
  121506. /**
  121507. * pvrtc compression format
  121508. */
  121509. pvrtc?: boolean;
  121510. /**
  121511. * etc2 compression format
  121512. */
  121513. etc2?: boolean;
  121514. };
  121515. /**
  121516. * If mipmap levels should be loaded for transcoded images (Default: true)
  121517. */
  121518. loadMipmapLevels?: boolean;
  121519. /**
  121520. * Index of a single image to load (Default: all images)
  121521. */
  121522. loadSingleImage?: number;
  121523. }
  121524. /**
  121525. * Used to load .Basis files
  121526. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  121527. */
  121528. export class BasisTools {
  121529. private static _IgnoreSupportedFormats;
  121530. /**
  121531. * URL to use when loading the basis transcoder
  121532. */
  121533. static JSModuleURL: string;
  121534. /**
  121535. * URL to use when loading the wasm module for the transcoder
  121536. */
  121537. static WasmModuleURL: string;
  121538. /**
  121539. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  121540. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  121541. * @returns internal format corresponding to the Basis format
  121542. */
  121543. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  121544. private static _WorkerPromise;
  121545. private static _Worker;
  121546. private static _actionId;
  121547. private static _CreateWorkerAsync;
  121548. /**
  121549. * Transcodes a loaded image file to compressed pixel data
  121550. * @param imageData image data to transcode
  121551. * @param config configuration options for the transcoding
  121552. * @returns a promise resulting in the transcoded image
  121553. */
  121554. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  121555. /**
  121556. * Loads a texture from the transcode result
  121557. * @param texture texture load to
  121558. * @param transcodeResult the result of transcoding the basis file to load from
  121559. */
  121560. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  121561. }
  121562. }
  121563. declare module BABYLON {
  121564. /**
  121565. * Loader for .basis file format
  121566. */
  121567. export class _BasisTextureLoader implements IInternalTextureLoader {
  121568. /**
  121569. * Defines whether the loader supports cascade loading the different faces.
  121570. */
  121571. readonly supportCascades: boolean;
  121572. /**
  121573. * This returns if the loader support the current file information.
  121574. * @param extension defines the file extension of the file being loaded
  121575. * @param textureFormatInUse defines the current compressed format in use iun the engine
  121576. * @param fallback defines the fallback internal texture if any
  121577. * @param isBase64 defines whether the texture is encoded as a base64
  121578. * @param isBuffer defines whether the texture data are stored as a buffer
  121579. * @returns true if the loader can load the specified file
  121580. */
  121581. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  121582. /**
  121583. * Transform the url before loading if required.
  121584. * @param rootUrl the url of the texture
  121585. * @param textureFormatInUse defines the current compressed format in use iun the engine
  121586. * @returns the transformed texture
  121587. */
  121588. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  121589. /**
  121590. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  121591. * @param rootUrl the url of the texture
  121592. * @param textureFormatInUse defines the current compressed format in use iun the engine
  121593. * @returns the fallback texture
  121594. */
  121595. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  121596. /**
  121597. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  121598. * @param data contains the texture data
  121599. * @param texture defines the BabylonJS internal texture
  121600. * @param createPolynomials will be true if polynomials have been requested
  121601. * @param onLoad defines the callback to trigger once the texture is ready
  121602. * @param onError defines the callback to trigger in case of error
  121603. */
  121604. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  121605. /**
  121606. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  121607. * @param data contains the texture data
  121608. * @param texture defines the BabylonJS internal texture
  121609. * @param callback defines the method to call once ready to upload
  121610. */
  121611. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  121612. }
  121613. }
  121614. declare module BABYLON {
  121615. /**
  121616. * 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.
  121617. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  121618. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  121619. */
  121620. export class CustomProceduralTexture extends ProceduralTexture {
  121621. private _animate;
  121622. private _time;
  121623. private _config;
  121624. private _texturePath;
  121625. /**
  121626. * Instantiates a new Custom Procedural Texture.
  121627. * 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.
  121628. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  121629. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  121630. * @param name Define the name of the texture
  121631. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  121632. * @param size Define the size of the texture to create
  121633. * @param scene Define the scene the texture belongs to
  121634. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  121635. * @param generateMipMaps Define if the texture should creates mip maps or not
  121636. */
  121637. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  121638. private _loadJson;
  121639. /**
  121640. * Is the texture ready to be used ? (rendered at least once)
  121641. * @returns true if ready, otherwise, false.
  121642. */
  121643. isReady(): boolean;
  121644. /**
  121645. * Render the texture to its associated render target.
  121646. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  121647. */
  121648. render(useCameraPostProcess?: boolean): void;
  121649. /**
  121650. * Update the list of dependant textures samplers in the shader.
  121651. */
  121652. updateTextures(): void;
  121653. /**
  121654. * Update the uniform values of the procedural texture in the shader.
  121655. */
  121656. updateShaderUniforms(): void;
  121657. /**
  121658. * Define if the texture animates or not.
  121659. */
  121660. animate: boolean;
  121661. }
  121662. }
  121663. declare module BABYLON {
  121664. /** @hidden */
  121665. export var noisePixelShader: {
  121666. name: string;
  121667. shader: string;
  121668. };
  121669. }
  121670. declare module BABYLON {
  121671. /**
  121672. * Class used to generate noise procedural textures
  121673. */
  121674. export class NoiseProceduralTexture extends ProceduralTexture {
  121675. private _time;
  121676. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  121677. brightness: number;
  121678. /** Defines the number of octaves to process */
  121679. octaves: number;
  121680. /** Defines the level of persistence (0.8 by default) */
  121681. persistence: number;
  121682. /** Gets or sets animation speed factor (default is 1) */
  121683. animationSpeedFactor: number;
  121684. /**
  121685. * Creates a new NoiseProceduralTexture
  121686. * @param name defines the name fo the texture
  121687. * @param size defines the size of the texture (default is 256)
  121688. * @param scene defines the hosting scene
  121689. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  121690. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  121691. */
  121692. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  121693. private _updateShaderUniforms;
  121694. protected _getDefines(): string;
  121695. /** Generate the current state of the procedural texture */
  121696. render(useCameraPostProcess?: boolean): void;
  121697. /**
  121698. * Serializes this noise procedural texture
  121699. * @returns a serialized noise procedural texture object
  121700. */
  121701. serialize(): any;
  121702. /**
  121703. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  121704. * @param parsedTexture defines parsed texture data
  121705. * @param scene defines the current scene
  121706. * @param rootUrl defines the root URL containing noise procedural texture information
  121707. * @returns a parsed NoiseProceduralTexture
  121708. */
  121709. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  121710. }
  121711. }
  121712. declare module BABYLON {
  121713. /**
  121714. * Raw cube texture where the raw buffers are passed in
  121715. */
  121716. export class RawCubeTexture extends CubeTexture {
  121717. /**
  121718. * Creates a cube texture where the raw buffers are passed in.
  121719. * @param scene defines the scene the texture is attached to
  121720. * @param data defines the array of data to use to create each face
  121721. * @param size defines the size of the textures
  121722. * @param format defines the format of the data
  121723. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  121724. * @param generateMipMaps defines if the engine should generate the mip levels
  121725. * @param invertY defines if data must be stored with Y axis inverted
  121726. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  121727. * @param compression defines the compression used (null by default)
  121728. */
  121729. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  121730. /**
  121731. * Updates the raw cube texture.
  121732. * @param data defines the data to store
  121733. * @param format defines the data format
  121734. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  121735. * @param invertY defines if data must be stored with Y axis inverted
  121736. * @param compression defines the compression used (null by default)
  121737. * @param level defines which level of the texture to update
  121738. */
  121739. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  121740. /**
  121741. * Updates a raw cube texture with RGBD encoded data.
  121742. * @param data defines the array of data [mipmap][face] to use to create each face
  121743. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  121744. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  121745. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  121746. * @returns a promsie that resolves when the operation is complete
  121747. */
  121748. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  121749. /**
  121750. * Clones the raw cube texture.
  121751. * @return a new cube texture
  121752. */
  121753. clone(): CubeTexture;
  121754. /** @hidden */
  121755. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  121756. }
  121757. }
  121758. declare module BABYLON {
  121759. /**
  121760. * Class used to store 3D textures containing user data
  121761. */
  121762. export class RawTexture3D extends Texture {
  121763. /** Gets or sets the texture format to use */
  121764. format: number;
  121765. private _engine;
  121766. /**
  121767. * Create a new RawTexture3D
  121768. * @param data defines the data of the texture
  121769. * @param width defines the width of the texture
  121770. * @param height defines the height of the texture
  121771. * @param depth defines the depth of the texture
  121772. * @param format defines the texture format to use
  121773. * @param scene defines the hosting scene
  121774. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  121775. * @param invertY defines if texture must be stored with Y axis inverted
  121776. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  121777. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  121778. */
  121779. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  121780. /** Gets or sets the texture format to use */
  121781. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  121782. /**
  121783. * Update the texture with new data
  121784. * @param data defines the data to store in the texture
  121785. */
  121786. update(data: ArrayBufferView): void;
  121787. }
  121788. }
  121789. declare module BABYLON {
  121790. /**
  121791. * Class used to store 2D array textures containing user data
  121792. */
  121793. export class RawTexture2DArray extends Texture {
  121794. /** Gets or sets the texture format to use */
  121795. format: number;
  121796. private _engine;
  121797. /**
  121798. * Create a new RawTexture2DArray
  121799. * @param data defines the data of the texture
  121800. * @param width defines the width of the texture
  121801. * @param height defines the height of the texture
  121802. * @param depth defines the number of layers of the texture
  121803. * @param format defines the texture format to use
  121804. * @param scene defines the hosting scene
  121805. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  121806. * @param invertY defines if texture must be stored with Y axis inverted
  121807. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  121808. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  121809. */
  121810. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  121811. /** Gets or sets the texture format to use */
  121812. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  121813. /**
  121814. * Update the texture with new data
  121815. * @param data defines the data to store in the texture
  121816. */
  121817. update(data: ArrayBufferView): void;
  121818. }
  121819. }
  121820. declare module BABYLON {
  121821. /**
  121822. * Creates a refraction texture used by refraction channel of the standard material.
  121823. * It is like a mirror but to see through a material.
  121824. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  121825. */
  121826. export class RefractionTexture extends RenderTargetTexture {
  121827. /**
  121828. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  121829. * 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.
  121830. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  121831. */
  121832. refractionPlane: Plane;
  121833. /**
  121834. * Define how deep under the surface we should see.
  121835. */
  121836. depth: number;
  121837. /**
  121838. * Creates a refraction texture used by refraction channel of the standard material.
  121839. * It is like a mirror but to see through a material.
  121840. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  121841. * @param name Define the texture name
  121842. * @param size Define the size of the underlying texture
  121843. * @param scene Define the scene the refraction belongs to
  121844. * @param generateMipMaps Define if we need to generate mips level for the refraction
  121845. */
  121846. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  121847. /**
  121848. * Clone the refraction texture.
  121849. * @returns the cloned texture
  121850. */
  121851. clone(): RefractionTexture;
  121852. /**
  121853. * Serialize the texture to a JSON representation you could use in Parse later on
  121854. * @returns the serialized JSON representation
  121855. */
  121856. serialize(): any;
  121857. }
  121858. }
  121859. declare module BABYLON {
  121860. /**
  121861. * Defines the options related to the creation of an HtmlElementTexture
  121862. */
  121863. export interface IHtmlElementTextureOptions {
  121864. /**
  121865. * Defines wether mip maps should be created or not.
  121866. */
  121867. generateMipMaps?: boolean;
  121868. /**
  121869. * Defines the sampling mode of the texture.
  121870. */
  121871. samplingMode?: number;
  121872. /**
  121873. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  121874. */
  121875. engine: Nullable<ThinEngine>;
  121876. /**
  121877. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  121878. */
  121879. scene: Nullable<Scene>;
  121880. }
  121881. /**
  121882. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  121883. * To be as efficient as possible depending on your constraints nothing aside the first upload
  121884. * is automatically managed.
  121885. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  121886. * in your application.
  121887. *
  121888. * As the update is not automatic, you need to call them manually.
  121889. */
  121890. export class HtmlElementTexture extends BaseTexture {
  121891. /**
  121892. * The texture URL.
  121893. */
  121894. element: HTMLVideoElement | HTMLCanvasElement;
  121895. private static readonly DefaultOptions;
  121896. private _textureMatrix;
  121897. private _engine;
  121898. private _isVideo;
  121899. private _generateMipMaps;
  121900. private _samplingMode;
  121901. /**
  121902. * Instantiates a HtmlElementTexture from the following parameters.
  121903. *
  121904. * @param name Defines the name of the texture
  121905. * @param element Defines the video or canvas the texture is filled with
  121906. * @param options Defines the other none mandatory texture creation options
  121907. */
  121908. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  121909. private _createInternalTexture;
  121910. /**
  121911. * Returns the texture matrix used in most of the material.
  121912. */
  121913. getTextureMatrix(): Matrix;
  121914. /**
  121915. * Updates the content of the texture.
  121916. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  121917. */
  121918. update(invertY?: Nullable<boolean>): void;
  121919. }
  121920. }
  121921. declare module BABYLON {
  121922. /**
  121923. * Enum used to define the target of a block
  121924. */
  121925. export enum NodeMaterialBlockTargets {
  121926. /** Vertex shader */
  121927. Vertex = 1,
  121928. /** Fragment shader */
  121929. Fragment = 2,
  121930. /** Neutral */
  121931. Neutral = 4,
  121932. /** Vertex and Fragment */
  121933. VertexAndFragment = 3
  121934. }
  121935. }
  121936. declare module BABYLON {
  121937. /**
  121938. * Defines the kind of connection point for node based material
  121939. */
  121940. export enum NodeMaterialBlockConnectionPointTypes {
  121941. /** Float */
  121942. Float = 1,
  121943. /** Int */
  121944. Int = 2,
  121945. /** Vector2 */
  121946. Vector2 = 4,
  121947. /** Vector3 */
  121948. Vector3 = 8,
  121949. /** Vector4 */
  121950. Vector4 = 16,
  121951. /** Color3 */
  121952. Color3 = 32,
  121953. /** Color4 */
  121954. Color4 = 64,
  121955. /** Matrix */
  121956. Matrix = 128,
  121957. /** Detect type based on connection */
  121958. AutoDetect = 1024,
  121959. /** Output type that will be defined by input type */
  121960. BasedOnInput = 2048
  121961. }
  121962. }
  121963. declare module BABYLON {
  121964. /**
  121965. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  121966. */
  121967. export enum NodeMaterialBlockConnectionPointMode {
  121968. /** Value is an uniform */
  121969. Uniform = 0,
  121970. /** Value is a mesh attribute */
  121971. Attribute = 1,
  121972. /** Value is a varying between vertex and fragment shaders */
  121973. Varying = 2,
  121974. /** Mode is undefined */
  121975. Undefined = 3
  121976. }
  121977. }
  121978. declare module BABYLON {
  121979. /**
  121980. * Enum used to define system values e.g. values automatically provided by the system
  121981. */
  121982. export enum NodeMaterialSystemValues {
  121983. /** World */
  121984. World = 1,
  121985. /** View */
  121986. View = 2,
  121987. /** Projection */
  121988. Projection = 3,
  121989. /** ViewProjection */
  121990. ViewProjection = 4,
  121991. /** WorldView */
  121992. WorldView = 5,
  121993. /** WorldViewProjection */
  121994. WorldViewProjection = 6,
  121995. /** CameraPosition */
  121996. CameraPosition = 7,
  121997. /** Fog Color */
  121998. FogColor = 8,
  121999. /** Delta time */
  122000. DeltaTime = 9
  122001. }
  122002. }
  122003. declare module BABYLON {
  122004. /**
  122005. * Root class for all node material optimizers
  122006. */
  122007. export class NodeMaterialOptimizer {
  122008. /**
  122009. * Function used to optimize a NodeMaterial graph
  122010. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  122011. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  122012. */
  122013. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  122014. }
  122015. }
  122016. declare module BABYLON {
  122017. /**
  122018. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  122019. */
  122020. export class TransformBlock extends NodeMaterialBlock {
  122021. /**
  122022. * Defines the value to use to complement W value to transform it to a Vector4
  122023. */
  122024. complementW: number;
  122025. /**
  122026. * Defines the value to use to complement z value to transform it to a Vector4
  122027. */
  122028. complementZ: number;
  122029. /**
  122030. * Creates a new TransformBlock
  122031. * @param name defines the block name
  122032. */
  122033. constructor(name: string);
  122034. /**
  122035. * Gets the current class name
  122036. * @returns the class name
  122037. */
  122038. getClassName(): string;
  122039. /**
  122040. * Gets the vector input
  122041. */
  122042. readonly vector: NodeMaterialConnectionPoint;
  122043. /**
  122044. * Gets the output component
  122045. */
  122046. readonly output: NodeMaterialConnectionPoint;
  122047. /**
  122048. * Gets the matrix transform input
  122049. */
  122050. readonly transform: NodeMaterialConnectionPoint;
  122051. protected _buildBlock(state: NodeMaterialBuildState): this;
  122052. serialize(): any;
  122053. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  122054. protected _dumpPropertiesCode(): string;
  122055. }
  122056. }
  122057. declare module BABYLON {
  122058. /**
  122059. * Block used to output the vertex position
  122060. */
  122061. export class VertexOutputBlock extends NodeMaterialBlock {
  122062. /**
  122063. * Creates a new VertexOutputBlock
  122064. * @param name defines the block name
  122065. */
  122066. constructor(name: string);
  122067. /**
  122068. * Gets the current class name
  122069. * @returns the class name
  122070. */
  122071. getClassName(): string;
  122072. /**
  122073. * Gets the vector input component
  122074. */
  122075. readonly vector: NodeMaterialConnectionPoint;
  122076. protected _buildBlock(state: NodeMaterialBuildState): this;
  122077. }
  122078. }
  122079. declare module BABYLON {
  122080. /**
  122081. * Block used to output the final color
  122082. */
  122083. export class FragmentOutputBlock extends NodeMaterialBlock {
  122084. /**
  122085. * Create a new FragmentOutputBlock
  122086. * @param name defines the block name
  122087. */
  122088. constructor(name: string);
  122089. /**
  122090. * Gets the current class name
  122091. * @returns the class name
  122092. */
  122093. getClassName(): string;
  122094. /**
  122095. * Gets the rgba input component
  122096. */
  122097. readonly rgba: NodeMaterialConnectionPoint;
  122098. /**
  122099. * Gets the rgb input component
  122100. */
  122101. readonly rgb: NodeMaterialConnectionPoint;
  122102. /**
  122103. * Gets the a input component
  122104. */
  122105. readonly a: NodeMaterialConnectionPoint;
  122106. protected _buildBlock(state: NodeMaterialBuildState): this;
  122107. }
  122108. }
  122109. declare module BABYLON {
  122110. /**
  122111. * Block used to read a reflection texture from a sampler
  122112. */
  122113. export class ReflectionTextureBlock extends NodeMaterialBlock {
  122114. private _define3DName;
  122115. private _defineCubicName;
  122116. private _defineExplicitName;
  122117. private _defineProjectionName;
  122118. private _defineLocalCubicName;
  122119. private _defineSphericalName;
  122120. private _definePlanarName;
  122121. private _defineEquirectangularName;
  122122. private _defineMirroredEquirectangularFixedName;
  122123. private _defineEquirectangularFixedName;
  122124. private _defineSkyboxName;
  122125. private _cubeSamplerName;
  122126. private _2DSamplerName;
  122127. private _positionUVWName;
  122128. private _directionWName;
  122129. private _reflectionCoordsName;
  122130. private _reflection2DCoordsName;
  122131. private _reflectionColorName;
  122132. private _reflectionMatrixName;
  122133. /**
  122134. * Gets or sets the texture associated with the node
  122135. */
  122136. texture: Nullable<BaseTexture>;
  122137. /**
  122138. * Create a new TextureBlock
  122139. * @param name defines the block name
  122140. */
  122141. constructor(name: string);
  122142. /**
  122143. * Gets the current class name
  122144. * @returns the class name
  122145. */
  122146. getClassName(): string;
  122147. /**
  122148. * Gets the world position input component
  122149. */
  122150. readonly position: NodeMaterialConnectionPoint;
  122151. /**
  122152. * Gets the world position input component
  122153. */
  122154. readonly worldPosition: NodeMaterialConnectionPoint;
  122155. /**
  122156. * Gets the world normal input component
  122157. */
  122158. readonly worldNormal: NodeMaterialConnectionPoint;
  122159. /**
  122160. * Gets the world input component
  122161. */
  122162. readonly world: NodeMaterialConnectionPoint;
  122163. /**
  122164. * Gets the camera (or eye) position component
  122165. */
  122166. readonly cameraPosition: NodeMaterialConnectionPoint;
  122167. /**
  122168. * Gets the view input component
  122169. */
  122170. readonly view: NodeMaterialConnectionPoint;
  122171. /**
  122172. * Gets the rgb output component
  122173. */
  122174. readonly rgb: NodeMaterialConnectionPoint;
  122175. /**
  122176. * Gets the r output component
  122177. */
  122178. readonly r: NodeMaterialConnectionPoint;
  122179. /**
  122180. * Gets the g output component
  122181. */
  122182. readonly g: NodeMaterialConnectionPoint;
  122183. /**
  122184. * Gets the b output component
  122185. */
  122186. readonly b: NodeMaterialConnectionPoint;
  122187. autoConfigure(material: NodeMaterial): void;
  122188. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  122189. isReady(): boolean;
  122190. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  122191. private _injectVertexCode;
  122192. private _writeOutput;
  122193. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  122194. protected _dumpPropertiesCode(): string;
  122195. serialize(): any;
  122196. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  122197. }
  122198. }
  122199. declare module BABYLON {
  122200. /**
  122201. * Interface used to configure the node material editor
  122202. */
  122203. export interface INodeMaterialEditorOptions {
  122204. /** Define the URl to load node editor script */
  122205. editorURL?: string;
  122206. }
  122207. /** @hidden */
  122208. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  122209. /** BONES */
  122210. NUM_BONE_INFLUENCERS: number;
  122211. BonesPerMesh: number;
  122212. BONETEXTURE: boolean;
  122213. /** MORPH TARGETS */
  122214. MORPHTARGETS: boolean;
  122215. MORPHTARGETS_NORMAL: boolean;
  122216. MORPHTARGETS_TANGENT: boolean;
  122217. MORPHTARGETS_UV: boolean;
  122218. NUM_MORPH_INFLUENCERS: number;
  122219. /** IMAGE PROCESSING */
  122220. IMAGEPROCESSING: boolean;
  122221. VIGNETTE: boolean;
  122222. VIGNETTEBLENDMODEMULTIPLY: boolean;
  122223. VIGNETTEBLENDMODEOPAQUE: boolean;
  122224. TONEMAPPING: boolean;
  122225. TONEMAPPING_ACES: boolean;
  122226. CONTRAST: boolean;
  122227. EXPOSURE: boolean;
  122228. COLORCURVES: boolean;
  122229. COLORGRADING: boolean;
  122230. COLORGRADING3D: boolean;
  122231. SAMPLER3DGREENDEPTH: boolean;
  122232. SAMPLER3DBGRMAP: boolean;
  122233. IMAGEPROCESSINGPOSTPROCESS: boolean;
  122234. /** MISC. */
  122235. BUMPDIRECTUV: number;
  122236. constructor();
  122237. setValue(name: string, value: boolean): void;
  122238. }
  122239. /**
  122240. * Class used to configure NodeMaterial
  122241. */
  122242. export interface INodeMaterialOptions {
  122243. /**
  122244. * Defines if blocks should emit comments
  122245. */
  122246. emitComments: boolean;
  122247. }
  122248. /**
  122249. * Class used to create a node based material built by assembling shader blocks
  122250. */
  122251. export class NodeMaterial extends PushMaterial {
  122252. private static _BuildIdGenerator;
  122253. private _options;
  122254. private _vertexCompilationState;
  122255. private _fragmentCompilationState;
  122256. private _sharedData;
  122257. private _buildId;
  122258. private _buildWasSuccessful;
  122259. private _cachedWorldViewMatrix;
  122260. private _cachedWorldViewProjectionMatrix;
  122261. private _optimizers;
  122262. private _animationFrame;
  122263. /** Define the URl to load node editor script */
  122264. static EditorURL: string;
  122265. private BJSNODEMATERIALEDITOR;
  122266. /** Get the inspector from bundle or global */
  122267. private _getGlobalNodeMaterialEditor;
  122268. /**
  122269. * Gets or sets data used by visual editor
  122270. * @see https://nme.babylonjs.com
  122271. */
  122272. editorData: any;
  122273. /**
  122274. * 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)
  122275. */
  122276. ignoreAlpha: boolean;
  122277. /**
  122278. * Defines the maximum number of lights that can be used in the material
  122279. */
  122280. maxSimultaneousLights: number;
  122281. /**
  122282. * Observable raised when the material is built
  122283. */
  122284. onBuildObservable: Observable<NodeMaterial>;
  122285. /**
  122286. * Gets or sets the root nodes of the material vertex shader
  122287. */
  122288. _vertexOutputNodes: NodeMaterialBlock[];
  122289. /**
  122290. * Gets or sets the root nodes of the material fragment (pixel) shader
  122291. */
  122292. _fragmentOutputNodes: NodeMaterialBlock[];
  122293. /** Gets or sets options to control the node material overall behavior */
  122294. options: INodeMaterialOptions;
  122295. /**
  122296. * Default configuration related to image processing available in the standard Material.
  122297. */
  122298. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  122299. /**
  122300. * Gets the image processing configuration used either in this material.
  122301. */
  122302. /**
  122303. * Sets the Default image processing configuration used either in the this material.
  122304. *
  122305. * If sets to null, the scene one is in use.
  122306. */
  122307. imageProcessingConfiguration: ImageProcessingConfiguration;
  122308. /**
  122309. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  122310. */
  122311. attachedBlocks: NodeMaterialBlock[];
  122312. /**
  122313. * Create a new node based material
  122314. * @param name defines the material name
  122315. * @param scene defines the hosting scene
  122316. * @param options defines creation option
  122317. */
  122318. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  122319. /**
  122320. * Gets the current class name of the material e.g. "NodeMaterial"
  122321. * @returns the class name
  122322. */
  122323. getClassName(): string;
  122324. /**
  122325. * Keep track of the image processing observer to allow dispose and replace.
  122326. */
  122327. private _imageProcessingObserver;
  122328. /**
  122329. * Attaches a new image processing configuration to the Standard Material.
  122330. * @param configuration
  122331. */
  122332. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  122333. /**
  122334. * Get a block by its name
  122335. * @param name defines the name of the block to retrieve
  122336. * @returns the required block or null if not found
  122337. */
  122338. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  122339. /**
  122340. * Get a block by its name
  122341. * @param predicate defines the predicate used to find the good candidate
  122342. * @returns the required block or null if not found
  122343. */
  122344. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  122345. /**
  122346. * Get an input block by its name
  122347. * @param predicate defines the predicate used to find the good candidate
  122348. * @returns the required input block or null if not found
  122349. */
  122350. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  122351. /**
  122352. * Gets the list of input blocks attached to this material
  122353. * @returns an array of InputBlocks
  122354. */
  122355. getInputBlocks(): InputBlock[];
  122356. /**
  122357. * Adds a new optimizer to the list of optimizers
  122358. * @param optimizer defines the optimizers to add
  122359. * @returns the current material
  122360. */
  122361. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  122362. /**
  122363. * Remove an optimizer from the list of optimizers
  122364. * @param optimizer defines the optimizers to remove
  122365. * @returns the current material
  122366. */
  122367. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  122368. /**
  122369. * Add a new block to the list of output nodes
  122370. * @param node defines the node to add
  122371. * @returns the current material
  122372. */
  122373. addOutputNode(node: NodeMaterialBlock): this;
  122374. /**
  122375. * Remove a block from the list of root nodes
  122376. * @param node defines the node to remove
  122377. * @returns the current material
  122378. */
  122379. removeOutputNode(node: NodeMaterialBlock): this;
  122380. private _addVertexOutputNode;
  122381. private _removeVertexOutputNode;
  122382. private _addFragmentOutputNode;
  122383. private _removeFragmentOutputNode;
  122384. /**
  122385. * Specifies if the material will require alpha blending
  122386. * @returns a boolean specifying if alpha blending is needed
  122387. */
  122388. needAlphaBlending(): boolean;
  122389. /**
  122390. * Specifies if this material should be rendered in alpha test mode
  122391. * @returns a boolean specifying if an alpha test is needed.
  122392. */
  122393. needAlphaTesting(): boolean;
  122394. private _initializeBlock;
  122395. private _resetDualBlocks;
  122396. /**
  122397. * Build the material and generates the inner effect
  122398. * @param verbose defines if the build should log activity
  122399. */
  122400. build(verbose?: boolean): void;
  122401. /**
  122402. * Runs an otpimization phase to try to improve the shader code
  122403. */
  122404. optimize(): void;
  122405. private _prepareDefinesForAttributes;
  122406. /**
  122407. * Get if the submesh is ready to be used and all its information available.
  122408. * Child classes can use it to update shaders
  122409. * @param mesh defines the mesh to check
  122410. * @param subMesh defines which submesh to check
  122411. * @param useInstances specifies that instances should be used
  122412. * @returns a boolean indicating that the submesh is ready or not
  122413. */
  122414. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  122415. /**
  122416. * Get a string representing the shaders built by the current node graph
  122417. */
  122418. readonly compiledShaders: string;
  122419. /**
  122420. * Binds the world matrix to the material
  122421. * @param world defines the world transformation matrix
  122422. */
  122423. bindOnlyWorldMatrix(world: Matrix): void;
  122424. /**
  122425. * Binds the submesh to this material by preparing the effect and shader to draw
  122426. * @param world defines the world transformation matrix
  122427. * @param mesh defines the mesh containing the submesh
  122428. * @param subMesh defines the submesh to bind the material to
  122429. */
  122430. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  122431. /**
  122432. * Gets the active textures from the material
  122433. * @returns an array of textures
  122434. */
  122435. getActiveTextures(): BaseTexture[];
  122436. /**
  122437. * Gets the list of texture blocks
  122438. * @returns an array of texture blocks
  122439. */
  122440. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  122441. /**
  122442. * Specifies if the material uses a texture
  122443. * @param texture defines the texture to check against the material
  122444. * @returns a boolean specifying if the material uses the texture
  122445. */
  122446. hasTexture(texture: BaseTexture): boolean;
  122447. /**
  122448. * Disposes the material
  122449. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  122450. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  122451. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  122452. */
  122453. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  122454. /** Creates the node editor window. */
  122455. private _createNodeEditor;
  122456. /**
  122457. * Launch the node material editor
  122458. * @param config Define the configuration of the editor
  122459. * @return a promise fulfilled when the node editor is visible
  122460. */
  122461. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  122462. /**
  122463. * Clear the current material
  122464. */
  122465. clear(): void;
  122466. /**
  122467. * Clear the current material and set it to a default state
  122468. */
  122469. setToDefault(): void;
  122470. /**
  122471. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  122472. * @param url defines the url to load from
  122473. * @returns a promise that will fullfil when the material is fully loaded
  122474. */
  122475. loadAsync(url: string): Promise<void>;
  122476. private _gatherBlocks;
  122477. /**
  122478. * Generate a string containing the code declaration required to create an equivalent of this material
  122479. * @returns a string
  122480. */
  122481. generateCode(): string;
  122482. /**
  122483. * Serializes this material in a JSON representation
  122484. * @returns the serialized material object
  122485. */
  122486. serialize(): any;
  122487. private _restoreConnections;
  122488. /**
  122489. * Clear the current graph and load a new one from a serialization object
  122490. * @param source defines the JSON representation of the material
  122491. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  122492. */
  122493. loadFromSerialization(source: any, rootUrl?: string): void;
  122494. /**
  122495. * Creates a node material from parsed material data
  122496. * @param source defines the JSON representation of the material
  122497. * @param scene defines the hosting scene
  122498. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  122499. * @returns a new node material
  122500. */
  122501. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  122502. /**
  122503. * Creates a new node material set to default basic configuration
  122504. * @param name defines the name of the material
  122505. * @param scene defines the hosting scene
  122506. * @returns a new NodeMaterial
  122507. */
  122508. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  122509. }
  122510. }
  122511. declare module BABYLON {
  122512. /**
  122513. * Block used to read a texture from a sampler
  122514. */
  122515. export class TextureBlock extends NodeMaterialBlock {
  122516. private _defineName;
  122517. private _linearDefineName;
  122518. private _tempTextureRead;
  122519. private _samplerName;
  122520. private _transformedUVName;
  122521. private _textureTransformName;
  122522. private _textureInfoName;
  122523. private _mainUVName;
  122524. private _mainUVDefineName;
  122525. /**
  122526. * Gets or sets the texture associated with the node
  122527. */
  122528. texture: Nullable<Texture>;
  122529. /**
  122530. * Create a new TextureBlock
  122531. * @param name defines the block name
  122532. */
  122533. constructor(name: string);
  122534. /**
  122535. * Gets the current class name
  122536. * @returns the class name
  122537. */
  122538. getClassName(): string;
  122539. /**
  122540. * Gets the uv input component
  122541. */
  122542. readonly uv: NodeMaterialConnectionPoint;
  122543. /**
  122544. * Gets the rgba output component
  122545. */
  122546. readonly rgba: NodeMaterialConnectionPoint;
  122547. /**
  122548. * Gets the rgb output component
  122549. */
  122550. readonly rgb: NodeMaterialConnectionPoint;
  122551. /**
  122552. * Gets the r output component
  122553. */
  122554. readonly r: NodeMaterialConnectionPoint;
  122555. /**
  122556. * Gets the g output component
  122557. */
  122558. readonly g: NodeMaterialConnectionPoint;
  122559. /**
  122560. * Gets the b output component
  122561. */
  122562. readonly b: NodeMaterialConnectionPoint;
  122563. /**
  122564. * Gets the a output component
  122565. */
  122566. readonly a: NodeMaterialConnectionPoint;
  122567. readonly target: NodeMaterialBlockTargets;
  122568. autoConfigure(material: NodeMaterial): void;
  122569. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  122570. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  122571. private _getTextureBase;
  122572. isReady(): boolean;
  122573. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  122574. private readonly _isMixed;
  122575. private _injectVertexCode;
  122576. private _writeTextureRead;
  122577. private _writeOutput;
  122578. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  122579. protected _dumpPropertiesCode(): string;
  122580. serialize(): any;
  122581. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  122582. }
  122583. }
  122584. declare module BABYLON {
  122585. /**
  122586. * Class used to store shared data between 2 NodeMaterialBuildState
  122587. */
  122588. export class NodeMaterialBuildStateSharedData {
  122589. /**
  122590. * Gets the list of emitted varyings
  122591. */
  122592. temps: string[];
  122593. /**
  122594. * Gets the list of emitted varyings
  122595. */
  122596. varyings: string[];
  122597. /**
  122598. * Gets the varying declaration string
  122599. */
  122600. varyingDeclaration: string;
  122601. /**
  122602. * Input blocks
  122603. */
  122604. inputBlocks: InputBlock[];
  122605. /**
  122606. * Input blocks
  122607. */
  122608. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  122609. /**
  122610. * Bindable blocks (Blocks that need to set data to the effect)
  122611. */
  122612. bindableBlocks: NodeMaterialBlock[];
  122613. /**
  122614. * List of blocks that can provide a compilation fallback
  122615. */
  122616. blocksWithFallbacks: NodeMaterialBlock[];
  122617. /**
  122618. * List of blocks that can provide a define update
  122619. */
  122620. blocksWithDefines: NodeMaterialBlock[];
  122621. /**
  122622. * List of blocks that can provide a repeatable content
  122623. */
  122624. repeatableContentBlocks: NodeMaterialBlock[];
  122625. /**
  122626. * List of blocks that can provide a dynamic list of uniforms
  122627. */
  122628. dynamicUniformBlocks: NodeMaterialBlock[];
  122629. /**
  122630. * List of blocks that can block the isReady function for the material
  122631. */
  122632. blockingBlocks: NodeMaterialBlock[];
  122633. /**
  122634. * Gets the list of animated inputs
  122635. */
  122636. animatedInputs: InputBlock[];
  122637. /**
  122638. * Build Id used to avoid multiple recompilations
  122639. */
  122640. buildId: number;
  122641. /** List of emitted variables */
  122642. variableNames: {
  122643. [key: string]: number;
  122644. };
  122645. /** List of emitted defines */
  122646. defineNames: {
  122647. [key: string]: number;
  122648. };
  122649. /** Should emit comments? */
  122650. emitComments: boolean;
  122651. /** Emit build activity */
  122652. verbose: boolean;
  122653. /** Gets or sets the hosting scene */
  122654. scene: Scene;
  122655. /**
  122656. * Gets the compilation hints emitted at compilation time
  122657. */
  122658. hints: {
  122659. needWorldViewMatrix: boolean;
  122660. needWorldViewProjectionMatrix: boolean;
  122661. needAlphaBlending: boolean;
  122662. needAlphaTesting: boolean;
  122663. };
  122664. /**
  122665. * List of compilation checks
  122666. */
  122667. checks: {
  122668. emitVertex: boolean;
  122669. emitFragment: boolean;
  122670. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  122671. };
  122672. /** Creates a new shared data */
  122673. constructor();
  122674. /**
  122675. * Emits console errors and exceptions if there is a failing check
  122676. */
  122677. emitErrors(): void;
  122678. }
  122679. }
  122680. declare module BABYLON {
  122681. /**
  122682. * Class used to store node based material build state
  122683. */
  122684. export class NodeMaterialBuildState {
  122685. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  122686. supportUniformBuffers: boolean;
  122687. /**
  122688. * Gets the list of emitted attributes
  122689. */
  122690. attributes: string[];
  122691. /**
  122692. * Gets the list of emitted uniforms
  122693. */
  122694. uniforms: string[];
  122695. /**
  122696. * Gets the list of emitted constants
  122697. */
  122698. constants: string[];
  122699. /**
  122700. * Gets the list of emitted samplers
  122701. */
  122702. samplers: string[];
  122703. /**
  122704. * Gets the list of emitted functions
  122705. */
  122706. functions: {
  122707. [key: string]: string;
  122708. };
  122709. /**
  122710. * Gets the list of emitted extensions
  122711. */
  122712. extensions: {
  122713. [key: string]: string;
  122714. };
  122715. /**
  122716. * Gets the target of the compilation state
  122717. */
  122718. target: NodeMaterialBlockTargets;
  122719. /**
  122720. * Gets the list of emitted counters
  122721. */
  122722. counters: {
  122723. [key: string]: number;
  122724. };
  122725. /**
  122726. * Shared data between multiple NodeMaterialBuildState instances
  122727. */
  122728. sharedData: NodeMaterialBuildStateSharedData;
  122729. /** @hidden */
  122730. _vertexState: NodeMaterialBuildState;
  122731. /** @hidden */
  122732. _attributeDeclaration: string;
  122733. /** @hidden */
  122734. _uniformDeclaration: string;
  122735. /** @hidden */
  122736. _constantDeclaration: string;
  122737. /** @hidden */
  122738. _samplerDeclaration: string;
  122739. /** @hidden */
  122740. _varyingTransfer: string;
  122741. private _repeatableContentAnchorIndex;
  122742. /** @hidden */
  122743. _builtCompilationString: string;
  122744. /**
  122745. * Gets the emitted compilation strings
  122746. */
  122747. compilationString: string;
  122748. /**
  122749. * Finalize the compilation strings
  122750. * @param state defines the current compilation state
  122751. */
  122752. finalize(state: NodeMaterialBuildState): void;
  122753. /** @hidden */
  122754. readonly _repeatableContentAnchor: string;
  122755. /** @hidden */
  122756. _getFreeVariableName(prefix: string): string;
  122757. /** @hidden */
  122758. _getFreeDefineName(prefix: string): string;
  122759. /** @hidden */
  122760. _excludeVariableName(name: string): void;
  122761. /** @hidden */
  122762. _emit2DSampler(name: string): void;
  122763. /** @hidden */
  122764. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  122765. /** @hidden */
  122766. _emitExtension(name: string, extension: string): void;
  122767. /** @hidden */
  122768. _emitFunction(name: string, code: string, comments: string): void;
  122769. /** @hidden */
  122770. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  122771. replaceStrings?: {
  122772. search: RegExp;
  122773. replace: string;
  122774. }[];
  122775. repeatKey?: string;
  122776. }): string;
  122777. /** @hidden */
  122778. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  122779. repeatKey?: string;
  122780. removeAttributes?: boolean;
  122781. removeUniforms?: boolean;
  122782. removeVaryings?: boolean;
  122783. removeIfDef?: boolean;
  122784. replaceStrings?: {
  122785. search: RegExp;
  122786. replace: string;
  122787. }[];
  122788. }, storeKey?: string): void;
  122789. /** @hidden */
  122790. _registerTempVariable(name: string): boolean;
  122791. /** @hidden */
  122792. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  122793. /** @hidden */
  122794. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  122795. /** @hidden */
  122796. _emitFloat(value: number): string;
  122797. }
  122798. }
  122799. declare module BABYLON {
  122800. /**
  122801. * Defines a block that can be used inside a node based material
  122802. */
  122803. export class NodeMaterialBlock {
  122804. private _buildId;
  122805. private _buildTarget;
  122806. private _target;
  122807. private _isFinalMerger;
  122808. private _isInput;
  122809. protected _isUnique: boolean;
  122810. /** @hidden */
  122811. _codeVariableName: string;
  122812. /** @hidden */
  122813. _inputs: NodeMaterialConnectionPoint[];
  122814. /** @hidden */
  122815. _outputs: NodeMaterialConnectionPoint[];
  122816. /** @hidden */
  122817. _preparationId: number;
  122818. /**
  122819. * Gets or sets the name of the block
  122820. */
  122821. name: string;
  122822. /**
  122823. * Gets or sets the unique id of the node
  122824. */
  122825. uniqueId: number;
  122826. /**
  122827. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  122828. */
  122829. readonly isUnique: boolean;
  122830. /**
  122831. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  122832. */
  122833. readonly isFinalMerger: boolean;
  122834. /**
  122835. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  122836. */
  122837. readonly isInput: boolean;
  122838. /**
  122839. * Gets or sets the build Id
  122840. */
  122841. buildId: number;
  122842. /**
  122843. * Gets or sets the target of the block
  122844. */
  122845. target: NodeMaterialBlockTargets;
  122846. /**
  122847. * Gets the list of input points
  122848. */
  122849. readonly inputs: NodeMaterialConnectionPoint[];
  122850. /** Gets the list of output points */
  122851. readonly outputs: NodeMaterialConnectionPoint[];
  122852. /**
  122853. * Find an input by its name
  122854. * @param name defines the name of the input to look for
  122855. * @returns the input or null if not found
  122856. */
  122857. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  122858. /**
  122859. * Find an output by its name
  122860. * @param name defines the name of the outputto look for
  122861. * @returns the output or null if not found
  122862. */
  122863. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  122864. /**
  122865. * Creates a new NodeMaterialBlock
  122866. * @param name defines the block name
  122867. * @param target defines the target of that block (Vertex by default)
  122868. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  122869. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  122870. */
  122871. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  122872. /**
  122873. * Initialize the block and prepare the context for build
  122874. * @param state defines the state that will be used for the build
  122875. */
  122876. initialize(state: NodeMaterialBuildState): void;
  122877. /**
  122878. * Bind data to effect. Will only be called for blocks with isBindable === true
  122879. * @param effect defines the effect to bind data to
  122880. * @param nodeMaterial defines the hosting NodeMaterial
  122881. * @param mesh defines the mesh that will be rendered
  122882. */
  122883. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  122884. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  122885. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  122886. protected _writeFloat(value: number): string;
  122887. /**
  122888. * Gets the current class name e.g. "NodeMaterialBlock"
  122889. * @returns the class name
  122890. */
  122891. getClassName(): string;
  122892. /**
  122893. * Register a new input. Must be called inside a block constructor
  122894. * @param name defines the connection point name
  122895. * @param type defines the connection point type
  122896. * @param isOptional defines a boolean indicating that this input can be omitted
  122897. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  122898. * @returns the current block
  122899. */
  122900. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  122901. /**
  122902. * Register a new output. Must be called inside a block constructor
  122903. * @param name defines the connection point name
  122904. * @param type defines the connection point type
  122905. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  122906. * @returns the current block
  122907. */
  122908. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  122909. /**
  122910. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  122911. * @param forOutput defines an optional connection point to check compatibility with
  122912. * @returns the first available input or null
  122913. */
  122914. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  122915. /**
  122916. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  122917. * @param forBlock defines an optional block to check compatibility with
  122918. * @returns the first available input or null
  122919. */
  122920. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  122921. /**
  122922. * Gets the sibling of the given output
  122923. * @param current defines the current output
  122924. * @returns the next output in the list or null
  122925. */
  122926. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  122927. /**
  122928. * Connect current block with another block
  122929. * @param other defines the block to connect with
  122930. * @param options define the various options to help pick the right connections
  122931. * @returns the current block
  122932. */
  122933. connectTo(other: NodeMaterialBlock, options?: {
  122934. input?: string;
  122935. output?: string;
  122936. outputSwizzle?: string;
  122937. }): this | undefined;
  122938. protected _buildBlock(state: NodeMaterialBuildState): void;
  122939. /**
  122940. * Add uniforms, samplers and uniform buffers at compilation time
  122941. * @param state defines the state to update
  122942. * @param nodeMaterial defines the node material requesting the update
  122943. * @param defines defines the material defines to update
  122944. * @param uniformBuffers defines the list of uniform buffer names
  122945. */
  122946. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  122947. /**
  122948. * Add potential fallbacks if shader compilation fails
  122949. * @param mesh defines the mesh to be rendered
  122950. * @param fallbacks defines the current prioritized list of fallbacks
  122951. */
  122952. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  122953. /**
  122954. * Initialize defines for shader compilation
  122955. * @param mesh defines the mesh to be rendered
  122956. * @param nodeMaterial defines the node material requesting the update
  122957. * @param defines defines the material defines to update
  122958. * @param useInstances specifies that instances should be used
  122959. */
  122960. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  122961. /**
  122962. * Update defines for shader compilation
  122963. * @param mesh defines the mesh to be rendered
  122964. * @param nodeMaterial defines the node material requesting the update
  122965. * @param defines defines the material defines to update
  122966. * @param useInstances specifies that instances should be used
  122967. */
  122968. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  122969. /**
  122970. * Lets the block try to connect some inputs automatically
  122971. * @param material defines the hosting NodeMaterial
  122972. */
  122973. autoConfigure(material: NodeMaterial): void;
  122974. /**
  122975. * Function called when a block is declared as repeatable content generator
  122976. * @param vertexShaderState defines the current compilation state for the vertex shader
  122977. * @param fragmentShaderState defines the current compilation state for the fragment shader
  122978. * @param mesh defines the mesh to be rendered
  122979. * @param defines defines the material defines to update
  122980. */
  122981. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  122982. /**
  122983. * Checks if the block is ready
  122984. * @param mesh defines the mesh to be rendered
  122985. * @param nodeMaterial defines the node material requesting the update
  122986. * @param defines defines the material defines to update
  122987. * @param useInstances specifies that instances should be used
  122988. * @returns true if the block is ready
  122989. */
  122990. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  122991. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  122992. private _processBuild;
  122993. /**
  122994. * Compile the current node and generate the shader code
  122995. * @param state defines the current compilation state (uniforms, samplers, current string)
  122996. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  122997. * @returns true if already built
  122998. */
  122999. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  123000. protected _inputRename(name: string): string;
  123001. protected _outputRename(name: string): string;
  123002. protected _dumpPropertiesCode(): string;
  123003. /** @hidden */
  123004. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  123005. /** @hidden */
  123006. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  123007. /**
  123008. * Clone the current block to a new identical block
  123009. * @param scene defines the hosting scene
  123010. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  123011. * @returns a copy of the current block
  123012. */
  123013. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  123014. /**
  123015. * Serializes this block in a JSON representation
  123016. * @returns the serialized block object
  123017. */
  123018. serialize(): any;
  123019. /** @hidden */
  123020. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  123021. /**
  123022. * Release resources
  123023. */
  123024. dispose(): void;
  123025. }
  123026. }
  123027. declare module BABYLON {
  123028. /**
  123029. * Enum defining the type of animations supported by InputBlock
  123030. */
  123031. export enum AnimatedInputBlockTypes {
  123032. /** No animation */
  123033. None = 0,
  123034. /** Time based animation. Will only work for floats */
  123035. Time = 1
  123036. }
  123037. }
  123038. declare module BABYLON {
  123039. /**
  123040. * Block used to expose an input value
  123041. */
  123042. export class InputBlock extends NodeMaterialBlock {
  123043. private _mode;
  123044. private _associatedVariableName;
  123045. private _storedValue;
  123046. private _valueCallback;
  123047. private _type;
  123048. private _animationType;
  123049. /** Gets or set a value used to limit the range of float values */
  123050. min: number;
  123051. /** Gets or set a value used to limit the range of float values */
  123052. max: number;
  123053. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  123054. matrixMode: number;
  123055. /** @hidden */
  123056. _systemValue: Nullable<NodeMaterialSystemValues>;
  123057. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  123058. visibleInInspector: boolean;
  123059. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  123060. isConstant: boolean;
  123061. /**
  123062. * Gets or sets the connection point type (default is float)
  123063. */
  123064. readonly type: NodeMaterialBlockConnectionPointTypes;
  123065. /**
  123066. * Creates a new InputBlock
  123067. * @param name defines the block name
  123068. * @param target defines the target of that block (Vertex by default)
  123069. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  123070. */
  123071. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  123072. /**
  123073. * Gets the output component
  123074. */
  123075. readonly output: NodeMaterialConnectionPoint;
  123076. /**
  123077. * Set the source of this connection point to a vertex attribute
  123078. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  123079. * @returns the current connection point
  123080. */
  123081. setAsAttribute(attributeName?: string): InputBlock;
  123082. /**
  123083. * Set the source of this connection point to a system value
  123084. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  123085. * @returns the current connection point
  123086. */
  123087. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  123088. /**
  123089. * Gets or sets the value of that point.
  123090. * Please note that this value will be ignored if valueCallback is defined
  123091. */
  123092. value: any;
  123093. /**
  123094. * Gets or sets a callback used to get the value of that point.
  123095. * Please note that setting this value will force the connection point to ignore the value property
  123096. */
  123097. valueCallback: () => any;
  123098. /**
  123099. * Gets or sets the associated variable name in the shader
  123100. */
  123101. associatedVariableName: string;
  123102. /** Gets or sets the type of animation applied to the input */
  123103. animationType: AnimatedInputBlockTypes;
  123104. /**
  123105. * Gets a boolean indicating that this connection point not defined yet
  123106. */
  123107. readonly isUndefined: boolean;
  123108. /**
  123109. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  123110. * In this case the connection point name must be the name of the uniform to use.
  123111. * Can only be set on inputs
  123112. */
  123113. isUniform: boolean;
  123114. /**
  123115. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  123116. * In this case the connection point name must be the name of the attribute to use
  123117. * Can only be set on inputs
  123118. */
  123119. isAttribute: boolean;
  123120. /**
  123121. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  123122. * Can only be set on exit points
  123123. */
  123124. isVarying: boolean;
  123125. /**
  123126. * Gets a boolean indicating that the current connection point is a system value
  123127. */
  123128. readonly isSystemValue: boolean;
  123129. /**
  123130. * Gets or sets the current well known value or null if not defined as a system value
  123131. */
  123132. systemValue: Nullable<NodeMaterialSystemValues>;
  123133. /**
  123134. * Gets the current class name
  123135. * @returns the class name
  123136. */
  123137. getClassName(): string;
  123138. /**
  123139. * Animate the input if animationType !== None
  123140. * @param scene defines the rendering scene
  123141. */
  123142. animate(scene: Scene): void;
  123143. private _emitDefine;
  123144. initialize(state: NodeMaterialBuildState): void;
  123145. /**
  123146. * Set the input block to its default value (based on its type)
  123147. */
  123148. setDefaultValue(): void;
  123149. private _emitConstant;
  123150. private _emit;
  123151. /** @hidden */
  123152. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  123153. /** @hidden */
  123154. _transmit(effect: Effect, scene: Scene): void;
  123155. protected _buildBlock(state: NodeMaterialBuildState): void;
  123156. protected _dumpPropertiesCode(): string;
  123157. serialize(): any;
  123158. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  123159. }
  123160. }
  123161. declare module BABYLON {
  123162. /**
  123163. * Enum used to define the compatibility state between two connection points
  123164. */
  123165. export enum NodeMaterialConnectionPointCompatibilityStates {
  123166. /** Points are compatibles */
  123167. Compatible = 0,
  123168. /** Points are incompatible because of their types */
  123169. TypeIncompatible = 1,
  123170. /** Points are incompatible because of their targets (vertex vs fragment) */
  123171. TargetIncompatible = 2
  123172. }
  123173. /**
  123174. * Defines a connection point for a block
  123175. */
  123176. export class NodeMaterialConnectionPoint {
  123177. /** @hidden */
  123178. _ownerBlock: NodeMaterialBlock;
  123179. /** @hidden */
  123180. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  123181. private _endpoints;
  123182. private _associatedVariableName;
  123183. /** @hidden */
  123184. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  123185. /** @hidden */
  123186. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  123187. private _type;
  123188. /** @hidden */
  123189. _enforceAssociatedVariableName: boolean;
  123190. /**
  123191. * Gets or sets the additional types supported by this connection point
  123192. */
  123193. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  123194. /**
  123195. * Gets or sets the additional types excluded by this connection point
  123196. */
  123197. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  123198. /**
  123199. * Observable triggered when this point is connected
  123200. */
  123201. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  123202. /**
  123203. * Gets or sets the associated variable name in the shader
  123204. */
  123205. associatedVariableName: string;
  123206. /**
  123207. * Gets or sets the connection point type (default is float)
  123208. */
  123209. type: NodeMaterialBlockConnectionPointTypes;
  123210. /**
  123211. * Gets or sets the connection point name
  123212. */
  123213. name: string;
  123214. /**
  123215. * Gets or sets a boolean indicating that this connection point can be omitted
  123216. */
  123217. isOptional: boolean;
  123218. /**
  123219. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  123220. */
  123221. define: string;
  123222. /** @hidden */
  123223. _prioritizeVertex: boolean;
  123224. private _target;
  123225. /** Gets or sets the target of that connection point */
  123226. target: NodeMaterialBlockTargets;
  123227. /**
  123228. * Gets a boolean indicating that the current point is connected
  123229. */
  123230. readonly isConnected: boolean;
  123231. /**
  123232. * Gets a boolean indicating that the current point is connected to an input block
  123233. */
  123234. readonly isConnectedToInputBlock: boolean;
  123235. /**
  123236. * Gets a the connected input block (if any)
  123237. */
  123238. readonly connectInputBlock: Nullable<InputBlock>;
  123239. /** Get the other side of the connection (if any) */
  123240. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  123241. /** Get the block that owns this connection point */
  123242. readonly ownerBlock: NodeMaterialBlock;
  123243. /** Get the block connected on the other side of this connection (if any) */
  123244. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  123245. /** Get the block connected on the endpoints of this connection (if any) */
  123246. readonly connectedBlocks: Array<NodeMaterialBlock>;
  123247. /** Gets the list of connected endpoints */
  123248. readonly endpoints: NodeMaterialConnectionPoint[];
  123249. /** Gets a boolean indicating if that output point is connected to at least one input */
  123250. readonly hasEndpoints: boolean;
  123251. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  123252. readonly isConnectedInVertexShader: boolean;
  123253. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  123254. readonly isConnectedInFragmentShader: boolean;
  123255. /**
  123256. * Creates a new connection point
  123257. * @param name defines the connection point name
  123258. * @param ownerBlock defines the block hosting this connection point
  123259. */
  123260. constructor(name: string, ownerBlock: NodeMaterialBlock);
  123261. /**
  123262. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  123263. * @returns the class name
  123264. */
  123265. getClassName(): string;
  123266. /**
  123267. * Gets a boolean indicating if the current point can be connected to another point
  123268. * @param connectionPoint defines the other connection point
  123269. * @returns a boolean
  123270. */
  123271. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  123272. /**
  123273. * Gets a number indicating if the current point can be connected to another point
  123274. * @param connectionPoint defines the other connection point
  123275. * @returns a number defining the compatibility state
  123276. */
  123277. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  123278. /**
  123279. * Connect this point to another connection point
  123280. * @param connectionPoint defines the other connection point
  123281. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  123282. * @returns the current connection point
  123283. */
  123284. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  123285. /**
  123286. * Disconnect this point from one of his endpoint
  123287. * @param endpoint defines the other connection point
  123288. * @returns the current connection point
  123289. */
  123290. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  123291. /**
  123292. * Serializes this point in a JSON representation
  123293. * @returns the serialized point object
  123294. */
  123295. serialize(): any;
  123296. /**
  123297. * Release resources
  123298. */
  123299. dispose(): void;
  123300. }
  123301. }
  123302. declare module BABYLON {
  123303. /**
  123304. * Block used to add support for vertex skinning (bones)
  123305. */
  123306. export class BonesBlock extends NodeMaterialBlock {
  123307. /**
  123308. * Creates a new BonesBlock
  123309. * @param name defines the block name
  123310. */
  123311. constructor(name: string);
  123312. /**
  123313. * Initialize the block and prepare the context for build
  123314. * @param state defines the state that will be used for the build
  123315. */
  123316. initialize(state: NodeMaterialBuildState): void;
  123317. /**
  123318. * Gets the current class name
  123319. * @returns the class name
  123320. */
  123321. getClassName(): string;
  123322. /**
  123323. * Gets the matrix indices input component
  123324. */
  123325. readonly matricesIndices: NodeMaterialConnectionPoint;
  123326. /**
  123327. * Gets the matrix weights input component
  123328. */
  123329. readonly matricesWeights: NodeMaterialConnectionPoint;
  123330. /**
  123331. * Gets the extra matrix indices input component
  123332. */
  123333. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  123334. /**
  123335. * Gets the extra matrix weights input component
  123336. */
  123337. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  123338. /**
  123339. * Gets the world input component
  123340. */
  123341. readonly world: NodeMaterialConnectionPoint;
  123342. /**
  123343. * Gets the output component
  123344. */
  123345. readonly output: NodeMaterialConnectionPoint;
  123346. autoConfigure(material: NodeMaterial): void;
  123347. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  123348. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  123349. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  123350. protected _buildBlock(state: NodeMaterialBuildState): this;
  123351. }
  123352. }
  123353. declare module BABYLON {
  123354. /**
  123355. * Block used to add support for instances
  123356. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  123357. */
  123358. export class InstancesBlock extends NodeMaterialBlock {
  123359. /**
  123360. * Creates a new InstancesBlock
  123361. * @param name defines the block name
  123362. */
  123363. constructor(name: string);
  123364. /**
  123365. * Gets the current class name
  123366. * @returns the class name
  123367. */
  123368. getClassName(): string;
  123369. /**
  123370. * Gets the first world row input component
  123371. */
  123372. readonly world0: NodeMaterialConnectionPoint;
  123373. /**
  123374. * Gets the second world row input component
  123375. */
  123376. readonly world1: NodeMaterialConnectionPoint;
  123377. /**
  123378. * Gets the third world row input component
  123379. */
  123380. readonly world2: NodeMaterialConnectionPoint;
  123381. /**
  123382. * Gets the forth world row input component
  123383. */
  123384. readonly world3: NodeMaterialConnectionPoint;
  123385. /**
  123386. * Gets the world input component
  123387. */
  123388. readonly world: NodeMaterialConnectionPoint;
  123389. /**
  123390. * Gets the output component
  123391. */
  123392. readonly output: NodeMaterialConnectionPoint;
  123393. autoConfigure(material: NodeMaterial): void;
  123394. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  123395. protected _buildBlock(state: NodeMaterialBuildState): this;
  123396. }
  123397. }
  123398. declare module BABYLON {
  123399. /**
  123400. * Block used to add morph targets support to vertex shader
  123401. */
  123402. export class MorphTargetsBlock extends NodeMaterialBlock {
  123403. private _repeatableContentAnchor;
  123404. private _repeatebleContentGenerated;
  123405. /**
  123406. * Create a new MorphTargetsBlock
  123407. * @param name defines the block name
  123408. */
  123409. constructor(name: string);
  123410. /**
  123411. * Gets the current class name
  123412. * @returns the class name
  123413. */
  123414. getClassName(): string;
  123415. /**
  123416. * Gets the position input component
  123417. */
  123418. readonly position: NodeMaterialConnectionPoint;
  123419. /**
  123420. * Gets the normal input component
  123421. */
  123422. readonly normal: NodeMaterialConnectionPoint;
  123423. /**
  123424. * Gets the tangent input component
  123425. */
  123426. readonly tangent: NodeMaterialConnectionPoint;
  123427. /**
  123428. * Gets the tangent input component
  123429. */
  123430. readonly uv: NodeMaterialConnectionPoint;
  123431. /**
  123432. * Gets the position output component
  123433. */
  123434. readonly positionOutput: NodeMaterialConnectionPoint;
  123435. /**
  123436. * Gets the normal output component
  123437. */
  123438. readonly normalOutput: NodeMaterialConnectionPoint;
  123439. /**
  123440. * Gets the tangent output component
  123441. */
  123442. readonly tangentOutput: NodeMaterialConnectionPoint;
  123443. /**
  123444. * Gets the tangent output component
  123445. */
  123446. readonly uvOutput: NodeMaterialConnectionPoint;
  123447. initialize(state: NodeMaterialBuildState): void;
  123448. autoConfigure(material: NodeMaterial): void;
  123449. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  123450. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  123451. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  123452. protected _buildBlock(state: NodeMaterialBuildState): this;
  123453. }
  123454. }
  123455. declare module BABYLON {
  123456. /**
  123457. * Block used to get data information from a light
  123458. */
  123459. export class LightInformationBlock extends NodeMaterialBlock {
  123460. private _lightDataUniformName;
  123461. private _lightColorUniformName;
  123462. private _lightTypeDefineName;
  123463. /**
  123464. * Gets or sets the light associated with this block
  123465. */
  123466. light: Nullable<Light>;
  123467. /**
  123468. * Creates a new LightInformationBlock
  123469. * @param name defines the block name
  123470. */
  123471. constructor(name: string);
  123472. /**
  123473. * Gets the current class name
  123474. * @returns the class name
  123475. */
  123476. getClassName(): string;
  123477. /**
  123478. * Gets the world position input component
  123479. */
  123480. readonly worldPosition: NodeMaterialConnectionPoint;
  123481. /**
  123482. * Gets the direction output component
  123483. */
  123484. readonly direction: NodeMaterialConnectionPoint;
  123485. /**
  123486. * Gets the direction output component
  123487. */
  123488. readonly color: NodeMaterialConnectionPoint;
  123489. /**
  123490. * Gets the direction output component
  123491. */
  123492. readonly intensity: NodeMaterialConnectionPoint;
  123493. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  123494. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  123495. protected _buildBlock(state: NodeMaterialBuildState): this;
  123496. serialize(): any;
  123497. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  123498. }
  123499. }
  123500. declare module BABYLON {
  123501. /**
  123502. * Block used to add image processing support to fragment shader
  123503. */
  123504. export class ImageProcessingBlock extends NodeMaterialBlock {
  123505. /**
  123506. * Create a new ImageProcessingBlock
  123507. * @param name defines the block name
  123508. */
  123509. constructor(name: string);
  123510. /**
  123511. * Gets the current class name
  123512. * @returns the class name
  123513. */
  123514. getClassName(): string;
  123515. /**
  123516. * Gets the color input component
  123517. */
  123518. readonly color: NodeMaterialConnectionPoint;
  123519. /**
  123520. * Gets the output component
  123521. */
  123522. readonly output: NodeMaterialConnectionPoint;
  123523. /**
  123524. * Initialize the block and prepare the context for build
  123525. * @param state defines the state that will be used for the build
  123526. */
  123527. initialize(state: NodeMaterialBuildState): void;
  123528. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  123529. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  123530. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  123531. protected _buildBlock(state: NodeMaterialBuildState): this;
  123532. }
  123533. }
  123534. declare module BABYLON {
  123535. /**
  123536. * Block used to pertub normals based on a normal map
  123537. */
  123538. export class PerturbNormalBlock extends NodeMaterialBlock {
  123539. private _tangentSpaceParameterName;
  123540. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  123541. invertX: boolean;
  123542. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  123543. invertY: boolean;
  123544. /**
  123545. * Create a new PerturbNormalBlock
  123546. * @param name defines the block name
  123547. */
  123548. constructor(name: string);
  123549. /**
  123550. * Gets the current class name
  123551. * @returns the class name
  123552. */
  123553. getClassName(): string;
  123554. /**
  123555. * Gets the world position input component
  123556. */
  123557. readonly worldPosition: NodeMaterialConnectionPoint;
  123558. /**
  123559. * Gets the world normal input component
  123560. */
  123561. readonly worldNormal: NodeMaterialConnectionPoint;
  123562. /**
  123563. * Gets the uv input component
  123564. */
  123565. readonly uv: NodeMaterialConnectionPoint;
  123566. /**
  123567. * Gets the normal map color input component
  123568. */
  123569. readonly normalMapColor: NodeMaterialConnectionPoint;
  123570. /**
  123571. * Gets the strength input component
  123572. */
  123573. readonly strength: NodeMaterialConnectionPoint;
  123574. /**
  123575. * Gets the output component
  123576. */
  123577. readonly output: NodeMaterialConnectionPoint;
  123578. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  123579. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  123580. autoConfigure(material: NodeMaterial): void;
  123581. protected _buildBlock(state: NodeMaterialBuildState): this;
  123582. protected _dumpPropertiesCode(): string;
  123583. serialize(): any;
  123584. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  123585. }
  123586. }
  123587. declare module BABYLON {
  123588. /**
  123589. * Block used to discard a pixel if a value is smaller than a cutoff
  123590. */
  123591. export class DiscardBlock extends NodeMaterialBlock {
  123592. /**
  123593. * Create a new DiscardBlock
  123594. * @param name defines the block name
  123595. */
  123596. constructor(name: string);
  123597. /**
  123598. * Gets the current class name
  123599. * @returns the class name
  123600. */
  123601. getClassName(): string;
  123602. /**
  123603. * Gets the color input component
  123604. */
  123605. readonly value: NodeMaterialConnectionPoint;
  123606. /**
  123607. * Gets the cutoff input component
  123608. */
  123609. readonly cutoff: NodeMaterialConnectionPoint;
  123610. protected _buildBlock(state: NodeMaterialBuildState): this;
  123611. }
  123612. }
  123613. declare module BABYLON {
  123614. /**
  123615. * Block used to test if the fragment shader is front facing
  123616. */
  123617. export class FrontFacingBlock extends NodeMaterialBlock {
  123618. /**
  123619. * Creates a new FrontFacingBlock
  123620. * @param name defines the block name
  123621. */
  123622. constructor(name: string);
  123623. /**
  123624. * Gets the current class name
  123625. * @returns the class name
  123626. */
  123627. getClassName(): string;
  123628. /**
  123629. * Gets the output component
  123630. */
  123631. readonly output: NodeMaterialConnectionPoint;
  123632. protected _buildBlock(state: NodeMaterialBuildState): this;
  123633. }
  123634. }
  123635. declare module BABYLON {
  123636. /**
  123637. * Block used to get the derivative value on x and y of a given input
  123638. */
  123639. export class DerivativeBlock extends NodeMaterialBlock {
  123640. /**
  123641. * Create a new DerivativeBlock
  123642. * @param name defines the block name
  123643. */
  123644. constructor(name: string);
  123645. /**
  123646. * Gets the current class name
  123647. * @returns the class name
  123648. */
  123649. getClassName(): string;
  123650. /**
  123651. * Gets the input component
  123652. */
  123653. readonly input: NodeMaterialConnectionPoint;
  123654. /**
  123655. * Gets the derivative output on x
  123656. */
  123657. readonly dx: NodeMaterialConnectionPoint;
  123658. /**
  123659. * Gets the derivative output on y
  123660. */
  123661. readonly dy: NodeMaterialConnectionPoint;
  123662. protected _buildBlock(state: NodeMaterialBuildState): this;
  123663. }
  123664. }
  123665. declare module BABYLON {
  123666. /**
  123667. * Block used to add support for scene fog
  123668. */
  123669. export class FogBlock extends NodeMaterialBlock {
  123670. private _fogDistanceName;
  123671. private _fogParameters;
  123672. /**
  123673. * Create a new FogBlock
  123674. * @param name defines the block name
  123675. */
  123676. constructor(name: string);
  123677. /**
  123678. * Gets the current class name
  123679. * @returns the class name
  123680. */
  123681. getClassName(): string;
  123682. /**
  123683. * Gets the world position input component
  123684. */
  123685. readonly worldPosition: NodeMaterialConnectionPoint;
  123686. /**
  123687. * Gets the view input component
  123688. */
  123689. readonly view: NodeMaterialConnectionPoint;
  123690. /**
  123691. * Gets the color input component
  123692. */
  123693. readonly input: NodeMaterialConnectionPoint;
  123694. /**
  123695. * Gets the fog color input component
  123696. */
  123697. readonly fogColor: NodeMaterialConnectionPoint;
  123698. /**
  123699. * Gets the output component
  123700. */
  123701. readonly output: NodeMaterialConnectionPoint;
  123702. autoConfigure(material: NodeMaterial): void;
  123703. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  123704. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  123705. protected _buildBlock(state: NodeMaterialBuildState): this;
  123706. }
  123707. }
  123708. declare module BABYLON {
  123709. /**
  123710. * Block used to add light in the fragment shader
  123711. */
  123712. export class LightBlock extends NodeMaterialBlock {
  123713. private _lightId;
  123714. /**
  123715. * Gets or sets the light associated with this block
  123716. */
  123717. light: Nullable<Light>;
  123718. /**
  123719. * Create a new LightBlock
  123720. * @param name defines the block name
  123721. */
  123722. constructor(name: string);
  123723. /**
  123724. * Gets the current class name
  123725. * @returns the class name
  123726. */
  123727. getClassName(): string;
  123728. /**
  123729. * Gets the world position input component
  123730. */
  123731. readonly worldPosition: NodeMaterialConnectionPoint;
  123732. /**
  123733. * Gets the world normal input component
  123734. */
  123735. readonly worldNormal: NodeMaterialConnectionPoint;
  123736. /**
  123737. * Gets the camera (or eye) position component
  123738. */
  123739. readonly cameraPosition: NodeMaterialConnectionPoint;
  123740. /**
  123741. * Gets the glossiness component
  123742. */
  123743. readonly glossiness: NodeMaterialConnectionPoint;
  123744. /**
  123745. * Gets the glossinness power component
  123746. */
  123747. readonly glossPower: NodeMaterialConnectionPoint;
  123748. /**
  123749. * Gets the diffuse color component
  123750. */
  123751. readonly diffuseColor: NodeMaterialConnectionPoint;
  123752. /**
  123753. * Gets the specular color component
  123754. */
  123755. readonly specularColor: NodeMaterialConnectionPoint;
  123756. /**
  123757. * Gets the diffuse output component
  123758. */
  123759. readonly diffuseOutput: NodeMaterialConnectionPoint;
  123760. /**
  123761. * Gets the specular output component
  123762. */
  123763. readonly specularOutput: NodeMaterialConnectionPoint;
  123764. autoConfigure(material: NodeMaterial): void;
  123765. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  123766. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  123767. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  123768. private _injectVertexCode;
  123769. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  123770. serialize(): any;
  123771. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  123772. }
  123773. }
  123774. declare module BABYLON {
  123775. /**
  123776. * Block used to multiply 2 values
  123777. */
  123778. export class MultiplyBlock extends NodeMaterialBlock {
  123779. /**
  123780. * Creates a new MultiplyBlock
  123781. * @param name defines the block name
  123782. */
  123783. constructor(name: string);
  123784. /**
  123785. * Gets the current class name
  123786. * @returns the class name
  123787. */
  123788. getClassName(): string;
  123789. /**
  123790. * Gets the left operand input component
  123791. */
  123792. readonly left: NodeMaterialConnectionPoint;
  123793. /**
  123794. * Gets the right operand input component
  123795. */
  123796. readonly right: NodeMaterialConnectionPoint;
  123797. /**
  123798. * Gets the output component
  123799. */
  123800. readonly output: NodeMaterialConnectionPoint;
  123801. protected _buildBlock(state: NodeMaterialBuildState): this;
  123802. }
  123803. }
  123804. declare module BABYLON {
  123805. /**
  123806. * Block used to add 2 vectors
  123807. */
  123808. export class AddBlock extends NodeMaterialBlock {
  123809. /**
  123810. * Creates a new AddBlock
  123811. * @param name defines the block name
  123812. */
  123813. constructor(name: string);
  123814. /**
  123815. * Gets the current class name
  123816. * @returns the class name
  123817. */
  123818. getClassName(): string;
  123819. /**
  123820. * Gets the left operand input component
  123821. */
  123822. readonly left: NodeMaterialConnectionPoint;
  123823. /**
  123824. * Gets the right operand input component
  123825. */
  123826. readonly right: NodeMaterialConnectionPoint;
  123827. /**
  123828. * Gets the output component
  123829. */
  123830. readonly output: NodeMaterialConnectionPoint;
  123831. protected _buildBlock(state: NodeMaterialBuildState): this;
  123832. }
  123833. }
  123834. declare module BABYLON {
  123835. /**
  123836. * Block used to scale a vector by a float
  123837. */
  123838. export class ScaleBlock extends NodeMaterialBlock {
  123839. /**
  123840. * Creates a new ScaleBlock
  123841. * @param name defines the block name
  123842. */
  123843. constructor(name: string);
  123844. /**
  123845. * Gets the current class name
  123846. * @returns the class name
  123847. */
  123848. getClassName(): string;
  123849. /**
  123850. * Gets the input component
  123851. */
  123852. readonly input: NodeMaterialConnectionPoint;
  123853. /**
  123854. * Gets the factor input component
  123855. */
  123856. readonly factor: NodeMaterialConnectionPoint;
  123857. /**
  123858. * Gets the output component
  123859. */
  123860. readonly output: NodeMaterialConnectionPoint;
  123861. protected _buildBlock(state: NodeMaterialBuildState): this;
  123862. }
  123863. }
  123864. declare module BABYLON {
  123865. /**
  123866. * Block used to clamp a float
  123867. */
  123868. export class ClampBlock extends NodeMaterialBlock {
  123869. /** Gets or sets the minimum range */
  123870. minimum: number;
  123871. /** Gets or sets the maximum range */
  123872. maximum: number;
  123873. /**
  123874. * Creates a new ClampBlock
  123875. * @param name defines the block name
  123876. */
  123877. constructor(name: string);
  123878. /**
  123879. * Gets the current class name
  123880. * @returns the class name
  123881. */
  123882. getClassName(): string;
  123883. /**
  123884. * Gets the value input component
  123885. */
  123886. readonly value: NodeMaterialConnectionPoint;
  123887. /**
  123888. * Gets the output component
  123889. */
  123890. readonly output: NodeMaterialConnectionPoint;
  123891. protected _buildBlock(state: NodeMaterialBuildState): this;
  123892. protected _dumpPropertiesCode(): string;
  123893. serialize(): any;
  123894. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  123895. }
  123896. }
  123897. declare module BABYLON {
  123898. /**
  123899. * Block used to apply a cross product between 2 vectors
  123900. */
  123901. export class CrossBlock extends NodeMaterialBlock {
  123902. /**
  123903. * Creates a new CrossBlock
  123904. * @param name defines the block name
  123905. */
  123906. constructor(name: string);
  123907. /**
  123908. * Gets the current class name
  123909. * @returns the class name
  123910. */
  123911. getClassName(): string;
  123912. /**
  123913. * Gets the left operand input component
  123914. */
  123915. readonly left: NodeMaterialConnectionPoint;
  123916. /**
  123917. * Gets the right operand input component
  123918. */
  123919. readonly right: NodeMaterialConnectionPoint;
  123920. /**
  123921. * Gets the output component
  123922. */
  123923. readonly output: NodeMaterialConnectionPoint;
  123924. protected _buildBlock(state: NodeMaterialBuildState): this;
  123925. }
  123926. }
  123927. declare module BABYLON {
  123928. /**
  123929. * Block used to apply a dot product between 2 vectors
  123930. */
  123931. export class DotBlock extends NodeMaterialBlock {
  123932. /**
  123933. * Creates a new DotBlock
  123934. * @param name defines the block name
  123935. */
  123936. constructor(name: string);
  123937. /**
  123938. * Gets the current class name
  123939. * @returns the class name
  123940. */
  123941. getClassName(): string;
  123942. /**
  123943. * Gets the left operand input component
  123944. */
  123945. readonly left: NodeMaterialConnectionPoint;
  123946. /**
  123947. * Gets the right operand input component
  123948. */
  123949. readonly right: NodeMaterialConnectionPoint;
  123950. /**
  123951. * Gets the output component
  123952. */
  123953. readonly output: NodeMaterialConnectionPoint;
  123954. protected _buildBlock(state: NodeMaterialBuildState): this;
  123955. }
  123956. }
  123957. declare module BABYLON {
  123958. /**
  123959. * Block used to remap a float from a range to a new one
  123960. */
  123961. export class RemapBlock extends NodeMaterialBlock {
  123962. /**
  123963. * Gets or sets the source range
  123964. */
  123965. sourceRange: Vector2;
  123966. /**
  123967. * Gets or sets the target range
  123968. */
  123969. targetRange: Vector2;
  123970. /**
  123971. * Creates a new RemapBlock
  123972. * @param name defines the block name
  123973. */
  123974. constructor(name: string);
  123975. /**
  123976. * Gets the current class name
  123977. * @returns the class name
  123978. */
  123979. getClassName(): string;
  123980. /**
  123981. * Gets the input component
  123982. */
  123983. readonly input: NodeMaterialConnectionPoint;
  123984. /**
  123985. * Gets the source min input component
  123986. */
  123987. readonly sourceMin: NodeMaterialConnectionPoint;
  123988. /**
  123989. * Gets the source max input component
  123990. */
  123991. readonly sourceMax: NodeMaterialConnectionPoint;
  123992. /**
  123993. * Gets the target min input component
  123994. */
  123995. readonly targetMin: NodeMaterialConnectionPoint;
  123996. /**
  123997. * Gets the target max input component
  123998. */
  123999. readonly targetMax: NodeMaterialConnectionPoint;
  124000. /**
  124001. * Gets the output component
  124002. */
  124003. readonly output: NodeMaterialConnectionPoint;
  124004. protected _buildBlock(state: NodeMaterialBuildState): this;
  124005. protected _dumpPropertiesCode(): string;
  124006. serialize(): any;
  124007. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  124008. }
  124009. }
  124010. declare module BABYLON {
  124011. /**
  124012. * Block used to normalize a vector
  124013. */
  124014. export class NormalizeBlock extends NodeMaterialBlock {
  124015. /**
  124016. * Creates a new NormalizeBlock
  124017. * @param name defines the block name
  124018. */
  124019. constructor(name: string);
  124020. /**
  124021. * Gets the current class name
  124022. * @returns the class name
  124023. */
  124024. getClassName(): string;
  124025. /**
  124026. * Gets the input component
  124027. */
  124028. readonly input: NodeMaterialConnectionPoint;
  124029. /**
  124030. * Gets the output component
  124031. */
  124032. readonly output: NodeMaterialConnectionPoint;
  124033. protected _buildBlock(state: NodeMaterialBuildState): this;
  124034. }
  124035. }
  124036. declare module BABYLON {
  124037. /**
  124038. * Operations supported by the Trigonometry block
  124039. */
  124040. export enum TrigonometryBlockOperations {
  124041. /** Cos */
  124042. Cos = 0,
  124043. /** Sin */
  124044. Sin = 1,
  124045. /** Abs */
  124046. Abs = 2,
  124047. /** Exp */
  124048. Exp = 3,
  124049. /** Exp2 */
  124050. Exp2 = 4,
  124051. /** Round */
  124052. Round = 5,
  124053. /** Floor */
  124054. Floor = 6,
  124055. /** Ceiling */
  124056. Ceiling = 7,
  124057. /** Square root */
  124058. Sqrt = 8,
  124059. /** Log */
  124060. Log = 9,
  124061. /** Tangent */
  124062. Tan = 10,
  124063. /** Arc tangent */
  124064. ArcTan = 11,
  124065. /** Arc cosinus */
  124066. ArcCos = 12,
  124067. /** Arc sinus */
  124068. ArcSin = 13,
  124069. /** Fraction */
  124070. Fract = 14,
  124071. /** Sign */
  124072. Sign = 15,
  124073. /** To radians (from degrees) */
  124074. Radians = 16,
  124075. /** To degrees (from radians) */
  124076. Degrees = 17
  124077. }
  124078. /**
  124079. * Block used to apply trigonometry operation to floats
  124080. */
  124081. export class TrigonometryBlock extends NodeMaterialBlock {
  124082. /**
  124083. * Gets or sets the operation applied by the block
  124084. */
  124085. operation: TrigonometryBlockOperations;
  124086. /**
  124087. * Creates a new TrigonometryBlock
  124088. * @param name defines the block name
  124089. */
  124090. constructor(name: string);
  124091. /**
  124092. * Gets the current class name
  124093. * @returns the class name
  124094. */
  124095. getClassName(): string;
  124096. /**
  124097. * Gets the input component
  124098. */
  124099. readonly input: NodeMaterialConnectionPoint;
  124100. /**
  124101. * Gets the output component
  124102. */
  124103. readonly output: NodeMaterialConnectionPoint;
  124104. protected _buildBlock(state: NodeMaterialBuildState): this;
  124105. serialize(): any;
  124106. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  124107. protected _dumpPropertiesCode(): string;
  124108. }
  124109. }
  124110. declare module BABYLON {
  124111. /**
  124112. * Block used to create a Color3/4 out of individual inputs (one for each component)
  124113. */
  124114. export class ColorMergerBlock extends NodeMaterialBlock {
  124115. /**
  124116. * Create a new ColorMergerBlock
  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 r component (input)
  124127. */
  124128. readonly r: NodeMaterialConnectionPoint;
  124129. /**
  124130. * Gets the g component (input)
  124131. */
  124132. readonly g: NodeMaterialConnectionPoint;
  124133. /**
  124134. * Gets the b component (input)
  124135. */
  124136. readonly b: NodeMaterialConnectionPoint;
  124137. /**
  124138. * Gets the a component (input)
  124139. */
  124140. readonly a: NodeMaterialConnectionPoint;
  124141. /**
  124142. * Gets the rgba component (output)
  124143. */
  124144. readonly rgba: NodeMaterialConnectionPoint;
  124145. /**
  124146. * Gets the rgb component (output)
  124147. */
  124148. readonly rgb: NodeMaterialConnectionPoint;
  124149. protected _buildBlock(state: NodeMaterialBuildState): this;
  124150. }
  124151. }
  124152. declare module BABYLON {
  124153. /**
  124154. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  124155. */
  124156. export class VectorMergerBlock extends NodeMaterialBlock {
  124157. /**
  124158. * Create a new VectorMergerBlock
  124159. * @param name defines the block name
  124160. */
  124161. constructor(name: string);
  124162. /**
  124163. * Gets the current class name
  124164. * @returns the class name
  124165. */
  124166. getClassName(): string;
  124167. /**
  124168. * Gets the x component (input)
  124169. */
  124170. readonly x: NodeMaterialConnectionPoint;
  124171. /**
  124172. * Gets the y component (input)
  124173. */
  124174. readonly y: NodeMaterialConnectionPoint;
  124175. /**
  124176. * Gets the z component (input)
  124177. */
  124178. readonly z: NodeMaterialConnectionPoint;
  124179. /**
  124180. * Gets the w component (input)
  124181. */
  124182. readonly w: NodeMaterialConnectionPoint;
  124183. /**
  124184. * Gets the xyzw component (output)
  124185. */
  124186. readonly xyzw: NodeMaterialConnectionPoint;
  124187. /**
  124188. * Gets the xyz component (output)
  124189. */
  124190. readonly xyz: NodeMaterialConnectionPoint;
  124191. /**
  124192. * Gets the xy component (output)
  124193. */
  124194. readonly xy: NodeMaterialConnectionPoint;
  124195. protected _buildBlock(state: NodeMaterialBuildState): this;
  124196. }
  124197. }
  124198. declare module BABYLON {
  124199. /**
  124200. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  124201. */
  124202. export class ColorSplitterBlock extends NodeMaterialBlock {
  124203. /**
  124204. * Create a new ColorSplitterBlock
  124205. * @param name defines the block name
  124206. */
  124207. constructor(name: string);
  124208. /**
  124209. * Gets the current class name
  124210. * @returns the class name
  124211. */
  124212. getClassName(): string;
  124213. /**
  124214. * Gets the rgba component (input)
  124215. */
  124216. readonly rgba: NodeMaterialConnectionPoint;
  124217. /**
  124218. * Gets the rgb component (input)
  124219. */
  124220. readonly rgbIn: NodeMaterialConnectionPoint;
  124221. /**
  124222. * Gets the rgb component (output)
  124223. */
  124224. readonly rgbOut: NodeMaterialConnectionPoint;
  124225. /**
  124226. * Gets the r component (output)
  124227. */
  124228. readonly r: NodeMaterialConnectionPoint;
  124229. /**
  124230. * Gets the g component (output)
  124231. */
  124232. readonly g: NodeMaterialConnectionPoint;
  124233. /**
  124234. * Gets the b component (output)
  124235. */
  124236. readonly b: NodeMaterialConnectionPoint;
  124237. /**
  124238. * Gets the a component (output)
  124239. */
  124240. readonly a: NodeMaterialConnectionPoint;
  124241. protected _inputRename(name: string): string;
  124242. protected _outputRename(name: string): string;
  124243. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  124244. }
  124245. }
  124246. declare module BABYLON {
  124247. /**
  124248. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  124249. */
  124250. export class VectorSplitterBlock extends NodeMaterialBlock {
  124251. /**
  124252. * Create a new VectorSplitterBlock
  124253. * @param name defines the block name
  124254. */
  124255. constructor(name: string);
  124256. /**
  124257. * Gets the current class name
  124258. * @returns the class name
  124259. */
  124260. getClassName(): string;
  124261. /**
  124262. * Gets the xyzw component (input)
  124263. */
  124264. readonly xyzw: NodeMaterialConnectionPoint;
  124265. /**
  124266. * Gets the xyz component (input)
  124267. */
  124268. readonly xyzIn: NodeMaterialConnectionPoint;
  124269. /**
  124270. * Gets the xy component (input)
  124271. */
  124272. readonly xyIn: NodeMaterialConnectionPoint;
  124273. /**
  124274. * Gets the xyz component (output)
  124275. */
  124276. readonly xyzOut: NodeMaterialConnectionPoint;
  124277. /**
  124278. * Gets the xy component (output)
  124279. */
  124280. readonly xyOut: NodeMaterialConnectionPoint;
  124281. /**
  124282. * Gets the x component (output)
  124283. */
  124284. readonly x: NodeMaterialConnectionPoint;
  124285. /**
  124286. * Gets the y component (output)
  124287. */
  124288. readonly y: NodeMaterialConnectionPoint;
  124289. /**
  124290. * Gets the z component (output)
  124291. */
  124292. readonly z: NodeMaterialConnectionPoint;
  124293. /**
  124294. * Gets the w component (output)
  124295. */
  124296. readonly w: NodeMaterialConnectionPoint;
  124297. protected _inputRename(name: string): string;
  124298. protected _outputRename(name: string): string;
  124299. protected _buildBlock(state: NodeMaterialBuildState): this;
  124300. }
  124301. }
  124302. declare module BABYLON {
  124303. /**
  124304. * Block used to lerp between 2 values
  124305. */
  124306. export class LerpBlock extends NodeMaterialBlock {
  124307. /**
  124308. * Creates a new LerpBlock
  124309. * @param name defines the block name
  124310. */
  124311. constructor(name: string);
  124312. /**
  124313. * Gets the current class name
  124314. * @returns the class name
  124315. */
  124316. getClassName(): string;
  124317. /**
  124318. * Gets the left operand input component
  124319. */
  124320. readonly left: NodeMaterialConnectionPoint;
  124321. /**
  124322. * Gets the right operand input component
  124323. */
  124324. readonly right: NodeMaterialConnectionPoint;
  124325. /**
  124326. * Gets the gradient operand input component
  124327. */
  124328. readonly gradient: NodeMaterialConnectionPoint;
  124329. /**
  124330. * Gets the output component
  124331. */
  124332. readonly output: NodeMaterialConnectionPoint;
  124333. protected _buildBlock(state: NodeMaterialBuildState): this;
  124334. }
  124335. }
  124336. declare module BABYLON {
  124337. /**
  124338. * Block used to divide 2 vectors
  124339. */
  124340. export class DivideBlock extends NodeMaterialBlock {
  124341. /**
  124342. * Creates a new DivideBlock
  124343. * @param name defines the block name
  124344. */
  124345. constructor(name: string);
  124346. /**
  124347. * Gets the current class name
  124348. * @returns the class name
  124349. */
  124350. getClassName(): string;
  124351. /**
  124352. * Gets the left operand input component
  124353. */
  124354. readonly left: NodeMaterialConnectionPoint;
  124355. /**
  124356. * Gets the right operand input component
  124357. */
  124358. readonly right: NodeMaterialConnectionPoint;
  124359. /**
  124360. * Gets the output component
  124361. */
  124362. readonly output: NodeMaterialConnectionPoint;
  124363. protected _buildBlock(state: NodeMaterialBuildState): this;
  124364. }
  124365. }
  124366. declare module BABYLON {
  124367. /**
  124368. * Block used to subtract 2 vectors
  124369. */
  124370. export class SubtractBlock extends NodeMaterialBlock {
  124371. /**
  124372. * Creates a new SubtractBlock
  124373. * @param name defines the block name
  124374. */
  124375. constructor(name: string);
  124376. /**
  124377. * Gets the current class name
  124378. * @returns the class name
  124379. */
  124380. getClassName(): string;
  124381. /**
  124382. * Gets the left operand input component
  124383. */
  124384. readonly left: NodeMaterialConnectionPoint;
  124385. /**
  124386. * Gets the right operand input component
  124387. */
  124388. readonly right: NodeMaterialConnectionPoint;
  124389. /**
  124390. * Gets the output component
  124391. */
  124392. readonly output: NodeMaterialConnectionPoint;
  124393. protected _buildBlock(state: NodeMaterialBuildState): this;
  124394. }
  124395. }
  124396. declare module BABYLON {
  124397. /**
  124398. * Block used to step a value
  124399. */
  124400. export class StepBlock extends NodeMaterialBlock {
  124401. /**
  124402. * Creates a new StepBlock
  124403. * @param name defines the block name
  124404. */
  124405. constructor(name: string);
  124406. /**
  124407. * Gets the current class name
  124408. * @returns the class name
  124409. */
  124410. getClassName(): string;
  124411. /**
  124412. * Gets the value operand input component
  124413. */
  124414. readonly value: NodeMaterialConnectionPoint;
  124415. /**
  124416. * Gets the edge operand input component
  124417. */
  124418. readonly edge: NodeMaterialConnectionPoint;
  124419. /**
  124420. * Gets the output component
  124421. */
  124422. readonly output: NodeMaterialConnectionPoint;
  124423. protected _buildBlock(state: NodeMaterialBuildState): this;
  124424. }
  124425. }
  124426. declare module BABYLON {
  124427. /**
  124428. * Block used to get the opposite (1 - x) of a value
  124429. */
  124430. export class OneMinusBlock extends NodeMaterialBlock {
  124431. /**
  124432. * Creates a new OneMinusBlock
  124433. * @param name defines the block name
  124434. */
  124435. constructor(name: string);
  124436. /**
  124437. * Gets the current class name
  124438. * @returns the class name
  124439. */
  124440. getClassName(): string;
  124441. /**
  124442. * Gets the input component
  124443. */
  124444. readonly input: NodeMaterialConnectionPoint;
  124445. /**
  124446. * Gets the output component
  124447. */
  124448. readonly output: NodeMaterialConnectionPoint;
  124449. protected _buildBlock(state: NodeMaterialBuildState): this;
  124450. }
  124451. }
  124452. declare module BABYLON {
  124453. /**
  124454. * Block used to get the view direction
  124455. */
  124456. export class ViewDirectionBlock extends NodeMaterialBlock {
  124457. /**
  124458. * Creates a new ViewDirectionBlock
  124459. * @param name defines the block name
  124460. */
  124461. constructor(name: string);
  124462. /**
  124463. * Gets the current class name
  124464. * @returns the class name
  124465. */
  124466. getClassName(): string;
  124467. /**
  124468. * Gets the world position component
  124469. */
  124470. readonly worldPosition: NodeMaterialConnectionPoint;
  124471. /**
  124472. * Gets the camera position component
  124473. */
  124474. readonly cameraPosition: NodeMaterialConnectionPoint;
  124475. /**
  124476. * Gets the output component
  124477. */
  124478. readonly output: NodeMaterialConnectionPoint;
  124479. autoConfigure(material: NodeMaterial): void;
  124480. protected _buildBlock(state: NodeMaterialBuildState): this;
  124481. }
  124482. }
  124483. declare module BABYLON {
  124484. /**
  124485. * Block used to compute fresnel value
  124486. */
  124487. export class FresnelBlock extends NodeMaterialBlock {
  124488. /**
  124489. * Create a new FresnelBlock
  124490. * @param name defines the block name
  124491. */
  124492. constructor(name: string);
  124493. /**
  124494. * Gets the current class name
  124495. * @returns the class name
  124496. */
  124497. getClassName(): string;
  124498. /**
  124499. * Gets the world normal input component
  124500. */
  124501. readonly worldNormal: NodeMaterialConnectionPoint;
  124502. /**
  124503. * Gets the view direction input component
  124504. */
  124505. readonly viewDirection: NodeMaterialConnectionPoint;
  124506. /**
  124507. * Gets the bias input component
  124508. */
  124509. readonly bias: NodeMaterialConnectionPoint;
  124510. /**
  124511. * Gets the camera (or eye) position component
  124512. */
  124513. readonly power: NodeMaterialConnectionPoint;
  124514. /**
  124515. * Gets the fresnel output component
  124516. */
  124517. readonly fresnel: NodeMaterialConnectionPoint;
  124518. autoConfigure(material: NodeMaterial): void;
  124519. protected _buildBlock(state: NodeMaterialBuildState): this;
  124520. }
  124521. }
  124522. declare module BABYLON {
  124523. /**
  124524. * Block used to get the max of 2 values
  124525. */
  124526. export class MaxBlock extends NodeMaterialBlock {
  124527. /**
  124528. * Creates a new MaxBlock
  124529. * @param name defines the block name
  124530. */
  124531. constructor(name: string);
  124532. /**
  124533. * Gets the current class name
  124534. * @returns the class name
  124535. */
  124536. getClassName(): string;
  124537. /**
  124538. * Gets the left operand input component
  124539. */
  124540. readonly left: NodeMaterialConnectionPoint;
  124541. /**
  124542. * Gets the right operand input component
  124543. */
  124544. readonly right: NodeMaterialConnectionPoint;
  124545. /**
  124546. * Gets the output component
  124547. */
  124548. readonly output: NodeMaterialConnectionPoint;
  124549. protected _buildBlock(state: NodeMaterialBuildState): this;
  124550. }
  124551. }
  124552. declare module BABYLON {
  124553. /**
  124554. * Block used to get the min of 2 values
  124555. */
  124556. export class MinBlock extends NodeMaterialBlock {
  124557. /**
  124558. * Creates a new MinBlock
  124559. * @param name defines the block name
  124560. */
  124561. constructor(name: string);
  124562. /**
  124563. * Gets the current class name
  124564. * @returns the class name
  124565. */
  124566. getClassName(): string;
  124567. /**
  124568. * Gets the left operand input component
  124569. */
  124570. readonly left: NodeMaterialConnectionPoint;
  124571. /**
  124572. * Gets the right operand input component
  124573. */
  124574. readonly right: NodeMaterialConnectionPoint;
  124575. /**
  124576. * Gets the output component
  124577. */
  124578. readonly output: NodeMaterialConnectionPoint;
  124579. protected _buildBlock(state: NodeMaterialBuildState): this;
  124580. }
  124581. }
  124582. declare module BABYLON {
  124583. /**
  124584. * Block used to get the distance between 2 values
  124585. */
  124586. export class DistanceBlock extends NodeMaterialBlock {
  124587. /**
  124588. * Creates a new DistanceBlock
  124589. * @param name defines the block name
  124590. */
  124591. constructor(name: string);
  124592. /**
  124593. * Gets the current class name
  124594. * @returns the class name
  124595. */
  124596. getClassName(): string;
  124597. /**
  124598. * Gets the left operand input component
  124599. */
  124600. readonly left: NodeMaterialConnectionPoint;
  124601. /**
  124602. * Gets the right operand input component
  124603. */
  124604. readonly right: NodeMaterialConnectionPoint;
  124605. /**
  124606. * Gets the output component
  124607. */
  124608. readonly output: NodeMaterialConnectionPoint;
  124609. protected _buildBlock(state: NodeMaterialBuildState): this;
  124610. }
  124611. }
  124612. declare module BABYLON {
  124613. /**
  124614. * Block used to get the length of a vector
  124615. */
  124616. export class LengthBlock extends NodeMaterialBlock {
  124617. /**
  124618. * Creates a new LengthBlock
  124619. * @param name defines the block name
  124620. */
  124621. constructor(name: string);
  124622. /**
  124623. * Gets the current class name
  124624. * @returns the class name
  124625. */
  124626. getClassName(): string;
  124627. /**
  124628. * Gets the value input component
  124629. */
  124630. readonly value: NodeMaterialConnectionPoint;
  124631. /**
  124632. * Gets the output component
  124633. */
  124634. readonly output: NodeMaterialConnectionPoint;
  124635. protected _buildBlock(state: NodeMaterialBuildState): this;
  124636. }
  124637. }
  124638. declare module BABYLON {
  124639. /**
  124640. * Block used to get negative version of a value (i.e. x * -1)
  124641. */
  124642. export class NegateBlock extends NodeMaterialBlock {
  124643. /**
  124644. * Creates a new NegateBlock
  124645. * @param name defines the block name
  124646. */
  124647. constructor(name: string);
  124648. /**
  124649. * Gets the current class name
  124650. * @returns the class name
  124651. */
  124652. getClassName(): string;
  124653. /**
  124654. * Gets the value input component
  124655. */
  124656. readonly value: NodeMaterialConnectionPoint;
  124657. /**
  124658. * Gets the output component
  124659. */
  124660. readonly output: NodeMaterialConnectionPoint;
  124661. protected _buildBlock(state: NodeMaterialBuildState): this;
  124662. }
  124663. }
  124664. declare module BABYLON {
  124665. /**
  124666. * Block used to get the value of the first parameter raised to the power of the second
  124667. */
  124668. export class PowBlock extends NodeMaterialBlock {
  124669. /**
  124670. * Creates a new PowBlock
  124671. * @param name defines the block name
  124672. */
  124673. constructor(name: string);
  124674. /**
  124675. * Gets the current class name
  124676. * @returns the class name
  124677. */
  124678. getClassName(): string;
  124679. /**
  124680. * Gets the value operand input component
  124681. */
  124682. readonly value: NodeMaterialConnectionPoint;
  124683. /**
  124684. * Gets the power operand input component
  124685. */
  124686. readonly power: NodeMaterialConnectionPoint;
  124687. /**
  124688. * Gets the output component
  124689. */
  124690. readonly output: NodeMaterialConnectionPoint;
  124691. protected _buildBlock(state: NodeMaterialBuildState): this;
  124692. }
  124693. }
  124694. declare module BABYLON {
  124695. /**
  124696. * Block used to get a random number
  124697. */
  124698. export class RandomNumberBlock extends NodeMaterialBlock {
  124699. /**
  124700. * Creates a new RandomNumberBlock
  124701. * @param name defines the block name
  124702. */
  124703. constructor(name: string);
  124704. /**
  124705. * Gets the current class name
  124706. * @returns the class name
  124707. */
  124708. getClassName(): string;
  124709. /**
  124710. * Gets the seed input component
  124711. */
  124712. readonly seed: NodeMaterialConnectionPoint;
  124713. /**
  124714. * Gets the output component
  124715. */
  124716. readonly output: NodeMaterialConnectionPoint;
  124717. protected _buildBlock(state: NodeMaterialBuildState): this;
  124718. }
  124719. }
  124720. declare module BABYLON {
  124721. /**
  124722. * Block used to compute arc tangent of 2 values
  124723. */
  124724. export class ArcTan2Block extends NodeMaterialBlock {
  124725. /**
  124726. * Creates a new ArcTan2Block
  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 x operand input component
  124737. */
  124738. readonly x: NodeMaterialConnectionPoint;
  124739. /**
  124740. * Gets the y operand input component
  124741. */
  124742. readonly y: NodeMaterialConnectionPoint;
  124743. /**
  124744. * Gets the output component
  124745. */
  124746. readonly output: NodeMaterialConnectionPoint;
  124747. protected _buildBlock(state: NodeMaterialBuildState): this;
  124748. }
  124749. }
  124750. declare module BABYLON {
  124751. /**
  124752. * Block used to smooth step a value
  124753. */
  124754. export class SmoothStepBlock extends NodeMaterialBlock {
  124755. /**
  124756. * Creates a new SmoothStepBlock
  124757. * @param name defines the block name
  124758. */
  124759. constructor(name: string);
  124760. /**
  124761. * Gets the current class name
  124762. * @returns the class name
  124763. */
  124764. getClassName(): string;
  124765. /**
  124766. * Gets the value operand input component
  124767. */
  124768. readonly value: NodeMaterialConnectionPoint;
  124769. /**
  124770. * Gets the first edge operand input component
  124771. */
  124772. readonly edge0: NodeMaterialConnectionPoint;
  124773. /**
  124774. * Gets the second edge operand input component
  124775. */
  124776. readonly edge1: NodeMaterialConnectionPoint;
  124777. /**
  124778. * Gets the output component
  124779. */
  124780. readonly output: NodeMaterialConnectionPoint;
  124781. protected _buildBlock(state: NodeMaterialBuildState): this;
  124782. }
  124783. }
  124784. declare module BABYLON {
  124785. /**
  124786. * Block used to get the reciprocal (1 / x) of a value
  124787. */
  124788. export class ReciprocalBlock extends NodeMaterialBlock {
  124789. /**
  124790. * Creates a new ReciprocalBlock
  124791. * @param name defines the block name
  124792. */
  124793. constructor(name: string);
  124794. /**
  124795. * Gets the current class name
  124796. * @returns the class name
  124797. */
  124798. getClassName(): string;
  124799. /**
  124800. * Gets the input component
  124801. */
  124802. readonly input: NodeMaterialConnectionPoint;
  124803. /**
  124804. * Gets the output component
  124805. */
  124806. readonly output: NodeMaterialConnectionPoint;
  124807. protected _buildBlock(state: NodeMaterialBuildState): this;
  124808. }
  124809. }
  124810. declare module BABYLON {
  124811. /**
  124812. * Block used to replace a color by another one
  124813. */
  124814. export class ReplaceColorBlock extends NodeMaterialBlock {
  124815. /**
  124816. * Creates a new ReplaceColorBlock
  124817. * @param name defines the block name
  124818. */
  124819. constructor(name: string);
  124820. /**
  124821. * Gets the current class name
  124822. * @returns the class name
  124823. */
  124824. getClassName(): string;
  124825. /**
  124826. * Gets the value input component
  124827. */
  124828. readonly value: NodeMaterialConnectionPoint;
  124829. /**
  124830. * Gets the reference input component
  124831. */
  124832. readonly reference: NodeMaterialConnectionPoint;
  124833. /**
  124834. * Gets the distance input component
  124835. */
  124836. readonly distance: NodeMaterialConnectionPoint;
  124837. /**
  124838. * Gets the replacement input component
  124839. */
  124840. readonly replacement: NodeMaterialConnectionPoint;
  124841. /**
  124842. * Gets the output component
  124843. */
  124844. readonly output: NodeMaterialConnectionPoint;
  124845. protected _buildBlock(state: NodeMaterialBuildState): this;
  124846. }
  124847. }
  124848. declare module BABYLON {
  124849. /**
  124850. * Block used to posterize a value
  124851. * @see https://en.wikipedia.org/wiki/Posterization
  124852. */
  124853. export class PosterizeBlock extends NodeMaterialBlock {
  124854. /**
  124855. * Creates a new PosterizeBlock
  124856. * @param name defines the block name
  124857. */
  124858. constructor(name: string);
  124859. /**
  124860. * Gets the current class name
  124861. * @returns the class name
  124862. */
  124863. getClassName(): string;
  124864. /**
  124865. * Gets the value input component
  124866. */
  124867. readonly value: NodeMaterialConnectionPoint;
  124868. /**
  124869. * Gets the steps input component
  124870. */
  124871. readonly steps: NodeMaterialConnectionPoint;
  124872. /**
  124873. * Gets the output component
  124874. */
  124875. readonly output: NodeMaterialConnectionPoint;
  124876. protected _buildBlock(state: NodeMaterialBuildState): this;
  124877. }
  124878. }
  124879. declare module BABYLON {
  124880. /**
  124881. * Operations supported by the Wave block
  124882. */
  124883. export enum WaveBlockKind {
  124884. /** SawTooth */
  124885. SawTooth = 0,
  124886. /** Square */
  124887. Square = 1,
  124888. /** Triangle */
  124889. Triangle = 2
  124890. }
  124891. /**
  124892. * Block used to apply wave operation to floats
  124893. */
  124894. export class WaveBlock extends NodeMaterialBlock {
  124895. /**
  124896. * Gets or sets the kibnd of wave to be applied by the block
  124897. */
  124898. kind: WaveBlockKind;
  124899. /**
  124900. * Creates a new WaveBlock
  124901. * @param name defines the block name
  124902. */
  124903. constructor(name: string);
  124904. /**
  124905. * Gets the current class name
  124906. * @returns the class name
  124907. */
  124908. getClassName(): string;
  124909. /**
  124910. * Gets the input component
  124911. */
  124912. readonly input: NodeMaterialConnectionPoint;
  124913. /**
  124914. * Gets the output component
  124915. */
  124916. readonly output: NodeMaterialConnectionPoint;
  124917. protected _buildBlock(state: NodeMaterialBuildState): this;
  124918. serialize(): any;
  124919. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  124920. }
  124921. }
  124922. declare module BABYLON {
  124923. /**
  124924. * Class used to store a color step for the GradientBlock
  124925. */
  124926. export class GradientBlockColorStep {
  124927. /**
  124928. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  124929. */
  124930. step: number;
  124931. /**
  124932. * Gets or sets the color associated with this step
  124933. */
  124934. color: Color3;
  124935. /**
  124936. * Creates a new GradientBlockColorStep
  124937. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  124938. * @param color defines the color associated with this step
  124939. */
  124940. constructor(
  124941. /**
  124942. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  124943. */
  124944. step: number,
  124945. /**
  124946. * Gets or sets the color associated with this step
  124947. */
  124948. color: Color3);
  124949. }
  124950. /**
  124951. * Block used to return a color from a gradient based on an input value between 0 and 1
  124952. */
  124953. export class GradientBlock extends NodeMaterialBlock {
  124954. /**
  124955. * Gets or sets the list of color steps
  124956. */
  124957. colorSteps: GradientBlockColorStep[];
  124958. /**
  124959. * Creates a new GradientBlock
  124960. * @param name defines the block name
  124961. */
  124962. constructor(name: string);
  124963. /**
  124964. * Gets the current class name
  124965. * @returns the class name
  124966. */
  124967. getClassName(): string;
  124968. /**
  124969. * Gets the gradient input component
  124970. */
  124971. readonly gradient: NodeMaterialConnectionPoint;
  124972. /**
  124973. * Gets the output component
  124974. */
  124975. readonly output: NodeMaterialConnectionPoint;
  124976. private _writeColorConstant;
  124977. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  124978. serialize(): any;
  124979. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  124980. protected _dumpPropertiesCode(): string;
  124981. }
  124982. }
  124983. declare module BABYLON {
  124984. /**
  124985. * Block used to normalize lerp between 2 values
  124986. */
  124987. export class NLerpBlock extends NodeMaterialBlock {
  124988. /**
  124989. * Creates a new NLerpBlock
  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 left operand input component
  125000. */
  125001. readonly left: NodeMaterialConnectionPoint;
  125002. /**
  125003. * Gets the right operand input component
  125004. */
  125005. readonly right: NodeMaterialConnectionPoint;
  125006. /**
  125007. * Gets the gradient operand input component
  125008. */
  125009. readonly gradient: NodeMaterialConnectionPoint;
  125010. /**
  125011. * Gets the output component
  125012. */
  125013. readonly output: NodeMaterialConnectionPoint;
  125014. protected _buildBlock(state: NodeMaterialBuildState): this;
  125015. }
  125016. }
  125017. declare module BABYLON {
  125018. /**
  125019. * block used to Generate a Worley Noise 3D Noise Pattern
  125020. */
  125021. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  125022. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  125023. manhattanDistance: boolean;
  125024. /**
  125025. * Creates a new WorleyNoise3DBlock
  125026. * @param name defines the block name
  125027. */
  125028. constructor(name: string);
  125029. /**
  125030. * Gets the current class name
  125031. * @returns the class name
  125032. */
  125033. getClassName(): string;
  125034. /**
  125035. * Gets the seed input component
  125036. */
  125037. readonly seed: NodeMaterialConnectionPoint;
  125038. /**
  125039. * Gets the jitter input component
  125040. */
  125041. readonly jitter: NodeMaterialConnectionPoint;
  125042. /**
  125043. * Gets the output component
  125044. */
  125045. readonly output: NodeMaterialConnectionPoint;
  125046. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  125047. /**
  125048. * Exposes the properties to the UI?
  125049. */
  125050. protected _dumpPropertiesCode(): string;
  125051. /**
  125052. * Exposes the properties to the Seralize?
  125053. */
  125054. serialize(): any;
  125055. /**
  125056. * Exposes the properties to the deseralize?
  125057. */
  125058. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  125059. }
  125060. }
  125061. declare module BABYLON {
  125062. /**
  125063. * block used to Generate a Simplex Perlin 3d Noise Pattern
  125064. */
  125065. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  125066. /**
  125067. * Creates a new SimplexPerlin3DBlock
  125068. * @param name defines the block name
  125069. */
  125070. constructor(name: string);
  125071. /**
  125072. * Gets the current class name
  125073. * @returns the class name
  125074. */
  125075. getClassName(): string;
  125076. /**
  125077. * Gets the seed operand input component
  125078. */
  125079. readonly seed: NodeMaterialConnectionPoint;
  125080. /**
  125081. * Gets the output component
  125082. */
  125083. readonly output: NodeMaterialConnectionPoint;
  125084. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  125085. }
  125086. }
  125087. declare module BABYLON {
  125088. /**
  125089. * Block used to blend normals
  125090. */
  125091. export class NormalBlendBlock extends NodeMaterialBlock {
  125092. /**
  125093. * Creates a new NormalBlendBlock
  125094. * @param name defines the block name
  125095. */
  125096. constructor(name: string);
  125097. /**
  125098. * Gets the current class name
  125099. * @returns the class name
  125100. */
  125101. getClassName(): string;
  125102. /**
  125103. * Gets the first input component
  125104. */
  125105. readonly input0: NodeMaterialConnectionPoint;
  125106. /**
  125107. * Gets the second input component
  125108. */
  125109. readonly input1: NodeMaterialConnectionPoint;
  125110. /**
  125111. * Gets the output component
  125112. */
  125113. readonly output: NodeMaterialConnectionPoint;
  125114. protected _buildBlock(state: NodeMaterialBuildState): this;
  125115. }
  125116. }
  125117. declare module BABYLON {
  125118. /**
  125119. * Block used to rotate a 2d vector by a given angle
  125120. */
  125121. export class Rotate2dBlock extends NodeMaterialBlock {
  125122. /**
  125123. * Creates a new Rotate2dBlock
  125124. * @param name defines the block name
  125125. */
  125126. constructor(name: string);
  125127. /**
  125128. * Gets the current class name
  125129. * @returns the class name
  125130. */
  125131. getClassName(): string;
  125132. /**
  125133. * Gets the input vector
  125134. */
  125135. readonly input: NodeMaterialConnectionPoint;
  125136. /**
  125137. * Gets the input angle
  125138. */
  125139. readonly angle: NodeMaterialConnectionPoint;
  125140. /**
  125141. * Gets the output component
  125142. */
  125143. readonly output: NodeMaterialConnectionPoint;
  125144. autoConfigure(material: NodeMaterial): void;
  125145. protected _buildBlock(state: NodeMaterialBuildState): this;
  125146. }
  125147. }
  125148. declare module BABYLON {
  125149. /**
  125150. * Effect Render Options
  125151. */
  125152. export interface IEffectRendererOptions {
  125153. /**
  125154. * Defines the vertices positions.
  125155. */
  125156. positions?: number[];
  125157. /**
  125158. * Defines the indices.
  125159. */
  125160. indices?: number[];
  125161. }
  125162. /**
  125163. * Helper class to render one or more effects
  125164. */
  125165. export class EffectRenderer {
  125166. private engine;
  125167. private static _DefaultOptions;
  125168. private _vertexBuffers;
  125169. private _indexBuffer;
  125170. private _ringBufferIndex;
  125171. private _ringScreenBuffer;
  125172. private _fullscreenViewport;
  125173. private _getNextFrameBuffer;
  125174. /**
  125175. * Creates an effect renderer
  125176. * @param engine the engine to use for rendering
  125177. * @param options defines the options of the effect renderer
  125178. */
  125179. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  125180. /**
  125181. * Sets the current viewport in normalized coordinates 0-1
  125182. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  125183. */
  125184. setViewport(viewport?: Viewport): void;
  125185. /**
  125186. * Binds the embedded attributes buffer to the effect.
  125187. * @param effect Defines the effect to bind the attributes for
  125188. */
  125189. bindBuffers(effect: Effect): void;
  125190. /**
  125191. * Sets the current effect wrapper to use during draw.
  125192. * The effect needs to be ready before calling this api.
  125193. * This also sets the default full screen position attribute.
  125194. * @param effectWrapper Defines the effect to draw with
  125195. */
  125196. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  125197. /**
  125198. * Draws a full screen quad.
  125199. */
  125200. draw(): void;
  125201. /**
  125202. * renders one or more effects to a specified texture
  125203. * @param effectWrappers list of effects to renderer
  125204. * @param outputTexture texture to draw to, if null it will render to the screen
  125205. */
  125206. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  125207. /**
  125208. * Disposes of the effect renderer
  125209. */
  125210. dispose(): void;
  125211. }
  125212. /**
  125213. * Options to create an EffectWrapper
  125214. */
  125215. interface EffectWrapperCreationOptions {
  125216. /**
  125217. * Engine to use to create the effect
  125218. */
  125219. engine: ThinEngine;
  125220. /**
  125221. * Fragment shader for the effect
  125222. */
  125223. fragmentShader: string;
  125224. /**
  125225. * Vertex shader for the effect
  125226. */
  125227. vertexShader?: string;
  125228. /**
  125229. * Attributes to use in the shader
  125230. */
  125231. attributeNames?: Array<string>;
  125232. /**
  125233. * Uniforms to use in the shader
  125234. */
  125235. uniformNames?: Array<string>;
  125236. /**
  125237. * Texture sampler names to use in the shader
  125238. */
  125239. samplerNames?: Array<string>;
  125240. /**
  125241. * The friendly name of the effect displayed in Spector.
  125242. */
  125243. name?: string;
  125244. }
  125245. /**
  125246. * Wraps an effect to be used for rendering
  125247. */
  125248. export class EffectWrapper {
  125249. /**
  125250. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  125251. */
  125252. onApplyObservable: Observable<{}>;
  125253. /**
  125254. * The underlying effect
  125255. */
  125256. effect: Effect;
  125257. /**
  125258. * Creates an effect to be renderer
  125259. * @param creationOptions options to create the effect
  125260. */
  125261. constructor(creationOptions: EffectWrapperCreationOptions);
  125262. /**
  125263. * Disposes of the effect wrapper
  125264. */
  125265. dispose(): void;
  125266. }
  125267. }
  125268. declare module BABYLON {
  125269. /**
  125270. * Helper class to push actions to a pool of workers.
  125271. */
  125272. export class WorkerPool implements IDisposable {
  125273. private _workerInfos;
  125274. private _pendingActions;
  125275. /**
  125276. * Constructor
  125277. * @param workers Array of workers to use for actions
  125278. */
  125279. constructor(workers: Array<Worker>);
  125280. /**
  125281. * Terminates all workers and clears any pending actions.
  125282. */
  125283. dispose(): void;
  125284. /**
  125285. * Pushes an action to the worker pool. If all the workers are active, the action will be
  125286. * pended until a worker has completed its action.
  125287. * @param action The action to perform. Call onComplete when the action is complete.
  125288. */
  125289. push(action: (worker: Worker, onComplete: () => void) => void): void;
  125290. private _execute;
  125291. }
  125292. }
  125293. declare module BABYLON {
  125294. /**
  125295. * Configuration for Draco compression
  125296. */
  125297. export interface IDracoCompressionConfiguration {
  125298. /**
  125299. * Configuration for the decoder.
  125300. */
  125301. decoder: {
  125302. /**
  125303. * The url to the WebAssembly module.
  125304. */
  125305. wasmUrl?: string;
  125306. /**
  125307. * The url to the WebAssembly binary.
  125308. */
  125309. wasmBinaryUrl?: string;
  125310. /**
  125311. * The url to the fallback JavaScript module.
  125312. */
  125313. fallbackUrl?: string;
  125314. };
  125315. }
  125316. /**
  125317. * Draco compression (https://google.github.io/draco/)
  125318. *
  125319. * This class wraps the Draco module.
  125320. *
  125321. * **Encoder**
  125322. *
  125323. * The encoder is not currently implemented.
  125324. *
  125325. * **Decoder**
  125326. *
  125327. * 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.
  125328. *
  125329. * To update the configuration, use the following code:
  125330. * ```javascript
  125331. * DracoCompression.Configuration = {
  125332. * decoder: {
  125333. * wasmUrl: "<url to the WebAssembly library>",
  125334. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  125335. * fallbackUrl: "<url to the fallback JavaScript library>",
  125336. * }
  125337. * };
  125338. * ```
  125339. *
  125340. * 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.
  125341. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  125342. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  125343. *
  125344. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  125345. * ```javascript
  125346. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  125347. * ```
  125348. *
  125349. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  125350. */
  125351. export class DracoCompression implements IDisposable {
  125352. private _workerPoolPromise?;
  125353. private _decoderModulePromise?;
  125354. /**
  125355. * The configuration. Defaults to the following urls:
  125356. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  125357. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  125358. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  125359. */
  125360. static Configuration: IDracoCompressionConfiguration;
  125361. /**
  125362. * Returns true if the decoder configuration is available.
  125363. */
  125364. static readonly DecoderAvailable: boolean;
  125365. /**
  125366. * Default number of workers to create when creating the draco compression object.
  125367. */
  125368. static DefaultNumWorkers: number;
  125369. private static GetDefaultNumWorkers;
  125370. private static _Default;
  125371. /**
  125372. * Default instance for the draco compression object.
  125373. */
  125374. static readonly Default: DracoCompression;
  125375. /**
  125376. * Constructor
  125377. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  125378. */
  125379. constructor(numWorkers?: number);
  125380. /**
  125381. * Stop all async operations and release resources.
  125382. */
  125383. dispose(): void;
  125384. /**
  125385. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  125386. * @returns a promise that resolves when ready
  125387. */
  125388. whenReadyAsync(): Promise<void>;
  125389. /**
  125390. * Decode Draco compressed mesh data to vertex data.
  125391. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  125392. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  125393. * @returns A promise that resolves with the decoded vertex data
  125394. */
  125395. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  125396. [kind: string]: number;
  125397. }): Promise<VertexData>;
  125398. }
  125399. }
  125400. declare module BABYLON {
  125401. /**
  125402. * Class for building Constructive Solid Geometry
  125403. */
  125404. export class CSG {
  125405. private polygons;
  125406. /**
  125407. * The world matrix
  125408. */
  125409. matrix: Matrix;
  125410. /**
  125411. * Stores the position
  125412. */
  125413. position: Vector3;
  125414. /**
  125415. * Stores the rotation
  125416. */
  125417. rotation: Vector3;
  125418. /**
  125419. * Stores the rotation quaternion
  125420. */
  125421. rotationQuaternion: Nullable<Quaternion>;
  125422. /**
  125423. * Stores the scaling vector
  125424. */
  125425. scaling: Vector3;
  125426. /**
  125427. * Convert the Mesh to CSG
  125428. * @param mesh The Mesh to convert to CSG
  125429. * @returns A new CSG from the Mesh
  125430. */
  125431. static FromMesh(mesh: Mesh): CSG;
  125432. /**
  125433. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  125434. * @param polygons Polygons used to construct a CSG solid
  125435. */
  125436. private static FromPolygons;
  125437. /**
  125438. * Clones, or makes a deep copy, of the CSG
  125439. * @returns A new CSG
  125440. */
  125441. clone(): CSG;
  125442. /**
  125443. * Unions this CSG with another CSG
  125444. * @param csg The CSG to union against this CSG
  125445. * @returns The unioned CSG
  125446. */
  125447. union(csg: CSG): CSG;
  125448. /**
  125449. * Unions this CSG with another CSG in place
  125450. * @param csg The CSG to union against this CSG
  125451. */
  125452. unionInPlace(csg: CSG): void;
  125453. /**
  125454. * Subtracts this CSG with another CSG
  125455. * @param csg The CSG to subtract against this CSG
  125456. * @returns A new CSG
  125457. */
  125458. subtract(csg: CSG): CSG;
  125459. /**
  125460. * Subtracts this CSG with another CSG in place
  125461. * @param csg The CSG to subtact against this CSG
  125462. */
  125463. subtractInPlace(csg: CSG): void;
  125464. /**
  125465. * Intersect this CSG with another CSG
  125466. * @param csg The CSG to intersect against this CSG
  125467. * @returns A new CSG
  125468. */
  125469. intersect(csg: CSG): CSG;
  125470. /**
  125471. * Intersects this CSG with another CSG in place
  125472. * @param csg The CSG to intersect against this CSG
  125473. */
  125474. intersectInPlace(csg: CSG): void;
  125475. /**
  125476. * Return a new CSG solid with solid and empty space switched. This solid is
  125477. * not modified.
  125478. * @returns A new CSG solid with solid and empty space switched
  125479. */
  125480. inverse(): CSG;
  125481. /**
  125482. * Inverses the CSG in place
  125483. */
  125484. inverseInPlace(): void;
  125485. /**
  125486. * This is used to keep meshes transformations so they can be restored
  125487. * when we build back a Babylon Mesh
  125488. * NB : All CSG operations are performed in world coordinates
  125489. * @param csg The CSG to copy the transform attributes from
  125490. * @returns This CSG
  125491. */
  125492. copyTransformAttributes(csg: CSG): CSG;
  125493. /**
  125494. * Build Raw mesh from CSG
  125495. * Coordinates here are in world space
  125496. * @param name The name of the mesh geometry
  125497. * @param scene The Scene
  125498. * @param keepSubMeshes Specifies if the submeshes should be kept
  125499. * @returns A new Mesh
  125500. */
  125501. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  125502. /**
  125503. * Build Mesh from CSG taking material and transforms into account
  125504. * @param name The name of the Mesh
  125505. * @param material The material of the Mesh
  125506. * @param scene The Scene
  125507. * @param keepSubMeshes Specifies if submeshes should be kept
  125508. * @returns The new Mesh
  125509. */
  125510. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  125511. }
  125512. }
  125513. declare module BABYLON {
  125514. /**
  125515. * Class used to create a trail following a mesh
  125516. */
  125517. export class TrailMesh extends Mesh {
  125518. private _generator;
  125519. private _autoStart;
  125520. private _running;
  125521. private _diameter;
  125522. private _length;
  125523. private _sectionPolygonPointsCount;
  125524. private _sectionVectors;
  125525. private _sectionNormalVectors;
  125526. private _beforeRenderObserver;
  125527. /**
  125528. * @constructor
  125529. * @param name The value used by scene.getMeshByName() to do a lookup.
  125530. * @param generator The mesh to generate a trail.
  125531. * @param scene The scene to add this mesh to.
  125532. * @param diameter Diameter of trailing mesh. Default is 1.
  125533. * @param length Length of trailing mesh. Default is 60.
  125534. * @param autoStart Automatically start trailing mesh. Default true.
  125535. */
  125536. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  125537. /**
  125538. * "TrailMesh"
  125539. * @returns "TrailMesh"
  125540. */
  125541. getClassName(): string;
  125542. private _createMesh;
  125543. /**
  125544. * Start trailing mesh.
  125545. */
  125546. start(): void;
  125547. /**
  125548. * Stop trailing mesh.
  125549. */
  125550. stop(): void;
  125551. /**
  125552. * Update trailing mesh geometry.
  125553. */
  125554. update(): void;
  125555. /**
  125556. * Returns a new TrailMesh object.
  125557. * @param name is a string, the name given to the new mesh
  125558. * @param newGenerator use new generator object for cloned trail mesh
  125559. * @returns a new mesh
  125560. */
  125561. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  125562. /**
  125563. * Serializes this trail mesh
  125564. * @param serializationObject object to write serialization to
  125565. */
  125566. serialize(serializationObject: any): void;
  125567. /**
  125568. * Parses a serialized trail mesh
  125569. * @param parsedMesh the serialized mesh
  125570. * @param scene the scene to create the trail mesh in
  125571. * @returns the created trail mesh
  125572. */
  125573. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  125574. }
  125575. }
  125576. declare module BABYLON {
  125577. /**
  125578. * Class containing static functions to help procedurally build meshes
  125579. */
  125580. export class TiledBoxBuilder {
  125581. /**
  125582. * Creates a box mesh
  125583. * 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)
  125584. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  125585. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125586. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125587. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125588. * @param name defines the name of the mesh
  125589. * @param options defines the options used to create the mesh
  125590. * @param scene defines the hosting scene
  125591. * @returns the box mesh
  125592. */
  125593. static CreateTiledBox(name: string, options: {
  125594. pattern?: number;
  125595. width?: number;
  125596. height?: number;
  125597. depth?: number;
  125598. tileSize?: number;
  125599. tileWidth?: number;
  125600. tileHeight?: number;
  125601. alignHorizontal?: number;
  125602. alignVertical?: number;
  125603. faceUV?: Vector4[];
  125604. faceColors?: Color4[];
  125605. sideOrientation?: number;
  125606. updatable?: boolean;
  125607. }, scene?: Nullable<Scene>): Mesh;
  125608. }
  125609. }
  125610. declare module BABYLON {
  125611. /**
  125612. * Class containing static functions to help procedurally build meshes
  125613. */
  125614. export class TorusKnotBuilder {
  125615. /**
  125616. * Creates a torus knot mesh
  125617. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  125618. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  125619. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  125620. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  125621. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125622. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125623. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  125624. * @param name defines the name of the mesh
  125625. * @param options defines the options used to create the mesh
  125626. * @param scene defines the hosting scene
  125627. * @returns the torus knot mesh
  125628. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  125629. */
  125630. static CreateTorusKnot(name: string, options: {
  125631. radius?: number;
  125632. tube?: number;
  125633. radialSegments?: number;
  125634. tubularSegments?: number;
  125635. p?: number;
  125636. q?: number;
  125637. updatable?: boolean;
  125638. sideOrientation?: number;
  125639. frontUVs?: Vector4;
  125640. backUVs?: Vector4;
  125641. }, scene: any): Mesh;
  125642. }
  125643. }
  125644. declare module BABYLON {
  125645. /**
  125646. * Polygon
  125647. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  125648. */
  125649. export class Polygon {
  125650. /**
  125651. * Creates a rectangle
  125652. * @param xmin bottom X coord
  125653. * @param ymin bottom Y coord
  125654. * @param xmax top X coord
  125655. * @param ymax top Y coord
  125656. * @returns points that make the resulting rectation
  125657. */
  125658. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  125659. /**
  125660. * Creates a circle
  125661. * @param radius radius of circle
  125662. * @param cx scale in x
  125663. * @param cy scale in y
  125664. * @param numberOfSides number of sides that make up the circle
  125665. * @returns points that make the resulting circle
  125666. */
  125667. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  125668. /**
  125669. * Creates a polygon from input string
  125670. * @param input Input polygon data
  125671. * @returns the parsed points
  125672. */
  125673. static Parse(input: string): Vector2[];
  125674. /**
  125675. * Starts building a polygon from x and y coordinates
  125676. * @param x x coordinate
  125677. * @param y y coordinate
  125678. * @returns the started path2
  125679. */
  125680. static StartingAt(x: number, y: number): Path2;
  125681. }
  125682. /**
  125683. * Builds a polygon
  125684. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  125685. */
  125686. export class PolygonMeshBuilder {
  125687. private _points;
  125688. private _outlinepoints;
  125689. private _holes;
  125690. private _name;
  125691. private _scene;
  125692. private _epoints;
  125693. private _eholes;
  125694. private _addToepoint;
  125695. /**
  125696. * Babylon reference to the earcut plugin.
  125697. */
  125698. bjsEarcut: any;
  125699. /**
  125700. * Creates a PolygonMeshBuilder
  125701. * @param name name of the builder
  125702. * @param contours Path of the polygon
  125703. * @param scene scene to add to when creating the mesh
  125704. * @param earcutInjection can be used to inject your own earcut reference
  125705. */
  125706. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  125707. /**
  125708. * Adds a whole within the polygon
  125709. * @param hole Array of points defining the hole
  125710. * @returns this
  125711. */
  125712. addHole(hole: Vector2[]): PolygonMeshBuilder;
  125713. /**
  125714. * Creates the polygon
  125715. * @param updatable If the mesh should be updatable
  125716. * @param depth The depth of the mesh created
  125717. * @returns the created mesh
  125718. */
  125719. build(updatable?: boolean, depth?: number): Mesh;
  125720. /**
  125721. * Creates the polygon
  125722. * @param depth The depth of the mesh created
  125723. * @returns the created VertexData
  125724. */
  125725. buildVertexData(depth?: number): VertexData;
  125726. /**
  125727. * Adds a side to the polygon
  125728. * @param positions points that make the polygon
  125729. * @param normals normals of the polygon
  125730. * @param uvs uvs of the polygon
  125731. * @param indices indices of the polygon
  125732. * @param bounds bounds of the polygon
  125733. * @param points points of the polygon
  125734. * @param depth depth of the polygon
  125735. * @param flip flip of the polygon
  125736. */
  125737. private addSide;
  125738. }
  125739. }
  125740. declare module BABYLON {
  125741. /**
  125742. * Class containing static functions to help procedurally build meshes
  125743. */
  125744. export class PolygonBuilder {
  125745. /**
  125746. * Creates a polygon mesh
  125747. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  125748. * * 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
  125749. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  125750. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125751. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  125752. * * Remember you can only change the shape positions, not their number when updating a polygon
  125753. * @param name defines the name of the mesh
  125754. * @param options defines the options used to create the mesh
  125755. * @param scene defines the hosting scene
  125756. * @param earcutInjection can be used to inject your own earcut reference
  125757. * @returns the polygon mesh
  125758. */
  125759. static CreatePolygon(name: string, options: {
  125760. shape: Vector3[];
  125761. holes?: Vector3[][];
  125762. depth?: number;
  125763. faceUV?: Vector4[];
  125764. faceColors?: Color4[];
  125765. updatable?: boolean;
  125766. sideOrientation?: number;
  125767. frontUVs?: Vector4;
  125768. backUVs?: Vector4;
  125769. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  125770. /**
  125771. * Creates an extruded polygon mesh, with depth in the Y direction.
  125772. * * 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)
  125773. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  125774. * @param name defines the name of the mesh
  125775. * @param options defines the options used to create the mesh
  125776. * @param scene defines the hosting scene
  125777. * @param earcutInjection can be used to inject your own earcut reference
  125778. * @returns the polygon mesh
  125779. */
  125780. static ExtrudePolygon(name: string, options: {
  125781. shape: Vector3[];
  125782. holes?: Vector3[][];
  125783. depth?: number;
  125784. faceUV?: Vector4[];
  125785. faceColors?: Color4[];
  125786. updatable?: boolean;
  125787. sideOrientation?: number;
  125788. frontUVs?: Vector4;
  125789. backUVs?: Vector4;
  125790. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  125791. }
  125792. }
  125793. declare module BABYLON {
  125794. /**
  125795. * Class containing static functions to help procedurally build meshes
  125796. */
  125797. export class LatheBuilder {
  125798. /**
  125799. * Creates lathe mesh.
  125800. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  125801. * * 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
  125802. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  125803. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  125804. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  125805. * * 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
  125806. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  125807. * * 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
  125808. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125809. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125810. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  125811. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125812. * @param name defines the name of the mesh
  125813. * @param options defines the options used to create the mesh
  125814. * @param scene defines the hosting scene
  125815. * @returns the lathe mesh
  125816. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  125817. */
  125818. static CreateLathe(name: string, options: {
  125819. shape: Vector3[];
  125820. radius?: number;
  125821. tessellation?: number;
  125822. clip?: number;
  125823. arc?: number;
  125824. closed?: boolean;
  125825. updatable?: boolean;
  125826. sideOrientation?: number;
  125827. frontUVs?: Vector4;
  125828. backUVs?: Vector4;
  125829. cap?: number;
  125830. invertUV?: boolean;
  125831. }, scene?: Nullable<Scene>): Mesh;
  125832. }
  125833. }
  125834. declare module BABYLON {
  125835. /**
  125836. * Class containing static functions to help procedurally build meshes
  125837. */
  125838. export class TiledPlaneBuilder {
  125839. /**
  125840. * Creates a tiled plane mesh
  125841. * * The parameter `pattern` will, depending on value, do nothing or
  125842. * * * flip (reflect about central vertical) alternate tiles across and up
  125843. * * * flip every tile on alternate rows
  125844. * * * rotate (180 degs) alternate tiles across and up
  125845. * * * rotate every tile on alternate rows
  125846. * * * flip and rotate alternate tiles across and up
  125847. * * * flip and rotate every tile on alternate rows
  125848. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  125849. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  125850. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125851. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  125852. * * 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)
  125853. * * 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)
  125854. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  125855. * @param name defines the name of the mesh
  125856. * @param options defines the options used to create the mesh
  125857. * @param scene defines the hosting scene
  125858. * @returns the box mesh
  125859. */
  125860. static CreateTiledPlane(name: string, options: {
  125861. pattern?: number;
  125862. tileSize?: number;
  125863. tileWidth?: number;
  125864. tileHeight?: number;
  125865. size?: number;
  125866. width?: number;
  125867. height?: number;
  125868. alignHorizontal?: number;
  125869. alignVertical?: number;
  125870. sideOrientation?: number;
  125871. frontUVs?: Vector4;
  125872. backUVs?: Vector4;
  125873. updatable?: boolean;
  125874. }, scene?: Nullable<Scene>): Mesh;
  125875. }
  125876. }
  125877. declare module BABYLON {
  125878. /**
  125879. * Class containing static functions to help procedurally build meshes
  125880. */
  125881. export class TubeBuilder {
  125882. /**
  125883. * Creates a tube mesh.
  125884. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  125885. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  125886. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  125887. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  125888. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  125889. * * 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)
  125890. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  125891. * * 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
  125892. * * 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
  125893. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125894. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125895. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  125896. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125897. * @param name defines the name of the mesh
  125898. * @param options defines the options used to create the mesh
  125899. * @param scene defines the hosting scene
  125900. * @returns the tube mesh
  125901. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  125902. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  125903. */
  125904. static CreateTube(name: string, options: {
  125905. path: Vector3[];
  125906. radius?: number;
  125907. tessellation?: number;
  125908. radiusFunction?: {
  125909. (i: number, distance: number): number;
  125910. };
  125911. cap?: number;
  125912. arc?: number;
  125913. updatable?: boolean;
  125914. sideOrientation?: number;
  125915. frontUVs?: Vector4;
  125916. backUVs?: Vector4;
  125917. instance?: Mesh;
  125918. invertUV?: boolean;
  125919. }, scene?: Nullable<Scene>): Mesh;
  125920. }
  125921. }
  125922. declare module BABYLON {
  125923. /**
  125924. * Class containing static functions to help procedurally build meshes
  125925. */
  125926. export class IcoSphereBuilder {
  125927. /**
  125928. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  125929. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  125930. * * 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`)
  125931. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  125932. * * 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
  125933. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125934. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125935. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125936. * @param name defines the name of the mesh
  125937. * @param options defines the options used to create the mesh
  125938. * @param scene defines the hosting scene
  125939. * @returns the icosahedron mesh
  125940. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  125941. */
  125942. static CreateIcoSphere(name: string, options: {
  125943. radius?: number;
  125944. radiusX?: number;
  125945. radiusY?: number;
  125946. radiusZ?: number;
  125947. flat?: boolean;
  125948. subdivisions?: number;
  125949. sideOrientation?: number;
  125950. frontUVs?: Vector4;
  125951. backUVs?: Vector4;
  125952. updatable?: boolean;
  125953. }, scene?: Nullable<Scene>): Mesh;
  125954. }
  125955. }
  125956. declare module BABYLON {
  125957. /**
  125958. * Class containing static functions to help procedurally build meshes
  125959. */
  125960. export class DecalBuilder {
  125961. /**
  125962. * Creates a decal mesh.
  125963. * 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
  125964. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  125965. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  125966. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  125967. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  125968. * @param name defines the name of the mesh
  125969. * @param sourceMesh defines the mesh where the decal must be applied
  125970. * @param options defines the options used to create the mesh
  125971. * @param scene defines the hosting scene
  125972. * @returns the decal mesh
  125973. * @see https://doc.babylonjs.com/how_to/decals
  125974. */
  125975. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  125976. position?: Vector3;
  125977. normal?: Vector3;
  125978. size?: Vector3;
  125979. angle?: number;
  125980. }): Mesh;
  125981. }
  125982. }
  125983. declare module BABYLON {
  125984. /**
  125985. * Class containing static functions to help procedurally build meshes
  125986. */
  125987. export class MeshBuilder {
  125988. /**
  125989. * Creates a box mesh
  125990. * * The parameter `size` sets the size (float) of each box side (default 1)
  125991. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  125992. * * 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)
  125993. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  125994. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125995. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125996. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125997. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  125998. * @param name defines the name of the mesh
  125999. * @param options defines the options used to create the mesh
  126000. * @param scene defines the hosting scene
  126001. * @returns the box mesh
  126002. */
  126003. static CreateBox(name: string, options: {
  126004. size?: number;
  126005. width?: number;
  126006. height?: number;
  126007. depth?: number;
  126008. faceUV?: Vector4[];
  126009. faceColors?: Color4[];
  126010. sideOrientation?: number;
  126011. frontUVs?: Vector4;
  126012. backUVs?: Vector4;
  126013. updatable?: boolean;
  126014. }, scene?: Nullable<Scene>): Mesh;
  126015. /**
  126016. * Creates a tiled box mesh
  126017. * * faceTiles sets the pattern, tile size and number of tiles for a face
  126018. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  126019. * @param name defines the name of the mesh
  126020. * @param options defines the options used to create the mesh
  126021. * @param scene defines the hosting scene
  126022. * @returns the tiled box mesh
  126023. */
  126024. static CreateTiledBox(name: string, options: {
  126025. pattern?: number;
  126026. size?: number;
  126027. width?: number;
  126028. height?: number;
  126029. depth: number;
  126030. tileSize?: number;
  126031. tileWidth?: number;
  126032. tileHeight?: number;
  126033. faceUV?: Vector4[];
  126034. faceColors?: Color4[];
  126035. alignHorizontal?: number;
  126036. alignVertical?: number;
  126037. sideOrientation?: number;
  126038. updatable?: boolean;
  126039. }, scene?: Nullable<Scene>): Mesh;
  126040. /**
  126041. * Creates a sphere mesh
  126042. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  126043. * * 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`)
  126044. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  126045. * * 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
  126046. * * 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)
  126047. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  126048. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  126049. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  126050. * @param name defines the name of the mesh
  126051. * @param options defines the options used to create the mesh
  126052. * @param scene defines the hosting scene
  126053. * @returns the sphere mesh
  126054. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  126055. */
  126056. static CreateSphere(name: string, options: {
  126057. segments?: number;
  126058. diameter?: number;
  126059. diameterX?: number;
  126060. diameterY?: number;
  126061. diameterZ?: number;
  126062. arc?: number;
  126063. slice?: number;
  126064. sideOrientation?: number;
  126065. frontUVs?: Vector4;
  126066. backUVs?: Vector4;
  126067. updatable?: boolean;
  126068. }, scene?: Nullable<Scene>): Mesh;
  126069. /**
  126070. * Creates a plane polygonal mesh. By default, this is a disc
  126071. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  126072. * * 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
  126073. * * 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
  126074. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  126075. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  126076. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  126077. * @param name defines the name of the mesh
  126078. * @param options defines the options used to create the mesh
  126079. * @param scene defines the hosting scene
  126080. * @returns the plane polygonal mesh
  126081. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  126082. */
  126083. static CreateDisc(name: string, options: {
  126084. radius?: number;
  126085. tessellation?: number;
  126086. arc?: number;
  126087. updatable?: boolean;
  126088. sideOrientation?: number;
  126089. frontUVs?: Vector4;
  126090. backUVs?: Vector4;
  126091. }, scene?: Nullable<Scene>): Mesh;
  126092. /**
  126093. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  126094. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  126095. * * 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`)
  126096. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  126097. * * 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
  126098. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  126099. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  126100. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  126101. * @param name defines the name of the mesh
  126102. * @param options defines the options used to create the mesh
  126103. * @param scene defines the hosting scene
  126104. * @returns the icosahedron mesh
  126105. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  126106. */
  126107. static CreateIcoSphere(name: string, options: {
  126108. radius?: number;
  126109. radiusX?: number;
  126110. radiusY?: number;
  126111. radiusZ?: number;
  126112. flat?: boolean;
  126113. subdivisions?: number;
  126114. sideOrientation?: number;
  126115. frontUVs?: Vector4;
  126116. backUVs?: Vector4;
  126117. updatable?: boolean;
  126118. }, scene?: Nullable<Scene>): Mesh;
  126119. /**
  126120. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  126121. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  126122. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  126123. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  126124. * * 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
  126125. * * 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
  126126. * * 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
  126127. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  126128. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  126129. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  126130. * * 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
  126131. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  126132. * * 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
  126133. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  126134. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  126135. * @param name defines the name of the mesh
  126136. * @param options defines the options used to create the mesh
  126137. * @param scene defines the hosting scene
  126138. * @returns the ribbon mesh
  126139. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  126140. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  126141. */
  126142. static CreateRibbon(name: string, options: {
  126143. pathArray: Vector3[][];
  126144. closeArray?: boolean;
  126145. closePath?: boolean;
  126146. offset?: number;
  126147. updatable?: boolean;
  126148. sideOrientation?: number;
  126149. frontUVs?: Vector4;
  126150. backUVs?: Vector4;
  126151. instance?: Mesh;
  126152. invertUV?: boolean;
  126153. uvs?: Vector2[];
  126154. colors?: Color4[];
  126155. }, scene?: Nullable<Scene>): Mesh;
  126156. /**
  126157. * Creates a cylinder or a cone mesh
  126158. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  126159. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  126160. * * 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.
  126161. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  126162. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  126163. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  126164. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  126165. * * 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).
  126166. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  126167. * * 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).
  126168. * * 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
  126169. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  126170. * * 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
  126171. * * 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.
  126172. * * If `enclose` is false, a ring surface is one element.
  126173. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  126174. * * 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
  126175. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  126176. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  126177. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  126178. * @param name defines the name of the mesh
  126179. * @param options defines the options used to create the mesh
  126180. * @param scene defines the hosting scene
  126181. * @returns the cylinder mesh
  126182. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  126183. */
  126184. static CreateCylinder(name: string, options: {
  126185. height?: number;
  126186. diameterTop?: number;
  126187. diameterBottom?: number;
  126188. diameter?: number;
  126189. tessellation?: number;
  126190. subdivisions?: number;
  126191. arc?: number;
  126192. faceColors?: Color4[];
  126193. faceUV?: Vector4[];
  126194. updatable?: boolean;
  126195. hasRings?: boolean;
  126196. enclose?: boolean;
  126197. cap?: number;
  126198. sideOrientation?: number;
  126199. frontUVs?: Vector4;
  126200. backUVs?: Vector4;
  126201. }, scene?: Nullable<Scene>): Mesh;
  126202. /**
  126203. * Creates a torus mesh
  126204. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  126205. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  126206. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  126207. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  126208. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  126209. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  126210. * @param name defines the name of the mesh
  126211. * @param options defines the options used to create the mesh
  126212. * @param scene defines the hosting scene
  126213. * @returns the torus mesh
  126214. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  126215. */
  126216. static CreateTorus(name: string, options: {
  126217. diameter?: number;
  126218. thickness?: number;
  126219. tessellation?: number;
  126220. updatable?: boolean;
  126221. sideOrientation?: number;
  126222. frontUVs?: Vector4;
  126223. backUVs?: Vector4;
  126224. }, scene?: Nullable<Scene>): Mesh;
  126225. /**
  126226. * Creates a torus knot mesh
  126227. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  126228. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  126229. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  126230. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  126231. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  126232. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  126233. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  126234. * @param name defines the name of the mesh
  126235. * @param options defines the options used to create the mesh
  126236. * @param scene defines the hosting scene
  126237. * @returns the torus knot mesh
  126238. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  126239. */
  126240. static CreateTorusKnot(name: string, options: {
  126241. radius?: number;
  126242. tube?: number;
  126243. radialSegments?: number;
  126244. tubularSegments?: number;
  126245. p?: number;
  126246. q?: number;
  126247. updatable?: boolean;
  126248. sideOrientation?: number;
  126249. frontUVs?: Vector4;
  126250. backUVs?: Vector4;
  126251. }, scene?: Nullable<Scene>): Mesh;
  126252. /**
  126253. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  126254. * * 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
  126255. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  126256. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  126257. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  126258. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  126259. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  126260. * * 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
  126261. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  126262. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  126263. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  126264. * @param name defines the name of the new line system
  126265. * @param options defines the options used to create the line system
  126266. * @param scene defines the hosting scene
  126267. * @returns a new line system mesh
  126268. */
  126269. static CreateLineSystem(name: string, options: {
  126270. lines: Vector3[][];
  126271. updatable?: boolean;
  126272. instance?: Nullable<LinesMesh>;
  126273. colors?: Nullable<Color4[][]>;
  126274. useVertexAlpha?: boolean;
  126275. }, scene: Nullable<Scene>): LinesMesh;
  126276. /**
  126277. * Creates a line mesh
  126278. * 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
  126279. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  126280. * * The parameter `points` is an array successive Vector3
  126281. * * 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
  126282. * * The optional parameter `colors` is an array of successive Color4, one per line point
  126283. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  126284. * * When updating an instance, remember that only point positions can change, not the number of points
  126285. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  126286. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  126287. * @param name defines the name of the new line system
  126288. * @param options defines the options used to create the line system
  126289. * @param scene defines the hosting scene
  126290. * @returns a new line mesh
  126291. */
  126292. static CreateLines(name: string, options: {
  126293. points: Vector3[];
  126294. updatable?: boolean;
  126295. instance?: Nullable<LinesMesh>;
  126296. colors?: Color4[];
  126297. useVertexAlpha?: boolean;
  126298. }, scene?: Nullable<Scene>): LinesMesh;
  126299. /**
  126300. * Creates a dashed line mesh
  126301. * * 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
  126302. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  126303. * * The parameter `points` is an array successive Vector3
  126304. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  126305. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  126306. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  126307. * * 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
  126308. * * When updating an instance, remember that only point positions can change, not the number of points
  126309. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  126310. * @param name defines the name of the mesh
  126311. * @param options defines the options used to create the mesh
  126312. * @param scene defines the hosting scene
  126313. * @returns the dashed line mesh
  126314. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  126315. */
  126316. static CreateDashedLines(name: string, options: {
  126317. points: Vector3[];
  126318. dashSize?: number;
  126319. gapSize?: number;
  126320. dashNb?: number;
  126321. updatable?: boolean;
  126322. instance?: LinesMesh;
  126323. }, scene?: Nullable<Scene>): LinesMesh;
  126324. /**
  126325. * 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.
  126326. * * 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.
  126327. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  126328. * * 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.
  126329. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  126330. * * 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
  126331. * * 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
  126332. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  126333. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  126334. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  126335. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  126336. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  126337. * @param name defines the name of the mesh
  126338. * @param options defines the options used to create the mesh
  126339. * @param scene defines the hosting scene
  126340. * @returns the extruded shape mesh
  126341. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  126342. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  126343. */
  126344. static ExtrudeShape(name: string, options: {
  126345. shape: Vector3[];
  126346. path: Vector3[];
  126347. scale?: number;
  126348. rotation?: number;
  126349. cap?: number;
  126350. updatable?: boolean;
  126351. sideOrientation?: number;
  126352. frontUVs?: Vector4;
  126353. backUVs?: Vector4;
  126354. instance?: Mesh;
  126355. invertUV?: boolean;
  126356. }, scene?: Nullable<Scene>): Mesh;
  126357. /**
  126358. * Creates an custom extruded shape mesh.
  126359. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  126360. * * 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.
  126361. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  126362. * * 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
  126363. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  126364. * * 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
  126365. * * It must returns a float value that will be the scale value applied to the shape on each path point
  126366. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  126367. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  126368. * * 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
  126369. * * 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
  126370. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  126371. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  126372. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  126373. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  126374. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  126375. * @param name defines the name of the mesh
  126376. * @param options defines the options used to create the mesh
  126377. * @param scene defines the hosting scene
  126378. * @returns the custom extruded shape mesh
  126379. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  126380. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  126381. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  126382. */
  126383. static ExtrudeShapeCustom(name: string, options: {
  126384. shape: Vector3[];
  126385. path: Vector3[];
  126386. scaleFunction?: any;
  126387. rotationFunction?: any;
  126388. ribbonCloseArray?: boolean;
  126389. ribbonClosePath?: boolean;
  126390. cap?: number;
  126391. updatable?: boolean;
  126392. sideOrientation?: number;
  126393. frontUVs?: Vector4;
  126394. backUVs?: Vector4;
  126395. instance?: Mesh;
  126396. invertUV?: boolean;
  126397. }, scene?: Nullable<Scene>): Mesh;
  126398. /**
  126399. * Creates lathe mesh.
  126400. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  126401. * * 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
  126402. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  126403. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  126404. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  126405. * * 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
  126406. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  126407. * * 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
  126408. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  126409. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  126410. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  126411. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  126412. * @param name defines the name of the mesh
  126413. * @param options defines the options used to create the mesh
  126414. * @param scene defines the hosting scene
  126415. * @returns the lathe mesh
  126416. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  126417. */
  126418. static CreateLathe(name: string, options: {
  126419. shape: Vector3[];
  126420. radius?: number;
  126421. tessellation?: number;
  126422. clip?: number;
  126423. arc?: number;
  126424. closed?: boolean;
  126425. updatable?: boolean;
  126426. sideOrientation?: number;
  126427. frontUVs?: Vector4;
  126428. backUVs?: Vector4;
  126429. cap?: number;
  126430. invertUV?: boolean;
  126431. }, scene?: Nullable<Scene>): Mesh;
  126432. /**
  126433. * Creates a tiled plane mesh
  126434. * * You can set a limited pattern arrangement with the tiles
  126435. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  126436. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  126437. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  126438. * @param name defines the name of the mesh
  126439. * @param options defines the options used to create the mesh
  126440. * @param scene defines the hosting scene
  126441. * @returns the plane mesh
  126442. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  126443. */
  126444. static CreateTiledPlane(name: string, options: {
  126445. pattern?: number;
  126446. tileSize?: number;
  126447. tileWidth?: number;
  126448. tileHeight?: number;
  126449. size?: number;
  126450. width?: number;
  126451. height?: number;
  126452. alignHorizontal?: number;
  126453. alignVertical?: number;
  126454. sideOrientation?: number;
  126455. frontUVs?: Vector4;
  126456. backUVs?: Vector4;
  126457. updatable?: boolean;
  126458. }, scene?: Nullable<Scene>): Mesh;
  126459. /**
  126460. * Creates a plane mesh
  126461. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  126462. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  126463. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  126464. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  126465. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  126466. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  126467. * @param name defines the name of the mesh
  126468. * @param options defines the options used to create the mesh
  126469. * @param scene defines the hosting scene
  126470. * @returns the plane mesh
  126471. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  126472. */
  126473. static CreatePlane(name: string, options: {
  126474. size?: number;
  126475. width?: number;
  126476. height?: number;
  126477. sideOrientation?: number;
  126478. frontUVs?: Vector4;
  126479. backUVs?: Vector4;
  126480. updatable?: boolean;
  126481. sourcePlane?: Plane;
  126482. }, scene?: Nullable<Scene>): Mesh;
  126483. /**
  126484. * Creates a ground mesh
  126485. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  126486. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  126487. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  126488. * @param name defines the name of the mesh
  126489. * @param options defines the options used to create the mesh
  126490. * @param scene defines the hosting scene
  126491. * @returns the ground mesh
  126492. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  126493. */
  126494. static CreateGround(name: string, options: {
  126495. width?: number;
  126496. height?: number;
  126497. subdivisions?: number;
  126498. subdivisionsX?: number;
  126499. subdivisionsY?: number;
  126500. updatable?: boolean;
  126501. }, scene?: Nullable<Scene>): Mesh;
  126502. /**
  126503. * Creates a tiled ground mesh
  126504. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  126505. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  126506. * * 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
  126507. * * 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
  126508. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  126509. * @param name defines the name of the mesh
  126510. * @param options defines the options used to create the mesh
  126511. * @param scene defines the hosting scene
  126512. * @returns the tiled ground mesh
  126513. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  126514. */
  126515. static CreateTiledGround(name: string, options: {
  126516. xmin: number;
  126517. zmin: number;
  126518. xmax: number;
  126519. zmax: number;
  126520. subdivisions?: {
  126521. w: number;
  126522. h: number;
  126523. };
  126524. precision?: {
  126525. w: number;
  126526. h: number;
  126527. };
  126528. updatable?: boolean;
  126529. }, scene?: Nullable<Scene>): Mesh;
  126530. /**
  126531. * Creates a ground mesh from a height map
  126532. * * The parameter `url` sets the URL of the height map image resource.
  126533. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  126534. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  126535. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  126536. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  126537. * * 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.
  126538. * * 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).
  126539. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  126540. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  126541. * @param name defines the name of the mesh
  126542. * @param url defines the url to the height map
  126543. * @param options defines the options used to create the mesh
  126544. * @param scene defines the hosting scene
  126545. * @returns the ground mesh
  126546. * @see https://doc.babylonjs.com/babylon101/height_map
  126547. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  126548. */
  126549. static CreateGroundFromHeightMap(name: string, url: string, options: {
  126550. width?: number;
  126551. height?: number;
  126552. subdivisions?: number;
  126553. minHeight?: number;
  126554. maxHeight?: number;
  126555. colorFilter?: Color3;
  126556. alphaFilter?: number;
  126557. updatable?: boolean;
  126558. onReady?: (mesh: GroundMesh) => void;
  126559. }, scene?: Nullable<Scene>): GroundMesh;
  126560. /**
  126561. * Creates a polygon mesh
  126562. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  126563. * * 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
  126564. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  126565. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  126566. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  126567. * * Remember you can only change the shape positions, not their number when updating a polygon
  126568. * @param name defines the name of the mesh
  126569. * @param options defines the options used to create the mesh
  126570. * @param scene defines the hosting scene
  126571. * @param earcutInjection can be used to inject your own earcut reference
  126572. * @returns the polygon mesh
  126573. */
  126574. static CreatePolygon(name: string, options: {
  126575. shape: Vector3[];
  126576. holes?: Vector3[][];
  126577. depth?: number;
  126578. faceUV?: Vector4[];
  126579. faceColors?: Color4[];
  126580. updatable?: boolean;
  126581. sideOrientation?: number;
  126582. frontUVs?: Vector4;
  126583. backUVs?: Vector4;
  126584. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  126585. /**
  126586. * Creates an extruded polygon mesh, with depth in the Y direction.
  126587. * * 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)
  126588. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  126589. * @param name defines the name of the mesh
  126590. * @param options defines the options used to create the mesh
  126591. * @param scene defines the hosting scene
  126592. * @param earcutInjection can be used to inject your own earcut reference
  126593. * @returns the polygon mesh
  126594. */
  126595. static ExtrudePolygon(name: string, options: {
  126596. shape: Vector3[];
  126597. holes?: Vector3[][];
  126598. depth?: number;
  126599. faceUV?: Vector4[];
  126600. faceColors?: Color4[];
  126601. updatable?: boolean;
  126602. sideOrientation?: number;
  126603. frontUVs?: Vector4;
  126604. backUVs?: Vector4;
  126605. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  126606. /**
  126607. * Creates a tube mesh.
  126608. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  126609. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  126610. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  126611. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  126612. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  126613. * * 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)
  126614. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  126615. * * 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
  126616. * * 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
  126617. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  126618. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  126619. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  126620. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  126621. * @param name defines the name of the mesh
  126622. * @param options defines the options used to create the mesh
  126623. * @param scene defines the hosting scene
  126624. * @returns the tube mesh
  126625. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  126626. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  126627. */
  126628. static CreateTube(name: string, options: {
  126629. path: Vector3[];
  126630. radius?: number;
  126631. tessellation?: number;
  126632. radiusFunction?: {
  126633. (i: number, distance: number): number;
  126634. };
  126635. cap?: number;
  126636. arc?: number;
  126637. updatable?: boolean;
  126638. sideOrientation?: number;
  126639. frontUVs?: Vector4;
  126640. backUVs?: Vector4;
  126641. instance?: Mesh;
  126642. invertUV?: boolean;
  126643. }, scene?: Nullable<Scene>): Mesh;
  126644. /**
  126645. * Creates a polyhedron mesh
  126646. * * 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
  126647. * * The parameter `size` (positive float, default 1) sets the polygon size
  126648. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  126649. * * 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`
  126650. * * 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
  126651. * * 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)`)
  126652. * * 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
  126653. * * 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
  126654. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  126655. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  126656. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  126657. * @param name defines the name of the mesh
  126658. * @param options defines the options used to create the mesh
  126659. * @param scene defines the hosting scene
  126660. * @returns the polyhedron mesh
  126661. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  126662. */
  126663. static CreatePolyhedron(name: string, options: {
  126664. type?: number;
  126665. size?: number;
  126666. sizeX?: number;
  126667. sizeY?: number;
  126668. sizeZ?: number;
  126669. custom?: any;
  126670. faceUV?: Vector4[];
  126671. faceColors?: Color4[];
  126672. flat?: boolean;
  126673. updatable?: boolean;
  126674. sideOrientation?: number;
  126675. frontUVs?: Vector4;
  126676. backUVs?: Vector4;
  126677. }, scene?: Nullable<Scene>): Mesh;
  126678. /**
  126679. * Creates a decal mesh.
  126680. * 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
  126681. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  126682. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  126683. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  126684. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  126685. * @param name defines the name of the mesh
  126686. * @param sourceMesh defines the mesh where the decal must be applied
  126687. * @param options defines the options used to create the mesh
  126688. * @param scene defines the hosting scene
  126689. * @returns the decal mesh
  126690. * @see https://doc.babylonjs.com/how_to/decals
  126691. */
  126692. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  126693. position?: Vector3;
  126694. normal?: Vector3;
  126695. size?: Vector3;
  126696. angle?: number;
  126697. }): Mesh;
  126698. }
  126699. }
  126700. declare module BABYLON {
  126701. /**
  126702. * A simplifier interface for future simplification implementations
  126703. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  126704. */
  126705. export interface ISimplifier {
  126706. /**
  126707. * Simplification of a given mesh according to the given settings.
  126708. * Since this requires computation, it is assumed that the function runs async.
  126709. * @param settings The settings of the simplification, including quality and distance
  126710. * @param successCallback A callback that will be called after the mesh was simplified.
  126711. * @param errorCallback in case of an error, this callback will be called. optional.
  126712. */
  126713. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  126714. }
  126715. /**
  126716. * Expected simplification settings.
  126717. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  126718. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  126719. */
  126720. export interface ISimplificationSettings {
  126721. /**
  126722. * Gets or sets the expected quality
  126723. */
  126724. quality: number;
  126725. /**
  126726. * Gets or sets the distance when this optimized version should be used
  126727. */
  126728. distance: number;
  126729. /**
  126730. * Gets an already optimized mesh
  126731. */
  126732. optimizeMesh?: boolean;
  126733. }
  126734. /**
  126735. * Class used to specify simplification options
  126736. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  126737. */
  126738. export class SimplificationSettings implements ISimplificationSettings {
  126739. /** expected quality */
  126740. quality: number;
  126741. /** distance when this optimized version should be used */
  126742. distance: number;
  126743. /** already optimized mesh */
  126744. optimizeMesh?: boolean | undefined;
  126745. /**
  126746. * Creates a SimplificationSettings
  126747. * @param quality expected quality
  126748. * @param distance distance when this optimized version should be used
  126749. * @param optimizeMesh already optimized mesh
  126750. */
  126751. constructor(
  126752. /** expected quality */
  126753. quality: number,
  126754. /** distance when this optimized version should be used */
  126755. distance: number,
  126756. /** already optimized mesh */
  126757. optimizeMesh?: boolean | undefined);
  126758. }
  126759. /**
  126760. * Interface used to define a simplification task
  126761. */
  126762. export interface ISimplificationTask {
  126763. /**
  126764. * Array of settings
  126765. */
  126766. settings: Array<ISimplificationSettings>;
  126767. /**
  126768. * Simplification type
  126769. */
  126770. simplificationType: SimplificationType;
  126771. /**
  126772. * Mesh to simplify
  126773. */
  126774. mesh: Mesh;
  126775. /**
  126776. * Callback called on success
  126777. */
  126778. successCallback?: () => void;
  126779. /**
  126780. * Defines if parallel processing can be used
  126781. */
  126782. parallelProcessing: boolean;
  126783. }
  126784. /**
  126785. * Queue used to order the simplification tasks
  126786. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  126787. */
  126788. export class SimplificationQueue {
  126789. private _simplificationArray;
  126790. /**
  126791. * Gets a boolean indicating that the process is still running
  126792. */
  126793. running: boolean;
  126794. /**
  126795. * Creates a new queue
  126796. */
  126797. constructor();
  126798. /**
  126799. * Adds a new simplification task
  126800. * @param task defines a task to add
  126801. */
  126802. addTask(task: ISimplificationTask): void;
  126803. /**
  126804. * Execute next task
  126805. */
  126806. executeNext(): void;
  126807. /**
  126808. * Execute a simplification task
  126809. * @param task defines the task to run
  126810. */
  126811. runSimplification(task: ISimplificationTask): void;
  126812. private getSimplifier;
  126813. }
  126814. /**
  126815. * The implemented types of simplification
  126816. * At the moment only Quadratic Error Decimation is implemented
  126817. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  126818. */
  126819. export enum SimplificationType {
  126820. /** Quadratic error decimation */
  126821. QUADRATIC = 0
  126822. }
  126823. }
  126824. declare module BABYLON {
  126825. interface Scene {
  126826. /** @hidden (Backing field) */
  126827. _simplificationQueue: SimplificationQueue;
  126828. /**
  126829. * Gets or sets the simplification queue attached to the scene
  126830. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  126831. */
  126832. simplificationQueue: SimplificationQueue;
  126833. }
  126834. interface Mesh {
  126835. /**
  126836. * Simplify the mesh according to the given array of settings.
  126837. * Function will return immediately and will simplify async
  126838. * @param settings a collection of simplification settings
  126839. * @param parallelProcessing should all levels calculate parallel or one after the other
  126840. * @param simplificationType the type of simplification to run
  126841. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  126842. * @returns the current mesh
  126843. */
  126844. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  126845. }
  126846. /**
  126847. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  126848. * created in a scene
  126849. */
  126850. export class SimplicationQueueSceneComponent implements ISceneComponent {
  126851. /**
  126852. * The component name helpfull to identify the component in the list of scene components.
  126853. */
  126854. readonly name: string;
  126855. /**
  126856. * The scene the component belongs to.
  126857. */
  126858. scene: Scene;
  126859. /**
  126860. * Creates a new instance of the component for the given scene
  126861. * @param scene Defines the scene to register the component in
  126862. */
  126863. constructor(scene: Scene);
  126864. /**
  126865. * Registers the component in a given scene
  126866. */
  126867. register(): void;
  126868. /**
  126869. * Rebuilds the elements related to this component in case of
  126870. * context lost for instance.
  126871. */
  126872. rebuild(): void;
  126873. /**
  126874. * Disposes the component and the associated ressources
  126875. */
  126876. dispose(): void;
  126877. private _beforeCameraUpdate;
  126878. }
  126879. }
  126880. declare module BABYLON {
  126881. /**
  126882. * Navigation plugin interface to add navigation constrained by a navigation mesh
  126883. */
  126884. export interface INavigationEnginePlugin {
  126885. /**
  126886. * plugin name
  126887. */
  126888. name: string;
  126889. /**
  126890. * Creates a navigation mesh
  126891. * @param meshes array of all the geometry used to compute the navigatio mesh
  126892. * @param parameters bunch of parameters used to filter geometry
  126893. */
  126894. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  126895. /**
  126896. * Create a navigation mesh debug mesh
  126897. * @param scene is where the mesh will be added
  126898. * @returns debug display mesh
  126899. */
  126900. createDebugNavMesh(scene: Scene): Mesh;
  126901. /**
  126902. * Get a navigation mesh constrained position, closest to the parameter position
  126903. * @param position world position
  126904. * @returns the closest point to position constrained by the navigation mesh
  126905. */
  126906. getClosestPoint(position: Vector3): Vector3;
  126907. /**
  126908. * Get a navigation mesh constrained position, within a particular radius
  126909. * @param position world position
  126910. * @param maxRadius the maximum distance to the constrained world position
  126911. * @returns the closest point to position constrained by the navigation mesh
  126912. */
  126913. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  126914. /**
  126915. * Compute the final position from a segment made of destination-position
  126916. * @param position world position
  126917. * @param destination world position
  126918. * @returns the resulting point along the navmesh
  126919. */
  126920. moveAlong(position: Vector3, destination: Vector3): Vector3;
  126921. /**
  126922. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  126923. * @param start world position
  126924. * @param end world position
  126925. * @returns array containing world position composing the path
  126926. */
  126927. computePath(start: Vector3, end: Vector3): Vector3[];
  126928. /**
  126929. * If this plugin is supported
  126930. * @returns true if plugin is supported
  126931. */
  126932. isSupported(): boolean;
  126933. /**
  126934. * Create a new Crowd so you can add agents
  126935. * @param maxAgents the maximum agent count in the crowd
  126936. * @param maxAgentRadius the maximum radius an agent can have
  126937. * @param scene to attach the crowd to
  126938. * @returns the crowd you can add agents to
  126939. */
  126940. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  126941. /**
  126942. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  126943. * The queries will try to find a solution within those bounds
  126944. * default is (1,1,1)
  126945. * @param extent x,y,z value that define the extent around the queries point of reference
  126946. */
  126947. setDefaultQueryExtent(extent: Vector3): void;
  126948. /**
  126949. * Get the Bounding box extent specified by setDefaultQueryExtent
  126950. * @returns the box extent values
  126951. */
  126952. getDefaultQueryExtent(): Vector3;
  126953. /**
  126954. * Release all resources
  126955. */
  126956. dispose(): void;
  126957. }
  126958. /**
  126959. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  126960. */
  126961. export interface ICrowd {
  126962. /**
  126963. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  126964. * You can attach anything to that node. The node position is updated in the scene update tick.
  126965. * @param pos world position that will be constrained by the navigation mesh
  126966. * @param parameters agent parameters
  126967. * @param transform hooked to the agent that will be update by the scene
  126968. * @returns agent index
  126969. */
  126970. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  126971. /**
  126972. * Returns the agent position in world space
  126973. * @param index agent index returned by addAgent
  126974. * @returns world space position
  126975. */
  126976. getAgentPosition(index: number): Vector3;
  126977. /**
  126978. * Gets the agent velocity in world space
  126979. * @param index agent index returned by addAgent
  126980. * @returns world space velocity
  126981. */
  126982. getAgentVelocity(index: number): Vector3;
  126983. /**
  126984. * remove a particular agent previously created
  126985. * @param index agent index returned by addAgent
  126986. */
  126987. removeAgent(index: number): void;
  126988. /**
  126989. * get the list of all agents attached to this crowd
  126990. * @returns list of agent indices
  126991. */
  126992. getAgents(): number[];
  126993. /**
  126994. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  126995. * @param deltaTime in seconds
  126996. */
  126997. update(deltaTime: number): void;
  126998. /**
  126999. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  127000. * @param index agent index returned by addAgent
  127001. * @param destination targeted world position
  127002. */
  127003. agentGoto(index: number, destination: Vector3): void;
  127004. /**
  127005. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  127006. * The queries will try to find a solution within those bounds
  127007. * default is (1,1,1)
  127008. * @param extent x,y,z value that define the extent around the queries point of reference
  127009. */
  127010. setDefaultQueryExtent(extent: Vector3): void;
  127011. /**
  127012. * Get the Bounding box extent specified by setDefaultQueryExtent
  127013. * @returns the box extent values
  127014. */
  127015. getDefaultQueryExtent(): Vector3;
  127016. /**
  127017. * Release all resources
  127018. */
  127019. dispose(): void;
  127020. }
  127021. /**
  127022. * Configures an agent
  127023. */
  127024. export interface IAgentParameters {
  127025. /**
  127026. * Agent radius. [Limit: >= 0]
  127027. */
  127028. radius: number;
  127029. /**
  127030. * Agent height. [Limit: > 0]
  127031. */
  127032. height: number;
  127033. /**
  127034. * Maximum allowed acceleration. [Limit: >= 0]
  127035. */
  127036. maxAcceleration: number;
  127037. /**
  127038. * Maximum allowed speed. [Limit: >= 0]
  127039. */
  127040. maxSpeed: number;
  127041. /**
  127042. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  127043. */
  127044. collisionQueryRange: number;
  127045. /**
  127046. * The path visibility optimization range. [Limit: > 0]
  127047. */
  127048. pathOptimizationRange: number;
  127049. /**
  127050. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  127051. */
  127052. separationWeight: number;
  127053. }
  127054. /**
  127055. * Configures the navigation mesh creation
  127056. */
  127057. export interface INavMeshParameters {
  127058. /**
  127059. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  127060. */
  127061. cs: number;
  127062. /**
  127063. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  127064. */
  127065. ch: number;
  127066. /**
  127067. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  127068. */
  127069. walkableSlopeAngle: number;
  127070. /**
  127071. * Minimum floor to 'ceiling' height that will still allow the floor area to
  127072. * be considered walkable. [Limit: >= 3] [Units: vx]
  127073. */
  127074. walkableHeight: number;
  127075. /**
  127076. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  127077. */
  127078. walkableClimb: number;
  127079. /**
  127080. * The distance to erode/shrink the walkable area of the heightfield away from
  127081. * obstructions. [Limit: >=0] [Units: vx]
  127082. */
  127083. walkableRadius: number;
  127084. /**
  127085. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  127086. */
  127087. maxEdgeLen: number;
  127088. /**
  127089. * The maximum distance a simplfied contour's border edges should deviate
  127090. * the original raw contour. [Limit: >=0] [Units: vx]
  127091. */
  127092. maxSimplificationError: number;
  127093. /**
  127094. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  127095. */
  127096. minRegionArea: number;
  127097. /**
  127098. * Any regions with a span count smaller than this value will, if possible,
  127099. * be merged with larger regions. [Limit: >=0] [Units: vx]
  127100. */
  127101. mergeRegionArea: number;
  127102. /**
  127103. * The maximum number of vertices allowed for polygons generated during the
  127104. * contour to polygon conversion process. [Limit: >= 3]
  127105. */
  127106. maxVertsPerPoly: number;
  127107. /**
  127108. * Sets the sampling distance to use when generating the detail mesh.
  127109. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  127110. */
  127111. detailSampleDist: number;
  127112. /**
  127113. * The maximum distance the detail mesh surface should deviate from heightfield
  127114. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  127115. */
  127116. detailSampleMaxError: number;
  127117. }
  127118. }
  127119. declare module BABYLON {
  127120. /**
  127121. * RecastJS navigation plugin
  127122. */
  127123. export class RecastJSPlugin implements INavigationEnginePlugin {
  127124. /**
  127125. * Reference to the Recast library
  127126. */
  127127. bjsRECAST: any;
  127128. /**
  127129. * plugin name
  127130. */
  127131. name: string;
  127132. /**
  127133. * the first navmesh created. We might extend this to support multiple navmeshes
  127134. */
  127135. navMesh: any;
  127136. /**
  127137. * Initializes the recastJS plugin
  127138. * @param recastInjection can be used to inject your own recast reference
  127139. */
  127140. constructor(recastInjection?: any);
  127141. /**
  127142. * Creates a navigation mesh
  127143. * @param meshes array of all the geometry used to compute the navigatio mesh
  127144. * @param parameters bunch of parameters used to filter geometry
  127145. */
  127146. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  127147. /**
  127148. * Create a navigation mesh debug mesh
  127149. * @param scene is where the mesh will be added
  127150. * @returns debug display mesh
  127151. */
  127152. createDebugNavMesh(scene: Scene): Mesh;
  127153. /**
  127154. * Get a navigation mesh constrained position, closest to the parameter position
  127155. * @param position world position
  127156. * @returns the closest point to position constrained by the navigation mesh
  127157. */
  127158. getClosestPoint(position: Vector3): Vector3;
  127159. /**
  127160. * Get a navigation mesh constrained position, within a particular radius
  127161. * @param position world position
  127162. * @param maxRadius the maximum distance to the constrained world position
  127163. * @returns the closest point to position constrained by the navigation mesh
  127164. */
  127165. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  127166. /**
  127167. * Compute the final position from a segment made of destination-position
  127168. * @param position world position
  127169. * @param destination world position
  127170. * @returns the resulting point along the navmesh
  127171. */
  127172. moveAlong(position: Vector3, destination: Vector3): Vector3;
  127173. /**
  127174. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  127175. * @param start world position
  127176. * @param end world position
  127177. * @returns array containing world position composing the path
  127178. */
  127179. computePath(start: Vector3, end: Vector3): Vector3[];
  127180. /**
  127181. * Create a new Crowd so you can add agents
  127182. * @param maxAgents the maximum agent count in the crowd
  127183. * @param maxAgentRadius the maximum radius an agent can have
  127184. * @param scene to attach the crowd to
  127185. * @returns the crowd you can add agents to
  127186. */
  127187. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  127188. /**
  127189. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  127190. * The queries will try to find a solution within those bounds
  127191. * default is (1,1,1)
  127192. * @param extent x,y,z value that define the extent around the queries point of reference
  127193. */
  127194. setDefaultQueryExtent(extent: Vector3): void;
  127195. /**
  127196. * Get the Bounding box extent specified by setDefaultQueryExtent
  127197. * @returns the box extent values
  127198. */
  127199. getDefaultQueryExtent(): Vector3;
  127200. /**
  127201. * Disposes
  127202. */
  127203. dispose(): void;
  127204. /**
  127205. * If this plugin is supported
  127206. * @returns true if plugin is supported
  127207. */
  127208. isSupported(): boolean;
  127209. }
  127210. /**
  127211. * Recast detour crowd implementation
  127212. */
  127213. export class RecastJSCrowd implements ICrowd {
  127214. /**
  127215. * Recast/detour plugin
  127216. */
  127217. bjsRECASTPlugin: RecastJSPlugin;
  127218. /**
  127219. * Link to the detour crowd
  127220. */
  127221. recastCrowd: any;
  127222. /**
  127223. * One transform per agent
  127224. */
  127225. transforms: TransformNode[];
  127226. /**
  127227. * All agents created
  127228. */
  127229. agents: number[];
  127230. /**
  127231. * Link to the scene is kept to unregister the crowd from the scene
  127232. */
  127233. private _scene;
  127234. /**
  127235. * Observer for crowd updates
  127236. */
  127237. private _onBeforeAnimationsObserver;
  127238. /**
  127239. * Constructor
  127240. * @param plugin recastJS plugin
  127241. * @param maxAgents the maximum agent count in the crowd
  127242. * @param maxAgentRadius the maximum radius an agent can have
  127243. * @param scene to attach the crowd to
  127244. * @returns the crowd you can add agents to
  127245. */
  127246. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  127247. /**
  127248. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  127249. * You can attach anything to that node. The node position is updated in the scene update tick.
  127250. * @param pos world position that will be constrained by the navigation mesh
  127251. * @param parameters agent parameters
  127252. * @param transform hooked to the agent that will be update by the scene
  127253. * @returns agent index
  127254. */
  127255. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  127256. /**
  127257. * Returns the agent position in world space
  127258. * @param index agent index returned by addAgent
  127259. * @returns world space position
  127260. */
  127261. getAgentPosition(index: number): Vector3;
  127262. /**
  127263. * Returns the agent velocity in world space
  127264. * @param index agent index returned by addAgent
  127265. * @returns world space velocity
  127266. */
  127267. getAgentVelocity(index: number): Vector3;
  127268. /**
  127269. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  127270. * @param index agent index returned by addAgent
  127271. * @param destination targeted world position
  127272. */
  127273. agentGoto(index: number, destination: Vector3): void;
  127274. /**
  127275. * remove a particular agent previously created
  127276. * @param index agent index returned by addAgent
  127277. */
  127278. removeAgent(index: number): void;
  127279. /**
  127280. * get the list of all agents attached to this crowd
  127281. * @returns list of agent indices
  127282. */
  127283. getAgents(): number[];
  127284. /**
  127285. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  127286. * @param deltaTime in seconds
  127287. */
  127288. update(deltaTime: number): void;
  127289. /**
  127290. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  127291. * The queries will try to find a solution within those bounds
  127292. * default is (1,1,1)
  127293. * @param extent x,y,z value that define the extent around the queries point of reference
  127294. */
  127295. setDefaultQueryExtent(extent: Vector3): void;
  127296. /**
  127297. * Get the Bounding box extent specified by setDefaultQueryExtent
  127298. * @returns the box extent values
  127299. */
  127300. getDefaultQueryExtent(): Vector3;
  127301. /**
  127302. * Release all resources
  127303. */
  127304. dispose(): void;
  127305. }
  127306. }
  127307. declare module BABYLON {
  127308. /**
  127309. * Class used to enable access to IndexedDB
  127310. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  127311. */
  127312. export class Database implements IOfflineProvider {
  127313. private _callbackManifestChecked;
  127314. private _currentSceneUrl;
  127315. private _db;
  127316. private _enableSceneOffline;
  127317. private _enableTexturesOffline;
  127318. private _manifestVersionFound;
  127319. private _mustUpdateRessources;
  127320. private _hasReachedQuota;
  127321. private _isSupported;
  127322. private _idbFactory;
  127323. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  127324. private static IsUASupportingBlobStorage;
  127325. /**
  127326. * Gets a boolean indicating if Database storate is enabled (off by default)
  127327. */
  127328. static IDBStorageEnabled: boolean;
  127329. /**
  127330. * Gets a boolean indicating if scene must be saved in the database
  127331. */
  127332. readonly enableSceneOffline: boolean;
  127333. /**
  127334. * Gets a boolean indicating if textures must be saved in the database
  127335. */
  127336. readonly enableTexturesOffline: boolean;
  127337. /**
  127338. * Creates a new Database
  127339. * @param urlToScene defines the url to load the scene
  127340. * @param callbackManifestChecked defines the callback to use when manifest is checked
  127341. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  127342. */
  127343. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  127344. private static _ParseURL;
  127345. private static _ReturnFullUrlLocation;
  127346. private _checkManifestFile;
  127347. /**
  127348. * Open the database and make it available
  127349. * @param successCallback defines the callback to call on success
  127350. * @param errorCallback defines the callback to call on error
  127351. */
  127352. open(successCallback: () => void, errorCallback: () => void): void;
  127353. /**
  127354. * Loads an image from the database
  127355. * @param url defines the url to load from
  127356. * @param image defines the target DOM image
  127357. */
  127358. loadImage(url: string, image: HTMLImageElement): void;
  127359. private _loadImageFromDBAsync;
  127360. private _saveImageIntoDBAsync;
  127361. private _checkVersionFromDB;
  127362. private _loadVersionFromDBAsync;
  127363. private _saveVersionIntoDBAsync;
  127364. /**
  127365. * Loads a file from database
  127366. * @param url defines the URL to load from
  127367. * @param sceneLoaded defines a callback to call on success
  127368. * @param progressCallBack defines a callback to call when progress changed
  127369. * @param errorCallback defines a callback to call on error
  127370. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  127371. */
  127372. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  127373. private _loadFileAsync;
  127374. private _saveFileAsync;
  127375. /**
  127376. * Validates if xhr data is correct
  127377. * @param xhr defines the request to validate
  127378. * @param dataType defines the expected data type
  127379. * @returns true if data is correct
  127380. */
  127381. private static _ValidateXHRData;
  127382. }
  127383. }
  127384. declare module BABYLON {
  127385. /** @hidden */
  127386. export var gpuUpdateParticlesPixelShader: {
  127387. name: string;
  127388. shader: string;
  127389. };
  127390. }
  127391. declare module BABYLON {
  127392. /** @hidden */
  127393. export var gpuUpdateParticlesVertexShader: {
  127394. name: string;
  127395. shader: string;
  127396. };
  127397. }
  127398. declare module BABYLON {
  127399. /** @hidden */
  127400. export var clipPlaneFragmentDeclaration2: {
  127401. name: string;
  127402. shader: string;
  127403. };
  127404. }
  127405. declare module BABYLON {
  127406. /** @hidden */
  127407. export var gpuRenderParticlesPixelShader: {
  127408. name: string;
  127409. shader: string;
  127410. };
  127411. }
  127412. declare module BABYLON {
  127413. /** @hidden */
  127414. export var clipPlaneVertexDeclaration2: {
  127415. name: string;
  127416. shader: string;
  127417. };
  127418. }
  127419. declare module BABYLON {
  127420. /** @hidden */
  127421. export var gpuRenderParticlesVertexShader: {
  127422. name: string;
  127423. shader: string;
  127424. };
  127425. }
  127426. declare module BABYLON {
  127427. /**
  127428. * This represents a GPU particle system in Babylon
  127429. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  127430. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  127431. */
  127432. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  127433. /**
  127434. * The layer mask we are rendering the particles through.
  127435. */
  127436. layerMask: number;
  127437. private _capacity;
  127438. private _activeCount;
  127439. private _currentActiveCount;
  127440. private _accumulatedCount;
  127441. private _renderEffect;
  127442. private _updateEffect;
  127443. private _buffer0;
  127444. private _buffer1;
  127445. private _spriteBuffer;
  127446. private _updateVAO;
  127447. private _renderVAO;
  127448. private _targetIndex;
  127449. private _sourceBuffer;
  127450. private _targetBuffer;
  127451. private _engine;
  127452. private _currentRenderId;
  127453. private _started;
  127454. private _stopped;
  127455. private _timeDelta;
  127456. private _randomTexture;
  127457. private _randomTexture2;
  127458. private _attributesStrideSize;
  127459. private _updateEffectOptions;
  127460. private _randomTextureSize;
  127461. private _actualFrame;
  127462. private readonly _rawTextureWidth;
  127463. /**
  127464. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  127465. */
  127466. static readonly IsSupported: boolean;
  127467. /**
  127468. * An event triggered when the system is disposed.
  127469. */
  127470. onDisposeObservable: Observable<GPUParticleSystem>;
  127471. /**
  127472. * Gets the maximum number of particles active at the same time.
  127473. * @returns The max number of active particles.
  127474. */
  127475. getCapacity(): number;
  127476. /**
  127477. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  127478. * to override the particles.
  127479. */
  127480. forceDepthWrite: boolean;
  127481. /**
  127482. * Gets or set the number of active particles
  127483. */
  127484. activeParticleCount: number;
  127485. private _preWarmDone;
  127486. /**
  127487. * Is this system ready to be used/rendered
  127488. * @return true if the system is ready
  127489. */
  127490. isReady(): boolean;
  127491. /**
  127492. * Gets if the system has been started. (Note: this will still be true after stop is called)
  127493. * @returns True if it has been started, otherwise false.
  127494. */
  127495. isStarted(): boolean;
  127496. /**
  127497. * Starts the particle system and begins to emit
  127498. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  127499. */
  127500. start(delay?: number): void;
  127501. /**
  127502. * Stops the particle system.
  127503. */
  127504. stop(): void;
  127505. /**
  127506. * Remove all active particles
  127507. */
  127508. reset(): void;
  127509. /**
  127510. * Returns the string "GPUParticleSystem"
  127511. * @returns a string containing the class name
  127512. */
  127513. getClassName(): string;
  127514. private _colorGradientsTexture;
  127515. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  127516. /**
  127517. * Adds a new color gradient
  127518. * @param gradient defines the gradient to use (between 0 and 1)
  127519. * @param color1 defines the color to affect to the specified gradient
  127520. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  127521. * @returns the current particle system
  127522. */
  127523. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  127524. /**
  127525. * Remove a specific color gradient
  127526. * @param gradient defines the gradient to remove
  127527. * @returns the current particle system
  127528. */
  127529. removeColorGradient(gradient: number): GPUParticleSystem;
  127530. private _angularSpeedGradientsTexture;
  127531. private _sizeGradientsTexture;
  127532. private _velocityGradientsTexture;
  127533. private _limitVelocityGradientsTexture;
  127534. private _dragGradientsTexture;
  127535. private _addFactorGradient;
  127536. /**
  127537. * Adds a new size gradient
  127538. * @param gradient defines the gradient to use (between 0 and 1)
  127539. * @param factor defines the size factor to affect to the specified gradient
  127540. * @returns the current particle system
  127541. */
  127542. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  127543. /**
  127544. * Remove a specific size gradient
  127545. * @param gradient defines the gradient to remove
  127546. * @returns the current particle system
  127547. */
  127548. removeSizeGradient(gradient: number): GPUParticleSystem;
  127549. /**
  127550. * Adds a new angular speed gradient
  127551. * @param gradient defines the gradient to use (between 0 and 1)
  127552. * @param factor defines the angular speed to affect to the specified gradient
  127553. * @returns the current particle system
  127554. */
  127555. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  127556. /**
  127557. * Remove a specific angular speed gradient
  127558. * @param gradient defines the gradient to remove
  127559. * @returns the current particle system
  127560. */
  127561. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  127562. /**
  127563. * Adds a new velocity gradient
  127564. * @param gradient defines the gradient to use (between 0 and 1)
  127565. * @param factor defines the velocity to affect to the specified gradient
  127566. * @returns the current particle system
  127567. */
  127568. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  127569. /**
  127570. * Remove a specific velocity gradient
  127571. * @param gradient defines the gradient to remove
  127572. * @returns the current particle system
  127573. */
  127574. removeVelocityGradient(gradient: number): GPUParticleSystem;
  127575. /**
  127576. * Adds a new limit velocity gradient
  127577. * @param gradient defines the gradient to use (between 0 and 1)
  127578. * @param factor defines the limit velocity value to affect to the specified gradient
  127579. * @returns the current particle system
  127580. */
  127581. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  127582. /**
  127583. * Remove a specific limit velocity gradient
  127584. * @param gradient defines the gradient to remove
  127585. * @returns the current particle system
  127586. */
  127587. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  127588. /**
  127589. * Adds a new drag gradient
  127590. * @param gradient defines the gradient to use (between 0 and 1)
  127591. * @param factor defines the drag value to affect to the specified gradient
  127592. * @returns the current particle system
  127593. */
  127594. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  127595. /**
  127596. * Remove a specific drag gradient
  127597. * @param gradient defines the gradient to remove
  127598. * @returns the current particle system
  127599. */
  127600. removeDragGradient(gradient: number): GPUParticleSystem;
  127601. /**
  127602. * Not supported by GPUParticleSystem
  127603. * @param gradient defines the gradient to use (between 0 and 1)
  127604. * @param factor defines the emit rate value to affect to the specified gradient
  127605. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  127606. * @returns the current particle system
  127607. */
  127608. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  127609. /**
  127610. * Not supported by GPUParticleSystem
  127611. * @param gradient defines the gradient to remove
  127612. * @returns the current particle system
  127613. */
  127614. removeEmitRateGradient(gradient: number): IParticleSystem;
  127615. /**
  127616. * Not supported by GPUParticleSystem
  127617. * @param gradient defines the gradient to use (between 0 and 1)
  127618. * @param factor defines the start size value to affect to the specified gradient
  127619. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  127620. * @returns the current particle system
  127621. */
  127622. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  127623. /**
  127624. * Not supported by GPUParticleSystem
  127625. * @param gradient defines the gradient to remove
  127626. * @returns the current particle system
  127627. */
  127628. removeStartSizeGradient(gradient: number): IParticleSystem;
  127629. /**
  127630. * Not supported by GPUParticleSystem
  127631. * @param gradient defines the gradient to use (between 0 and 1)
  127632. * @param min defines the color remap minimal range
  127633. * @param max defines the color remap maximal range
  127634. * @returns the current particle system
  127635. */
  127636. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  127637. /**
  127638. * Not supported by GPUParticleSystem
  127639. * @param gradient defines the gradient to remove
  127640. * @returns the current particle system
  127641. */
  127642. removeColorRemapGradient(): IParticleSystem;
  127643. /**
  127644. * Not supported by GPUParticleSystem
  127645. * @param gradient defines the gradient to use (between 0 and 1)
  127646. * @param min defines the alpha remap minimal range
  127647. * @param max defines the alpha remap maximal range
  127648. * @returns the current particle system
  127649. */
  127650. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  127651. /**
  127652. * Not supported by GPUParticleSystem
  127653. * @param gradient defines the gradient to remove
  127654. * @returns the current particle system
  127655. */
  127656. removeAlphaRemapGradient(): IParticleSystem;
  127657. /**
  127658. * Not supported by GPUParticleSystem
  127659. * @param gradient defines the gradient to use (between 0 and 1)
  127660. * @param color defines the color to affect to the specified gradient
  127661. * @returns the current particle system
  127662. */
  127663. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  127664. /**
  127665. * Not supported by GPUParticleSystem
  127666. * @param gradient defines the gradient to remove
  127667. * @returns the current particle system
  127668. */
  127669. removeRampGradient(): IParticleSystem;
  127670. /**
  127671. * Not supported by GPUParticleSystem
  127672. * @returns the list of ramp gradients
  127673. */
  127674. getRampGradients(): Nullable<Array<Color3Gradient>>;
  127675. /**
  127676. * Not supported by GPUParticleSystem
  127677. * Gets or sets a boolean indicating that ramp gradients must be used
  127678. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  127679. */
  127680. useRampGradients: boolean;
  127681. /**
  127682. * Not supported by GPUParticleSystem
  127683. * @param gradient defines the gradient to use (between 0 and 1)
  127684. * @param factor defines the life time factor to affect to the specified gradient
  127685. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  127686. * @returns the current particle system
  127687. */
  127688. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  127689. /**
  127690. * Not supported by GPUParticleSystem
  127691. * @param gradient defines the gradient to remove
  127692. * @returns the current particle system
  127693. */
  127694. removeLifeTimeGradient(gradient: number): IParticleSystem;
  127695. /**
  127696. * Instantiates a GPU particle system.
  127697. * 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.
  127698. * @param name The name of the particle system
  127699. * @param options The options used to create the system
  127700. * @param scene The scene the particle system belongs to
  127701. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  127702. */
  127703. constructor(name: string, options: Partial<{
  127704. capacity: number;
  127705. randomTextureSize: number;
  127706. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  127707. protected _reset(): void;
  127708. private _createUpdateVAO;
  127709. private _createRenderVAO;
  127710. private _initialize;
  127711. /** @hidden */
  127712. _recreateUpdateEffect(): void;
  127713. /** @hidden */
  127714. _recreateRenderEffect(): void;
  127715. /**
  127716. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  127717. * @param preWarm defines if we are in the pre-warmimg phase
  127718. */
  127719. animate(preWarm?: boolean): void;
  127720. private _createFactorGradientTexture;
  127721. private _createSizeGradientTexture;
  127722. private _createAngularSpeedGradientTexture;
  127723. private _createVelocityGradientTexture;
  127724. private _createLimitVelocityGradientTexture;
  127725. private _createDragGradientTexture;
  127726. private _createColorGradientTexture;
  127727. /**
  127728. * Renders the particle system in its current state
  127729. * @param preWarm defines if the system should only update the particles but not render them
  127730. * @returns the current number of particles
  127731. */
  127732. render(preWarm?: boolean): number;
  127733. /**
  127734. * Rebuilds the particle system
  127735. */
  127736. rebuild(): void;
  127737. private _releaseBuffers;
  127738. private _releaseVAOs;
  127739. /**
  127740. * Disposes the particle system and free the associated resources
  127741. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  127742. */
  127743. dispose(disposeTexture?: boolean): void;
  127744. /**
  127745. * Clones the particle system.
  127746. * @param name The name of the cloned object
  127747. * @param newEmitter The new emitter to use
  127748. * @returns the cloned particle system
  127749. */
  127750. clone(name: string, newEmitter: any): GPUParticleSystem;
  127751. /**
  127752. * Serializes the particle system to a JSON object.
  127753. * @returns the JSON object
  127754. */
  127755. serialize(): any;
  127756. /**
  127757. * Parses a JSON object to create a GPU particle system.
  127758. * @param parsedParticleSystem The JSON object to parse
  127759. * @param scene The scene to create the particle system in
  127760. * @param rootUrl The root url to use to load external dependencies like texture
  127761. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  127762. * @returns the parsed GPU particle system
  127763. */
  127764. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  127765. }
  127766. }
  127767. declare module BABYLON {
  127768. /**
  127769. * Represents a set of particle systems working together to create a specific effect
  127770. */
  127771. export class ParticleSystemSet implements IDisposable {
  127772. /**
  127773. * Gets or sets base Assets URL
  127774. */
  127775. static BaseAssetsUrl: string;
  127776. private _emitterCreationOptions;
  127777. private _emitterNode;
  127778. /**
  127779. * Gets the particle system list
  127780. */
  127781. systems: IParticleSystem[];
  127782. /**
  127783. * Gets the emitter node used with this set
  127784. */
  127785. readonly emitterNode: Nullable<TransformNode>;
  127786. /**
  127787. * Creates a new emitter mesh as a sphere
  127788. * @param options defines the options used to create the sphere
  127789. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  127790. * @param scene defines the hosting scene
  127791. */
  127792. setEmitterAsSphere(options: {
  127793. diameter: number;
  127794. segments: number;
  127795. color: Color3;
  127796. }, renderingGroupId: number, scene: Scene): void;
  127797. /**
  127798. * Starts all particle systems of the set
  127799. * @param emitter defines an optional mesh to use as emitter for the particle systems
  127800. */
  127801. start(emitter?: AbstractMesh): void;
  127802. /**
  127803. * Release all associated resources
  127804. */
  127805. dispose(): void;
  127806. /**
  127807. * Serialize the set into a JSON compatible object
  127808. * @returns a JSON compatible representation of the set
  127809. */
  127810. serialize(): any;
  127811. /**
  127812. * Parse a new ParticleSystemSet from a serialized source
  127813. * @param data defines a JSON compatible representation of the set
  127814. * @param scene defines the hosting scene
  127815. * @param gpu defines if we want GPU particles or CPU particles
  127816. * @returns a new ParticleSystemSet
  127817. */
  127818. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  127819. }
  127820. }
  127821. declare module BABYLON {
  127822. /**
  127823. * This class is made for on one-liner static method to help creating particle system set.
  127824. */
  127825. export class ParticleHelper {
  127826. /**
  127827. * Gets or sets base Assets URL
  127828. */
  127829. static BaseAssetsUrl: string;
  127830. /**
  127831. * Create a default particle system that you can tweak
  127832. * @param emitter defines the emitter to use
  127833. * @param capacity defines the system capacity (default is 500 particles)
  127834. * @param scene defines the hosting scene
  127835. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  127836. * @returns the new Particle system
  127837. */
  127838. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  127839. /**
  127840. * This is the main static method (one-liner) of this helper to create different particle systems
  127841. * @param type This string represents the type to the particle system to create
  127842. * @param scene The scene where the particle system should live
  127843. * @param gpu If the system will use gpu
  127844. * @returns the ParticleSystemSet created
  127845. */
  127846. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  127847. /**
  127848. * Static function used to export a particle system to a ParticleSystemSet variable.
  127849. * Please note that the emitter shape is not exported
  127850. * @param systems defines the particle systems to export
  127851. * @returns the created particle system set
  127852. */
  127853. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  127854. }
  127855. }
  127856. declare module BABYLON {
  127857. interface Engine {
  127858. /**
  127859. * Create an effect to use with particle systems.
  127860. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  127861. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  127862. * @param uniformsNames defines a list of attribute names
  127863. * @param samplers defines an array of string used to represent textures
  127864. * @param defines defines the string containing the defines to use to compile the shaders
  127865. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  127866. * @param onCompiled defines a function to call when the effect creation is successful
  127867. * @param onError defines a function to call when the effect creation has failed
  127868. * @returns the new Effect
  127869. */
  127870. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  127871. }
  127872. interface Mesh {
  127873. /**
  127874. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  127875. * @returns an array of IParticleSystem
  127876. */
  127877. getEmittedParticleSystems(): IParticleSystem[];
  127878. /**
  127879. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  127880. * @returns an array of IParticleSystem
  127881. */
  127882. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  127883. }
  127884. /**
  127885. * @hidden
  127886. */
  127887. export var _IDoNeedToBeInTheBuild: number;
  127888. }
  127889. declare module BABYLON {
  127890. /** Defines the 4 color options */
  127891. export enum PointColor {
  127892. /** color value */
  127893. Color = 2,
  127894. /** uv value */
  127895. UV = 1,
  127896. /** random value */
  127897. Random = 0,
  127898. /** stated value */
  127899. Stated = 3
  127900. }
  127901. /**
  127902. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  127903. * 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.
  127904. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  127905. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  127906. *
  127907. * Full documentation here : TO BE ENTERED
  127908. */
  127909. export class PointsCloudSystem implements IDisposable {
  127910. /**
  127911. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  127912. * Example : var p = SPS.particles[i];
  127913. */
  127914. particles: CloudPoint[];
  127915. /**
  127916. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  127917. */
  127918. nbParticles: number;
  127919. /**
  127920. * This a counter for your own usage. It's not set by any SPS functions.
  127921. */
  127922. counter: number;
  127923. /**
  127924. * The PCS name. This name is also given to the underlying mesh.
  127925. */
  127926. name: string;
  127927. /**
  127928. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  127929. */
  127930. mesh: Mesh;
  127931. /**
  127932. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  127933. * Please read :
  127934. */
  127935. vars: any;
  127936. /**
  127937. * @hidden
  127938. */
  127939. _size: number;
  127940. private _scene;
  127941. private _promises;
  127942. private _positions;
  127943. private _indices;
  127944. private _normals;
  127945. private _colors;
  127946. private _uvs;
  127947. private _indices32;
  127948. private _positions32;
  127949. private _colors32;
  127950. private _uvs32;
  127951. private _updatable;
  127952. private _isVisibilityBoxLocked;
  127953. private _alwaysVisible;
  127954. private _groups;
  127955. private _groupCounter;
  127956. private _computeParticleColor;
  127957. private _computeParticleTexture;
  127958. private _computeParticleRotation;
  127959. private _computeBoundingBox;
  127960. private _isReady;
  127961. /**
  127962. * Creates a PCS (Points Cloud System) object
  127963. * @param name (String) is the PCS name, this will be the underlying mesh name
  127964. * @param pointSize (number) is the size for each point
  127965. * @param scene (Scene) is the scene in which the PCS is added
  127966. * @param options defines the options of the PCS e.g.
  127967. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  127968. */
  127969. constructor(name: string, pointSize: number, scene: Scene, options?: {
  127970. updatable?: boolean;
  127971. });
  127972. /**
  127973. * Builds the PCS underlying mesh. Returns a standard Mesh.
  127974. * If no points were added to the PCS, the returned mesh is just a single point.
  127975. * @returns a promise for the created mesh
  127976. */
  127977. buildMeshAsync(): Promise<Mesh>;
  127978. /**
  127979. * @hidden
  127980. */
  127981. private _buildMesh;
  127982. private _addParticle;
  127983. private _randomUnitVector;
  127984. private _getColorIndicesForCoord;
  127985. private _setPointsColorOrUV;
  127986. private _colorFromTexture;
  127987. private _calculateDensity;
  127988. /**
  127989. * Adds points to the PCS in random positions within a unit sphere
  127990. * @param nb (positive integer) the number of particles to be created from this model
  127991. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  127992. * @returns the number of groups in the system
  127993. */
  127994. addPoints(nb: number, pointFunction?: any): number;
  127995. /**
  127996. * Adds points to the PCS from the surface of the model shape
  127997. * @param mesh is any Mesh object that will be used as a surface model for the points
  127998. * @param nb (positive integer) the number of particles to be created from this model
  127999. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  128000. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  128001. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  128002. * @returns the number of groups in the system
  128003. */
  128004. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  128005. /**
  128006. * Adds points to the PCS inside the model shape
  128007. * @param mesh is any Mesh object that will be used as a surface model for the points
  128008. * @param nb (positive integer) the number of particles to be created from this model
  128009. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  128010. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  128011. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  128012. * @returns the number of groups in the system
  128013. */
  128014. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  128015. /**
  128016. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  128017. * This method calls `updateParticle()` for each particle of the SPS.
  128018. * For an animated SPS, it is usually called within the render loop.
  128019. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  128020. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  128021. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  128022. * @returns the PCS.
  128023. */
  128024. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  128025. /**
  128026. * Disposes the PCS.
  128027. */
  128028. dispose(): void;
  128029. /**
  128030. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  128031. * doc :
  128032. * @returns the PCS.
  128033. */
  128034. refreshVisibleSize(): PointsCloudSystem;
  128035. /**
  128036. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  128037. * @param size the size (float) of the visibility box
  128038. * note : this doesn't lock the PCS mesh bounding box.
  128039. * doc :
  128040. */
  128041. setVisibilityBox(size: number): void;
  128042. /**
  128043. * Gets whether the PCS is always visible or not
  128044. * doc :
  128045. */
  128046. /**
  128047. * Sets the PCS as always visible or not
  128048. * doc :
  128049. */
  128050. isAlwaysVisible: boolean;
  128051. /**
  128052. * Tells to `setParticles()` to compute the particle rotations or not
  128053. * Default value : false. The PCS is faster when it's set to false
  128054. * Note : particle rotations are only applied to parent particles
  128055. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  128056. */
  128057. computeParticleRotation: boolean;
  128058. /**
  128059. * Tells to `setParticles()` to compute the particle colors or not.
  128060. * Default value : true. The PCS is faster when it's set to false.
  128061. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  128062. */
  128063. /**
  128064. * Gets if `setParticles()` computes the particle colors or not.
  128065. * Default value : false. The PCS is faster when it's set to false.
  128066. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  128067. */
  128068. computeParticleColor: boolean;
  128069. /**
  128070. * Gets if `setParticles()` computes the particle textures or not.
  128071. * Default value : false. The PCS is faster when it's set to false.
  128072. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  128073. */
  128074. computeParticleTexture: boolean;
  128075. /**
  128076. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  128077. */
  128078. /**
  128079. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  128080. */
  128081. computeBoundingBox: boolean;
  128082. /**
  128083. * This function does nothing. It may be overwritten to set all the particle first values.
  128084. * The PCS doesn't call this function, you may have to call it by your own.
  128085. * doc :
  128086. */
  128087. initParticles(): void;
  128088. /**
  128089. * This function does nothing. It may be overwritten to recycle a particle
  128090. * The PCS doesn't call this function, you can to call it
  128091. * doc :
  128092. * @param particle The particle to recycle
  128093. * @returns the recycled particle
  128094. */
  128095. recycleParticle(particle: CloudPoint): CloudPoint;
  128096. /**
  128097. * Updates a particle : this function should be overwritten by the user.
  128098. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  128099. * doc :
  128100. * @example : just set a particle position or velocity and recycle conditions
  128101. * @param particle The particle to update
  128102. * @returns the updated particle
  128103. */
  128104. updateParticle(particle: CloudPoint): CloudPoint;
  128105. /**
  128106. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  128107. * This does nothing and may be overwritten by the user.
  128108. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  128109. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  128110. * @param update the boolean update value actually passed to setParticles()
  128111. */
  128112. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  128113. /**
  128114. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  128115. * This will be passed three parameters.
  128116. * This does nothing and may be overwritten by the user.
  128117. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  128118. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  128119. * @param update the boolean update value actually passed to setParticles()
  128120. */
  128121. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  128122. }
  128123. }
  128124. declare module BABYLON {
  128125. /**
  128126. * Represents one particle of a points cloud system.
  128127. */
  128128. export class CloudPoint {
  128129. /**
  128130. * particle global index
  128131. */
  128132. idx: number;
  128133. /**
  128134. * The color of the particle
  128135. */
  128136. color: Nullable<Color4>;
  128137. /**
  128138. * The world space position of the particle.
  128139. */
  128140. position: Vector3;
  128141. /**
  128142. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  128143. */
  128144. rotation: Vector3;
  128145. /**
  128146. * The world space rotation quaternion of the particle.
  128147. */
  128148. rotationQuaternion: Nullable<Quaternion>;
  128149. /**
  128150. * The uv of the particle.
  128151. */
  128152. uv: Nullable<Vector2>;
  128153. /**
  128154. * The current speed of the particle.
  128155. */
  128156. velocity: Vector3;
  128157. /**
  128158. * The pivot point in the particle local space.
  128159. */
  128160. pivot: Vector3;
  128161. /**
  128162. * Must the particle be translated from its pivot point in its local space ?
  128163. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  128164. * Default : false
  128165. */
  128166. translateFromPivot: boolean;
  128167. /**
  128168. * Index of this particle in the global "positions" array (Internal use)
  128169. * @hidden
  128170. */
  128171. _pos: number;
  128172. /**
  128173. * @hidden Index of this particle in the global "indices" array (Internal use)
  128174. */
  128175. _ind: number;
  128176. /**
  128177. * Group this particle belongs to
  128178. */
  128179. _group: PointsGroup;
  128180. /**
  128181. * Group id of this particle
  128182. */
  128183. groupId: number;
  128184. /**
  128185. * Index of the particle in its group id (Internal use)
  128186. */
  128187. idxInGroup: number;
  128188. /**
  128189. * @hidden Particle BoundingInfo object (Internal use)
  128190. */
  128191. _boundingInfo: BoundingInfo;
  128192. /**
  128193. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  128194. */
  128195. _pcs: PointsCloudSystem;
  128196. /**
  128197. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  128198. */
  128199. _stillInvisible: boolean;
  128200. /**
  128201. * @hidden Last computed particle rotation matrix
  128202. */
  128203. _rotationMatrix: number[];
  128204. /**
  128205. * Parent particle Id, if any.
  128206. * Default null.
  128207. */
  128208. parentId: Nullable<number>;
  128209. /**
  128210. * @hidden Internal global position in the PCS.
  128211. */
  128212. _globalPosition: Vector3;
  128213. /**
  128214. * Creates a Point Cloud object.
  128215. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  128216. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  128217. * @param group (PointsGroup) is the group the particle belongs to
  128218. * @param groupId (integer) is the group identifier in the PCS.
  128219. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  128220. * @param pcs defines the PCS it is associated to
  128221. */
  128222. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  128223. /**
  128224. * get point size
  128225. */
  128226. /**
  128227. * Set point size
  128228. */
  128229. size: Vector3;
  128230. /**
  128231. * Legacy support, changed quaternion to rotationQuaternion
  128232. */
  128233. /**
  128234. * Legacy support, changed quaternion to rotationQuaternion
  128235. */
  128236. quaternion: Nullable<Quaternion>;
  128237. /**
  128238. * Returns a boolean. True if the particle intersects a mesh, else false
  128239. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  128240. * @param target is the object (point or mesh) what the intersection is computed against
  128241. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  128242. * @returns true if it intersects
  128243. */
  128244. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  128245. /**
  128246. * get the rotation matrix of the particle
  128247. * @hidden
  128248. */
  128249. getRotationMatrix(m: Matrix): void;
  128250. }
  128251. /**
  128252. * Represents a group of points in a points cloud system
  128253. * * PCS internal tool, don't use it manually.
  128254. */
  128255. export class PointsGroup {
  128256. /**
  128257. * The group id
  128258. * @hidden
  128259. */
  128260. groupID: number;
  128261. /**
  128262. * image data for group (internal use)
  128263. * @hidden
  128264. */
  128265. _groupImageData: Nullable<ArrayBufferView>;
  128266. /**
  128267. * Image Width (internal use)
  128268. * @hidden
  128269. */
  128270. _groupImgWidth: number;
  128271. /**
  128272. * Image Height (internal use)
  128273. * @hidden
  128274. */
  128275. _groupImgHeight: number;
  128276. /**
  128277. * Custom position function (internal use)
  128278. * @hidden
  128279. */
  128280. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  128281. /**
  128282. * density per facet for surface points
  128283. * @hidden
  128284. */
  128285. _groupDensity: number[];
  128286. /**
  128287. * Only when points are colored by texture carries pointer to texture list array
  128288. * @hidden
  128289. */
  128290. _textureNb: number;
  128291. /**
  128292. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  128293. * PCS internal tool, don't use it manually.
  128294. * @hidden
  128295. */
  128296. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  128297. }
  128298. }
  128299. declare module BABYLON {
  128300. interface Scene {
  128301. /** @hidden (Backing field) */
  128302. _physicsEngine: Nullable<IPhysicsEngine>;
  128303. /**
  128304. * Gets the current physics engine
  128305. * @returns a IPhysicsEngine or null if none attached
  128306. */
  128307. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  128308. /**
  128309. * Enables physics to the current scene
  128310. * @param gravity defines the scene's gravity for the physics engine
  128311. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  128312. * @return a boolean indicating if the physics engine was initialized
  128313. */
  128314. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  128315. /**
  128316. * Disables and disposes the physics engine associated with the scene
  128317. */
  128318. disablePhysicsEngine(): void;
  128319. /**
  128320. * Gets a boolean indicating if there is an active physics engine
  128321. * @returns a boolean indicating if there is an active physics engine
  128322. */
  128323. isPhysicsEnabled(): boolean;
  128324. /**
  128325. * Deletes a physics compound impostor
  128326. * @param compound defines the compound to delete
  128327. */
  128328. deleteCompoundImpostor(compound: any): void;
  128329. /**
  128330. * An event triggered when physic simulation is about to be run
  128331. */
  128332. onBeforePhysicsObservable: Observable<Scene>;
  128333. /**
  128334. * An event triggered when physic simulation has been done
  128335. */
  128336. onAfterPhysicsObservable: Observable<Scene>;
  128337. }
  128338. interface AbstractMesh {
  128339. /** @hidden */
  128340. _physicsImpostor: Nullable<PhysicsImpostor>;
  128341. /**
  128342. * Gets or sets impostor used for physic simulation
  128343. * @see http://doc.babylonjs.com/features/physics_engine
  128344. */
  128345. physicsImpostor: Nullable<PhysicsImpostor>;
  128346. /**
  128347. * Gets the current physics impostor
  128348. * @see http://doc.babylonjs.com/features/physics_engine
  128349. * @returns a physics impostor or null
  128350. */
  128351. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  128352. /** Apply a physic impulse to the mesh
  128353. * @param force defines the force to apply
  128354. * @param contactPoint defines where to apply the force
  128355. * @returns the current mesh
  128356. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  128357. */
  128358. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  128359. /**
  128360. * Creates a physic joint between two meshes
  128361. * @param otherMesh defines the other mesh to use
  128362. * @param pivot1 defines the pivot to use on this mesh
  128363. * @param pivot2 defines the pivot to use on the other mesh
  128364. * @param options defines additional options (can be plugin dependent)
  128365. * @returns the current mesh
  128366. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  128367. */
  128368. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  128369. /** @hidden */
  128370. _disposePhysicsObserver: Nullable<Observer<Node>>;
  128371. }
  128372. /**
  128373. * Defines the physics engine scene component responsible to manage a physics engine
  128374. */
  128375. export class PhysicsEngineSceneComponent implements ISceneComponent {
  128376. /**
  128377. * The component name helpful to identify the component in the list of scene components.
  128378. */
  128379. readonly name: string;
  128380. /**
  128381. * The scene the component belongs to.
  128382. */
  128383. scene: Scene;
  128384. /**
  128385. * Creates a new instance of the component for the given scene
  128386. * @param scene Defines the scene to register the component in
  128387. */
  128388. constructor(scene: Scene);
  128389. /**
  128390. * Registers the component in a given scene
  128391. */
  128392. register(): void;
  128393. /**
  128394. * Rebuilds the elements related to this component in case of
  128395. * context lost for instance.
  128396. */
  128397. rebuild(): void;
  128398. /**
  128399. * Disposes the component and the associated ressources
  128400. */
  128401. dispose(): void;
  128402. }
  128403. }
  128404. declare module BABYLON {
  128405. /**
  128406. * A helper for physics simulations
  128407. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  128408. */
  128409. export class PhysicsHelper {
  128410. private _scene;
  128411. private _physicsEngine;
  128412. /**
  128413. * Initializes the Physics helper
  128414. * @param scene Babylon.js scene
  128415. */
  128416. constructor(scene: Scene);
  128417. /**
  128418. * Applies a radial explosion impulse
  128419. * @param origin the origin of the explosion
  128420. * @param radiusOrEventOptions the radius or the options of radial explosion
  128421. * @param strength the explosion strength
  128422. * @param falloff possible options: Constant & Linear. Defaults to Constant
  128423. * @returns A physics radial explosion event, or null
  128424. */
  128425. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  128426. /**
  128427. * Applies a radial explosion force
  128428. * @param origin the origin of the explosion
  128429. * @param radiusOrEventOptions the radius or the options of radial explosion
  128430. * @param strength the explosion strength
  128431. * @param falloff possible options: Constant & Linear. Defaults to Constant
  128432. * @returns A physics radial explosion event, or null
  128433. */
  128434. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  128435. /**
  128436. * Creates a gravitational field
  128437. * @param origin the origin of the explosion
  128438. * @param radiusOrEventOptions the radius or the options of radial explosion
  128439. * @param strength the explosion strength
  128440. * @param falloff possible options: Constant & Linear. Defaults to Constant
  128441. * @returns A physics gravitational field event, or null
  128442. */
  128443. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  128444. /**
  128445. * Creates a physics updraft event
  128446. * @param origin the origin of the updraft
  128447. * @param radiusOrEventOptions the radius or the options of the updraft
  128448. * @param strength the strength of the updraft
  128449. * @param height the height of the updraft
  128450. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  128451. * @returns A physics updraft event, or null
  128452. */
  128453. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  128454. /**
  128455. * Creates a physics vortex event
  128456. * @param origin the of the vortex
  128457. * @param radiusOrEventOptions the radius or the options of the vortex
  128458. * @param strength the strength of the vortex
  128459. * @param height the height of the vortex
  128460. * @returns a Physics vortex event, or null
  128461. * A physics vortex event or null
  128462. */
  128463. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  128464. }
  128465. /**
  128466. * Represents a physics radial explosion event
  128467. */
  128468. class PhysicsRadialExplosionEvent {
  128469. private _scene;
  128470. private _options;
  128471. private _sphere;
  128472. private _dataFetched;
  128473. /**
  128474. * Initializes a radial explosioin event
  128475. * @param _scene BabylonJS scene
  128476. * @param _options The options for the vortex event
  128477. */
  128478. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  128479. /**
  128480. * Returns the data related to the radial explosion event (sphere).
  128481. * @returns The radial explosion event data
  128482. */
  128483. getData(): PhysicsRadialExplosionEventData;
  128484. /**
  128485. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  128486. * @param impostor A physics imposter
  128487. * @param origin the origin of the explosion
  128488. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  128489. */
  128490. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  128491. /**
  128492. * Triggers affecterd impostors callbacks
  128493. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  128494. */
  128495. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  128496. /**
  128497. * Disposes the sphere.
  128498. * @param force Specifies if the sphere should be disposed by force
  128499. */
  128500. dispose(force?: boolean): void;
  128501. /*** Helpers ***/
  128502. private _prepareSphere;
  128503. private _intersectsWithSphere;
  128504. }
  128505. /**
  128506. * Represents a gravitational field event
  128507. */
  128508. class PhysicsGravitationalFieldEvent {
  128509. private _physicsHelper;
  128510. private _scene;
  128511. private _origin;
  128512. private _options;
  128513. private _tickCallback;
  128514. private _sphere;
  128515. private _dataFetched;
  128516. /**
  128517. * Initializes the physics gravitational field event
  128518. * @param _physicsHelper A physics helper
  128519. * @param _scene BabylonJS scene
  128520. * @param _origin The origin position of the gravitational field event
  128521. * @param _options The options for the vortex event
  128522. */
  128523. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  128524. /**
  128525. * Returns the data related to the gravitational field event (sphere).
  128526. * @returns A gravitational field event
  128527. */
  128528. getData(): PhysicsGravitationalFieldEventData;
  128529. /**
  128530. * Enables the gravitational field.
  128531. */
  128532. enable(): void;
  128533. /**
  128534. * Disables the gravitational field.
  128535. */
  128536. disable(): void;
  128537. /**
  128538. * Disposes the sphere.
  128539. * @param force The force to dispose from the gravitational field event
  128540. */
  128541. dispose(force?: boolean): void;
  128542. private _tick;
  128543. }
  128544. /**
  128545. * Represents a physics updraft event
  128546. */
  128547. class PhysicsUpdraftEvent {
  128548. private _scene;
  128549. private _origin;
  128550. private _options;
  128551. private _physicsEngine;
  128552. private _originTop;
  128553. private _originDirection;
  128554. private _tickCallback;
  128555. private _cylinder;
  128556. private _cylinderPosition;
  128557. private _dataFetched;
  128558. /**
  128559. * Initializes the physics updraft event
  128560. * @param _scene BabylonJS scene
  128561. * @param _origin The origin position of the updraft
  128562. * @param _options The options for the updraft event
  128563. */
  128564. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  128565. /**
  128566. * Returns the data related to the updraft event (cylinder).
  128567. * @returns A physics updraft event
  128568. */
  128569. getData(): PhysicsUpdraftEventData;
  128570. /**
  128571. * Enables the updraft.
  128572. */
  128573. enable(): void;
  128574. /**
  128575. * Disables the updraft.
  128576. */
  128577. disable(): void;
  128578. /**
  128579. * Disposes the cylinder.
  128580. * @param force Specifies if the updraft should be disposed by force
  128581. */
  128582. dispose(force?: boolean): void;
  128583. private getImpostorHitData;
  128584. private _tick;
  128585. /*** Helpers ***/
  128586. private _prepareCylinder;
  128587. private _intersectsWithCylinder;
  128588. }
  128589. /**
  128590. * Represents a physics vortex event
  128591. */
  128592. class PhysicsVortexEvent {
  128593. private _scene;
  128594. private _origin;
  128595. private _options;
  128596. private _physicsEngine;
  128597. private _originTop;
  128598. private _tickCallback;
  128599. private _cylinder;
  128600. private _cylinderPosition;
  128601. private _dataFetched;
  128602. /**
  128603. * Initializes the physics vortex event
  128604. * @param _scene The BabylonJS scene
  128605. * @param _origin The origin position of the vortex
  128606. * @param _options The options for the vortex event
  128607. */
  128608. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  128609. /**
  128610. * Returns the data related to the vortex event (cylinder).
  128611. * @returns The physics vortex event data
  128612. */
  128613. getData(): PhysicsVortexEventData;
  128614. /**
  128615. * Enables the vortex.
  128616. */
  128617. enable(): void;
  128618. /**
  128619. * Disables the cortex.
  128620. */
  128621. disable(): void;
  128622. /**
  128623. * Disposes the sphere.
  128624. * @param force
  128625. */
  128626. dispose(force?: boolean): void;
  128627. private getImpostorHitData;
  128628. private _tick;
  128629. /*** Helpers ***/
  128630. private _prepareCylinder;
  128631. private _intersectsWithCylinder;
  128632. }
  128633. /**
  128634. * Options fot the radial explosion event
  128635. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  128636. */
  128637. export class PhysicsRadialExplosionEventOptions {
  128638. /**
  128639. * The radius of the sphere for the radial explosion.
  128640. */
  128641. radius: number;
  128642. /**
  128643. * The strenth of the explosion.
  128644. */
  128645. strength: number;
  128646. /**
  128647. * The strenght of the force in correspondence to the distance of the affected object
  128648. */
  128649. falloff: PhysicsRadialImpulseFalloff;
  128650. /**
  128651. * Sphere options for the radial explosion.
  128652. */
  128653. sphere: {
  128654. segments: number;
  128655. diameter: number;
  128656. };
  128657. /**
  128658. * Sphere options for the radial explosion.
  128659. */
  128660. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  128661. }
  128662. /**
  128663. * Options fot the updraft event
  128664. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  128665. */
  128666. export class PhysicsUpdraftEventOptions {
  128667. /**
  128668. * The radius of the cylinder for the vortex
  128669. */
  128670. radius: number;
  128671. /**
  128672. * The strenth of the updraft.
  128673. */
  128674. strength: number;
  128675. /**
  128676. * The height of the cylinder for the updraft.
  128677. */
  128678. height: number;
  128679. /**
  128680. * The mode for the the updraft.
  128681. */
  128682. updraftMode: PhysicsUpdraftMode;
  128683. }
  128684. /**
  128685. * Options fot the vortex event
  128686. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  128687. */
  128688. export class PhysicsVortexEventOptions {
  128689. /**
  128690. * The radius of the cylinder for the vortex
  128691. */
  128692. radius: number;
  128693. /**
  128694. * The strenth of the vortex.
  128695. */
  128696. strength: number;
  128697. /**
  128698. * The height of the cylinder for the vortex.
  128699. */
  128700. height: number;
  128701. /**
  128702. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  128703. */
  128704. centripetalForceThreshold: number;
  128705. /**
  128706. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  128707. */
  128708. centripetalForceMultiplier: number;
  128709. /**
  128710. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  128711. */
  128712. centrifugalForceMultiplier: number;
  128713. /**
  128714. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  128715. */
  128716. updraftForceMultiplier: number;
  128717. }
  128718. /**
  128719. * The strenght of the force in correspondence to the distance of the affected object
  128720. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  128721. */
  128722. export enum PhysicsRadialImpulseFalloff {
  128723. /** Defines that impulse is constant in strength across it's whole radius */
  128724. Constant = 0,
  128725. /** Defines that impulse gets weaker if it's further from the origin */
  128726. Linear = 1
  128727. }
  128728. /**
  128729. * The strength of the force in correspondence to the distance of the affected object
  128730. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  128731. */
  128732. export enum PhysicsUpdraftMode {
  128733. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  128734. Center = 0,
  128735. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  128736. Perpendicular = 1
  128737. }
  128738. /**
  128739. * Interface for a physics hit data
  128740. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  128741. */
  128742. export interface PhysicsHitData {
  128743. /**
  128744. * The force applied at the contact point
  128745. */
  128746. force: Vector3;
  128747. /**
  128748. * The contact point
  128749. */
  128750. contactPoint: Vector3;
  128751. /**
  128752. * The distance from the origin to the contact point
  128753. */
  128754. distanceFromOrigin: number;
  128755. }
  128756. /**
  128757. * Interface for radial explosion event data
  128758. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  128759. */
  128760. export interface PhysicsRadialExplosionEventData {
  128761. /**
  128762. * A sphere used for the radial explosion event
  128763. */
  128764. sphere: Mesh;
  128765. }
  128766. /**
  128767. * Interface for gravitational field event data
  128768. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  128769. */
  128770. export interface PhysicsGravitationalFieldEventData {
  128771. /**
  128772. * A sphere mesh used for the gravitational field event
  128773. */
  128774. sphere: Mesh;
  128775. }
  128776. /**
  128777. * Interface for updraft event data
  128778. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  128779. */
  128780. export interface PhysicsUpdraftEventData {
  128781. /**
  128782. * A cylinder used for the updraft event
  128783. */
  128784. cylinder: Mesh;
  128785. }
  128786. /**
  128787. * Interface for vortex event data
  128788. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  128789. */
  128790. export interface PhysicsVortexEventData {
  128791. /**
  128792. * A cylinder used for the vortex event
  128793. */
  128794. cylinder: Mesh;
  128795. }
  128796. /**
  128797. * Interface for an affected physics impostor
  128798. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  128799. */
  128800. export interface PhysicsAffectedImpostorWithData {
  128801. /**
  128802. * The impostor affected by the effect
  128803. */
  128804. impostor: PhysicsImpostor;
  128805. /**
  128806. * The data about the hit/horce from the explosion
  128807. */
  128808. hitData: PhysicsHitData;
  128809. }
  128810. }
  128811. declare module BABYLON {
  128812. /** @hidden */
  128813. export var blackAndWhitePixelShader: {
  128814. name: string;
  128815. shader: string;
  128816. };
  128817. }
  128818. declare module BABYLON {
  128819. /**
  128820. * Post process used to render in black and white
  128821. */
  128822. export class BlackAndWhitePostProcess extends PostProcess {
  128823. /**
  128824. * Linear about to convert he result to black and white (default: 1)
  128825. */
  128826. degree: number;
  128827. /**
  128828. * Creates a black and white post process
  128829. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  128830. * @param name The name of the effect.
  128831. * @param options The required width/height ratio to downsize to before computing the render pass.
  128832. * @param camera The camera to apply the render pass to.
  128833. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  128834. * @param engine The engine which the post process will be applied. (default: current engine)
  128835. * @param reusable If the post process can be reused on the same frame. (default: false)
  128836. */
  128837. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  128838. }
  128839. }
  128840. declare module BABYLON {
  128841. /**
  128842. * This represents a set of one or more post processes in Babylon.
  128843. * A post process can be used to apply a shader to a texture after it is rendered.
  128844. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  128845. */
  128846. export class PostProcessRenderEffect {
  128847. private _postProcesses;
  128848. private _getPostProcesses;
  128849. private _singleInstance;
  128850. private _cameras;
  128851. private _indicesForCamera;
  128852. /**
  128853. * Name of the effect
  128854. * @hidden
  128855. */
  128856. _name: string;
  128857. /**
  128858. * Instantiates a post process render effect.
  128859. * A post process can be used to apply a shader to a texture after it is rendered.
  128860. * @param engine The engine the effect is tied to
  128861. * @param name The name of the effect
  128862. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  128863. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  128864. */
  128865. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  128866. /**
  128867. * Checks if all the post processes in the effect are supported.
  128868. */
  128869. readonly isSupported: boolean;
  128870. /**
  128871. * Updates the current state of the effect
  128872. * @hidden
  128873. */
  128874. _update(): void;
  128875. /**
  128876. * Attaches the effect on cameras
  128877. * @param cameras The camera to attach to.
  128878. * @hidden
  128879. */
  128880. _attachCameras(cameras: Camera): void;
  128881. /**
  128882. * Attaches the effect on cameras
  128883. * @param cameras The camera to attach to.
  128884. * @hidden
  128885. */
  128886. _attachCameras(cameras: Camera[]): void;
  128887. /**
  128888. * Detaches the effect on cameras
  128889. * @param cameras The camera to detatch from.
  128890. * @hidden
  128891. */
  128892. _detachCameras(cameras: Camera): void;
  128893. /**
  128894. * Detatches the effect on cameras
  128895. * @param cameras The camera to detatch from.
  128896. * @hidden
  128897. */
  128898. _detachCameras(cameras: Camera[]): void;
  128899. /**
  128900. * Enables the effect on given cameras
  128901. * @param cameras The camera to enable.
  128902. * @hidden
  128903. */
  128904. _enable(cameras: Camera): void;
  128905. /**
  128906. * Enables the effect on given cameras
  128907. * @param cameras The camera to enable.
  128908. * @hidden
  128909. */
  128910. _enable(cameras: Nullable<Camera[]>): void;
  128911. /**
  128912. * Disables the effect on the given cameras
  128913. * @param cameras The camera to disable.
  128914. * @hidden
  128915. */
  128916. _disable(cameras: Camera): void;
  128917. /**
  128918. * Disables the effect on the given cameras
  128919. * @param cameras The camera to disable.
  128920. * @hidden
  128921. */
  128922. _disable(cameras: Nullable<Camera[]>): void;
  128923. /**
  128924. * Gets a list of the post processes contained in the effect.
  128925. * @param camera The camera to get the post processes on.
  128926. * @returns The list of the post processes in the effect.
  128927. */
  128928. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  128929. }
  128930. }
  128931. declare module BABYLON {
  128932. /** @hidden */
  128933. export var extractHighlightsPixelShader: {
  128934. name: string;
  128935. shader: string;
  128936. };
  128937. }
  128938. declare module BABYLON {
  128939. /**
  128940. * 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.
  128941. */
  128942. export class ExtractHighlightsPostProcess extends PostProcess {
  128943. /**
  128944. * The luminance threshold, pixels below this value will be set to black.
  128945. */
  128946. threshold: number;
  128947. /** @hidden */
  128948. _exposure: number;
  128949. /**
  128950. * Post process which has the input texture to be used when performing highlight extraction
  128951. * @hidden
  128952. */
  128953. _inputPostProcess: Nullable<PostProcess>;
  128954. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  128955. }
  128956. }
  128957. declare module BABYLON {
  128958. /** @hidden */
  128959. export var bloomMergePixelShader: {
  128960. name: string;
  128961. shader: string;
  128962. };
  128963. }
  128964. declare module BABYLON {
  128965. /**
  128966. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  128967. */
  128968. export class BloomMergePostProcess extends PostProcess {
  128969. /** Weight of the bloom to be added to the original input. */
  128970. weight: number;
  128971. /**
  128972. * Creates a new instance of @see BloomMergePostProcess
  128973. * @param name The name of the effect.
  128974. * @param originalFromInput Post process which's input will be used for the merge.
  128975. * @param blurred Blurred highlights post process which's output will be used.
  128976. * @param weight Weight of the bloom to be added to the original input.
  128977. * @param options The required width/height ratio to downsize to before computing the render pass.
  128978. * @param camera The camera to apply the render pass to.
  128979. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  128980. * @param engine The engine which the post process will be applied. (default: current engine)
  128981. * @param reusable If the post process can be reused on the same frame. (default: false)
  128982. * @param textureType Type of textures used when performing the post process. (default: 0)
  128983. * @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)
  128984. */
  128985. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  128986. /** Weight of the bloom to be added to the original input. */
  128987. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  128988. }
  128989. }
  128990. declare module BABYLON {
  128991. /**
  128992. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  128993. */
  128994. export class BloomEffect extends PostProcessRenderEffect {
  128995. private bloomScale;
  128996. /**
  128997. * @hidden Internal
  128998. */
  128999. _effects: Array<PostProcess>;
  129000. /**
  129001. * @hidden Internal
  129002. */
  129003. _downscale: ExtractHighlightsPostProcess;
  129004. private _blurX;
  129005. private _blurY;
  129006. private _merge;
  129007. /**
  129008. * The luminance threshold to find bright areas of the image to bloom.
  129009. */
  129010. threshold: number;
  129011. /**
  129012. * The strength of the bloom.
  129013. */
  129014. weight: number;
  129015. /**
  129016. * Specifies the size of the bloom blur kernel, relative to the final output size
  129017. */
  129018. kernel: number;
  129019. /**
  129020. * Creates a new instance of @see BloomEffect
  129021. * @param scene The scene the effect belongs to.
  129022. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  129023. * @param bloomKernel The size of the kernel to be used when applying the blur.
  129024. * @param bloomWeight The the strength of bloom.
  129025. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  129026. * @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)
  129027. */
  129028. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  129029. /**
  129030. * Disposes each of the internal effects for a given camera.
  129031. * @param camera The camera to dispose the effect on.
  129032. */
  129033. disposeEffects(camera: Camera): void;
  129034. /**
  129035. * @hidden Internal
  129036. */
  129037. _updateEffects(): void;
  129038. /**
  129039. * Internal
  129040. * @returns if all the contained post processes are ready.
  129041. * @hidden
  129042. */
  129043. _isReady(): boolean;
  129044. }
  129045. }
  129046. declare module BABYLON {
  129047. /** @hidden */
  129048. export var chromaticAberrationPixelShader: {
  129049. name: string;
  129050. shader: string;
  129051. };
  129052. }
  129053. declare module BABYLON {
  129054. /**
  129055. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  129056. */
  129057. export class ChromaticAberrationPostProcess extends PostProcess {
  129058. /**
  129059. * The amount of seperation of rgb channels (default: 30)
  129060. */
  129061. aberrationAmount: number;
  129062. /**
  129063. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  129064. */
  129065. radialIntensity: number;
  129066. /**
  129067. * 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))
  129068. */
  129069. direction: Vector2;
  129070. /**
  129071. * 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))
  129072. */
  129073. centerPosition: Vector2;
  129074. /**
  129075. * Creates a new instance ChromaticAberrationPostProcess
  129076. * @param name The name of the effect.
  129077. * @param screenWidth The width of the screen to apply the effect on.
  129078. * @param screenHeight The height of the screen to apply the effect on.
  129079. * @param options The required width/height ratio to downsize to before computing the render pass.
  129080. * @param camera The camera to apply the render pass to.
  129081. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  129082. * @param engine The engine which the post process will be applied. (default: current engine)
  129083. * @param reusable If the post process can be reused on the same frame. (default: false)
  129084. * @param textureType Type of textures used when performing the post process. (default: 0)
  129085. * @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)
  129086. */
  129087. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  129088. }
  129089. }
  129090. declare module BABYLON {
  129091. /** @hidden */
  129092. export var circleOfConfusionPixelShader: {
  129093. name: string;
  129094. shader: string;
  129095. };
  129096. }
  129097. declare module BABYLON {
  129098. /**
  129099. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  129100. */
  129101. export class CircleOfConfusionPostProcess extends PostProcess {
  129102. /**
  129103. * 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.
  129104. */
  129105. lensSize: number;
  129106. /**
  129107. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  129108. */
  129109. fStop: number;
  129110. /**
  129111. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  129112. */
  129113. focusDistance: number;
  129114. /**
  129115. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  129116. */
  129117. focalLength: number;
  129118. private _depthTexture;
  129119. /**
  129120. * Creates a new instance CircleOfConfusionPostProcess
  129121. * @param name The name of the effect.
  129122. * @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.
  129123. * @param options The required width/height ratio to downsize to before computing the render pass.
  129124. * @param camera The camera to apply the render pass to.
  129125. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  129126. * @param engine The engine which the post process will be applied. (default: current engine)
  129127. * @param reusable If the post process can be reused on the same frame. (default: false)
  129128. * @param textureType Type of textures used when performing the post process. (default: 0)
  129129. * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)
  129130. */
  129131. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  129132. /**
  129133. * 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.
  129134. */
  129135. depthTexture: RenderTargetTexture;
  129136. }
  129137. }
  129138. declare module BABYLON {
  129139. /** @hidden */
  129140. export var colorCorrectionPixelShader: {
  129141. name: string;
  129142. shader: string;
  129143. };
  129144. }
  129145. declare module BABYLON {
  129146. /**
  129147. *
  129148. * This post-process allows the modification of rendered colors by using
  129149. * a 'look-up table' (LUT). This effect is also called Color Grading.
  129150. *
  129151. * The object needs to be provided an url to a texture containing the color
  129152. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  129153. * Use an image editing software to tweak the LUT to match your needs.
  129154. *
  129155. * For an example of a color LUT, see here:
  129156. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  129157. * For explanations on color grading, see here:
  129158. * @see http://udn.epicgames.com/Three/ColorGrading.html
  129159. *
  129160. */
  129161. export class ColorCorrectionPostProcess extends PostProcess {
  129162. private _colorTableTexture;
  129163. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  129164. }
  129165. }
  129166. declare module BABYLON {
  129167. /** @hidden */
  129168. export var convolutionPixelShader: {
  129169. name: string;
  129170. shader: string;
  129171. };
  129172. }
  129173. declare module BABYLON {
  129174. /**
  129175. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  129176. * input texture to perform effects such as edge detection or sharpening
  129177. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  129178. */
  129179. export class ConvolutionPostProcess extends PostProcess {
  129180. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  129181. kernel: number[];
  129182. /**
  129183. * Creates a new instance ConvolutionPostProcess
  129184. * @param name The name of the effect.
  129185. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  129186. * @param options The required width/height ratio to downsize to before computing the render pass.
  129187. * @param camera The camera to apply the render pass to.
  129188. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  129189. * @param engine The engine which the post process will be applied. (default: current engine)
  129190. * @param reusable If the post process can be reused on the same frame. (default: false)
  129191. * @param textureType Type of textures used when performing the post process. (default: 0)
  129192. */
  129193. constructor(name: string,
  129194. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  129195. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  129196. /**
  129197. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  129198. */
  129199. static EdgeDetect0Kernel: number[];
  129200. /**
  129201. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  129202. */
  129203. static EdgeDetect1Kernel: number[];
  129204. /**
  129205. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  129206. */
  129207. static EdgeDetect2Kernel: number[];
  129208. /**
  129209. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  129210. */
  129211. static SharpenKernel: number[];
  129212. /**
  129213. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  129214. */
  129215. static EmbossKernel: number[];
  129216. /**
  129217. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  129218. */
  129219. static GaussianKernel: number[];
  129220. }
  129221. }
  129222. declare module BABYLON {
  129223. /**
  129224. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  129225. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  129226. * based on samples that have a large difference in distance than the center pixel.
  129227. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  129228. */
  129229. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  129230. direction: Vector2;
  129231. /**
  129232. * Creates a new instance CircleOfConfusionPostProcess
  129233. * @param name The name of the effect.
  129234. * @param scene The scene the effect belongs to.
  129235. * @param direction The direction the blur should be applied.
  129236. * @param kernel The size of the kernel used to blur.
  129237. * @param options The required width/height ratio to downsize to before computing the render pass.
  129238. * @param camera The camera to apply the render pass to.
  129239. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  129240. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  129241. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  129242. * @param engine The engine which the post process will be applied. (default: current engine)
  129243. * @param reusable If the post process can be reused on the same frame. (default: false)
  129244. * @param textureType Type of textures used when performing the post process. (default: 0)
  129245. * @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)
  129246. */
  129247. 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);
  129248. }
  129249. }
  129250. declare module BABYLON {
  129251. /** @hidden */
  129252. export var depthOfFieldMergePixelShader: {
  129253. name: string;
  129254. shader: string;
  129255. };
  129256. }
  129257. declare module BABYLON {
  129258. /**
  129259. * Options to be set when merging outputs from the default pipeline.
  129260. */
  129261. export class DepthOfFieldMergePostProcessOptions {
  129262. /**
  129263. * The original image to merge on top of
  129264. */
  129265. originalFromInput: PostProcess;
  129266. /**
  129267. * Parameters to perform the merge of the depth of field effect
  129268. */
  129269. depthOfField?: {
  129270. circleOfConfusion: PostProcess;
  129271. blurSteps: Array<PostProcess>;
  129272. };
  129273. /**
  129274. * Parameters to perform the merge of bloom effect
  129275. */
  129276. bloom?: {
  129277. blurred: PostProcess;
  129278. weight: number;
  129279. };
  129280. }
  129281. /**
  129282. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  129283. */
  129284. export class DepthOfFieldMergePostProcess extends PostProcess {
  129285. private blurSteps;
  129286. /**
  129287. * Creates a new instance of DepthOfFieldMergePostProcess
  129288. * @param name The name of the effect.
  129289. * @param originalFromInput Post process which's input will be used for the merge.
  129290. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  129291. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  129292. * @param options The required width/height ratio to downsize to before computing the render pass.
  129293. * @param camera The camera to apply the render pass to.
  129294. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  129295. * @param engine The engine which the post process will be applied. (default: current engine)
  129296. * @param reusable If the post process can be reused on the same frame. (default: false)
  129297. * @param textureType Type of textures used when performing the post process. (default: 0)
  129298. * @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)
  129299. */
  129300. 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);
  129301. /**
  129302. * Updates the effect with the current post process compile time values and recompiles the shader.
  129303. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  129304. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  129305. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  129306. * @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
  129307. * @param onCompiled Called when the shader has been compiled.
  129308. * @param onError Called if there is an error when compiling a shader.
  129309. */
  129310. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  129311. }
  129312. }
  129313. declare module BABYLON {
  129314. /**
  129315. * Specifies the level of max blur that should be applied when using the depth of field effect
  129316. */
  129317. export enum DepthOfFieldEffectBlurLevel {
  129318. /**
  129319. * Subtle blur
  129320. */
  129321. Low = 0,
  129322. /**
  129323. * Medium blur
  129324. */
  129325. Medium = 1,
  129326. /**
  129327. * Large blur
  129328. */
  129329. High = 2
  129330. }
  129331. /**
  129332. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  129333. */
  129334. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  129335. private _circleOfConfusion;
  129336. /**
  129337. * @hidden Internal, blurs from high to low
  129338. */
  129339. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  129340. private _depthOfFieldBlurY;
  129341. private _dofMerge;
  129342. /**
  129343. * @hidden Internal post processes in depth of field effect
  129344. */
  129345. _effects: Array<PostProcess>;
  129346. /**
  129347. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  129348. */
  129349. focalLength: number;
  129350. /**
  129351. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  129352. */
  129353. fStop: number;
  129354. /**
  129355. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  129356. */
  129357. focusDistance: number;
  129358. /**
  129359. * 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.
  129360. */
  129361. lensSize: number;
  129362. /**
  129363. * Creates a new instance DepthOfFieldEffect
  129364. * @param scene The scene the effect belongs to.
  129365. * @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.
  129366. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  129367. * @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)
  129368. */
  129369. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  129370. /**
  129371. * Get the current class name of the current effet
  129372. * @returns "DepthOfFieldEffect"
  129373. */
  129374. getClassName(): string;
  129375. /**
  129376. * 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.
  129377. */
  129378. depthTexture: RenderTargetTexture;
  129379. /**
  129380. * Disposes each of the internal effects for a given camera.
  129381. * @param camera The camera to dispose the effect on.
  129382. */
  129383. disposeEffects(camera: Camera): void;
  129384. /**
  129385. * @hidden Internal
  129386. */
  129387. _updateEffects(): void;
  129388. /**
  129389. * Internal
  129390. * @returns if all the contained post processes are ready.
  129391. * @hidden
  129392. */
  129393. _isReady(): boolean;
  129394. }
  129395. }
  129396. declare module BABYLON {
  129397. /** @hidden */
  129398. export var displayPassPixelShader: {
  129399. name: string;
  129400. shader: string;
  129401. };
  129402. }
  129403. declare module BABYLON {
  129404. /**
  129405. * DisplayPassPostProcess which produces an output the same as it's input
  129406. */
  129407. export class DisplayPassPostProcess extends PostProcess {
  129408. /**
  129409. * Creates the DisplayPassPostProcess
  129410. * @param name The name of the effect.
  129411. * @param options The required width/height ratio to downsize to before computing the render pass.
  129412. * @param camera The camera to apply the render pass to.
  129413. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  129414. * @param engine The engine which the post process will be applied. (default: current engine)
  129415. * @param reusable If the post process can be reused on the same frame. (default: false)
  129416. */
  129417. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  129418. }
  129419. }
  129420. declare module BABYLON {
  129421. /** @hidden */
  129422. export var filterPixelShader: {
  129423. name: string;
  129424. shader: string;
  129425. };
  129426. }
  129427. declare module BABYLON {
  129428. /**
  129429. * Applies a kernel filter to the image
  129430. */
  129431. export class FilterPostProcess extends PostProcess {
  129432. /** The matrix to be applied to the image */
  129433. kernelMatrix: Matrix;
  129434. /**
  129435. *
  129436. * @param name The name of the effect.
  129437. * @param kernelMatrix The matrix to be applied to the image
  129438. * @param options The required width/height ratio to downsize to before computing the render pass.
  129439. * @param camera The camera to apply the render pass to.
  129440. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  129441. * @param engine The engine which the post process will be applied. (default: current engine)
  129442. * @param reusable If the post process can be reused on the same frame. (default: false)
  129443. */
  129444. constructor(name: string,
  129445. /** The matrix to be applied to the image */
  129446. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  129447. }
  129448. }
  129449. declare module BABYLON {
  129450. /** @hidden */
  129451. export var fxaaPixelShader: {
  129452. name: string;
  129453. shader: string;
  129454. };
  129455. }
  129456. declare module BABYLON {
  129457. /** @hidden */
  129458. export var fxaaVertexShader: {
  129459. name: string;
  129460. shader: string;
  129461. };
  129462. }
  129463. declare module BABYLON {
  129464. /**
  129465. * Fxaa post process
  129466. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  129467. */
  129468. export class FxaaPostProcess extends PostProcess {
  129469. /** @hidden */
  129470. texelWidth: number;
  129471. /** @hidden */
  129472. texelHeight: number;
  129473. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  129474. private _getDefines;
  129475. }
  129476. }
  129477. declare module BABYLON {
  129478. /** @hidden */
  129479. export var grainPixelShader: {
  129480. name: string;
  129481. shader: string;
  129482. };
  129483. }
  129484. declare module BABYLON {
  129485. /**
  129486. * The GrainPostProcess adds noise to the image at mid luminance levels
  129487. */
  129488. export class GrainPostProcess extends PostProcess {
  129489. /**
  129490. * The intensity of the grain added (default: 30)
  129491. */
  129492. intensity: number;
  129493. /**
  129494. * If the grain should be randomized on every frame
  129495. */
  129496. animated: boolean;
  129497. /**
  129498. * Creates a new instance of @see GrainPostProcess
  129499. * @param name The name of the effect.
  129500. * @param options The required width/height ratio to downsize to before computing the render pass.
  129501. * @param camera The camera to apply the render pass to.
  129502. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  129503. * @param engine The engine which the post process will be applied. (default: current engine)
  129504. * @param reusable If the post process can be reused on the same frame. (default: false)
  129505. * @param textureType Type of textures used when performing the post process. (default: 0)
  129506. * @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)
  129507. */
  129508. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  129509. }
  129510. }
  129511. declare module BABYLON {
  129512. /** @hidden */
  129513. export var highlightsPixelShader: {
  129514. name: string;
  129515. shader: string;
  129516. };
  129517. }
  129518. declare module BABYLON {
  129519. /**
  129520. * Extracts highlights from the image
  129521. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  129522. */
  129523. export class HighlightsPostProcess extends PostProcess {
  129524. /**
  129525. * Extracts highlights from the image
  129526. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  129527. * @param name The name of the effect.
  129528. * @param options The required width/height ratio to downsize to before computing the render pass.
  129529. * @param camera The camera to apply the render pass to.
  129530. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  129531. * @param engine The engine which the post process will be applied. (default: current engine)
  129532. * @param reusable If the post process can be reused on the same frame. (default: false)
  129533. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  129534. */
  129535. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  129536. }
  129537. }
  129538. declare module BABYLON {
  129539. /** @hidden */
  129540. export var mrtFragmentDeclaration: {
  129541. name: string;
  129542. shader: string;
  129543. };
  129544. }
  129545. declare module BABYLON {
  129546. /** @hidden */
  129547. export var geometryPixelShader: {
  129548. name: string;
  129549. shader: string;
  129550. };
  129551. }
  129552. declare module BABYLON {
  129553. /** @hidden */
  129554. export var geometryVertexShader: {
  129555. name: string;
  129556. shader: string;
  129557. };
  129558. }
  129559. declare module BABYLON {
  129560. /** @hidden */
  129561. interface ISavedTransformationMatrix {
  129562. world: Matrix;
  129563. viewProjection: Matrix;
  129564. }
  129565. /**
  129566. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  129567. */
  129568. export class GeometryBufferRenderer {
  129569. /**
  129570. * Constant used to retrieve the position texture index in the G-Buffer textures array
  129571. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  129572. */
  129573. static readonly POSITION_TEXTURE_TYPE: number;
  129574. /**
  129575. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  129576. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  129577. */
  129578. static readonly VELOCITY_TEXTURE_TYPE: number;
  129579. /**
  129580. * Dictionary used to store the previous transformation matrices of each rendered mesh
  129581. * in order to compute objects velocities when enableVelocity is set to "true"
  129582. * @hidden
  129583. */
  129584. _previousTransformationMatrices: {
  129585. [index: number]: ISavedTransformationMatrix;
  129586. };
  129587. /**
  129588. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  129589. * in order to compute objects velocities when enableVelocity is set to "true"
  129590. * @hidden
  129591. */
  129592. _previousBonesTransformationMatrices: {
  129593. [index: number]: Float32Array;
  129594. };
  129595. /**
  129596. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  129597. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  129598. */
  129599. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  129600. private _scene;
  129601. private _multiRenderTarget;
  129602. private _ratio;
  129603. private _enablePosition;
  129604. private _enableVelocity;
  129605. private _positionIndex;
  129606. private _velocityIndex;
  129607. protected _effect: Effect;
  129608. protected _cachedDefines: string;
  129609. /**
  129610. * Set the render list (meshes to be rendered) used in the G buffer.
  129611. */
  129612. renderList: Mesh[];
  129613. /**
  129614. * Gets wether or not G buffer are supported by the running hardware.
  129615. * This requires draw buffer supports
  129616. */
  129617. readonly isSupported: boolean;
  129618. /**
  129619. * Returns the index of the given texture type in the G-Buffer textures array
  129620. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  129621. * @returns the index of the given texture type in the G-Buffer textures array
  129622. */
  129623. getTextureIndex(textureType: number): number;
  129624. /**
  129625. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  129626. */
  129627. /**
  129628. * Sets whether or not objects positions are enabled for the G buffer.
  129629. */
  129630. enablePosition: boolean;
  129631. /**
  129632. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  129633. */
  129634. /**
  129635. * Sets wether or not objects velocities are enabled for the G buffer.
  129636. */
  129637. enableVelocity: boolean;
  129638. /**
  129639. * Gets the scene associated with the buffer.
  129640. */
  129641. readonly scene: Scene;
  129642. /**
  129643. * Gets the ratio used by the buffer during its creation.
  129644. * How big is the buffer related to the main canvas.
  129645. */
  129646. readonly ratio: number;
  129647. /** @hidden */
  129648. static _SceneComponentInitialization: (scene: Scene) => void;
  129649. /**
  129650. * Creates a new G Buffer for the scene
  129651. * @param scene The scene the buffer belongs to
  129652. * @param ratio How big is the buffer related to the main canvas.
  129653. */
  129654. constructor(scene: Scene, ratio?: number);
  129655. /**
  129656. * Checks wether everything is ready to render a submesh to the G buffer.
  129657. * @param subMesh the submesh to check readiness for
  129658. * @param useInstances is the mesh drawn using instance or not
  129659. * @returns true if ready otherwise false
  129660. */
  129661. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  129662. /**
  129663. * Gets the current underlying G Buffer.
  129664. * @returns the buffer
  129665. */
  129666. getGBuffer(): MultiRenderTarget;
  129667. /**
  129668. * Gets the number of samples used to render the buffer (anti aliasing).
  129669. */
  129670. /**
  129671. * Sets the number of samples used to render the buffer (anti aliasing).
  129672. */
  129673. samples: number;
  129674. /**
  129675. * Disposes the renderer and frees up associated resources.
  129676. */
  129677. dispose(): void;
  129678. protected _createRenderTargets(): void;
  129679. private _copyBonesTransformationMatrices;
  129680. }
  129681. }
  129682. declare module BABYLON {
  129683. interface Scene {
  129684. /** @hidden (Backing field) */
  129685. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  129686. /**
  129687. * Gets or Sets the current geometry buffer associated to the scene.
  129688. */
  129689. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  129690. /**
  129691. * Enables a GeometryBufferRender and associates it with the scene
  129692. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  129693. * @returns the GeometryBufferRenderer
  129694. */
  129695. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  129696. /**
  129697. * Disables the GeometryBufferRender associated with the scene
  129698. */
  129699. disableGeometryBufferRenderer(): void;
  129700. }
  129701. /**
  129702. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  129703. * in several rendering techniques.
  129704. */
  129705. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  129706. /**
  129707. * The component name helpful to identify the component in the list of scene components.
  129708. */
  129709. readonly name: string;
  129710. /**
  129711. * The scene the component belongs to.
  129712. */
  129713. scene: Scene;
  129714. /**
  129715. * Creates a new instance of the component for the given scene
  129716. * @param scene Defines the scene to register the component in
  129717. */
  129718. constructor(scene: Scene);
  129719. /**
  129720. * Registers the component in a given scene
  129721. */
  129722. register(): void;
  129723. /**
  129724. * Rebuilds the elements related to this component in case of
  129725. * context lost for instance.
  129726. */
  129727. rebuild(): void;
  129728. /**
  129729. * Disposes the component and the associated ressources
  129730. */
  129731. dispose(): void;
  129732. private _gatherRenderTargets;
  129733. }
  129734. }
  129735. declare module BABYLON {
  129736. /** @hidden */
  129737. export var motionBlurPixelShader: {
  129738. name: string;
  129739. shader: string;
  129740. };
  129741. }
  129742. declare module BABYLON {
  129743. /**
  129744. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  129745. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  129746. * As an example, all you have to do is to create the post-process:
  129747. * var mb = new BABYLON.MotionBlurPostProcess(
  129748. * 'mb', // The name of the effect.
  129749. * scene, // The scene containing the objects to blur according to their velocity.
  129750. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  129751. * camera // The camera to apply the render pass to.
  129752. * );
  129753. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  129754. */
  129755. export class MotionBlurPostProcess extends PostProcess {
  129756. /**
  129757. * Defines how much the image is blurred by the movement. Default value is equal to 1
  129758. */
  129759. motionStrength: number;
  129760. /**
  129761. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  129762. */
  129763. /**
  129764. * Sets the number of iterations to be used for motion blur quality
  129765. */
  129766. motionBlurSamples: number;
  129767. private _motionBlurSamples;
  129768. private _geometryBufferRenderer;
  129769. /**
  129770. * Creates a new instance MotionBlurPostProcess
  129771. * @param name The name of the effect.
  129772. * @param scene The scene containing the objects to blur according to their velocity.
  129773. * @param options The required width/height ratio to downsize to before computing the render pass.
  129774. * @param camera The camera to apply the render pass to.
  129775. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  129776. * @param engine The engine which the post process will be applied. (default: current engine)
  129777. * @param reusable If the post process can be reused on the same frame. (default: false)
  129778. * @param textureType Type of textures used when performing the post process. (default: 0)
  129779. * @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)
  129780. */
  129781. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  129782. /**
  129783. * Excludes the given skinned mesh from computing bones velocities.
  129784. * 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.
  129785. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  129786. */
  129787. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  129788. /**
  129789. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  129790. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  129791. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  129792. */
  129793. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  129794. /**
  129795. * Disposes the post process.
  129796. * @param camera The camera to dispose the post process on.
  129797. */
  129798. dispose(camera?: Camera): void;
  129799. }
  129800. }
  129801. declare module BABYLON {
  129802. /** @hidden */
  129803. export var refractionPixelShader: {
  129804. name: string;
  129805. shader: string;
  129806. };
  129807. }
  129808. declare module BABYLON {
  129809. /**
  129810. * Post process which applies a refractin texture
  129811. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  129812. */
  129813. export class RefractionPostProcess extends PostProcess {
  129814. /** the base color of the refraction (used to taint the rendering) */
  129815. color: Color3;
  129816. /** simulated refraction depth */
  129817. depth: number;
  129818. /** the coefficient of the base color (0 to remove base color tainting) */
  129819. colorLevel: number;
  129820. private _refTexture;
  129821. private _ownRefractionTexture;
  129822. /**
  129823. * Gets or sets the refraction texture
  129824. * Please note that you are responsible for disposing the texture if you set it manually
  129825. */
  129826. refractionTexture: Texture;
  129827. /**
  129828. * Initializes the RefractionPostProcess
  129829. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  129830. * @param name The name of the effect.
  129831. * @param refractionTextureUrl Url of the refraction texture to use
  129832. * @param color the base color of the refraction (used to taint the rendering)
  129833. * @param depth simulated refraction depth
  129834. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  129835. * @param camera The camera to apply the render pass to.
  129836. * @param options The required width/height ratio to downsize to before computing the render pass.
  129837. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  129838. * @param engine The engine which the post process will be applied. (default: current engine)
  129839. * @param reusable If the post process can be reused on the same frame. (default: false)
  129840. */
  129841. constructor(name: string, refractionTextureUrl: string,
  129842. /** the base color of the refraction (used to taint the rendering) */
  129843. color: Color3,
  129844. /** simulated refraction depth */
  129845. depth: number,
  129846. /** the coefficient of the base color (0 to remove base color tainting) */
  129847. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  129848. /**
  129849. * Disposes of the post process
  129850. * @param camera Camera to dispose post process on
  129851. */
  129852. dispose(camera: Camera): void;
  129853. }
  129854. }
  129855. declare module BABYLON {
  129856. /** @hidden */
  129857. export var sharpenPixelShader: {
  129858. name: string;
  129859. shader: string;
  129860. };
  129861. }
  129862. declare module BABYLON {
  129863. /**
  129864. * The SharpenPostProcess applies a sharpen kernel to every pixel
  129865. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  129866. */
  129867. export class SharpenPostProcess extends PostProcess {
  129868. /**
  129869. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  129870. */
  129871. colorAmount: number;
  129872. /**
  129873. * How much sharpness should be applied (default: 0.3)
  129874. */
  129875. edgeAmount: number;
  129876. /**
  129877. * Creates a new instance ConvolutionPostProcess
  129878. * @param name The name of the effect.
  129879. * @param options The required width/height ratio to downsize to before computing the render pass.
  129880. * @param camera The camera to apply the render pass to.
  129881. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  129882. * @param engine The engine which the post process will be applied. (default: current engine)
  129883. * @param reusable If the post process can be reused on the same frame. (default: false)
  129884. * @param textureType Type of textures used when performing the post process. (default: 0)
  129885. * @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)
  129886. */
  129887. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  129888. }
  129889. }
  129890. declare module BABYLON {
  129891. /**
  129892. * PostProcessRenderPipeline
  129893. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  129894. */
  129895. export class PostProcessRenderPipeline {
  129896. private engine;
  129897. private _renderEffects;
  129898. private _renderEffectsForIsolatedPass;
  129899. /**
  129900. * List of inspectable custom properties (used by the Inspector)
  129901. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  129902. */
  129903. inspectableCustomProperties: IInspectable[];
  129904. /**
  129905. * @hidden
  129906. */
  129907. protected _cameras: Camera[];
  129908. /** @hidden */
  129909. _name: string;
  129910. /**
  129911. * Gets pipeline name
  129912. */
  129913. readonly name: string;
  129914. /** Gets the list of attached cameras */
  129915. readonly cameras: Camera[];
  129916. /**
  129917. * Initializes a PostProcessRenderPipeline
  129918. * @param engine engine to add the pipeline to
  129919. * @param name name of the pipeline
  129920. */
  129921. constructor(engine: Engine, name: string);
  129922. /**
  129923. * Gets the class name
  129924. * @returns "PostProcessRenderPipeline"
  129925. */
  129926. getClassName(): string;
  129927. /**
  129928. * If all the render effects in the pipeline are supported
  129929. */
  129930. readonly isSupported: boolean;
  129931. /**
  129932. * Adds an effect to the pipeline
  129933. * @param renderEffect the effect to add
  129934. */
  129935. addEffect(renderEffect: PostProcessRenderEffect): void;
  129936. /** @hidden */
  129937. _rebuild(): void;
  129938. /** @hidden */
  129939. _enableEffect(renderEffectName: string, cameras: Camera): void;
  129940. /** @hidden */
  129941. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  129942. /** @hidden */
  129943. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  129944. /** @hidden */
  129945. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  129946. /** @hidden */
  129947. _attachCameras(cameras: Camera, unique: boolean): void;
  129948. /** @hidden */
  129949. _attachCameras(cameras: Camera[], unique: boolean): void;
  129950. /** @hidden */
  129951. _detachCameras(cameras: Camera): void;
  129952. /** @hidden */
  129953. _detachCameras(cameras: Nullable<Camera[]>): void;
  129954. /** @hidden */
  129955. _update(): void;
  129956. /** @hidden */
  129957. _reset(): void;
  129958. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  129959. /**
  129960. * Disposes of the pipeline
  129961. */
  129962. dispose(): void;
  129963. }
  129964. }
  129965. declare module BABYLON {
  129966. /**
  129967. * PostProcessRenderPipelineManager class
  129968. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  129969. */
  129970. export class PostProcessRenderPipelineManager {
  129971. private _renderPipelines;
  129972. /**
  129973. * Initializes a PostProcessRenderPipelineManager
  129974. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  129975. */
  129976. constructor();
  129977. /**
  129978. * Gets the list of supported render pipelines
  129979. */
  129980. readonly supportedPipelines: PostProcessRenderPipeline[];
  129981. /**
  129982. * Adds a pipeline to the manager
  129983. * @param renderPipeline The pipeline to add
  129984. */
  129985. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  129986. /**
  129987. * Attaches a camera to the pipeline
  129988. * @param renderPipelineName The name of the pipeline to attach to
  129989. * @param cameras the camera to attach
  129990. * @param unique if the camera can be attached multiple times to the pipeline
  129991. */
  129992. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  129993. /**
  129994. * Detaches a camera from the pipeline
  129995. * @param renderPipelineName The name of the pipeline to detach from
  129996. * @param cameras the camera to detach
  129997. */
  129998. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  129999. /**
  130000. * Enables an effect by name on a pipeline
  130001. * @param renderPipelineName the name of the pipeline to enable the effect in
  130002. * @param renderEffectName the name of the effect to enable
  130003. * @param cameras the cameras that the effect should be enabled on
  130004. */
  130005. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  130006. /**
  130007. * Disables an effect by name on a pipeline
  130008. * @param renderPipelineName the name of the pipeline to disable the effect in
  130009. * @param renderEffectName the name of the effect to disable
  130010. * @param cameras the cameras that the effect should be disabled on
  130011. */
  130012. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  130013. /**
  130014. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  130015. */
  130016. update(): void;
  130017. /** @hidden */
  130018. _rebuild(): void;
  130019. /**
  130020. * Disposes of the manager and pipelines
  130021. */
  130022. dispose(): void;
  130023. }
  130024. }
  130025. declare module BABYLON {
  130026. interface Scene {
  130027. /** @hidden (Backing field) */
  130028. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  130029. /**
  130030. * Gets the postprocess render pipeline manager
  130031. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  130032. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  130033. */
  130034. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  130035. }
  130036. /**
  130037. * Defines the Render Pipeline scene component responsible to rendering pipelines
  130038. */
  130039. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  130040. /**
  130041. * The component name helpfull to identify the component in the list of scene components.
  130042. */
  130043. readonly name: string;
  130044. /**
  130045. * The scene the component belongs to.
  130046. */
  130047. scene: Scene;
  130048. /**
  130049. * Creates a new instance of the component for the given scene
  130050. * @param scene Defines the scene to register the component in
  130051. */
  130052. constructor(scene: Scene);
  130053. /**
  130054. * Registers the component in a given scene
  130055. */
  130056. register(): void;
  130057. /**
  130058. * Rebuilds the elements related to this component in case of
  130059. * context lost for instance.
  130060. */
  130061. rebuild(): void;
  130062. /**
  130063. * Disposes the component and the associated ressources
  130064. */
  130065. dispose(): void;
  130066. private _gatherRenderTargets;
  130067. }
  130068. }
  130069. declare module BABYLON {
  130070. /**
  130071. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  130072. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  130073. */
  130074. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  130075. private _scene;
  130076. private _camerasToBeAttached;
  130077. /**
  130078. * ID of the sharpen post process,
  130079. */
  130080. private readonly SharpenPostProcessId;
  130081. /**
  130082. * @ignore
  130083. * ID of the image processing post process;
  130084. */
  130085. readonly ImageProcessingPostProcessId: string;
  130086. /**
  130087. * @ignore
  130088. * ID of the Fast Approximate Anti-Aliasing post process;
  130089. */
  130090. readonly FxaaPostProcessId: string;
  130091. /**
  130092. * ID of the chromatic aberration post process,
  130093. */
  130094. private readonly ChromaticAberrationPostProcessId;
  130095. /**
  130096. * ID of the grain post process
  130097. */
  130098. private readonly GrainPostProcessId;
  130099. /**
  130100. * Sharpen post process which will apply a sharpen convolution to enhance edges
  130101. */
  130102. sharpen: SharpenPostProcess;
  130103. private _sharpenEffect;
  130104. private bloom;
  130105. /**
  130106. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  130107. */
  130108. depthOfField: DepthOfFieldEffect;
  130109. /**
  130110. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  130111. */
  130112. fxaa: FxaaPostProcess;
  130113. /**
  130114. * Image post processing pass used to perform operations such as tone mapping or color grading.
  130115. */
  130116. imageProcessing: ImageProcessingPostProcess;
  130117. /**
  130118. * Chromatic aberration post process which will shift rgb colors in the image
  130119. */
  130120. chromaticAberration: ChromaticAberrationPostProcess;
  130121. private _chromaticAberrationEffect;
  130122. /**
  130123. * Grain post process which add noise to the image
  130124. */
  130125. grain: GrainPostProcess;
  130126. private _grainEffect;
  130127. /**
  130128. * Glow post process which adds a glow to emissive areas of the image
  130129. */
  130130. private _glowLayer;
  130131. /**
  130132. * Animations which can be used to tweak settings over a period of time
  130133. */
  130134. animations: Animation[];
  130135. private _imageProcessingConfigurationObserver;
  130136. private _sharpenEnabled;
  130137. private _bloomEnabled;
  130138. private _depthOfFieldEnabled;
  130139. private _depthOfFieldBlurLevel;
  130140. private _fxaaEnabled;
  130141. private _imageProcessingEnabled;
  130142. private _defaultPipelineTextureType;
  130143. private _bloomScale;
  130144. private _chromaticAberrationEnabled;
  130145. private _grainEnabled;
  130146. private _buildAllowed;
  130147. /**
  130148. * Gets active scene
  130149. */
  130150. readonly scene: Scene;
  130151. /**
  130152. * Enable or disable the sharpen process from the pipeline
  130153. */
  130154. sharpenEnabled: boolean;
  130155. private _resizeObserver;
  130156. private _hardwareScaleLevel;
  130157. private _bloomKernel;
  130158. /**
  130159. * Specifies the size of the bloom blur kernel, relative to the final output size
  130160. */
  130161. bloomKernel: number;
  130162. /**
  130163. * Specifies the weight of the bloom in the final rendering
  130164. */
  130165. private _bloomWeight;
  130166. /**
  130167. * Specifies the luma threshold for the area that will be blurred by the bloom
  130168. */
  130169. private _bloomThreshold;
  130170. private _hdr;
  130171. /**
  130172. * The strength of the bloom.
  130173. */
  130174. bloomWeight: number;
  130175. /**
  130176. * The strength of the bloom.
  130177. */
  130178. bloomThreshold: number;
  130179. /**
  130180. * The scale of the bloom, lower value will provide better performance.
  130181. */
  130182. bloomScale: number;
  130183. /**
  130184. * Enable or disable the bloom from the pipeline
  130185. */
  130186. bloomEnabled: boolean;
  130187. private _rebuildBloom;
  130188. /**
  130189. * If the depth of field is enabled.
  130190. */
  130191. depthOfFieldEnabled: boolean;
  130192. /**
  130193. * Blur level of the depth of field effect. (Higher blur will effect performance)
  130194. */
  130195. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  130196. /**
  130197. * If the anti aliasing is enabled.
  130198. */
  130199. fxaaEnabled: boolean;
  130200. private _samples;
  130201. /**
  130202. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  130203. */
  130204. samples: number;
  130205. /**
  130206. * If image processing is enabled.
  130207. */
  130208. imageProcessingEnabled: boolean;
  130209. /**
  130210. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  130211. */
  130212. glowLayerEnabled: boolean;
  130213. /**
  130214. * Gets the glow layer (or null if not defined)
  130215. */
  130216. readonly glowLayer: Nullable<GlowLayer>;
  130217. /**
  130218. * Enable or disable the chromaticAberration process from the pipeline
  130219. */
  130220. chromaticAberrationEnabled: boolean;
  130221. /**
  130222. * Enable or disable the grain process from the pipeline
  130223. */
  130224. grainEnabled: boolean;
  130225. /**
  130226. * @constructor
  130227. * @param name - The rendering pipeline name (default: "")
  130228. * @param hdr - If high dynamic range textures should be used (default: true)
  130229. * @param scene - The scene linked to this pipeline (default: the last created scene)
  130230. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  130231. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  130232. */
  130233. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  130234. /**
  130235. * Get the class name
  130236. * @returns "DefaultRenderingPipeline"
  130237. */
  130238. getClassName(): string;
  130239. /**
  130240. * Force the compilation of the entire pipeline.
  130241. */
  130242. prepare(): void;
  130243. private _hasCleared;
  130244. private _prevPostProcess;
  130245. private _prevPrevPostProcess;
  130246. private _setAutoClearAndTextureSharing;
  130247. private _depthOfFieldSceneObserver;
  130248. private _buildPipeline;
  130249. private _disposePostProcesses;
  130250. /**
  130251. * Adds a camera to the pipeline
  130252. * @param camera the camera to be added
  130253. */
  130254. addCamera(camera: Camera): void;
  130255. /**
  130256. * Removes a camera from the pipeline
  130257. * @param camera the camera to remove
  130258. */
  130259. removeCamera(camera: Camera): void;
  130260. /**
  130261. * Dispose of the pipeline and stop all post processes
  130262. */
  130263. dispose(): void;
  130264. /**
  130265. * Serialize the rendering pipeline (Used when exporting)
  130266. * @returns the serialized object
  130267. */
  130268. serialize(): any;
  130269. /**
  130270. * Parse the serialized pipeline
  130271. * @param source Source pipeline.
  130272. * @param scene The scene to load the pipeline to.
  130273. * @param rootUrl The URL of the serialized pipeline.
  130274. * @returns An instantiated pipeline from the serialized object.
  130275. */
  130276. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  130277. }
  130278. }
  130279. declare module BABYLON {
  130280. /** @hidden */
  130281. export var lensHighlightsPixelShader: {
  130282. name: string;
  130283. shader: string;
  130284. };
  130285. }
  130286. declare module BABYLON {
  130287. /** @hidden */
  130288. export var depthOfFieldPixelShader: {
  130289. name: string;
  130290. shader: string;
  130291. };
  130292. }
  130293. declare module BABYLON {
  130294. /**
  130295. * BABYLON.JS Chromatic Aberration GLSL Shader
  130296. * Author: Olivier Guyot
  130297. * Separates very slightly R, G and B colors on the edges of the screen
  130298. * Inspired by Francois Tarlier & Martins Upitis
  130299. */
  130300. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  130301. /**
  130302. * @ignore
  130303. * The chromatic aberration PostProcess id in the pipeline
  130304. */
  130305. LensChromaticAberrationEffect: string;
  130306. /**
  130307. * @ignore
  130308. * The highlights enhancing PostProcess id in the pipeline
  130309. */
  130310. HighlightsEnhancingEffect: string;
  130311. /**
  130312. * @ignore
  130313. * The depth-of-field PostProcess id in the pipeline
  130314. */
  130315. LensDepthOfFieldEffect: string;
  130316. private _scene;
  130317. private _depthTexture;
  130318. private _grainTexture;
  130319. private _chromaticAberrationPostProcess;
  130320. private _highlightsPostProcess;
  130321. private _depthOfFieldPostProcess;
  130322. private _edgeBlur;
  130323. private _grainAmount;
  130324. private _chromaticAberration;
  130325. private _distortion;
  130326. private _highlightsGain;
  130327. private _highlightsThreshold;
  130328. private _dofDistance;
  130329. private _dofAperture;
  130330. private _dofDarken;
  130331. private _dofPentagon;
  130332. private _blurNoise;
  130333. /**
  130334. * @constructor
  130335. *
  130336. * Effect parameters are as follow:
  130337. * {
  130338. * chromatic_aberration: number; // from 0 to x (1 for realism)
  130339. * edge_blur: number; // from 0 to x (1 for realism)
  130340. * distortion: number; // from 0 to x (1 for realism)
  130341. * grain_amount: number; // from 0 to 1
  130342. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  130343. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  130344. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  130345. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  130346. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  130347. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  130348. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  130349. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  130350. * }
  130351. * Note: if an effect parameter is unset, effect is disabled
  130352. *
  130353. * @param name The rendering pipeline name
  130354. * @param parameters - An object containing all parameters (see above)
  130355. * @param scene The scene linked to this pipeline
  130356. * @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)
  130357. * @param cameras The array of cameras that the rendering pipeline will be attached to
  130358. */
  130359. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  130360. /**
  130361. * Get the class name
  130362. * @returns "LensRenderingPipeline"
  130363. */
  130364. getClassName(): string;
  130365. /**
  130366. * Gets associated scene
  130367. */
  130368. readonly scene: Scene;
  130369. /**
  130370. * Gets or sets the edge blur
  130371. */
  130372. edgeBlur: number;
  130373. /**
  130374. * Gets or sets the grain amount
  130375. */
  130376. grainAmount: number;
  130377. /**
  130378. * Gets or sets the chromatic aberration amount
  130379. */
  130380. chromaticAberration: number;
  130381. /**
  130382. * Gets or sets the depth of field aperture
  130383. */
  130384. dofAperture: number;
  130385. /**
  130386. * Gets or sets the edge distortion
  130387. */
  130388. edgeDistortion: number;
  130389. /**
  130390. * Gets or sets the depth of field distortion
  130391. */
  130392. dofDistortion: number;
  130393. /**
  130394. * Gets or sets the darken out of focus amount
  130395. */
  130396. darkenOutOfFocus: number;
  130397. /**
  130398. * Gets or sets a boolean indicating if blur noise is enabled
  130399. */
  130400. blurNoise: boolean;
  130401. /**
  130402. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  130403. */
  130404. pentagonBokeh: boolean;
  130405. /**
  130406. * Gets or sets the highlight grain amount
  130407. */
  130408. highlightsGain: number;
  130409. /**
  130410. * Gets or sets the highlight threshold
  130411. */
  130412. highlightsThreshold: number;
  130413. /**
  130414. * Sets the amount of blur at the edges
  130415. * @param amount blur amount
  130416. */
  130417. setEdgeBlur(amount: number): void;
  130418. /**
  130419. * Sets edge blur to 0
  130420. */
  130421. disableEdgeBlur(): void;
  130422. /**
  130423. * Sets the amout of grain
  130424. * @param amount Amount of grain
  130425. */
  130426. setGrainAmount(amount: number): void;
  130427. /**
  130428. * Set grain amount to 0
  130429. */
  130430. disableGrain(): void;
  130431. /**
  130432. * Sets the chromatic aberration amount
  130433. * @param amount amount of chromatic aberration
  130434. */
  130435. setChromaticAberration(amount: number): void;
  130436. /**
  130437. * Sets chromatic aberration amount to 0
  130438. */
  130439. disableChromaticAberration(): void;
  130440. /**
  130441. * Sets the EdgeDistortion amount
  130442. * @param amount amount of EdgeDistortion
  130443. */
  130444. setEdgeDistortion(amount: number): void;
  130445. /**
  130446. * Sets edge distortion to 0
  130447. */
  130448. disableEdgeDistortion(): void;
  130449. /**
  130450. * Sets the FocusDistance amount
  130451. * @param amount amount of FocusDistance
  130452. */
  130453. setFocusDistance(amount: number): void;
  130454. /**
  130455. * Disables depth of field
  130456. */
  130457. disableDepthOfField(): void;
  130458. /**
  130459. * Sets the Aperture amount
  130460. * @param amount amount of Aperture
  130461. */
  130462. setAperture(amount: number): void;
  130463. /**
  130464. * Sets the DarkenOutOfFocus amount
  130465. * @param amount amount of DarkenOutOfFocus
  130466. */
  130467. setDarkenOutOfFocus(amount: number): void;
  130468. private _pentagonBokehIsEnabled;
  130469. /**
  130470. * Creates a pentagon bokeh effect
  130471. */
  130472. enablePentagonBokeh(): void;
  130473. /**
  130474. * Disables the pentagon bokeh effect
  130475. */
  130476. disablePentagonBokeh(): void;
  130477. /**
  130478. * Enables noise blur
  130479. */
  130480. enableNoiseBlur(): void;
  130481. /**
  130482. * Disables noise blur
  130483. */
  130484. disableNoiseBlur(): void;
  130485. /**
  130486. * Sets the HighlightsGain amount
  130487. * @param amount amount of HighlightsGain
  130488. */
  130489. setHighlightsGain(amount: number): void;
  130490. /**
  130491. * Sets the HighlightsThreshold amount
  130492. * @param amount amount of HighlightsThreshold
  130493. */
  130494. setHighlightsThreshold(amount: number): void;
  130495. /**
  130496. * Disables highlights
  130497. */
  130498. disableHighlights(): void;
  130499. /**
  130500. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  130501. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  130502. */
  130503. dispose(disableDepthRender?: boolean): void;
  130504. private _createChromaticAberrationPostProcess;
  130505. private _createHighlightsPostProcess;
  130506. private _createDepthOfFieldPostProcess;
  130507. private _createGrainTexture;
  130508. }
  130509. }
  130510. declare module BABYLON {
  130511. /** @hidden */
  130512. export var ssao2PixelShader: {
  130513. name: string;
  130514. shader: string;
  130515. };
  130516. }
  130517. declare module BABYLON {
  130518. /** @hidden */
  130519. export var ssaoCombinePixelShader: {
  130520. name: string;
  130521. shader: string;
  130522. };
  130523. }
  130524. declare module BABYLON {
  130525. /**
  130526. * Render pipeline to produce ssao effect
  130527. */
  130528. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  130529. /**
  130530. * @ignore
  130531. * The PassPostProcess id in the pipeline that contains the original scene color
  130532. */
  130533. SSAOOriginalSceneColorEffect: string;
  130534. /**
  130535. * @ignore
  130536. * The SSAO PostProcess id in the pipeline
  130537. */
  130538. SSAORenderEffect: string;
  130539. /**
  130540. * @ignore
  130541. * The horizontal blur PostProcess id in the pipeline
  130542. */
  130543. SSAOBlurHRenderEffect: string;
  130544. /**
  130545. * @ignore
  130546. * The vertical blur PostProcess id in the pipeline
  130547. */
  130548. SSAOBlurVRenderEffect: string;
  130549. /**
  130550. * @ignore
  130551. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  130552. */
  130553. SSAOCombineRenderEffect: string;
  130554. /**
  130555. * The output strength of the SSAO post-process. Default value is 1.0.
  130556. */
  130557. totalStrength: number;
  130558. /**
  130559. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  130560. */
  130561. maxZ: number;
  130562. /**
  130563. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  130564. */
  130565. minZAspect: number;
  130566. private _samples;
  130567. /**
  130568. * Number of samples used for the SSAO calculations. Default value is 8
  130569. */
  130570. samples: number;
  130571. private _textureSamples;
  130572. /**
  130573. * Number of samples to use for antialiasing
  130574. */
  130575. textureSamples: number;
  130576. /**
  130577. * Ratio object used for SSAO ratio and blur ratio
  130578. */
  130579. private _ratio;
  130580. /**
  130581. * Dynamically generated sphere sampler.
  130582. */
  130583. private _sampleSphere;
  130584. /**
  130585. * Blur filter offsets
  130586. */
  130587. private _samplerOffsets;
  130588. private _expensiveBlur;
  130589. /**
  130590. * If bilateral blur should be used
  130591. */
  130592. expensiveBlur: boolean;
  130593. /**
  130594. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  130595. */
  130596. radius: number;
  130597. /**
  130598. * The base color of the SSAO post-process
  130599. * The final result is "base + ssao" between [0, 1]
  130600. */
  130601. base: number;
  130602. /**
  130603. * Support test.
  130604. */
  130605. static readonly IsSupported: boolean;
  130606. private _scene;
  130607. private _depthTexture;
  130608. private _normalTexture;
  130609. private _randomTexture;
  130610. private _originalColorPostProcess;
  130611. private _ssaoPostProcess;
  130612. private _blurHPostProcess;
  130613. private _blurVPostProcess;
  130614. private _ssaoCombinePostProcess;
  130615. /**
  130616. * Gets active scene
  130617. */
  130618. readonly scene: Scene;
  130619. /**
  130620. * @constructor
  130621. * @param name The rendering pipeline name
  130622. * @param scene The scene linked to this pipeline
  130623. * @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 }
  130624. * @param cameras The array of cameras that the rendering pipeline will be attached to
  130625. */
  130626. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  130627. /**
  130628. * Get the class name
  130629. * @returns "SSAO2RenderingPipeline"
  130630. */
  130631. getClassName(): string;
  130632. /**
  130633. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  130634. */
  130635. dispose(disableGeometryBufferRenderer?: boolean): void;
  130636. private _createBlurPostProcess;
  130637. /** @hidden */
  130638. _rebuild(): void;
  130639. private _bits;
  130640. private _radicalInverse_VdC;
  130641. private _hammersley;
  130642. private _hemisphereSample_uniform;
  130643. private _generateHemisphere;
  130644. private _createSSAOPostProcess;
  130645. private _createSSAOCombinePostProcess;
  130646. private _createRandomTexture;
  130647. /**
  130648. * Serialize the rendering pipeline (Used when exporting)
  130649. * @returns the serialized object
  130650. */
  130651. serialize(): any;
  130652. /**
  130653. * Parse the serialized pipeline
  130654. * @param source Source pipeline.
  130655. * @param scene The scene to load the pipeline to.
  130656. * @param rootUrl The URL of the serialized pipeline.
  130657. * @returns An instantiated pipeline from the serialized object.
  130658. */
  130659. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  130660. }
  130661. }
  130662. declare module BABYLON {
  130663. /** @hidden */
  130664. export var ssaoPixelShader: {
  130665. name: string;
  130666. shader: string;
  130667. };
  130668. }
  130669. declare module BABYLON {
  130670. /**
  130671. * Render pipeline to produce ssao effect
  130672. */
  130673. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  130674. /**
  130675. * @ignore
  130676. * The PassPostProcess id in the pipeline that contains the original scene color
  130677. */
  130678. SSAOOriginalSceneColorEffect: string;
  130679. /**
  130680. * @ignore
  130681. * The SSAO PostProcess id in the pipeline
  130682. */
  130683. SSAORenderEffect: string;
  130684. /**
  130685. * @ignore
  130686. * The horizontal blur PostProcess id in the pipeline
  130687. */
  130688. SSAOBlurHRenderEffect: string;
  130689. /**
  130690. * @ignore
  130691. * The vertical blur PostProcess id in the pipeline
  130692. */
  130693. SSAOBlurVRenderEffect: string;
  130694. /**
  130695. * @ignore
  130696. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  130697. */
  130698. SSAOCombineRenderEffect: string;
  130699. /**
  130700. * The output strength of the SSAO post-process. Default value is 1.0.
  130701. */
  130702. totalStrength: number;
  130703. /**
  130704. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  130705. */
  130706. radius: number;
  130707. /**
  130708. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  130709. * Must not be equal to fallOff and superior to fallOff.
  130710. * Default value is 0.0075
  130711. */
  130712. area: number;
  130713. /**
  130714. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  130715. * Must not be equal to area and inferior to area.
  130716. * Default value is 0.000001
  130717. */
  130718. fallOff: number;
  130719. /**
  130720. * The base color of the SSAO post-process
  130721. * The final result is "base + ssao" between [0, 1]
  130722. */
  130723. base: number;
  130724. private _scene;
  130725. private _depthTexture;
  130726. private _randomTexture;
  130727. private _originalColorPostProcess;
  130728. private _ssaoPostProcess;
  130729. private _blurHPostProcess;
  130730. private _blurVPostProcess;
  130731. private _ssaoCombinePostProcess;
  130732. private _firstUpdate;
  130733. /**
  130734. * Gets active scene
  130735. */
  130736. readonly scene: Scene;
  130737. /**
  130738. * @constructor
  130739. * @param name - The rendering pipeline name
  130740. * @param scene - The scene linked to this pipeline
  130741. * @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 }
  130742. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  130743. */
  130744. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  130745. /**
  130746. * Get the class name
  130747. * @returns "SSAORenderingPipeline"
  130748. */
  130749. getClassName(): string;
  130750. /**
  130751. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  130752. */
  130753. dispose(disableDepthRender?: boolean): void;
  130754. private _createBlurPostProcess;
  130755. /** @hidden */
  130756. _rebuild(): void;
  130757. private _createSSAOPostProcess;
  130758. private _createSSAOCombinePostProcess;
  130759. private _createRandomTexture;
  130760. }
  130761. }
  130762. declare module BABYLON {
  130763. /** @hidden */
  130764. export var standardPixelShader: {
  130765. name: string;
  130766. shader: string;
  130767. };
  130768. }
  130769. declare module BABYLON {
  130770. /**
  130771. * Standard rendering pipeline
  130772. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  130773. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  130774. */
  130775. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  130776. /**
  130777. * Public members
  130778. */
  130779. /**
  130780. * Post-process which contains the original scene color before the pipeline applies all the effects
  130781. */
  130782. originalPostProcess: Nullable<PostProcess>;
  130783. /**
  130784. * Post-process used to down scale an image x4
  130785. */
  130786. downSampleX4PostProcess: Nullable<PostProcess>;
  130787. /**
  130788. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  130789. */
  130790. brightPassPostProcess: Nullable<PostProcess>;
  130791. /**
  130792. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  130793. */
  130794. blurHPostProcesses: PostProcess[];
  130795. /**
  130796. * Post-process array storing all the vertical blur post-processes used by the pipeline
  130797. */
  130798. blurVPostProcesses: PostProcess[];
  130799. /**
  130800. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  130801. */
  130802. textureAdderPostProcess: Nullable<PostProcess>;
  130803. /**
  130804. * Post-process used to create volumetric lighting effect
  130805. */
  130806. volumetricLightPostProcess: Nullable<PostProcess>;
  130807. /**
  130808. * Post-process used to smooth the previous volumetric light post-process on the X axis
  130809. */
  130810. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  130811. /**
  130812. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  130813. */
  130814. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  130815. /**
  130816. * Post-process used to merge the volumetric light effect and the real scene color
  130817. */
  130818. volumetricLightMergePostProces: Nullable<PostProcess>;
  130819. /**
  130820. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  130821. */
  130822. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  130823. /**
  130824. * Base post-process used to calculate the average luminance of the final image for HDR
  130825. */
  130826. luminancePostProcess: Nullable<PostProcess>;
  130827. /**
  130828. * Post-processes used to create down sample post-processes in order to get
  130829. * the average luminance of the final image for HDR
  130830. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  130831. */
  130832. luminanceDownSamplePostProcesses: PostProcess[];
  130833. /**
  130834. * Post-process used to create a HDR effect (light adaptation)
  130835. */
  130836. hdrPostProcess: Nullable<PostProcess>;
  130837. /**
  130838. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  130839. */
  130840. textureAdderFinalPostProcess: Nullable<PostProcess>;
  130841. /**
  130842. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  130843. */
  130844. lensFlareFinalPostProcess: Nullable<PostProcess>;
  130845. /**
  130846. * Post-process used to merge the final HDR post-process and the real scene color
  130847. */
  130848. hdrFinalPostProcess: Nullable<PostProcess>;
  130849. /**
  130850. * Post-process used to create a lens flare effect
  130851. */
  130852. lensFlarePostProcess: Nullable<PostProcess>;
  130853. /**
  130854. * Post-process that merges the result of the lens flare post-process and the real scene color
  130855. */
  130856. lensFlareComposePostProcess: Nullable<PostProcess>;
  130857. /**
  130858. * Post-process used to create a motion blur effect
  130859. */
  130860. motionBlurPostProcess: Nullable<PostProcess>;
  130861. /**
  130862. * Post-process used to create a depth of field effect
  130863. */
  130864. depthOfFieldPostProcess: Nullable<PostProcess>;
  130865. /**
  130866. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  130867. */
  130868. fxaaPostProcess: Nullable<FxaaPostProcess>;
  130869. /**
  130870. * Represents the brightness threshold in order to configure the illuminated surfaces
  130871. */
  130872. brightThreshold: number;
  130873. /**
  130874. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  130875. */
  130876. blurWidth: number;
  130877. /**
  130878. * Sets if the blur for highlighted surfaces must be only horizontal
  130879. */
  130880. horizontalBlur: boolean;
  130881. /**
  130882. * Gets the overall exposure used by the pipeline
  130883. */
  130884. /**
  130885. * Sets the overall exposure used by the pipeline
  130886. */
  130887. exposure: number;
  130888. /**
  130889. * Texture used typically to simulate "dirty" on camera lens
  130890. */
  130891. lensTexture: Nullable<Texture>;
  130892. /**
  130893. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  130894. */
  130895. volumetricLightCoefficient: number;
  130896. /**
  130897. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  130898. */
  130899. volumetricLightPower: number;
  130900. /**
  130901. * Used the set the blur intensity to smooth the volumetric lights
  130902. */
  130903. volumetricLightBlurScale: number;
  130904. /**
  130905. * Light (spot or directional) used to generate the volumetric lights rays
  130906. * The source light must have a shadow generate so the pipeline can get its
  130907. * depth map
  130908. */
  130909. sourceLight: Nullable<SpotLight | DirectionalLight>;
  130910. /**
  130911. * For eye adaptation, represents the minimum luminance the eye can see
  130912. */
  130913. hdrMinimumLuminance: number;
  130914. /**
  130915. * For eye adaptation, represents the decrease luminance speed
  130916. */
  130917. hdrDecreaseRate: number;
  130918. /**
  130919. * For eye adaptation, represents the increase luminance speed
  130920. */
  130921. hdrIncreaseRate: number;
  130922. /**
  130923. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  130924. */
  130925. /**
  130926. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  130927. */
  130928. hdrAutoExposure: boolean;
  130929. /**
  130930. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  130931. */
  130932. lensColorTexture: Nullable<Texture>;
  130933. /**
  130934. * The overall strengh for the lens flare effect
  130935. */
  130936. lensFlareStrength: number;
  130937. /**
  130938. * Dispersion coefficient for lens flare ghosts
  130939. */
  130940. lensFlareGhostDispersal: number;
  130941. /**
  130942. * Main lens flare halo width
  130943. */
  130944. lensFlareHaloWidth: number;
  130945. /**
  130946. * Based on the lens distortion effect, defines how much the lens flare result
  130947. * is distorted
  130948. */
  130949. lensFlareDistortionStrength: number;
  130950. /**
  130951. * Configures the blur intensity used for for lens flare (halo)
  130952. */
  130953. lensFlareBlurWidth: number;
  130954. /**
  130955. * Lens star texture must be used to simulate rays on the flares and is available
  130956. * in the documentation
  130957. */
  130958. lensStarTexture: Nullable<Texture>;
  130959. /**
  130960. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  130961. * flare effect by taking account of the dirt texture
  130962. */
  130963. lensFlareDirtTexture: Nullable<Texture>;
  130964. /**
  130965. * Represents the focal length for the depth of field effect
  130966. */
  130967. depthOfFieldDistance: number;
  130968. /**
  130969. * Represents the blur intensity for the blurred part of the depth of field effect
  130970. */
  130971. depthOfFieldBlurWidth: number;
  130972. /**
  130973. * Gets how much the image is blurred by the movement while using the motion blur post-process
  130974. */
  130975. /**
  130976. * Sets how much the image is blurred by the movement while using the motion blur post-process
  130977. */
  130978. motionStrength: number;
  130979. /**
  130980. * Gets wether or not the motion blur post-process is object based or screen based.
  130981. */
  130982. /**
  130983. * Sets wether or not the motion blur post-process should be object based or screen based
  130984. */
  130985. objectBasedMotionBlur: boolean;
  130986. /**
  130987. * List of animations for the pipeline (IAnimatable implementation)
  130988. */
  130989. animations: Animation[];
  130990. /**
  130991. * Private members
  130992. */
  130993. private _scene;
  130994. private _currentDepthOfFieldSource;
  130995. private _basePostProcess;
  130996. private _fixedExposure;
  130997. private _currentExposure;
  130998. private _hdrAutoExposure;
  130999. private _hdrCurrentLuminance;
  131000. private _motionStrength;
  131001. private _isObjectBasedMotionBlur;
  131002. private _floatTextureType;
  131003. private _camerasToBeAttached;
  131004. private _ratio;
  131005. private _bloomEnabled;
  131006. private _depthOfFieldEnabled;
  131007. private _vlsEnabled;
  131008. private _lensFlareEnabled;
  131009. private _hdrEnabled;
  131010. private _motionBlurEnabled;
  131011. private _fxaaEnabled;
  131012. private _motionBlurSamples;
  131013. private _volumetricLightStepsCount;
  131014. private _samples;
  131015. /**
  131016. * @ignore
  131017. * Specifies if the bloom pipeline is enabled
  131018. */
  131019. BloomEnabled: boolean;
  131020. /**
  131021. * @ignore
  131022. * Specifies if the depth of field pipeline is enabed
  131023. */
  131024. DepthOfFieldEnabled: boolean;
  131025. /**
  131026. * @ignore
  131027. * Specifies if the lens flare pipeline is enabed
  131028. */
  131029. LensFlareEnabled: boolean;
  131030. /**
  131031. * @ignore
  131032. * Specifies if the HDR pipeline is enabled
  131033. */
  131034. HDREnabled: boolean;
  131035. /**
  131036. * @ignore
  131037. * Specifies if the volumetric lights scattering effect is enabled
  131038. */
  131039. VLSEnabled: boolean;
  131040. /**
  131041. * @ignore
  131042. * Specifies if the motion blur effect is enabled
  131043. */
  131044. MotionBlurEnabled: boolean;
  131045. /**
  131046. * Specifies if anti-aliasing is enabled
  131047. */
  131048. fxaaEnabled: boolean;
  131049. /**
  131050. * Specifies the number of steps used to calculate the volumetric lights
  131051. * Typically in interval [50, 200]
  131052. */
  131053. volumetricLightStepsCount: number;
  131054. /**
  131055. * Specifies the number of samples used for the motion blur effect
  131056. * Typically in interval [16, 64]
  131057. */
  131058. motionBlurSamples: number;
  131059. /**
  131060. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  131061. */
  131062. samples: number;
  131063. /**
  131064. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  131065. * @constructor
  131066. * @param name The rendering pipeline name
  131067. * @param scene The scene linked to this pipeline
  131068. * @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)
  131069. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  131070. * @param cameras The array of cameras that the rendering pipeline will be attached to
  131071. */
  131072. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  131073. private _buildPipeline;
  131074. private _createDownSampleX4PostProcess;
  131075. private _createBrightPassPostProcess;
  131076. private _createBlurPostProcesses;
  131077. private _createTextureAdderPostProcess;
  131078. private _createVolumetricLightPostProcess;
  131079. private _createLuminancePostProcesses;
  131080. private _createHdrPostProcess;
  131081. private _createLensFlarePostProcess;
  131082. private _createDepthOfFieldPostProcess;
  131083. private _createMotionBlurPostProcess;
  131084. private _getDepthTexture;
  131085. private _disposePostProcesses;
  131086. /**
  131087. * Dispose of the pipeline and stop all post processes
  131088. */
  131089. dispose(): void;
  131090. /**
  131091. * Serialize the rendering pipeline (Used when exporting)
  131092. * @returns the serialized object
  131093. */
  131094. serialize(): any;
  131095. /**
  131096. * Parse the serialized pipeline
  131097. * @param source Source pipeline.
  131098. * @param scene The scene to load the pipeline to.
  131099. * @param rootUrl The URL of the serialized pipeline.
  131100. * @returns An instantiated pipeline from the serialized object.
  131101. */
  131102. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  131103. /**
  131104. * Luminance steps
  131105. */
  131106. static LuminanceSteps: number;
  131107. }
  131108. }
  131109. declare module BABYLON {
  131110. /** @hidden */
  131111. export var tonemapPixelShader: {
  131112. name: string;
  131113. shader: string;
  131114. };
  131115. }
  131116. declare module BABYLON {
  131117. /** Defines operator used for tonemapping */
  131118. export enum TonemappingOperator {
  131119. /** Hable */
  131120. Hable = 0,
  131121. /** Reinhard */
  131122. Reinhard = 1,
  131123. /** HejiDawson */
  131124. HejiDawson = 2,
  131125. /** Photographic */
  131126. Photographic = 3
  131127. }
  131128. /**
  131129. * Defines a post process to apply tone mapping
  131130. */
  131131. export class TonemapPostProcess extends PostProcess {
  131132. private _operator;
  131133. /** Defines the required exposure adjustement */
  131134. exposureAdjustment: number;
  131135. /**
  131136. * Creates a new TonemapPostProcess
  131137. * @param name defines the name of the postprocess
  131138. * @param _operator defines the operator to use
  131139. * @param exposureAdjustment defines the required exposure adjustement
  131140. * @param camera defines the camera to use (can be null)
  131141. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  131142. * @param engine defines the hosting engine (can be ignore if camera is set)
  131143. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  131144. */
  131145. constructor(name: string, _operator: TonemappingOperator,
  131146. /** Defines the required exposure adjustement */
  131147. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  131148. }
  131149. }
  131150. declare module BABYLON {
  131151. /** @hidden */
  131152. export var depthVertexShader: {
  131153. name: string;
  131154. shader: string;
  131155. };
  131156. }
  131157. declare module BABYLON {
  131158. /** @hidden */
  131159. export var volumetricLightScatteringPixelShader: {
  131160. name: string;
  131161. shader: string;
  131162. };
  131163. }
  131164. declare module BABYLON {
  131165. /** @hidden */
  131166. export var volumetricLightScatteringPassVertexShader: {
  131167. name: string;
  131168. shader: string;
  131169. };
  131170. }
  131171. declare module BABYLON {
  131172. /** @hidden */
  131173. export var volumetricLightScatteringPassPixelShader: {
  131174. name: string;
  131175. shader: string;
  131176. };
  131177. }
  131178. declare module BABYLON {
  131179. /**
  131180. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  131181. */
  131182. export class VolumetricLightScatteringPostProcess extends PostProcess {
  131183. private _volumetricLightScatteringPass;
  131184. private _volumetricLightScatteringRTT;
  131185. private _viewPort;
  131186. private _screenCoordinates;
  131187. private _cachedDefines;
  131188. /**
  131189. * If not undefined, the mesh position is computed from the attached node position
  131190. */
  131191. attachedNode: {
  131192. position: Vector3;
  131193. };
  131194. /**
  131195. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  131196. */
  131197. customMeshPosition: Vector3;
  131198. /**
  131199. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  131200. */
  131201. useCustomMeshPosition: boolean;
  131202. /**
  131203. * If the post-process should inverse the light scattering direction
  131204. */
  131205. invert: boolean;
  131206. /**
  131207. * The internal mesh used by the post-process
  131208. */
  131209. mesh: Mesh;
  131210. /**
  131211. * @hidden
  131212. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  131213. */
  131214. useDiffuseColor: boolean;
  131215. /**
  131216. * Array containing the excluded meshes not rendered in the internal pass
  131217. */
  131218. excludedMeshes: AbstractMesh[];
  131219. /**
  131220. * Controls the overall intensity of the post-process
  131221. */
  131222. exposure: number;
  131223. /**
  131224. * Dissipates each sample's contribution in range [0, 1]
  131225. */
  131226. decay: number;
  131227. /**
  131228. * Controls the overall intensity of each sample
  131229. */
  131230. weight: number;
  131231. /**
  131232. * Controls the density of each sample
  131233. */
  131234. density: number;
  131235. /**
  131236. * @constructor
  131237. * @param name The post-process name
  131238. * @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)
  131239. * @param camera The camera that the post-process will be attached to
  131240. * @param mesh The mesh used to create the light scattering
  131241. * @param samples The post-process quality, default 100
  131242. * @param samplingModeThe post-process filtering mode
  131243. * @param engine The babylon engine
  131244. * @param reusable If the post-process is reusable
  131245. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  131246. */
  131247. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  131248. /**
  131249. * Returns the string "VolumetricLightScatteringPostProcess"
  131250. * @returns "VolumetricLightScatteringPostProcess"
  131251. */
  131252. getClassName(): string;
  131253. private _isReady;
  131254. /**
  131255. * Sets the new light position for light scattering effect
  131256. * @param position The new custom light position
  131257. */
  131258. setCustomMeshPosition(position: Vector3): void;
  131259. /**
  131260. * Returns the light position for light scattering effect
  131261. * @return Vector3 The custom light position
  131262. */
  131263. getCustomMeshPosition(): Vector3;
  131264. /**
  131265. * Disposes the internal assets and detaches the post-process from the camera
  131266. */
  131267. dispose(camera: Camera): void;
  131268. /**
  131269. * Returns the render target texture used by the post-process
  131270. * @return the render target texture used by the post-process
  131271. */
  131272. getPass(): RenderTargetTexture;
  131273. private _meshExcluded;
  131274. private _createPass;
  131275. private _updateMeshScreenCoordinates;
  131276. /**
  131277. * Creates a default mesh for the Volumeric Light Scattering post-process
  131278. * @param name The mesh name
  131279. * @param scene The scene where to create the mesh
  131280. * @return the default mesh
  131281. */
  131282. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  131283. }
  131284. }
  131285. declare module BABYLON {
  131286. interface Scene {
  131287. /** @hidden (Backing field) */
  131288. _boundingBoxRenderer: BoundingBoxRenderer;
  131289. /** @hidden (Backing field) */
  131290. _forceShowBoundingBoxes: boolean;
  131291. /**
  131292. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  131293. */
  131294. forceShowBoundingBoxes: boolean;
  131295. /**
  131296. * Gets the bounding box renderer associated with the scene
  131297. * @returns a BoundingBoxRenderer
  131298. */
  131299. getBoundingBoxRenderer(): BoundingBoxRenderer;
  131300. }
  131301. interface AbstractMesh {
  131302. /** @hidden (Backing field) */
  131303. _showBoundingBox: boolean;
  131304. /**
  131305. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  131306. */
  131307. showBoundingBox: boolean;
  131308. }
  131309. /**
  131310. * Component responsible of rendering the bounding box of the meshes in a scene.
  131311. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  131312. */
  131313. export class BoundingBoxRenderer implements ISceneComponent {
  131314. /**
  131315. * The component name helpfull to identify the component in the list of scene components.
  131316. */
  131317. readonly name: string;
  131318. /**
  131319. * The scene the component belongs to.
  131320. */
  131321. scene: Scene;
  131322. /**
  131323. * Color of the bounding box lines placed in front of an object
  131324. */
  131325. frontColor: Color3;
  131326. /**
  131327. * Color of the bounding box lines placed behind an object
  131328. */
  131329. backColor: Color3;
  131330. /**
  131331. * Defines if the renderer should show the back lines or not
  131332. */
  131333. showBackLines: boolean;
  131334. /**
  131335. * @hidden
  131336. */
  131337. renderList: SmartArray<BoundingBox>;
  131338. private _colorShader;
  131339. private _vertexBuffers;
  131340. private _indexBuffer;
  131341. private _fillIndexBuffer;
  131342. private _fillIndexData;
  131343. /**
  131344. * Instantiates a new bounding box renderer in a scene.
  131345. * @param scene the scene the renderer renders in
  131346. */
  131347. constructor(scene: Scene);
  131348. /**
  131349. * Registers the component in a given scene
  131350. */
  131351. register(): void;
  131352. private _evaluateSubMesh;
  131353. private _activeMesh;
  131354. private _prepareRessources;
  131355. private _createIndexBuffer;
  131356. /**
  131357. * Rebuilds the elements related to this component in case of
  131358. * context lost for instance.
  131359. */
  131360. rebuild(): void;
  131361. /**
  131362. * @hidden
  131363. */
  131364. reset(): void;
  131365. /**
  131366. * Render the bounding boxes of a specific rendering group
  131367. * @param renderingGroupId defines the rendering group to render
  131368. */
  131369. render(renderingGroupId: number): void;
  131370. /**
  131371. * In case of occlusion queries, we can render the occlusion bounding box through this method
  131372. * @param mesh Define the mesh to render the occlusion bounding box for
  131373. */
  131374. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  131375. /**
  131376. * Dispose and release the resources attached to this renderer.
  131377. */
  131378. dispose(): void;
  131379. }
  131380. }
  131381. declare module BABYLON {
  131382. /** @hidden */
  131383. export var depthPixelShader: {
  131384. name: string;
  131385. shader: string;
  131386. };
  131387. }
  131388. declare module BABYLON {
  131389. /**
  131390. * This represents a depth renderer in Babylon.
  131391. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  131392. */
  131393. export class DepthRenderer {
  131394. private _scene;
  131395. private _depthMap;
  131396. private _effect;
  131397. private readonly _storeNonLinearDepth;
  131398. private readonly _clearColor;
  131399. /** Get if the depth renderer is using packed depth or not */
  131400. readonly isPacked: boolean;
  131401. private _cachedDefines;
  131402. private _camera;
  131403. /**
  131404. * Specifiess that the depth renderer will only be used within
  131405. * the camera it is created for.
  131406. * This can help forcing its rendering during the camera processing.
  131407. */
  131408. useOnlyInActiveCamera: boolean;
  131409. /** @hidden */
  131410. static _SceneComponentInitialization: (scene: Scene) => void;
  131411. /**
  131412. * Instantiates a depth renderer
  131413. * @param scene The scene the renderer belongs to
  131414. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  131415. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  131416. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  131417. */
  131418. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  131419. /**
  131420. * Creates the depth rendering effect and checks if the effect is ready.
  131421. * @param subMesh The submesh to be used to render the depth map of
  131422. * @param useInstances If multiple world instances should be used
  131423. * @returns if the depth renderer is ready to render the depth map
  131424. */
  131425. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  131426. /**
  131427. * Gets the texture which the depth map will be written to.
  131428. * @returns The depth map texture
  131429. */
  131430. getDepthMap(): RenderTargetTexture;
  131431. /**
  131432. * Disposes of the depth renderer.
  131433. */
  131434. dispose(): void;
  131435. }
  131436. }
  131437. declare module BABYLON {
  131438. interface Scene {
  131439. /** @hidden (Backing field) */
  131440. _depthRenderer: {
  131441. [id: string]: DepthRenderer;
  131442. };
  131443. /**
  131444. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  131445. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  131446. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  131447. * @returns the created depth renderer
  131448. */
  131449. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  131450. /**
  131451. * Disables a depth renderer for a given camera
  131452. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  131453. */
  131454. disableDepthRenderer(camera?: Nullable<Camera>): void;
  131455. }
  131456. /**
  131457. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  131458. * in several rendering techniques.
  131459. */
  131460. export class DepthRendererSceneComponent implements ISceneComponent {
  131461. /**
  131462. * The component name helpfull to identify the component in the list of scene components.
  131463. */
  131464. readonly name: string;
  131465. /**
  131466. * The scene the component belongs to.
  131467. */
  131468. scene: Scene;
  131469. /**
  131470. * Creates a new instance of the component for the given scene
  131471. * @param scene Defines the scene to register the component in
  131472. */
  131473. constructor(scene: Scene);
  131474. /**
  131475. * Registers the component in a given scene
  131476. */
  131477. register(): void;
  131478. /**
  131479. * Rebuilds the elements related to this component in case of
  131480. * context lost for instance.
  131481. */
  131482. rebuild(): void;
  131483. /**
  131484. * Disposes the component and the associated ressources
  131485. */
  131486. dispose(): void;
  131487. private _gatherRenderTargets;
  131488. private _gatherActiveCameraRenderTargets;
  131489. }
  131490. }
  131491. declare module BABYLON {
  131492. /** @hidden */
  131493. export var outlinePixelShader: {
  131494. name: string;
  131495. shader: string;
  131496. };
  131497. }
  131498. declare module BABYLON {
  131499. /** @hidden */
  131500. export var outlineVertexShader: {
  131501. name: string;
  131502. shader: string;
  131503. };
  131504. }
  131505. declare module BABYLON {
  131506. interface Scene {
  131507. /** @hidden */
  131508. _outlineRenderer: OutlineRenderer;
  131509. /**
  131510. * Gets the outline renderer associated with the scene
  131511. * @returns a OutlineRenderer
  131512. */
  131513. getOutlineRenderer(): OutlineRenderer;
  131514. }
  131515. interface AbstractMesh {
  131516. /** @hidden (Backing field) */
  131517. _renderOutline: boolean;
  131518. /**
  131519. * Gets or sets a boolean indicating if the outline must be rendered as well
  131520. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  131521. */
  131522. renderOutline: boolean;
  131523. /** @hidden (Backing field) */
  131524. _renderOverlay: boolean;
  131525. /**
  131526. * Gets or sets a boolean indicating if the overlay must be rendered as well
  131527. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  131528. */
  131529. renderOverlay: boolean;
  131530. }
  131531. /**
  131532. * This class is responsible to draw bothe outline/overlay of meshes.
  131533. * It should not be used directly but through the available method on mesh.
  131534. */
  131535. export class OutlineRenderer implements ISceneComponent {
  131536. /**
  131537. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  131538. */
  131539. private static _StencilReference;
  131540. /**
  131541. * The name of the component. Each component must have a unique name.
  131542. */
  131543. name: string;
  131544. /**
  131545. * The scene the component belongs to.
  131546. */
  131547. scene: Scene;
  131548. /**
  131549. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  131550. */
  131551. zOffset: number;
  131552. private _engine;
  131553. private _effect;
  131554. private _cachedDefines;
  131555. private _savedDepthWrite;
  131556. /**
  131557. * Instantiates a new outline renderer. (There could be only one per scene).
  131558. * @param scene Defines the scene it belongs to
  131559. */
  131560. constructor(scene: Scene);
  131561. /**
  131562. * Register the component to one instance of a scene.
  131563. */
  131564. register(): void;
  131565. /**
  131566. * Rebuilds the elements related to this component in case of
  131567. * context lost for instance.
  131568. */
  131569. rebuild(): void;
  131570. /**
  131571. * Disposes the component and the associated ressources.
  131572. */
  131573. dispose(): void;
  131574. /**
  131575. * Renders the outline in the canvas.
  131576. * @param subMesh Defines the sumesh to render
  131577. * @param batch Defines the batch of meshes in case of instances
  131578. * @param useOverlay Defines if the rendering is for the overlay or the outline
  131579. */
  131580. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  131581. /**
  131582. * Returns whether or not the outline renderer is ready for a given submesh.
  131583. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  131584. * @param subMesh Defines the submesh to check readyness for
  131585. * @param useInstances Defines wheter wee are trying to render instances or not
  131586. * @returns true if ready otherwise false
  131587. */
  131588. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  131589. private _beforeRenderingMesh;
  131590. private _afterRenderingMesh;
  131591. }
  131592. }
  131593. declare module BABYLON {
  131594. /**
  131595. * Class used to manage multiple sprites of different sizes on the same spritesheet
  131596. * @see http://doc.babylonjs.com/babylon101/sprites
  131597. */
  131598. export class SpritePackedManager extends SpriteManager {
  131599. /** defines the packed manager's name */
  131600. name: string;
  131601. /**
  131602. * Creates a new sprite manager from a packed sprite sheet
  131603. * @param name defines the manager's name
  131604. * @param imgUrl defines the sprite sheet url
  131605. * @param capacity defines the maximum allowed number of sprites
  131606. * @param scene defines the hosting scene
  131607. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  131608. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  131609. * @param samplingMode defines the smapling mode to use with spritesheet
  131610. * @param fromPacked set to true; do not alter
  131611. */
  131612. constructor(
  131613. /** defines the packed manager's name */
  131614. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  131615. }
  131616. }
  131617. declare module BABYLON {
  131618. /**
  131619. * Defines the list of states available for a task inside a AssetsManager
  131620. */
  131621. export enum AssetTaskState {
  131622. /**
  131623. * Initialization
  131624. */
  131625. INIT = 0,
  131626. /**
  131627. * Running
  131628. */
  131629. RUNNING = 1,
  131630. /**
  131631. * Done
  131632. */
  131633. DONE = 2,
  131634. /**
  131635. * Error
  131636. */
  131637. ERROR = 3
  131638. }
  131639. /**
  131640. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  131641. */
  131642. export abstract class AbstractAssetTask {
  131643. /**
  131644. * Task name
  131645. */ name: string;
  131646. /**
  131647. * Callback called when the task is successful
  131648. */
  131649. onSuccess: (task: any) => void;
  131650. /**
  131651. * Callback called when the task is not successful
  131652. */
  131653. onError: (task: any, message?: string, exception?: any) => void;
  131654. /**
  131655. * Creates a new AssetsManager
  131656. * @param name defines the name of the task
  131657. */
  131658. constructor(
  131659. /**
  131660. * Task name
  131661. */ name: string);
  131662. private _isCompleted;
  131663. private _taskState;
  131664. private _errorObject;
  131665. /**
  131666. * Get if the task is completed
  131667. */
  131668. readonly isCompleted: boolean;
  131669. /**
  131670. * Gets the current state of the task
  131671. */
  131672. readonly taskState: AssetTaskState;
  131673. /**
  131674. * Gets the current error object (if task is in error)
  131675. */
  131676. readonly errorObject: {
  131677. message?: string;
  131678. exception?: any;
  131679. };
  131680. /**
  131681. * Internal only
  131682. * @hidden
  131683. */
  131684. _setErrorObject(message?: string, exception?: any): void;
  131685. /**
  131686. * Execute the current task
  131687. * @param scene defines the scene where you want your assets to be loaded
  131688. * @param onSuccess is a callback called when the task is successfully executed
  131689. * @param onError is a callback called if an error occurs
  131690. */
  131691. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  131692. /**
  131693. * Execute the current task
  131694. * @param scene defines the scene where you want your assets to be loaded
  131695. * @param onSuccess is a callback called when the task is successfully executed
  131696. * @param onError is a callback called if an error occurs
  131697. */
  131698. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  131699. /**
  131700. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  131701. * This can be used with failed tasks that have the reason for failure fixed.
  131702. */
  131703. reset(): void;
  131704. private onErrorCallback;
  131705. private onDoneCallback;
  131706. }
  131707. /**
  131708. * Define the interface used by progress events raised during assets loading
  131709. */
  131710. export interface IAssetsProgressEvent {
  131711. /**
  131712. * Defines the number of remaining tasks to process
  131713. */
  131714. remainingCount: number;
  131715. /**
  131716. * Defines the total number of tasks
  131717. */
  131718. totalCount: number;
  131719. /**
  131720. * Defines the task that was just processed
  131721. */
  131722. task: AbstractAssetTask;
  131723. }
  131724. /**
  131725. * Class used to share progress information about assets loading
  131726. */
  131727. export class AssetsProgressEvent implements IAssetsProgressEvent {
  131728. /**
  131729. * Defines the number of remaining tasks to process
  131730. */
  131731. remainingCount: number;
  131732. /**
  131733. * Defines the total number of tasks
  131734. */
  131735. totalCount: number;
  131736. /**
  131737. * Defines the task that was just processed
  131738. */
  131739. task: AbstractAssetTask;
  131740. /**
  131741. * Creates a AssetsProgressEvent
  131742. * @param remainingCount defines the number of remaining tasks to process
  131743. * @param totalCount defines the total number of tasks
  131744. * @param task defines the task that was just processed
  131745. */
  131746. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  131747. }
  131748. /**
  131749. * Define a task used by AssetsManager to load meshes
  131750. */
  131751. export class MeshAssetTask extends AbstractAssetTask {
  131752. /**
  131753. * Defines the name of the task
  131754. */
  131755. name: string;
  131756. /**
  131757. * Defines the list of mesh's names you want to load
  131758. */
  131759. meshesNames: any;
  131760. /**
  131761. * Defines the root url to use as a base to load your meshes and associated resources
  131762. */
  131763. rootUrl: string;
  131764. /**
  131765. * Defines the filename of the scene to load from
  131766. */
  131767. sceneFilename: string;
  131768. /**
  131769. * Gets the list of loaded meshes
  131770. */
  131771. loadedMeshes: Array<AbstractMesh>;
  131772. /**
  131773. * Gets the list of loaded particle systems
  131774. */
  131775. loadedParticleSystems: Array<IParticleSystem>;
  131776. /**
  131777. * Gets the list of loaded skeletons
  131778. */
  131779. loadedSkeletons: Array<Skeleton>;
  131780. /**
  131781. * Gets the list of loaded animation groups
  131782. */
  131783. loadedAnimationGroups: Array<AnimationGroup>;
  131784. /**
  131785. * Callback called when the task is successful
  131786. */
  131787. onSuccess: (task: MeshAssetTask) => void;
  131788. /**
  131789. * Callback called when the task is successful
  131790. */
  131791. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  131792. /**
  131793. * Creates a new MeshAssetTask
  131794. * @param name defines the name of the task
  131795. * @param meshesNames defines the list of mesh's names you want to load
  131796. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  131797. * @param sceneFilename defines the filename of the scene to load from
  131798. */
  131799. constructor(
  131800. /**
  131801. * Defines the name of the task
  131802. */
  131803. name: string,
  131804. /**
  131805. * Defines the list of mesh's names you want to load
  131806. */
  131807. meshesNames: any,
  131808. /**
  131809. * Defines the root url to use as a base to load your meshes and associated resources
  131810. */
  131811. rootUrl: string,
  131812. /**
  131813. * Defines the filename of the scene to load from
  131814. */
  131815. sceneFilename: string);
  131816. /**
  131817. * Execute the current task
  131818. * @param scene defines the scene where you want your assets to be loaded
  131819. * @param onSuccess is a callback called when the task is successfully executed
  131820. * @param onError is a callback called if an error occurs
  131821. */
  131822. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  131823. }
  131824. /**
  131825. * Define a task used by AssetsManager to load text content
  131826. */
  131827. export class TextFileAssetTask extends AbstractAssetTask {
  131828. /**
  131829. * Defines the name of the task
  131830. */
  131831. name: string;
  131832. /**
  131833. * Defines the location of the file to load
  131834. */
  131835. url: string;
  131836. /**
  131837. * Gets the loaded text string
  131838. */
  131839. text: string;
  131840. /**
  131841. * Callback called when the task is successful
  131842. */
  131843. onSuccess: (task: TextFileAssetTask) => void;
  131844. /**
  131845. * Callback called when the task is successful
  131846. */
  131847. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  131848. /**
  131849. * Creates a new TextFileAssetTask object
  131850. * @param name defines the name of the task
  131851. * @param url defines the location of the file to load
  131852. */
  131853. constructor(
  131854. /**
  131855. * Defines the name of the task
  131856. */
  131857. name: string,
  131858. /**
  131859. * Defines the location of the file to load
  131860. */
  131861. url: string);
  131862. /**
  131863. * Execute the current task
  131864. * @param scene defines the scene where you want your assets to be loaded
  131865. * @param onSuccess is a callback called when the task is successfully executed
  131866. * @param onError is a callback called if an error occurs
  131867. */
  131868. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  131869. }
  131870. /**
  131871. * Define a task used by AssetsManager to load binary data
  131872. */
  131873. export class BinaryFileAssetTask extends AbstractAssetTask {
  131874. /**
  131875. * Defines the name of the task
  131876. */
  131877. name: string;
  131878. /**
  131879. * Defines the location of the file to load
  131880. */
  131881. url: string;
  131882. /**
  131883. * Gets the lodaded data (as an array buffer)
  131884. */
  131885. data: ArrayBuffer;
  131886. /**
  131887. * Callback called when the task is successful
  131888. */
  131889. onSuccess: (task: BinaryFileAssetTask) => void;
  131890. /**
  131891. * Callback called when the task is successful
  131892. */
  131893. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  131894. /**
  131895. * Creates a new BinaryFileAssetTask object
  131896. * @param name defines the name of the new task
  131897. * @param url defines the location of the file to load
  131898. */
  131899. constructor(
  131900. /**
  131901. * Defines the name of the task
  131902. */
  131903. name: string,
  131904. /**
  131905. * Defines the location of the file to load
  131906. */
  131907. url: string);
  131908. /**
  131909. * Execute the current task
  131910. * @param scene defines the scene where you want your assets to be loaded
  131911. * @param onSuccess is a callback called when the task is successfully executed
  131912. * @param onError is a callback called if an error occurs
  131913. */
  131914. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  131915. }
  131916. /**
  131917. * Define a task used by AssetsManager to load images
  131918. */
  131919. export class ImageAssetTask extends AbstractAssetTask {
  131920. /**
  131921. * Defines the name of the task
  131922. */
  131923. name: string;
  131924. /**
  131925. * Defines the location of the image to load
  131926. */
  131927. url: string;
  131928. /**
  131929. * Gets the loaded images
  131930. */
  131931. image: HTMLImageElement;
  131932. /**
  131933. * Callback called when the task is successful
  131934. */
  131935. onSuccess: (task: ImageAssetTask) => void;
  131936. /**
  131937. * Callback called when the task is successful
  131938. */
  131939. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  131940. /**
  131941. * Creates a new ImageAssetTask
  131942. * @param name defines the name of the task
  131943. * @param url defines the location of the image to load
  131944. */
  131945. constructor(
  131946. /**
  131947. * Defines the name of the task
  131948. */
  131949. name: string,
  131950. /**
  131951. * Defines the location of the image to load
  131952. */
  131953. url: string);
  131954. /**
  131955. * Execute the current task
  131956. * @param scene defines the scene where you want your assets to be loaded
  131957. * @param onSuccess is a callback called when the task is successfully executed
  131958. * @param onError is a callback called if an error occurs
  131959. */
  131960. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  131961. }
  131962. /**
  131963. * Defines the interface used by texture loading tasks
  131964. */
  131965. export interface ITextureAssetTask<TEX extends BaseTexture> {
  131966. /**
  131967. * Gets the loaded texture
  131968. */
  131969. texture: TEX;
  131970. }
  131971. /**
  131972. * Define a task used by AssetsManager to load 2D textures
  131973. */
  131974. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  131975. /**
  131976. * Defines the name of the task
  131977. */
  131978. name: string;
  131979. /**
  131980. * Defines the location of the file to load
  131981. */
  131982. url: string;
  131983. /**
  131984. * Defines if mipmap should not be generated (default is false)
  131985. */
  131986. noMipmap?: boolean | undefined;
  131987. /**
  131988. * Defines if texture must be inverted on Y axis (default is false)
  131989. */
  131990. invertY?: boolean | undefined;
  131991. /**
  131992. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  131993. */
  131994. samplingMode: number;
  131995. /**
  131996. * Gets the loaded texture
  131997. */
  131998. texture: Texture;
  131999. /**
  132000. * Callback called when the task is successful
  132001. */
  132002. onSuccess: (task: TextureAssetTask) => void;
  132003. /**
  132004. * Callback called when the task is successful
  132005. */
  132006. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  132007. /**
  132008. * Creates a new TextureAssetTask object
  132009. * @param name defines the name of the task
  132010. * @param url defines the location of the file to load
  132011. * @param noMipmap defines if mipmap should not be generated (default is false)
  132012. * @param invertY defines if texture must be inverted on Y axis (default is false)
  132013. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  132014. */
  132015. constructor(
  132016. /**
  132017. * Defines the name of the task
  132018. */
  132019. name: string,
  132020. /**
  132021. * Defines the location of the file to load
  132022. */
  132023. url: string,
  132024. /**
  132025. * Defines if mipmap should not be generated (default is false)
  132026. */
  132027. noMipmap?: boolean | undefined,
  132028. /**
  132029. * Defines if texture must be inverted on Y axis (default is false)
  132030. */
  132031. invertY?: boolean | undefined,
  132032. /**
  132033. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  132034. */
  132035. samplingMode?: number);
  132036. /**
  132037. * Execute the current task
  132038. * @param scene defines the scene where you want your assets to be loaded
  132039. * @param onSuccess is a callback called when the task is successfully executed
  132040. * @param onError is a callback called if an error occurs
  132041. */
  132042. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  132043. }
  132044. /**
  132045. * Define a task used by AssetsManager to load cube textures
  132046. */
  132047. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  132048. /**
  132049. * Defines the name of the task
  132050. */
  132051. name: string;
  132052. /**
  132053. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  132054. */
  132055. url: string;
  132056. /**
  132057. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  132058. */
  132059. extensions?: string[] | undefined;
  132060. /**
  132061. * Defines if mipmaps should not be generated (default is false)
  132062. */
  132063. noMipmap?: boolean | undefined;
  132064. /**
  132065. * Defines the explicit list of files (undefined by default)
  132066. */
  132067. files?: string[] | undefined;
  132068. /**
  132069. * Gets the loaded texture
  132070. */
  132071. texture: CubeTexture;
  132072. /**
  132073. * Callback called when the task is successful
  132074. */
  132075. onSuccess: (task: CubeTextureAssetTask) => void;
  132076. /**
  132077. * Callback called when the task is successful
  132078. */
  132079. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  132080. /**
  132081. * Creates a new CubeTextureAssetTask
  132082. * @param name defines the name of the task
  132083. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  132084. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  132085. * @param noMipmap defines if mipmaps should not be generated (default is false)
  132086. * @param files defines the explicit list of files (undefined by default)
  132087. */
  132088. constructor(
  132089. /**
  132090. * Defines the name of the task
  132091. */
  132092. name: string,
  132093. /**
  132094. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  132095. */
  132096. url: string,
  132097. /**
  132098. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  132099. */
  132100. extensions?: string[] | undefined,
  132101. /**
  132102. * Defines if mipmaps should not be generated (default is false)
  132103. */
  132104. noMipmap?: boolean | undefined,
  132105. /**
  132106. * Defines the explicit list of files (undefined by default)
  132107. */
  132108. files?: string[] | undefined);
  132109. /**
  132110. * Execute the current task
  132111. * @param scene defines the scene where you want your assets to be loaded
  132112. * @param onSuccess is a callback called when the task is successfully executed
  132113. * @param onError is a callback called if an error occurs
  132114. */
  132115. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  132116. }
  132117. /**
  132118. * Define a task used by AssetsManager to load HDR cube textures
  132119. */
  132120. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  132121. /**
  132122. * Defines the name of the task
  132123. */
  132124. name: string;
  132125. /**
  132126. * Defines the location of the file to load
  132127. */
  132128. url: string;
  132129. /**
  132130. * Defines the desired size (the more it increases the longer the generation will be)
  132131. */
  132132. size: number;
  132133. /**
  132134. * Defines if mipmaps should not be generated (default is false)
  132135. */
  132136. noMipmap: boolean;
  132137. /**
  132138. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  132139. */
  132140. generateHarmonics: boolean;
  132141. /**
  132142. * 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)
  132143. */
  132144. gammaSpace: boolean;
  132145. /**
  132146. * Internal Use Only
  132147. */
  132148. reserved: boolean;
  132149. /**
  132150. * Gets the loaded texture
  132151. */
  132152. texture: HDRCubeTexture;
  132153. /**
  132154. * Callback called when the task is successful
  132155. */
  132156. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  132157. /**
  132158. * Callback called when the task is successful
  132159. */
  132160. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  132161. /**
  132162. * Creates a new HDRCubeTextureAssetTask object
  132163. * @param name defines the name of the task
  132164. * @param url defines the location of the file to load
  132165. * @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.
  132166. * @param noMipmap defines if mipmaps should not be generated (default is false)
  132167. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  132168. * @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)
  132169. * @param reserved Internal use only
  132170. */
  132171. constructor(
  132172. /**
  132173. * Defines the name of the task
  132174. */
  132175. name: string,
  132176. /**
  132177. * Defines the location of the file to load
  132178. */
  132179. url: string,
  132180. /**
  132181. * Defines the desired size (the more it increases the longer the generation will be)
  132182. */
  132183. size: number,
  132184. /**
  132185. * Defines if mipmaps should not be generated (default is false)
  132186. */
  132187. noMipmap?: boolean,
  132188. /**
  132189. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  132190. */
  132191. generateHarmonics?: boolean,
  132192. /**
  132193. * 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)
  132194. */
  132195. gammaSpace?: boolean,
  132196. /**
  132197. * Internal Use Only
  132198. */
  132199. reserved?: boolean);
  132200. /**
  132201. * Execute the current task
  132202. * @param scene defines the scene where you want your assets to be loaded
  132203. * @param onSuccess is a callback called when the task is successfully executed
  132204. * @param onError is a callback called if an error occurs
  132205. */
  132206. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  132207. }
  132208. /**
  132209. * Define a task used by AssetsManager to load Equirectangular cube textures
  132210. */
  132211. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  132212. /**
  132213. * Defines the name of the task
  132214. */
  132215. name: string;
  132216. /**
  132217. * Defines the location of the file to load
  132218. */
  132219. url: string;
  132220. /**
  132221. * Defines the desired size (the more it increases the longer the generation will be)
  132222. */
  132223. size: number;
  132224. /**
  132225. * Defines if mipmaps should not be generated (default is false)
  132226. */
  132227. noMipmap: boolean;
  132228. /**
  132229. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  132230. * but the standard material would require them in Gamma space) (default is true)
  132231. */
  132232. gammaSpace: boolean;
  132233. /**
  132234. * Gets the loaded texture
  132235. */
  132236. texture: EquiRectangularCubeTexture;
  132237. /**
  132238. * Callback called when the task is successful
  132239. */
  132240. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  132241. /**
  132242. * Callback called when the task is successful
  132243. */
  132244. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  132245. /**
  132246. * Creates a new EquiRectangularCubeTextureAssetTask object
  132247. * @param name defines the name of the task
  132248. * @param url defines the location of the file to load
  132249. * @param size defines the desired size (the more it increases the longer the generation will be)
  132250. * If the size is omitted this implies you are using a preprocessed cubemap.
  132251. * @param noMipmap defines if mipmaps should not be generated (default is false)
  132252. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  132253. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  132254. * (default is true)
  132255. */
  132256. constructor(
  132257. /**
  132258. * Defines the name of the task
  132259. */
  132260. name: string,
  132261. /**
  132262. * Defines the location of the file to load
  132263. */
  132264. url: string,
  132265. /**
  132266. * Defines the desired size (the more it increases the longer the generation will be)
  132267. */
  132268. size: number,
  132269. /**
  132270. * Defines if mipmaps should not be generated (default is false)
  132271. */
  132272. noMipmap?: boolean,
  132273. /**
  132274. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  132275. * but the standard material would require them in Gamma space) (default is true)
  132276. */
  132277. gammaSpace?: boolean);
  132278. /**
  132279. * Execute the current task
  132280. * @param scene defines the scene where you want your assets to be loaded
  132281. * @param onSuccess is a callback called when the task is successfully executed
  132282. * @param onError is a callback called if an error occurs
  132283. */
  132284. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  132285. }
  132286. /**
  132287. * This class can be used to easily import assets into a scene
  132288. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  132289. */
  132290. export class AssetsManager {
  132291. private _scene;
  132292. private _isLoading;
  132293. protected _tasks: AbstractAssetTask[];
  132294. protected _waitingTasksCount: number;
  132295. protected _totalTasksCount: number;
  132296. /**
  132297. * Callback called when all tasks are processed
  132298. */
  132299. onFinish: (tasks: AbstractAssetTask[]) => void;
  132300. /**
  132301. * Callback called when a task is successful
  132302. */
  132303. onTaskSuccess: (task: AbstractAssetTask) => void;
  132304. /**
  132305. * Callback called when a task had an error
  132306. */
  132307. onTaskError: (task: AbstractAssetTask) => void;
  132308. /**
  132309. * Callback called when a task is done (whatever the result is)
  132310. */
  132311. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  132312. /**
  132313. * Observable called when all tasks are processed
  132314. */
  132315. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  132316. /**
  132317. * Observable called when a task had an error
  132318. */
  132319. onTaskErrorObservable: Observable<AbstractAssetTask>;
  132320. /**
  132321. * Observable called when all tasks were executed
  132322. */
  132323. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  132324. /**
  132325. * Observable called when a task is done (whatever the result is)
  132326. */
  132327. onProgressObservable: Observable<IAssetsProgressEvent>;
  132328. /**
  132329. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  132330. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  132331. */
  132332. useDefaultLoadingScreen: boolean;
  132333. /**
  132334. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  132335. * when all assets have been downloaded.
  132336. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  132337. */
  132338. autoHideLoadingUI: boolean;
  132339. /**
  132340. * Creates a new AssetsManager
  132341. * @param scene defines the scene to work on
  132342. */
  132343. constructor(scene: Scene);
  132344. /**
  132345. * Add a MeshAssetTask to the list of active tasks
  132346. * @param taskName defines the name of the new task
  132347. * @param meshesNames defines the name of meshes to load
  132348. * @param rootUrl defines the root url to use to locate files
  132349. * @param sceneFilename defines the filename of the scene file
  132350. * @returns a new MeshAssetTask object
  132351. */
  132352. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  132353. /**
  132354. * Add a TextFileAssetTask to the list of active tasks
  132355. * @param taskName defines the name of the new task
  132356. * @param url defines the url of the file to load
  132357. * @returns a new TextFileAssetTask object
  132358. */
  132359. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  132360. /**
  132361. * Add a BinaryFileAssetTask to the list of active tasks
  132362. * @param taskName defines the name of the new task
  132363. * @param url defines the url of the file to load
  132364. * @returns a new BinaryFileAssetTask object
  132365. */
  132366. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  132367. /**
  132368. * Add a ImageAssetTask to the list of active tasks
  132369. * @param taskName defines the name of the new task
  132370. * @param url defines the url of the file to load
  132371. * @returns a new ImageAssetTask object
  132372. */
  132373. addImageTask(taskName: string, url: string): ImageAssetTask;
  132374. /**
  132375. * Add a TextureAssetTask to the list of active tasks
  132376. * @param taskName defines the name of the new task
  132377. * @param url defines the url of the file to load
  132378. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  132379. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  132380. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  132381. * @returns a new TextureAssetTask object
  132382. */
  132383. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  132384. /**
  132385. * Add a CubeTextureAssetTask to the list of active tasks
  132386. * @param taskName defines the name of the new task
  132387. * @param url defines the url of the file to load
  132388. * @param extensions defines the extension to use to load the cube map (can be null)
  132389. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  132390. * @param files defines the list of files to load (can be null)
  132391. * @returns a new CubeTextureAssetTask object
  132392. */
  132393. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  132394. /**
  132395. *
  132396. * Add a HDRCubeTextureAssetTask to the list of active tasks
  132397. * @param taskName defines the name of the new task
  132398. * @param url defines the url of the file to load
  132399. * @param size defines the size you want for the cubemap (can be null)
  132400. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  132401. * @param generateHarmonics defines if you want to automatically generate (true by default)
  132402. * @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)
  132403. * @param reserved Internal use only
  132404. * @returns a new HDRCubeTextureAssetTask object
  132405. */
  132406. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  132407. /**
  132408. *
  132409. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  132410. * @param taskName defines the name of the new task
  132411. * @param url defines the url of the file to load
  132412. * @param size defines the size you want for the cubemap (can be null)
  132413. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  132414. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  132415. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  132416. * @returns a new EquiRectangularCubeTextureAssetTask object
  132417. */
  132418. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  132419. /**
  132420. * Remove a task from the assets manager.
  132421. * @param task the task to remove
  132422. */
  132423. removeTask(task: AbstractAssetTask): void;
  132424. private _decreaseWaitingTasksCount;
  132425. private _runTask;
  132426. /**
  132427. * Reset the AssetsManager and remove all tasks
  132428. * @return the current instance of the AssetsManager
  132429. */
  132430. reset(): AssetsManager;
  132431. /**
  132432. * Start the loading process
  132433. * @return the current instance of the AssetsManager
  132434. */
  132435. load(): AssetsManager;
  132436. /**
  132437. * Start the loading process as an async operation
  132438. * @return a promise returning the list of failed tasks
  132439. */
  132440. loadAsync(): Promise<void>;
  132441. }
  132442. }
  132443. declare module BABYLON {
  132444. /**
  132445. * Wrapper class for promise with external resolve and reject.
  132446. */
  132447. export class Deferred<T> {
  132448. /**
  132449. * The promise associated with this deferred object.
  132450. */
  132451. readonly promise: Promise<T>;
  132452. private _resolve;
  132453. private _reject;
  132454. /**
  132455. * The resolve method of the promise associated with this deferred object.
  132456. */
  132457. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  132458. /**
  132459. * The reject method of the promise associated with this deferred object.
  132460. */
  132461. readonly reject: (reason?: any) => void;
  132462. /**
  132463. * Constructor for this deferred object.
  132464. */
  132465. constructor();
  132466. }
  132467. }
  132468. declare module BABYLON {
  132469. /**
  132470. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  132471. */
  132472. export class MeshExploder {
  132473. private _centerMesh;
  132474. private _meshes;
  132475. private _meshesOrigins;
  132476. private _toCenterVectors;
  132477. private _scaledDirection;
  132478. private _newPosition;
  132479. private _centerPosition;
  132480. /**
  132481. * Explodes meshes from a center mesh.
  132482. * @param meshes The meshes to explode.
  132483. * @param centerMesh The mesh to be center of explosion.
  132484. */
  132485. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  132486. private _setCenterMesh;
  132487. /**
  132488. * Get class name
  132489. * @returns "MeshExploder"
  132490. */
  132491. getClassName(): string;
  132492. /**
  132493. * "Exploded meshes"
  132494. * @returns Array of meshes with the centerMesh at index 0.
  132495. */
  132496. getMeshes(): Array<Mesh>;
  132497. /**
  132498. * Explodes meshes giving a specific direction
  132499. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  132500. */
  132501. explode(direction?: number): void;
  132502. }
  132503. }
  132504. declare module BABYLON {
  132505. /**
  132506. * Class used to help managing file picking and drag'n'drop
  132507. */
  132508. export class FilesInput {
  132509. /**
  132510. * List of files ready to be loaded
  132511. */
  132512. static readonly FilesToLoad: {
  132513. [key: string]: File;
  132514. };
  132515. /**
  132516. * Callback called when a file is processed
  132517. */
  132518. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  132519. private _engine;
  132520. private _currentScene;
  132521. private _sceneLoadedCallback;
  132522. private _progressCallback;
  132523. private _additionalRenderLoopLogicCallback;
  132524. private _textureLoadingCallback;
  132525. private _startingProcessingFilesCallback;
  132526. private _onReloadCallback;
  132527. private _errorCallback;
  132528. private _elementToMonitor;
  132529. private _sceneFileToLoad;
  132530. private _filesToLoad;
  132531. /**
  132532. * Creates a new FilesInput
  132533. * @param engine defines the rendering engine
  132534. * @param scene defines the hosting scene
  132535. * @param sceneLoadedCallback callback called when scene is loaded
  132536. * @param progressCallback callback called to track progress
  132537. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  132538. * @param textureLoadingCallback callback called when a texture is loading
  132539. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  132540. * @param onReloadCallback callback called when a reload is requested
  132541. * @param errorCallback callback call if an error occurs
  132542. */
  132543. 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);
  132544. private _dragEnterHandler;
  132545. private _dragOverHandler;
  132546. private _dropHandler;
  132547. /**
  132548. * Calls this function to listen to drag'n'drop events on a specific DOM element
  132549. * @param elementToMonitor defines the DOM element to track
  132550. */
  132551. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  132552. /**
  132553. * Release all associated resources
  132554. */
  132555. dispose(): void;
  132556. private renderFunction;
  132557. private drag;
  132558. private drop;
  132559. private _traverseFolder;
  132560. private _processFiles;
  132561. /**
  132562. * Load files from a drop event
  132563. * @param event defines the drop event to use as source
  132564. */
  132565. loadFiles(event: any): void;
  132566. private _processReload;
  132567. /**
  132568. * Reload the current scene from the loaded files
  132569. */
  132570. reload(): void;
  132571. }
  132572. }
  132573. declare module BABYLON {
  132574. /**
  132575. * Defines the root class used to create scene optimization to use with SceneOptimizer
  132576. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  132577. */
  132578. export class SceneOptimization {
  132579. /**
  132580. * Defines the priority of this optimization (0 by default which means first in the list)
  132581. */
  132582. priority: number;
  132583. /**
  132584. * Gets a string describing the action executed by the current optimization
  132585. * @returns description string
  132586. */
  132587. getDescription(): string;
  132588. /**
  132589. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  132590. * @param scene defines the current scene where to apply this optimization
  132591. * @param optimizer defines the current optimizer
  132592. * @returns true if everything that can be done was applied
  132593. */
  132594. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  132595. /**
  132596. * Creates the SceneOptimization object
  132597. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  132598. * @param desc defines the description associated with the optimization
  132599. */
  132600. constructor(
  132601. /**
  132602. * Defines the priority of this optimization (0 by default which means first in the list)
  132603. */
  132604. priority?: number);
  132605. }
  132606. /**
  132607. * Defines an optimization used to reduce the size of render target textures
  132608. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  132609. */
  132610. export class TextureOptimization extends SceneOptimization {
  132611. /**
  132612. * Defines the priority of this optimization (0 by default which means first in the list)
  132613. */
  132614. priority: number;
  132615. /**
  132616. * 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
  132617. */
  132618. maximumSize: number;
  132619. /**
  132620. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  132621. */
  132622. step: number;
  132623. /**
  132624. * Gets a string describing the action executed by the current optimization
  132625. * @returns description string
  132626. */
  132627. getDescription(): string;
  132628. /**
  132629. * Creates the TextureOptimization object
  132630. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  132631. * @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
  132632. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  132633. */
  132634. constructor(
  132635. /**
  132636. * Defines the priority of this optimization (0 by default which means first in the list)
  132637. */
  132638. priority?: number,
  132639. /**
  132640. * 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
  132641. */
  132642. maximumSize?: number,
  132643. /**
  132644. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  132645. */
  132646. step?: number);
  132647. /**
  132648. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  132649. * @param scene defines the current scene where to apply this optimization
  132650. * @param optimizer defines the current optimizer
  132651. * @returns true if everything that can be done was applied
  132652. */
  132653. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  132654. }
  132655. /**
  132656. * Defines an optimization used to increase or decrease the rendering resolution
  132657. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  132658. */
  132659. export class HardwareScalingOptimization extends SceneOptimization {
  132660. /**
  132661. * Defines the priority of this optimization (0 by default which means first in the list)
  132662. */
  132663. priority: number;
  132664. /**
  132665. * Defines the maximum scale to use (2 by default)
  132666. */
  132667. maximumScale: number;
  132668. /**
  132669. * Defines the step to use between two passes (0.5 by default)
  132670. */
  132671. step: number;
  132672. private _currentScale;
  132673. private _directionOffset;
  132674. /**
  132675. * Gets a string describing the action executed by the current optimization
  132676. * @return description string
  132677. */
  132678. getDescription(): string;
  132679. /**
  132680. * Creates the HardwareScalingOptimization object
  132681. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  132682. * @param maximumScale defines the maximum scale to use (2 by default)
  132683. * @param step defines the step to use between two passes (0.5 by default)
  132684. */
  132685. constructor(
  132686. /**
  132687. * Defines the priority of this optimization (0 by default which means first in the list)
  132688. */
  132689. priority?: number,
  132690. /**
  132691. * Defines the maximum scale to use (2 by default)
  132692. */
  132693. maximumScale?: number,
  132694. /**
  132695. * Defines the step to use between two passes (0.5 by default)
  132696. */
  132697. step?: number);
  132698. /**
  132699. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  132700. * @param scene defines the current scene where to apply this optimization
  132701. * @param optimizer defines the current optimizer
  132702. * @returns true if everything that can be done was applied
  132703. */
  132704. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  132705. }
  132706. /**
  132707. * Defines an optimization used to remove shadows
  132708. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  132709. */
  132710. export class ShadowsOptimization extends SceneOptimization {
  132711. /**
  132712. * Gets a string describing the action executed by the current optimization
  132713. * @return description string
  132714. */
  132715. getDescription(): string;
  132716. /**
  132717. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  132718. * @param scene defines the current scene where to apply this optimization
  132719. * @param optimizer defines the current optimizer
  132720. * @returns true if everything that can be done was applied
  132721. */
  132722. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  132723. }
  132724. /**
  132725. * Defines an optimization used to turn post-processes off
  132726. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  132727. */
  132728. export class PostProcessesOptimization extends SceneOptimization {
  132729. /**
  132730. * Gets a string describing the action executed by the current optimization
  132731. * @return description string
  132732. */
  132733. getDescription(): string;
  132734. /**
  132735. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  132736. * @param scene defines the current scene where to apply this optimization
  132737. * @param optimizer defines the current optimizer
  132738. * @returns true if everything that can be done was applied
  132739. */
  132740. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  132741. }
  132742. /**
  132743. * Defines an optimization used to turn lens flares off
  132744. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  132745. */
  132746. export class LensFlaresOptimization extends SceneOptimization {
  132747. /**
  132748. * Gets a string describing the action executed by the current optimization
  132749. * @return description string
  132750. */
  132751. getDescription(): string;
  132752. /**
  132753. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  132754. * @param scene defines the current scene where to apply this optimization
  132755. * @param optimizer defines the current optimizer
  132756. * @returns true if everything that can be done was applied
  132757. */
  132758. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  132759. }
  132760. /**
  132761. * Defines an optimization based on user defined callback.
  132762. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  132763. */
  132764. export class CustomOptimization extends SceneOptimization {
  132765. /**
  132766. * Callback called to apply the custom optimization.
  132767. */
  132768. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  132769. /**
  132770. * Callback called to get custom description
  132771. */
  132772. onGetDescription: () => string;
  132773. /**
  132774. * Gets a string describing the action executed by the current optimization
  132775. * @returns description string
  132776. */
  132777. getDescription(): string;
  132778. /**
  132779. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  132780. * @param scene defines the current scene where to apply this optimization
  132781. * @param optimizer defines the current optimizer
  132782. * @returns true if everything that can be done was applied
  132783. */
  132784. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  132785. }
  132786. /**
  132787. * Defines an optimization used to turn particles off
  132788. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  132789. */
  132790. export class ParticlesOptimization extends SceneOptimization {
  132791. /**
  132792. * Gets a string describing the action executed by the current optimization
  132793. * @return description string
  132794. */
  132795. getDescription(): string;
  132796. /**
  132797. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  132798. * @param scene defines the current scene where to apply this optimization
  132799. * @param optimizer defines the current optimizer
  132800. * @returns true if everything that can be done was applied
  132801. */
  132802. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  132803. }
  132804. /**
  132805. * Defines an optimization used to turn render targets off
  132806. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  132807. */
  132808. export class RenderTargetsOptimization extends SceneOptimization {
  132809. /**
  132810. * Gets a string describing the action executed by the current optimization
  132811. * @return description string
  132812. */
  132813. getDescription(): string;
  132814. /**
  132815. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  132816. * @param scene defines the current scene where to apply this optimization
  132817. * @param optimizer defines the current optimizer
  132818. * @returns true if everything that can be done was applied
  132819. */
  132820. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  132821. }
  132822. /**
  132823. * Defines an optimization used to merge meshes with compatible materials
  132824. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  132825. */
  132826. export class MergeMeshesOptimization extends SceneOptimization {
  132827. private static _UpdateSelectionTree;
  132828. /**
  132829. * Gets or sets a boolean which defines if optimization octree has to be updated
  132830. */
  132831. /**
  132832. * Gets or sets a boolean which defines if optimization octree has to be updated
  132833. */
  132834. static UpdateSelectionTree: boolean;
  132835. /**
  132836. * Gets a string describing the action executed by the current optimization
  132837. * @return description string
  132838. */
  132839. getDescription(): string;
  132840. private _canBeMerged;
  132841. /**
  132842. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  132843. * @param scene defines the current scene where to apply this optimization
  132844. * @param optimizer defines the current optimizer
  132845. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  132846. * @returns true if everything that can be done was applied
  132847. */
  132848. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  132849. }
  132850. /**
  132851. * Defines a list of options used by SceneOptimizer
  132852. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  132853. */
  132854. export class SceneOptimizerOptions {
  132855. /**
  132856. * Defines the target frame rate to reach (60 by default)
  132857. */
  132858. targetFrameRate: number;
  132859. /**
  132860. * Defines the interval between two checkes (2000ms by default)
  132861. */
  132862. trackerDuration: number;
  132863. /**
  132864. * Gets the list of optimizations to apply
  132865. */
  132866. optimizations: SceneOptimization[];
  132867. /**
  132868. * Creates a new list of options used by SceneOptimizer
  132869. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  132870. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  132871. */
  132872. constructor(
  132873. /**
  132874. * Defines the target frame rate to reach (60 by default)
  132875. */
  132876. targetFrameRate?: number,
  132877. /**
  132878. * Defines the interval between two checkes (2000ms by default)
  132879. */
  132880. trackerDuration?: number);
  132881. /**
  132882. * Add a new optimization
  132883. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  132884. * @returns the current SceneOptimizerOptions
  132885. */
  132886. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  132887. /**
  132888. * Add a new custom optimization
  132889. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  132890. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  132891. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  132892. * @returns the current SceneOptimizerOptions
  132893. */
  132894. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  132895. /**
  132896. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  132897. * @param targetFrameRate defines the target frame rate (60 by default)
  132898. * @returns a SceneOptimizerOptions object
  132899. */
  132900. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  132901. /**
  132902. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  132903. * @param targetFrameRate defines the target frame rate (60 by default)
  132904. * @returns a SceneOptimizerOptions object
  132905. */
  132906. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  132907. /**
  132908. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  132909. * @param targetFrameRate defines the target frame rate (60 by default)
  132910. * @returns a SceneOptimizerOptions object
  132911. */
  132912. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  132913. }
  132914. /**
  132915. * Class used to run optimizations in order to reach a target frame rate
  132916. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  132917. */
  132918. export class SceneOptimizer implements IDisposable {
  132919. private _isRunning;
  132920. private _options;
  132921. private _scene;
  132922. private _currentPriorityLevel;
  132923. private _targetFrameRate;
  132924. private _trackerDuration;
  132925. private _currentFrameRate;
  132926. private _sceneDisposeObserver;
  132927. private _improvementMode;
  132928. /**
  132929. * Defines an observable called when the optimizer reaches the target frame rate
  132930. */
  132931. onSuccessObservable: Observable<SceneOptimizer>;
  132932. /**
  132933. * Defines an observable called when the optimizer enables an optimization
  132934. */
  132935. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  132936. /**
  132937. * Defines an observable called when the optimizer is not able to reach the target frame rate
  132938. */
  132939. onFailureObservable: Observable<SceneOptimizer>;
  132940. /**
  132941. * Gets a boolean indicating if the optimizer is in improvement mode
  132942. */
  132943. readonly isInImprovementMode: boolean;
  132944. /**
  132945. * Gets the current priority level (0 at start)
  132946. */
  132947. readonly currentPriorityLevel: number;
  132948. /**
  132949. * Gets the current frame rate checked by the SceneOptimizer
  132950. */
  132951. readonly currentFrameRate: number;
  132952. /**
  132953. * Gets or sets the current target frame rate (60 by default)
  132954. */
  132955. /**
  132956. * Gets or sets the current target frame rate (60 by default)
  132957. */
  132958. targetFrameRate: number;
  132959. /**
  132960. * Gets or sets the current interval between two checks (every 2000ms by default)
  132961. */
  132962. /**
  132963. * Gets or sets the current interval between two checks (every 2000ms by default)
  132964. */
  132965. trackerDuration: number;
  132966. /**
  132967. * Gets the list of active optimizations
  132968. */
  132969. readonly optimizations: SceneOptimization[];
  132970. /**
  132971. * Creates a new SceneOptimizer
  132972. * @param scene defines the scene to work on
  132973. * @param options defines the options to use with the SceneOptimizer
  132974. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  132975. * @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)
  132976. */
  132977. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  132978. /**
  132979. * Stops the current optimizer
  132980. */
  132981. stop(): void;
  132982. /**
  132983. * Reset the optimizer to initial step (current priority level = 0)
  132984. */
  132985. reset(): void;
  132986. /**
  132987. * Start the optimizer. By default it will try to reach a specific framerate
  132988. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  132989. */
  132990. start(): void;
  132991. private _checkCurrentState;
  132992. /**
  132993. * Release all resources
  132994. */
  132995. dispose(): void;
  132996. /**
  132997. * Helper function to create a SceneOptimizer with one single line of code
  132998. * @param scene defines the scene to work on
  132999. * @param options defines the options to use with the SceneOptimizer
  133000. * @param onSuccess defines a callback to call on success
  133001. * @param onFailure defines a callback to call on failure
  133002. * @returns the new SceneOptimizer object
  133003. */
  133004. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  133005. }
  133006. }
  133007. declare module BABYLON {
  133008. /**
  133009. * Class used to serialize a scene into a string
  133010. */
  133011. export class SceneSerializer {
  133012. /**
  133013. * Clear cache used by a previous serialization
  133014. */
  133015. static ClearCache(): void;
  133016. /**
  133017. * Serialize a scene into a JSON compatible object
  133018. * @param scene defines the scene to serialize
  133019. * @returns a JSON compatible object
  133020. */
  133021. static Serialize(scene: Scene): any;
  133022. /**
  133023. * Serialize a mesh into a JSON compatible object
  133024. * @param toSerialize defines the mesh to serialize
  133025. * @param withParents defines if parents must be serialized as well
  133026. * @param withChildren defines if children must be serialized as well
  133027. * @returns a JSON compatible object
  133028. */
  133029. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  133030. }
  133031. }
  133032. declare module BABYLON {
  133033. /**
  133034. * Class used to host texture specific utilities
  133035. */
  133036. export class TextureTools {
  133037. /**
  133038. * Uses the GPU to create a copy texture rescaled at a given size
  133039. * @param texture Texture to copy from
  133040. * @param width defines the desired width
  133041. * @param height defines the desired height
  133042. * @param useBilinearMode defines if bilinear mode has to be used
  133043. * @return the generated texture
  133044. */
  133045. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  133046. }
  133047. }
  133048. declare module BABYLON {
  133049. /**
  133050. * This represents the different options available for the video capture.
  133051. */
  133052. export interface VideoRecorderOptions {
  133053. /** Defines the mime type of the video. */
  133054. mimeType: string;
  133055. /** Defines the FPS the video should be recorded at. */
  133056. fps: number;
  133057. /** Defines the chunk size for the recording data. */
  133058. recordChunckSize: number;
  133059. /** The audio tracks to attach to the recording. */
  133060. audioTracks?: MediaStreamTrack[];
  133061. }
  133062. /**
  133063. * This can help with recording videos from BabylonJS.
  133064. * This is based on the available WebRTC functionalities of the browser.
  133065. *
  133066. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  133067. */
  133068. export class VideoRecorder {
  133069. private static readonly _defaultOptions;
  133070. /**
  133071. * Returns whether or not the VideoRecorder is available in your browser.
  133072. * @param engine Defines the Babylon Engine.
  133073. * @returns true if supported otherwise false.
  133074. */
  133075. static IsSupported(engine: Engine): boolean;
  133076. private readonly _options;
  133077. private _canvas;
  133078. private _mediaRecorder;
  133079. private _recordedChunks;
  133080. private _fileName;
  133081. private _resolve;
  133082. private _reject;
  133083. /**
  133084. * True when a recording is already in progress.
  133085. */
  133086. readonly isRecording: boolean;
  133087. /**
  133088. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  133089. * @param engine Defines the BabylonJS Engine you wish to record.
  133090. * @param options Defines options that can be used to customize the capture.
  133091. */
  133092. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  133093. /**
  133094. * Stops the current recording before the default capture timeout passed in the startRecording function.
  133095. */
  133096. stopRecording(): void;
  133097. /**
  133098. * Starts recording the canvas for a max duration specified in parameters.
  133099. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  133100. * If null no automatic download will start and you can rely on the promise to get the data back.
  133101. * @param maxDuration Defines the maximum recording time in seconds.
  133102. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  133103. * @return A promise callback at the end of the recording with the video data in Blob.
  133104. */
  133105. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  133106. /**
  133107. * Releases internal resources used during the recording.
  133108. */
  133109. dispose(): void;
  133110. private _handleDataAvailable;
  133111. private _handleError;
  133112. private _handleStop;
  133113. }
  133114. }
  133115. declare module BABYLON {
  133116. /**
  133117. * Class containing a set of static utilities functions for screenshots
  133118. */
  133119. export class ScreenshotTools {
  133120. /**
  133121. * Captures a screenshot of the current rendering
  133122. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  133123. * @param engine defines the rendering engine
  133124. * @param camera defines the source camera
  133125. * @param size This parameter can be set to a single number or to an object with the
  133126. * following (optional) properties: precision, width, height. If a single number is passed,
  133127. * it will be used for both width and height. If an object is passed, the screenshot size
  133128. * will be derived from the parameters. The precision property is a multiplier allowing
  133129. * rendering at a higher or lower resolution
  133130. * @param successCallback defines the callback receives a single parameter which contains the
  133131. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  133132. * src parameter of an <img> to display it
  133133. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  133134. * Check your browser for supported MIME types
  133135. */
  133136. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  133137. /**
  133138. * Captures a screenshot of the current rendering
  133139. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  133140. * @param engine defines the rendering engine
  133141. * @param camera defines the source camera
  133142. * @param size This parameter can be set to a single number or to an object with the
  133143. * following (optional) properties: precision, width, height. If a single number is passed,
  133144. * it will be used for both width and height. If an object is passed, the screenshot size
  133145. * will be derived from the parameters. The precision property is a multiplier allowing
  133146. * rendering at a higher or lower resolution
  133147. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  133148. * Check your browser for supported MIME types
  133149. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  133150. * to the src parameter of an <img> to display it
  133151. */
  133152. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  133153. /**
  133154. * Generates an image screenshot from the specified camera.
  133155. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  133156. * @param engine The engine to use for rendering
  133157. * @param camera The camera to use for rendering
  133158. * @param size This parameter can be set to a single number or to an object with the
  133159. * following (optional) properties: precision, width, height. If a single number is passed,
  133160. * it will be used for both width and height. If an object is passed, the screenshot size
  133161. * will be derived from the parameters. The precision property is a multiplier allowing
  133162. * rendering at a higher or lower resolution
  133163. * @param successCallback The callback receives a single parameter which contains the
  133164. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  133165. * src parameter of an <img> to display it
  133166. * @param mimeType The MIME type of the screenshot image (default: image/png).
  133167. * Check your browser for supported MIME types
  133168. * @param samples Texture samples (default: 1)
  133169. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  133170. * @param fileName A name for for the downloaded file.
  133171. */
  133172. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  133173. /**
  133174. * Generates an image screenshot from the specified camera.
  133175. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  133176. * @param engine The engine to use for rendering
  133177. * @param camera The camera to use for rendering
  133178. * @param size This parameter can be set to a single number or to an object with the
  133179. * following (optional) properties: precision, width, height. If a single number is passed,
  133180. * it will be used for both width and height. If an object is passed, the screenshot size
  133181. * will be derived from the parameters. The precision property is a multiplier allowing
  133182. * rendering at a higher or lower resolution
  133183. * @param mimeType The MIME type of the screenshot image (default: image/png).
  133184. * Check your browser for supported MIME types
  133185. * @param samples Texture samples (default: 1)
  133186. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  133187. * @param fileName A name for for the downloaded file.
  133188. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  133189. * to the src parameter of an <img> to display it
  133190. */
  133191. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  133192. /**
  133193. * Gets height and width for screenshot size
  133194. * @private
  133195. */
  133196. private static _getScreenshotSize;
  133197. }
  133198. }
  133199. declare module BABYLON {
  133200. /**
  133201. * Interface for a data buffer
  133202. */
  133203. export interface IDataBuffer {
  133204. /**
  133205. * Reads bytes from the data buffer.
  133206. * @param byteOffset The byte offset to read
  133207. * @param byteLength The byte length to read
  133208. * @returns A promise that resolves when the bytes are read
  133209. */
  133210. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  133211. /**
  133212. * The byte length of the buffer.
  133213. */
  133214. readonly byteLength: number;
  133215. }
  133216. /**
  133217. * Utility class for reading from a data buffer
  133218. */
  133219. export class DataReader {
  133220. /**
  133221. * The data buffer associated with this data reader.
  133222. */
  133223. readonly buffer: IDataBuffer;
  133224. /**
  133225. * The current byte offset from the beginning of the data buffer.
  133226. */
  133227. byteOffset: number;
  133228. private _dataView;
  133229. private _dataByteOffset;
  133230. /**
  133231. * Constructor
  133232. * @param buffer The buffer to read
  133233. */
  133234. constructor(buffer: IDataBuffer);
  133235. /**
  133236. * Loads the given byte length.
  133237. * @param byteLength The byte length to load
  133238. * @returns A promise that resolves when the load is complete
  133239. */
  133240. loadAsync(byteLength: number): Promise<void>;
  133241. /**
  133242. * Read a unsigned 32-bit integer from the currently loaded data range.
  133243. * @returns The 32-bit integer read
  133244. */
  133245. readUint32(): number;
  133246. /**
  133247. * Read a byte array from the currently loaded data range.
  133248. * @param byteLength The byte length to read
  133249. * @returns The byte array read
  133250. */
  133251. readUint8Array(byteLength: number): Uint8Array;
  133252. /**
  133253. * Read a string from the currently loaded data range.
  133254. * @param byteLength The byte length to read
  133255. * @returns The string read
  133256. */
  133257. readString(byteLength: number): string;
  133258. /**
  133259. * Skips the given byte length the currently loaded data range.
  133260. * @param byteLength The byte length to skip
  133261. */
  133262. skipBytes(byteLength: number): void;
  133263. }
  133264. }
  133265. declare module BABYLON {
  133266. /**
  133267. * A cursor which tracks a point on a path
  133268. */
  133269. export class PathCursor {
  133270. private path;
  133271. /**
  133272. * Stores path cursor callbacks for when an onchange event is triggered
  133273. */
  133274. private _onchange;
  133275. /**
  133276. * The value of the path cursor
  133277. */
  133278. value: number;
  133279. /**
  133280. * The animation array of the path cursor
  133281. */
  133282. animations: Animation[];
  133283. /**
  133284. * Initializes the path cursor
  133285. * @param path The path to track
  133286. */
  133287. constructor(path: Path2);
  133288. /**
  133289. * Gets the cursor point on the path
  133290. * @returns A point on the path cursor at the cursor location
  133291. */
  133292. getPoint(): Vector3;
  133293. /**
  133294. * Moves the cursor ahead by the step amount
  133295. * @param step The amount to move the cursor forward
  133296. * @returns This path cursor
  133297. */
  133298. moveAhead(step?: number): PathCursor;
  133299. /**
  133300. * Moves the cursor behind by the step amount
  133301. * @param step The amount to move the cursor back
  133302. * @returns This path cursor
  133303. */
  133304. moveBack(step?: number): PathCursor;
  133305. /**
  133306. * Moves the cursor by the step amount
  133307. * If the step amount is greater than one, an exception is thrown
  133308. * @param step The amount to move the cursor
  133309. * @returns This path cursor
  133310. */
  133311. move(step: number): PathCursor;
  133312. /**
  133313. * Ensures that the value is limited between zero and one
  133314. * @returns This path cursor
  133315. */
  133316. private ensureLimits;
  133317. /**
  133318. * Runs onchange callbacks on change (used by the animation engine)
  133319. * @returns This path cursor
  133320. */
  133321. private raiseOnChange;
  133322. /**
  133323. * Executes a function on change
  133324. * @param f A path cursor onchange callback
  133325. * @returns This path cursor
  133326. */
  133327. onchange(f: (cursor: PathCursor) => void): PathCursor;
  133328. }
  133329. }
  133330. declare module BABYLON {
  133331. /** @hidden */
  133332. export var blurPixelShader: {
  133333. name: string;
  133334. shader: string;
  133335. };
  133336. }
  133337. declare module BABYLON {
  133338. /** @hidden */
  133339. export var pointCloudVertexDeclaration: {
  133340. name: string;
  133341. shader: string;
  133342. };
  133343. }
  133344. // Mixins
  133345. interface Window {
  133346. mozIndexedDB: IDBFactory;
  133347. webkitIndexedDB: IDBFactory;
  133348. msIndexedDB: IDBFactory;
  133349. webkitURL: typeof URL;
  133350. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  133351. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  133352. WebGLRenderingContext: WebGLRenderingContext;
  133353. MSGesture: MSGesture;
  133354. CANNON: any;
  133355. AudioContext: AudioContext;
  133356. webkitAudioContext: AudioContext;
  133357. PointerEvent: any;
  133358. Math: Math;
  133359. Uint8Array: Uint8ArrayConstructor;
  133360. Float32Array: Float32ArrayConstructor;
  133361. mozURL: typeof URL;
  133362. msURL: typeof URL;
  133363. VRFrameData: any; // WebVR, from specs 1.1
  133364. DracoDecoderModule: any;
  133365. setImmediate(handler: (...args: any[]) => void): number;
  133366. }
  133367. interface HTMLCanvasElement {
  133368. requestPointerLock(): void;
  133369. msRequestPointerLock?(): void;
  133370. mozRequestPointerLock?(): void;
  133371. webkitRequestPointerLock?(): void;
  133372. /** Track wether a record is in progress */
  133373. isRecording: boolean;
  133374. /** Capture Stream method defined by some browsers */
  133375. captureStream(fps?: number): MediaStream;
  133376. }
  133377. interface CanvasRenderingContext2D {
  133378. msImageSmoothingEnabled: boolean;
  133379. }
  133380. interface MouseEvent {
  133381. mozMovementX: number;
  133382. mozMovementY: number;
  133383. webkitMovementX: number;
  133384. webkitMovementY: number;
  133385. msMovementX: number;
  133386. msMovementY: number;
  133387. }
  133388. interface Navigator {
  133389. mozGetVRDevices: (any: any) => any;
  133390. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  133391. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  133392. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  133393. webkitGetGamepads(): Gamepad[];
  133394. msGetGamepads(): Gamepad[];
  133395. webkitGamepads(): Gamepad[];
  133396. }
  133397. interface HTMLVideoElement {
  133398. mozSrcObject: any;
  133399. }
  133400. interface Math {
  133401. fround(x: number): number;
  133402. imul(a: number, b: number): number;
  133403. }
  133404. interface WebGLRenderingContext {
  133405. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  133406. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  133407. vertexAttribDivisor(index: number, divisor: number): void;
  133408. createVertexArray(): any;
  133409. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  133410. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  133411. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  133412. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  133413. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  133414. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  133415. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  133416. // Queries
  133417. createQuery(): WebGLQuery;
  133418. deleteQuery(query: WebGLQuery): void;
  133419. beginQuery(target: number, query: WebGLQuery): void;
  133420. endQuery(target: number): void;
  133421. getQueryParameter(query: WebGLQuery, pname: number): any;
  133422. getQuery(target: number, pname: number): any;
  133423. MAX_SAMPLES: number;
  133424. RGBA8: number;
  133425. READ_FRAMEBUFFER: number;
  133426. DRAW_FRAMEBUFFER: number;
  133427. UNIFORM_BUFFER: number;
  133428. HALF_FLOAT_OES: number;
  133429. RGBA16F: number;
  133430. RGBA32F: number;
  133431. R32F: number;
  133432. RG32F: number;
  133433. RGB32F: number;
  133434. R16F: number;
  133435. RG16F: number;
  133436. RGB16F: number;
  133437. RED: number;
  133438. RG: number;
  133439. R8: number;
  133440. RG8: number;
  133441. UNSIGNED_INT_24_8: number;
  133442. DEPTH24_STENCIL8: number;
  133443. MIN: number;
  133444. MAX: number;
  133445. /* Multiple Render Targets */
  133446. drawBuffers(buffers: number[]): void;
  133447. readBuffer(src: number): void;
  133448. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  133449. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  133450. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  133451. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  133452. // Occlusion Query
  133453. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  133454. ANY_SAMPLES_PASSED: number;
  133455. QUERY_RESULT_AVAILABLE: number;
  133456. QUERY_RESULT: number;
  133457. }
  133458. interface WebGLProgram {
  133459. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  133460. }
  133461. interface EXT_disjoint_timer_query {
  133462. QUERY_COUNTER_BITS_EXT: number;
  133463. TIME_ELAPSED_EXT: number;
  133464. TIMESTAMP_EXT: number;
  133465. GPU_DISJOINT_EXT: number;
  133466. QUERY_RESULT_EXT: number;
  133467. QUERY_RESULT_AVAILABLE_EXT: number;
  133468. queryCounterEXT(query: WebGLQuery, target: number): void;
  133469. createQueryEXT(): WebGLQuery;
  133470. beginQueryEXT(target: number, query: WebGLQuery): void;
  133471. endQueryEXT(target: number): void;
  133472. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  133473. deleteQueryEXT(query: WebGLQuery): void;
  133474. }
  133475. interface WebGLUniformLocation {
  133476. _currentState: any;
  133477. }
  133478. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  133479. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  133480. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  133481. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  133482. interface WebGLRenderingContext {
  133483. readonly RASTERIZER_DISCARD: number;
  133484. readonly DEPTH_COMPONENT24: number;
  133485. readonly TEXTURE_3D: number;
  133486. readonly TEXTURE_2D_ARRAY: number;
  133487. readonly TEXTURE_COMPARE_FUNC: number;
  133488. readonly TEXTURE_COMPARE_MODE: number;
  133489. readonly COMPARE_REF_TO_TEXTURE: number;
  133490. readonly TEXTURE_WRAP_R: number;
  133491. readonly HALF_FLOAT: number;
  133492. readonly RGB8: number;
  133493. readonly RED_INTEGER: number;
  133494. readonly RG_INTEGER: number;
  133495. readonly RGB_INTEGER: number;
  133496. readonly RGBA_INTEGER: number;
  133497. readonly R8_SNORM: number;
  133498. readonly RG8_SNORM: number;
  133499. readonly RGB8_SNORM: number;
  133500. readonly RGBA8_SNORM: number;
  133501. readonly R8I: number;
  133502. readonly RG8I: number;
  133503. readonly RGB8I: number;
  133504. readonly RGBA8I: number;
  133505. readonly R8UI: number;
  133506. readonly RG8UI: number;
  133507. readonly RGB8UI: number;
  133508. readonly RGBA8UI: number;
  133509. readonly R16I: number;
  133510. readonly RG16I: number;
  133511. readonly RGB16I: number;
  133512. readonly RGBA16I: number;
  133513. readonly R16UI: number;
  133514. readonly RG16UI: number;
  133515. readonly RGB16UI: number;
  133516. readonly RGBA16UI: number;
  133517. readonly R32I: number;
  133518. readonly RG32I: number;
  133519. readonly RGB32I: number;
  133520. readonly RGBA32I: number;
  133521. readonly R32UI: number;
  133522. readonly RG32UI: number;
  133523. readonly RGB32UI: number;
  133524. readonly RGBA32UI: number;
  133525. readonly RGB10_A2UI: number;
  133526. readonly R11F_G11F_B10F: number;
  133527. readonly RGB9_E5: number;
  133528. readonly RGB10_A2: number;
  133529. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  133530. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  133531. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  133532. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  133533. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  133534. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  133535. 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;
  133536. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  133537. readonly TRANSFORM_FEEDBACK: number;
  133538. readonly INTERLEAVED_ATTRIBS: number;
  133539. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  133540. createTransformFeedback(): WebGLTransformFeedback;
  133541. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  133542. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  133543. beginTransformFeedback(primitiveMode: number): void;
  133544. endTransformFeedback(): void;
  133545. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  133546. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  133547. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  133548. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  133549. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  133550. }
  133551. interface ImageBitmap {
  133552. readonly width: number;
  133553. readonly height: number;
  133554. close(): void;
  133555. }
  133556. interface WebGLQuery extends WebGLObject {
  133557. }
  133558. declare var WebGLQuery: {
  133559. prototype: WebGLQuery;
  133560. new(): WebGLQuery;
  133561. };
  133562. interface WebGLSampler extends WebGLObject {
  133563. }
  133564. declare var WebGLSampler: {
  133565. prototype: WebGLSampler;
  133566. new(): WebGLSampler;
  133567. };
  133568. interface WebGLSync extends WebGLObject {
  133569. }
  133570. declare var WebGLSync: {
  133571. prototype: WebGLSync;
  133572. new(): WebGLSync;
  133573. };
  133574. interface WebGLTransformFeedback extends WebGLObject {
  133575. }
  133576. declare var WebGLTransformFeedback: {
  133577. prototype: WebGLTransformFeedback;
  133578. new(): WebGLTransformFeedback;
  133579. };
  133580. interface WebGLVertexArrayObject extends WebGLObject {
  133581. }
  133582. declare var WebGLVertexArrayObject: {
  133583. prototype: WebGLVertexArrayObject;
  133584. new(): WebGLVertexArrayObject;
  133585. };
  133586. // Type definitions for WebVR API
  133587. // Project: https://w3c.github.io/webvr/
  133588. // Definitions by: six a <https://github.com/lostfictions>
  133589. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  133590. interface VRDisplay extends EventTarget {
  133591. /**
  133592. * Dictionary of capabilities describing the VRDisplay.
  133593. */
  133594. readonly capabilities: VRDisplayCapabilities;
  133595. /**
  133596. * z-depth defining the far plane of the eye view frustum
  133597. * enables mapping of values in the render target depth
  133598. * attachment to scene coordinates. Initially set to 10000.0.
  133599. */
  133600. depthFar: number;
  133601. /**
  133602. * z-depth defining the near plane of the eye view frustum
  133603. * enables mapping of values in the render target depth
  133604. * attachment to scene coordinates. Initially set to 0.01.
  133605. */
  133606. depthNear: number;
  133607. /**
  133608. * An identifier for this distinct VRDisplay. Used as an
  133609. * association point in the Gamepad API.
  133610. */
  133611. readonly displayId: number;
  133612. /**
  133613. * A display name, a user-readable name identifying it.
  133614. */
  133615. readonly displayName: string;
  133616. readonly isConnected: boolean;
  133617. readonly isPresenting: boolean;
  133618. /**
  133619. * If this VRDisplay supports room-scale experiences, the optional
  133620. * stage attribute contains details on the room-scale parameters.
  133621. */
  133622. readonly stageParameters: VRStageParameters | null;
  133623. /**
  133624. * Passing the value returned by `requestAnimationFrame` to
  133625. * `cancelAnimationFrame` will unregister the callback.
  133626. * @param handle Define the hanle of the request to cancel
  133627. */
  133628. cancelAnimationFrame(handle: number): void;
  133629. /**
  133630. * Stops presenting to the VRDisplay.
  133631. * @returns a promise to know when it stopped
  133632. */
  133633. exitPresent(): Promise<void>;
  133634. /**
  133635. * Return the current VREyeParameters for the given eye.
  133636. * @param whichEye Define the eye we want the parameter for
  133637. * @returns the eye parameters
  133638. */
  133639. getEyeParameters(whichEye: string): VREyeParameters;
  133640. /**
  133641. * Populates the passed VRFrameData with the information required to render
  133642. * the current frame.
  133643. * @param frameData Define the data structure to populate
  133644. * @returns true if ok otherwise false
  133645. */
  133646. getFrameData(frameData: VRFrameData): boolean;
  133647. /**
  133648. * Get the layers currently being presented.
  133649. * @returns the list of VR layers
  133650. */
  133651. getLayers(): VRLayer[];
  133652. /**
  133653. * Return a VRPose containing the future predicted pose of the VRDisplay
  133654. * when the current frame will be presented. The value returned will not
  133655. * change until JavaScript has returned control to the browser.
  133656. *
  133657. * The VRPose will contain the position, orientation, velocity,
  133658. * and acceleration of each of these properties.
  133659. * @returns the pose object
  133660. */
  133661. getPose(): VRPose;
  133662. /**
  133663. * Return the current instantaneous pose of the VRDisplay, with no
  133664. * prediction applied.
  133665. * @returns the current instantaneous pose
  133666. */
  133667. getImmediatePose(): VRPose;
  133668. /**
  133669. * The callback passed to `requestAnimationFrame` will be called
  133670. * any time a new frame should be rendered. When the VRDisplay is
  133671. * presenting the callback will be called at the native refresh
  133672. * rate of the HMD. When not presenting this function acts
  133673. * identically to how window.requestAnimationFrame acts. Content should
  133674. * make no assumptions of frame rate or vsync behavior as the HMD runs
  133675. * asynchronously from other displays and at differing refresh rates.
  133676. * @param callback Define the eaction to run next frame
  133677. * @returns the request handle it
  133678. */
  133679. requestAnimationFrame(callback: FrameRequestCallback): number;
  133680. /**
  133681. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  133682. * Repeat calls while already presenting will update the VRLayers being displayed.
  133683. * @param layers Define the list of layer to present
  133684. * @returns a promise to know when the request has been fulfilled
  133685. */
  133686. requestPresent(layers: VRLayer[]): Promise<void>;
  133687. /**
  133688. * Reset the pose for this display, treating its current position and
  133689. * orientation as the "origin/zero" values. VRPose.position,
  133690. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  133691. * updated when calling resetPose(). This should be called in only
  133692. * sitting-space experiences.
  133693. */
  133694. resetPose(): void;
  133695. /**
  133696. * The VRLayer provided to the VRDisplay will be captured and presented
  133697. * in the HMD. Calling this function has the same effect on the source
  133698. * canvas as any other operation that uses its source image, and canvases
  133699. * created without preserveDrawingBuffer set to true will be cleared.
  133700. * @param pose Define the pose to submit
  133701. */
  133702. submitFrame(pose?: VRPose): void;
  133703. }
  133704. declare var VRDisplay: {
  133705. prototype: VRDisplay;
  133706. new(): VRDisplay;
  133707. };
  133708. interface VRLayer {
  133709. leftBounds?: number[] | Float32Array | null;
  133710. rightBounds?: number[] | Float32Array | null;
  133711. source?: HTMLCanvasElement | null;
  133712. }
  133713. interface VRDisplayCapabilities {
  133714. readonly canPresent: boolean;
  133715. readonly hasExternalDisplay: boolean;
  133716. readonly hasOrientation: boolean;
  133717. readonly hasPosition: boolean;
  133718. readonly maxLayers: number;
  133719. }
  133720. interface VREyeParameters {
  133721. /** @deprecated */
  133722. readonly fieldOfView: VRFieldOfView;
  133723. readonly offset: Float32Array;
  133724. readonly renderHeight: number;
  133725. readonly renderWidth: number;
  133726. }
  133727. interface VRFieldOfView {
  133728. readonly downDegrees: number;
  133729. readonly leftDegrees: number;
  133730. readonly rightDegrees: number;
  133731. readonly upDegrees: number;
  133732. }
  133733. interface VRFrameData {
  133734. readonly leftProjectionMatrix: Float32Array;
  133735. readonly leftViewMatrix: Float32Array;
  133736. readonly pose: VRPose;
  133737. readonly rightProjectionMatrix: Float32Array;
  133738. readonly rightViewMatrix: Float32Array;
  133739. readonly timestamp: number;
  133740. }
  133741. interface VRPose {
  133742. readonly angularAcceleration: Float32Array | null;
  133743. readonly angularVelocity: Float32Array | null;
  133744. readonly linearAcceleration: Float32Array | null;
  133745. readonly linearVelocity: Float32Array | null;
  133746. readonly orientation: Float32Array | null;
  133747. readonly position: Float32Array | null;
  133748. readonly timestamp: number;
  133749. }
  133750. interface VRStageParameters {
  133751. sittingToStandingTransform?: Float32Array;
  133752. sizeX?: number;
  133753. sizeY?: number;
  133754. }
  133755. interface Navigator {
  133756. getVRDisplays(): Promise<VRDisplay[]>;
  133757. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  133758. }
  133759. interface Window {
  133760. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  133761. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  133762. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  133763. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  133764. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  133765. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  133766. }
  133767. interface Gamepad {
  133768. readonly displayId: number;
  133769. }
  133770. type XRSessionMode =
  133771. | "inline"
  133772. | "immersive-vr"
  133773. | "immersive-ar";
  133774. type XRReferenceSpaceType =
  133775. | "viewer"
  133776. | "local"
  133777. | "local-floor"
  133778. | "bounded-floor"
  133779. | "unbounded";
  133780. type XREnvironmentBlendMode =
  133781. | "opaque"
  133782. | "additive"
  133783. | "alpha-blend";
  133784. type XRVisibilityState =
  133785. | "visible"
  133786. | "visible-blurred"
  133787. | "hidden";
  133788. type XRHandedness =
  133789. | "none"
  133790. | "left"
  133791. | "right";
  133792. type XRTargetRayMode =
  133793. | "gaze"
  133794. | "tracked-pointer"
  133795. | "screen";
  133796. type XREye =
  133797. | "none"
  133798. | "left"
  133799. | "right";
  133800. interface XRSpace extends EventTarget {
  133801. }
  133802. interface XRRenderState {
  133803. depthNear?: number;
  133804. depthFar?: number;
  133805. inlineVerticalFieldOfView?: number;
  133806. baseLayer?: XRWebGLLayer;
  133807. }
  133808. interface XRInputSource {
  133809. handedness: XRHandedness;
  133810. targetRayMode: XRTargetRayMode;
  133811. targetRaySpace: XRSpace;
  133812. gripSpace: XRSpace | undefined;
  133813. gamepad: Gamepad | undefined;
  133814. profiles: Array<string>;
  133815. }
  133816. interface XRSession {
  133817. addEventListener: Function;
  133818. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  133819. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  133820. requestAnimationFrame: Function;
  133821. end(): Promise<void>;
  133822. renderState: XRRenderState;
  133823. inputSources: Array<XRInputSource>;
  133824. }
  133825. interface XRReferenceSpace extends XRSpace {
  133826. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  133827. onreset: any;
  133828. }
  133829. interface XRFrame {
  133830. session: XRSession;
  133831. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  133832. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  133833. }
  133834. interface XRViewerPose extends XRPose {
  133835. views: Array<XRView>;
  133836. }
  133837. interface XRPose {
  133838. transform: XRRigidTransform;
  133839. emulatedPosition: boolean;
  133840. }
  133841. interface XRWebGLLayerOptions {
  133842. antialias ?: boolean;
  133843. depth ?: boolean;
  133844. stencil ?: boolean;
  133845. alpha ?: boolean;
  133846. multiview ?: boolean;
  133847. framebufferScaleFactor ?: number;
  133848. }
  133849. declare var XRWebGLLayer: {
  133850. prototype: XRWebGLLayer;
  133851. new(session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  133852. };
  133853. interface XRWebGLLayer {
  133854. framebuffer: WebGLFramebuffer;
  133855. framebufferWidth: number;
  133856. framebufferHeight: number;
  133857. getViewport: Function;
  133858. }
  133859. interface XRRigidTransform {
  133860. position: DOMPointReadOnly;
  133861. orientation: DOMPointReadOnly;
  133862. matrix: Float32Array;
  133863. inverse: XRRigidTransform;
  133864. }
  133865. interface XRView {
  133866. eye: XREye;
  133867. projectionMatrix: Float32Array;
  133868. transform: XRRigidTransform;
  133869. }
  133870. interface XRInputSourceChangeEvent {
  133871. session: XRSession;
  133872. removed: Array<XRInputSource>;
  133873. added: Array<XRInputSource>;
  133874. }